/*
* Title: japlot.jaxodraw
* Description: Graphical user interface for drawing Feynman diagrams
* @author Daniele Binosi
* @author Lukas Theussl
Copyright (C) 2003-2006, Daniele Binosi and Lukas Theussl
See the file LICENSE in the source distribution home directory
for a full copy of the GPL (GNU General Public License).
This file is part of japlot.jaxodraw.
japlot.jaxodraw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
japlot.jaxodraw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package japlot.jaxodraw;
/** Defines a number of greek letters and some methods to convert them into
* LaTeX strings and back.
*/
public final class JaxoGreek {
// lower case greek letters
/** The greek letter alpha. */
public static final char ALPHA = (char) (1 + (11 * 16) + (3 * 256));
/** The greek letter beta. */
public static final char BETA = (char) (2 + (11 * 16) + (3 * 256));
/** The greek letter gamma. */
public static final char GAMMA = (char) (3 + (11 * 16) + (3 * 256));
/** The greek letter delta. */
public static final char DELTA = (char) (4 + (11 * 16) + (3 * 256));
/** The greek letter epsilon. */
public static final char EPSILON = (char) (5 + (11 * 16) + (3 * 256));
/** The greek letter zeta. */
public static final char ZETA = (char) (6 + (11 * 16) + (3 * 256));
/** The greek letter eta. */
public static final char ETA = (char) (7 + (11 * 16) + (3 * 256));
/** The greek letter theta. */
public static final char THETA = (char) (8 + (11 * 16) + (3 * 256));
/** The greek letter iota. */
public static final char IOTA = (char) (9 + (11 * 16) + (3 * 256));
/** The greek letter kappa. */
public static final char KAPPA = (char) (10 + (11 * 16) + (3 * 256));
/** The greek letter lambda. */
public static final char LAMBDA = (char) (11 + (11 * 16) + (3 * 256));
/** The greek letter mu. */
public static final char MU = (char) (12 + (11 * 16) + (3 * 256));
/** The greek letter nu. */
public static final char NU = (char) (13 + (11 * 16) + (3 * 256));
/** The greek letter xi. */
public static final char XI = (char) (14 + (11 * 16) + (3 * 256));
/** The greek letter omikron. */
public static final char OMIKRON = (char) (15 + (11 * 16) + (3 * 256));
/** The greek letter pi. */
public static final char PI = (char) (0 + (12 * 16) + (3 * 256));
/** The greek letter rho. */
public static final char RHO = (char) (1 + (12 * 16) + (3 * 256));
/** The greek letter sigma (corresponding to LaTeX's \varsigma). */
public static final char VARSIGMA = (char) (2 + (12 * 16) + (3 * 256));
/** The greek letter sigma. */
public static final char SIGMA = (char) (3 + (12 * 16) + (3 * 256));
/** The greek letter tau. */
public static final char TAU = (char) (4 + (12 * 16) + (3 * 256));
/** The greek letter upsilon. */
public static final char UPSILON = (char) (5 + (12 * 16) + (3 * 256));
/** The greek letter phi. */
public static final char PHI = (char) (6 + (12 * 16) + (3 * 256));
/** The greek letter chi. */
public static final char CHI = (char) (7 + (12 * 16) + (3 * 256));
/** The greek letter psi. */
public static final char PSI = (char) (8 + (12 * 16) + (3 * 256));
/** The greek letter omega. */
public static final char OMEGA = (char) (9 + (12 * 16) + (3 * 256));
/** The greek letter theta (corresponding to LaTeX's \vartheta). */
public static final char VARTHETA = (char) (1 + (13 * 16) + (3 * 256));
/** The greek letter phi (corresponding to LaTeX's \varphi). */
public static final char VARPHI = (char) (5 + (13 * 16) + (3 * 256));
// upper case greek letters
/** The greek upper case letter gamma. */
public static final char UPPER_GAMMA = (char) (3 + (9 * 16) + (3 * 256));
/** The greek upper case letter delta. */
public static final char UPPER_DELTA = (char) (4 + (9 * 16) + (3 * 256));
/** The greek upper case letter theta. */
public static final char UPPER_THETA = (char) (8 + (9 * 16) + (3 * 256));
/** The greek upper case letter lambda. */
public static final char UPPER_LAMBDA = (char) (
11 + (9 * 16) + (3 * 256)
);
/** The greek upper case letter xi. */
public static final char UPPER_XI = (char) (14 + (9 * 16) + (3 * 256));
/** The greek upper case letter pi. */
public static final char UPPER_PI = (char) (0 + (10 * 16) + (3 * 256));
/** The greek upper case letter sigma. */
public static final char UPPER_SIGMA = (char) (3 + (10 * 16) + (3 * 256));
/** The greek upper case letter phi. */
public static final char UPPER_PHI = (char) (6 + (10 * 16) + (3 * 256));
/** The greek upper case letter psi. */
public static final char UPPER_PSI = (char) (8 + (10 * 16) + (3 * 256));
/** The greek upper case letter omega. */
public static final char UPPER_OMEGA = (char) (9 + (10 * 16) + (3 * 256));
/** A character array holding all the defined greek characters. */
private static char[] greekLetters =
{
ALPHA, BETA, GAMMA, DELTA, EPSILON, ZETA, ETA, THETA, IOTA, KAPPA,
LAMBDA, MU, NU, XI, OMIKRON, PI, RHO, VARSIGMA, SIGMA, TAU, UPSILON,
PHI, CHI, PSI, OMEGA, VARTHETA, VARPHI, UPPER_GAMMA, UPPER_DELTA,
UPPER_THETA, UPPER_LAMBDA, UPPER_XI, UPPER_PI, UPPER_SIGMA, UPPER_PHI,
UPPER_PSI, UPPER_OMEGA
};
/** The number of greek letters defined by this class. */
private static int nofGreekLetters = greekLetters.length;
/** An array of strings, holding all the LaTeX commands corresponding
* to the greek characters defined in this class.
*/
private static String[] latexGreekLetters =
{
"\\alpha", "\\beta", "\\gamma", "\\delta", "\\epsilon", "\\zeta",
"\\eta", "\\theta", "\\iota", "\\kappa", "\\lambda", "\\mu", "\\nu",
"\\xi", "o", "\\pi", "\\rho", "\\varsigma", "\\sigma", "\\tau",
"\\upsilon", "\\phi", "\\chi", "\\psi", "\\omega", "\\vartheta",
"\\varphi", "\\Gamma", "\\Delta", "\\Theta", "\\Lambda", "\\Xi", "\\Pi",
"\\Sigma", "\\Phi", "\\Psi", "\\Omega"
};
/** Empty private constructor to prevent the class from being
* explicitly instantiated.
*/
private JaxoGreek() {
// empty on purpose
}
/** Returns the index of the greek character a.
* @param a A greek character.
* @return The index of a if a is a greek character,
* otherwise returns nofGreekLetters.
*/
private static int getIndex(char a) {
int i = 0;
while ((greekLetters[i] != a) && (i < (nofGreekLetters - 1))) {
i++;
}
if (greekLetters[i] == a) {
return i;
} else {
return nofGreekLetters;
}
}
/** Returns the index of the LaTeX string s that corresponds to a
* greek character.
* @param s A string with a latex command for a greek character.
* @return The index of s if it corresponds to the LaTeX command of a
* greek character, otherwise returns nofGreekLetters.
*/
private static int getIndex(String s) {
int i = 0;
while ((latexGreekLetters[i].compareTo(s) != 0)
&& (i < (nofGreekLetters - 1))) {
i++;
}
if (latexGreekLetters[i].compareTo(s) == 0) {
return i;
} else {
return nofGreekLetters;
}
}
/** Gets the LaTeX command for the greek character at index i.
* @param i The index of the greek character whose LaTex command
* is to be returned.
* @return The LaTeX command of the greek character at index i.
*/
// private static String getLatexGreekLetter(int i) {
// if (i < nofGreekLetters) {
// return latexGreekLetters[i];
// } else {
// return "?";
// }
// }
/** Gets the LaTeX command for the greek character a.
* @param a The greek character whose LaTex command is to be returned.
* @return The LaTeX command of the greek character a or "?" if
* a does not correspond to any greek character..
*/
public static String getLatexGreekLetter(char a) {
String thisLetter = "?";
int i = getIndex(a);
if (i < nofGreekLetters) {
thisLetter = latexGreekLetters[i];
}
return thisLetter;
}
/** Returns the greek character at index i.
* @param i The index of the greek character whic is to be returned.
* @return The greek character at index i.
*/
// private static char getGreekLetter(int i) {
// if (i < nofGreekLetters) {
// return greekLetters[i];
// } else {
// return '?';
// }
// }
/** Returns the greek character whose LaTex command is s.
* @param s The LaTeX command whose corresponding greek character
* is to be returned.
* @return The greek character corresponding to the LaTex command s
* or ? if s does not correspond to any greek character.
*/
public static char getGreekLetter(String s) {
int i = getIndex(s);
if (i < nofGreekLetters) {
return greekLetters[i];
} else {
return '?';
}
}
/** Tests whether the given character corresponds to one of the
* greek characters defined in this class.
* @param a A character.
* @return True if a corresponds to one of the greek characters
* defined in this class, false otherwise.
*/
public static boolean isGreekLetter(char a) {
boolean isGreek = false;
int i = getIndex(a);
if (i < nofGreekLetters) {
isGreek = true;
}
return isGreek;
}
}
Ads help maintain this website.