/*
* 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;
import java.awt.Color;
/** Defines all the colors of the LaTex colordvi package (approximately). */
public final class JaxoColor {
/** The color GreenYellow. */
public static final Color GREEN_YELLOW = new Color(214, 232, 15);
/** The color Yellow. */
public static final Color YELLOW = new Color(249, 229, 38);
/** The color Goldenrod. */
public static final Color GOLDEN_ROD = new Color(249, 214, 22);
/** The color Dandelion. */
public static final Color DANDELION = new Color(255, 198, 30);
/** The color Apricot. */
public static final Color APRICOT = new Color(252, 165, 119);
/** The color Peach. */
public static final Color PEACH = new Color(252, 127, 63);
/** The color Melon. */
public static final Color MELON = new Color(249, 130, 127);
/** The color YellowOrange. */
public static final Color YELLOW_ORANGE = new Color(234, 175, 15);
/** The color Orange. */
public static final Color ORANGE = new Color(221, 79, 5);
/** The color BurntOrange. */
public static final Color BURNT_ORANGE = new Color(221, 117, 0);
/** The color Bittersweet. */
public static final Color BITTERSWEET = new Color(188, 79, 7);
/** The color RedOrange. */
public static final Color RED_ORANGE = new Color(226, 61, 40);
/** The color Mahagony. */
public static final Color MAHOGANY = new Color(155, 48, 28);
/** The color Maroon. */
public static final Color MAROON = new Color(163, 38, 56);
/** The color BrickRed. */
public static final Color BRICK_RED = new Color(175, 38, 38);
/** The color Red. */
public static final Color RED = new Color(255, 0, 0);
/** The color OrangeRed. */
public static final Color ORANGE_RED = new Color(206, 0, 124);
/** The color RubineRed. */
public static final Color RUBINE_RED = new Color(204, 0, 160);
/** The color WildStrawberry. */
public static final Color WILDSTRAWBERRY = new Color(211, 5, 71);
/** The color Salmon. */
public static final Color SALMON = new Color(252, 140, 153);
/** The color CarnationPink. */
public static final Color CARNATION_PINK = new Color(237, 114, 170);
/** The color Magenta. */
public static final Color MAGENTA = new Color(219, 40, 165);
/** The color VioletRed. */
public static final Color VIOLET_RED = new Color(226, 40, 130);
/** The color Rhodamine. */
public static final Color RHODAMINE = new Color(234, 107, 191);
/** The color Mulberry. */
public static final Color MULBERRY = new Color(173, 0, 117);
/** The color RedViolet. */
public static final Color RED_VIOLET = new Color(170, 0, 102);
/** The color Fuchsia. */
public static final Color FUCHSIA = new Color(163, 5, 127);
/** The color Lavender. */
public static final Color LAVENDER = new Color(249, 147, 196);
/** The color Thistle. */
public static final Color THISTLE = new Color(232, 127, 201);
/** The color Orchid. */
public static final Color ORCHID = new Color(211, 107, 198);
/** The color DarkOrchid. */
public static final Color DARK_ORCHID = new Color(142, 71, 173);
/** The color Purple. */
public static final Color PURPLE = new Color(137, 79, 191);
/** The color Plum. */
public static final Color PLUM = new Color(81, 45, 68);
/** The color Violet. */
public static final Color VIOLET = new Color(48, 68, 181);
/** The color RoyalPurple. */
public static final Color ROYAL_PURPLE = new Color(89, 17, 142);
/** The color BlueViolet. */
public static final Color BLUE_VIOLET = new Color(53, 0, 109);
/** The color Periwinkle. */
public static final Color PERIWINKLE = new Color(147, 122, 204);
/** The color CadetBlue. */
public static final Color CADET_BLUE = new Color(94, 104, 196);
/** The color CornflowerBlue. */
public static final Color CORNFLOWER_BLUE = new Color(117, 178, 221);
/** The color MidnightBlue. */
public static final Color MIDNIGHT_BLUE = new Color(0, 79, 109);
/** The color NavyBlue. */
public static final Color NAVY_BLUE = new Color(0, 81, 186);
/** The color RoyalBlue. */
public static final Color ROYAL_BLUE = new Color(0, 132, 201);
/** The color Blue. */
public static final Color BLUE = new Color(0, 56, 168);
/** The color Cerulean. */
public static final Color CERULEAN = new Color(0, 198, 178);
/** The color Cyan. */
public static final Color CYAN = new Color(94, 221, 193);
/** The color ProcessBlue. */
public static final Color PROCESS_BLUE = new Color(71, 214, 193);
/** The color SkyBlue. */
public static final Color SKY_BLUE = new Color(81, 191, 226);
/** The color Turquoise. */
public static final Color TURQUOISE = new Color(0, 183, 198);
/** The color TealBlue. */
public static final Color TEAL_BLUE = new Color(0, 132, 142);
/** The color Aquamarine. */
public static final Color AQUAMARINE = new Color(0, 155, 170);
/** The color BlueGreen. */
public static final Color BLUE_GREEN = new Color(0, 158, 160);
/** The color Emerald. */
public static final Color EMERALD = new Color(0, 183, 96);
/** The color JungleGreen. */
public static final Color JUNGLE_GREEN = new Color(0, 119, 112);
/** The color SeaGreen. */
public static final Color SEA_GREEN = new Color(0, 175, 153);
/** The color Green. */
public static final Color GREEN = new Color(0, 255, 0);
/** The color ForestGreen. */
public static final Color FOREST_GREEN = new Color(0, 107, 63);
/** The color PineGreen. */
public static final Color PINE_GREEN = new Color(0, 102, 99);
/** The color LimeGreen. */
public static final Color LIME_GREEN = new Color(140, 214, 0);
/** The color YellowGreen. */
public static final Color YELLOW_GREEN = new Color(127, 186, 0);
/** The color SpringGreen. */
public static final Color SPRING_GREEN = new Color(204, 226, 38);
/** The color OliveGreen. */
public static final Color OLIVE_GREEN = new Color(135, 137, 5);
/** The color RawSienna. */
public static final Color RAWSIENNA = new Color(153, 89, 5);
/** The color Sepia. */
public static final Color SEPIA = new Color(99, 58, 17);
/** The color Brown. */
public static final Color BROWN = new Color(132, 63, 15);
/** The color Tan. */
public static final Color TAN = new Color(249, 114, 66);
/** The color Gray. */
public static final Color GRAY = new Color(102, 109, 112);
/** The color Black. */
public static final Color BLACK = new Color(0, 0, 0);
/** The color GrayScale15. */
public static final Color GRAYSCALE15 = new Color(15, 15, 15);
/** The color GrayScale30. */
public static final Color GRAYSCALE30 = new Color(30, 30, 30);
/** The color GrayScale45. */
public static final Color GRAYSCALE45 = new Color(45, 45, 45);
/** The color GrayScale60. */
public static final Color GRAYSCALE60 = new Color(60, 60, 60);
/** The color GrayScale75. */
public static final Color GRAYSCALE75 = new Color(75, 75, 75);
/** The color GrayScale90. */
public static final Color GRAYSCALE90 = new Color(90, 90, 90);
/** The color GrayScale105. */
public static final Color GRAYSCALE105 = new Color(105, 105, 105);
/** The color GrayScale120. */
public static final Color GRAYSCALE120 = new Color(120, 120, 120);
/** The color GrayScale135. */
public static final Color GRAYSCALE135 = new Color(135, 135, 135);
/** The color GrayScale150. */
public static final Color GRAYSCALE150 = new Color(150, 150, 150);
/** The color GrayScale165. */
public static final Color GRAYSCALE165 = new Color(165, 165, 165);
/** The color GrayScale180. */
public static final Color GRAYSCALE180 = new Color(180, 180, 180);
/** The color GrayScale195. */
public static final Color GRAYSCALE195 = new Color(195, 195, 195);
/** The color GrayScale210. */
public static final Color GRAYSCALE210 = new Color(210, 210, 210);
/** The color GrayScale225. */
public static final Color GRAYSCALE225 = new Color(225, 225, 225);
/** The color GrayScale240. */
public static final Color GRAYSCALE240 = new Color(240, 240, 240);
/** The color White. */
public static final Color WHITE = new Color(255, 255, 255);
/** List containing all the colors of JaxoColor. */
private static Color[] colorList =
{
GREEN_YELLOW, YELLOW, GOLDEN_ROD, DANDELION, APRICOT, PEACH, MELON,
YELLOW_ORANGE, ORANGE, BURNT_ORANGE, BITTERSWEET, RED_ORANGE, MAHOGANY,
MAROON, BRICK_RED, RED, ORANGE_RED, RUBINE_RED, WILDSTRAWBERRY, SALMON,
CARNATION_PINK, MAGENTA, VIOLET_RED, RHODAMINE, MULBERRY, RED_VIOLET,
FUCHSIA, LAVENDER, THISTLE, ORCHID, DARK_ORCHID, PURPLE, PLUM, VIOLET,
ROYAL_PURPLE, BLUE_VIOLET, PERIWINKLE, CADET_BLUE, CORNFLOWER_BLUE,
MIDNIGHT_BLUE, NAVY_BLUE, ROYAL_BLUE, BLUE, CERULEAN, CYAN,
PROCESS_BLUE, SKY_BLUE, TURQUOISE, TEAL_BLUE, AQUAMARINE, BLUE_GREEN,
EMERALD, JUNGLE_GREEN, SEA_GREEN, GREEN, FOREST_GREEN, PINE_GREEN,
LIME_GREEN, YELLOW_GREEN, SPRING_GREEN, OLIVE_GREEN, RAWSIENNA, SEPIA,
BROWN, TAN, GRAY, BLACK, GRAYSCALE15, GRAYSCALE30, GRAYSCALE45,
GRAYSCALE60, GRAYSCALE75, GRAYSCALE90, GRAYSCALE105, GRAYSCALE120,
GRAYSCALE135, GRAYSCALE150, GRAYSCALE165, GRAYSCALE180, GRAYSCALE195,
GRAYSCALE210, GRAYSCALE225, GRAYSCALE240, WHITE
};
/** The number of colors defined by JaxoColor. */
private static int nofColors = colorList.length;
/** List containing the names of all the colors of JaxoColor.
* These are the english names as defined by colordvi.sty and
* at the same time the keys for the translation into other languages.
*/
private static String[] colorName =
{
"GreenYellow", "Yellow", "Goldenrod", "Dandelion", "Apricot", "Peach",
"Melon", "YellowOrange", "Orange", "BurntOrange", "Bittersweet",
"RedOrange", "Mahogany", "Maroon", "BrickRed", "Red", "OrangeRed",
"RubineRed", "WildStrawberry", "Salmon", "CarnationPink", "Magenta",
"VioletRed", "Rhodamine", "Mulberry", "RedViolet", "Fuchsia",
"Lavender", "Thistle", "Orchid", "DarkOrchid", "Purple", "Plum",
"Violet", "RoyalPurple", "BlueViolet", "Periwinkle", "CadetBlue",
"CornflowerBlue", "MidnightBlue", "NavyBlue", "RoyalBlue", "Blue",
"Cerulean", "Cyan", "ProcessBlue", "SkyBlue", "Turquoise", "TealBlue",
"Aquamarine", "BlueGreen", "Emerald", "JungleGreen", "SeaGreen",
"Green", "ForestGreen", "PineGreen", "LimeGreen", "YellowGreen",
"SpringGreen", "OliveGreen", "RawSienna", "Sepia", "Brown", "Tan",
"Gray", "Black", "GrayScale15", "GrayScale30", "GrayScale45",
"GrayScale60", "GrayScale75", "GrayScale90", "GrayScale105",
"GrayScale120", "GrayScale135", "GrayScale150", "GrayScale165",
"GrayScale180", "GrayScale195", "GrayScale210", "GrayScale225",
"GrayScale240", "White"
};
/** Empty private constructor to prevent the class from being
* explicitly instantiated.
*/
private JaxoColor() {
// empty on purpose
}
/** Returns the color at index i of the colorList.
* @param i Index of the color to be returned
* @return Color at index i.
*/
public static Color getColor(int i) {
return colorList[i];
}
/** Returns the color corresponding to the name cName.
* @param cName The name of the color to be returned.
* @return The color corresponding to the name cName.
*/
public static Color getColor(String cName) {
int i = 0;
boolean notinthelist = false;
while (colorName[i].compareTo(cName) != 0) {
i++;
if (i >= getNofColors()) {
notinthelist = true;
break;
}
}
if (notinthelist) {
return colorList[getIndex(JaxoColor.BLACK)];
} else {
return colorList[i];
}
}
/** Returns the name of the color at index i in the colorList.
* @param i Index of the color whose name is to be returned.
* @return Name of the color at index i.
*/
public static String getColorName(int i) {
return colorName[i];
}
/** Returns the name of the color color.
* @param color Color whose name is to be returned.
* @return Name of the color color.
*/
public static String getColorName(Color color) {
int i = 0;
while (!(colorList[i].equals(color))) {
i++;
}
return colorName[i];
}
/** Returns the number of colors defined by JaxoColor.
* @return The number of colors defined by JaxoColor.
*/
public static int getNofColors() {
return nofColors;
}
/** Returns the index in the colorList of the color color.
* @param color The color whose index is to be returned.
* @return The index of the color color.
*/
public static int getIndex(Color color) {
int i = 0;
while (!(colorList[i].equals(color))) {
i++;
}
return i;
}
/** Returnes the index in the colorList of the color whose name is cName.
* @param cName The name of the color whose index is to be returned.
* @return The index in the colorList of the color whose name is cName.
*/
public static int getIndex(String cName) {
int i = 0;
while (colorName[i].compareTo(cName) != 0) {
i++;
}
return i;
}
/** Returns the name of the grayscale that corresponds to color,
* or sets it to a warning message, if color is not a grayscale.
* @param color The color whose grayscale name is to be returned.
* @return The name of the grayscale corresponding to color.
*/
public static String getGreyScale(Color color) {
String greyScale = "";
int i = 0;
while (!(colorList[i].equals(color))) {
i++;
}
if (i >= getIndex(BLACK)) {
int r = color.getRed();
float frac = (float) ((int) ((1000 * (float) r) / 255)) / 1000;
greyScale = Float.toString(frac);
} else {
greyScale =
java.util.ResourceBundle.getBundle(JaxoPrefs.getPref(
JaxoPrefs.PREF_LANGUAGE)).getString("not_a_Greyscale!");
}
return greyScale;
}
/** Checks whether the given color is one of the grey scales
* defined in this class.
* @param color A color.
* @return True if color is a greyscale, false otherwise.
*/
public static boolean isGrayScale(Color color) {
boolean itis = false;
int i = 0;
while (!(colorList[i].equals(color))) {
i++;
}
if ((i >= getIndex(BLACK)) && (i != getIndex(WHITE))) {
itis = true;
}
return itis;
}
/** Returns a String containing the LaTex color command
* (as used by the package colordvi) to set the color color.
* @param color The color to be set in the LaTex command.
* @return The String representation of the LaTex command.
*/
public static String getLatexColorCommand(Color color) {
String base = "\\SetColor{";
String closing = "}";
String thisColor = "";
int i = 0;
while (!(colorList[i].equals(color))) {
i++;
}
// grayscale colors can only be used for filling,
// for drawing we take black
if ((i > getIndex(BLACK)) && (i != getIndex(WHITE))) {
thisColor = "Black";
} else {
thisColor = colorName[i];
}
String latexColor = base.concat(thisColor.concat(closing));
return latexColor;
}
/** Returns the grayscale that corresponds to the float value f.
* or null if f is not between 0.f and 1.f
* @param f A float between 0.f and 1.f
* @return The gray scale corresponding to the float value f.
*/
public static Color getGrayScale(float f) {
Color grayScale = null;
if ((f >= 0.f) && (f <= 1.f)) {
int offset = Math.round(17.f * f);
grayScale = colorList[getIndex(BLACK) + offset];
}
return grayScale;
}
}
Ads help maintain this website.