下面列出了java.awt.Color#LIGHT_GRAY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Color getColorBoxLineColor() {
int a = color.getAlpha();
Color borderColor;
if (a < 127) {
borderColor = Color.GRAY;
} else {
//int cMin = Math.min(color.getRed(), Math.min(color.getGreen(), color.getBlue()));
int cMax = Math.max(color.getRed(), Math.max(color.getGreen(), color.getBlue()));
if (cMax < 127) {
borderColor = Color.LIGHT_GRAY;
} else {
borderColor = Color.GRAY;
}
}
return borderColor;
}
public MergedMoleculesPopUp(JTable parent, int row, int col, List<Molecule> molecules) {
GenericTableModel model = new GenericTableModel();
for(Molecule mol : molecules) {
model.addRow(mol);
}
MoleculeDescriptor header = model.cloneDescriptor();
header.removeParam(MoleculeDescriptor.LABEL_DETECTIONS);
model.setDescriptor(header);
//
JComponent mergedMoleculesTable = new JScrollPane(new JTable(model));
mergedMoleculesTable.setPreferredSize(new Dimension(450, 250));
//
new TableCellBalloonTip(parent, mergedMoleculesTable, row, col,
new RoundedBalloonStyle(5, 10, Color.LIGHT_GRAY, Color.BLUE),
new RightBelowPositioner(10, 10), BalloonTip.getDefaultCloseButton());
}
/**
* C'tor
* The combo box is initialized with some basic colors and user can also
* pick a custom color
*/
public ColorComboBox() {
this( new Color[] {
Color.BLACK,
Color.BLUE,
Color.CYAN,
Color.DARK_GRAY,
Color.GRAY,
Color.GREEN,
Color.LIGHT_GRAY,
Color.MAGENTA,
Color.ORANGE,
Color.PINK,
Color.RED,
Color.WHITE,
Color.YELLOW,
}, new String[0], true);
}
@Alpha
@ConfigItem(
position = 13,
keyName = "markerColor12",
name = "Group 12 tile color",
description = "Configures the color of the 12th group of marked tiles",
hidden = true,
unhide = "amount",
unhideValue = "12"
)
default Color markerColor12()
{
return Color.LIGHT_GRAY;
}
/**
* Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#getBorderColour()}.
* Test method for {@link
* com.sldeditor.ui.legend.option.LegendOptionData#setBorderColour(java.awt.Color)}.
*/
@Test
public void testBorderColour() {
LegendOptionData data = new LegendOptionData();
Color expectedColor = Color.LIGHT_GRAY;
data.setBorderColour(expectedColor);
assertEquals(expectedColor, data.getBorderColour());
}
/**
* Constructor
*/
public GridLine(){
this.color = Color.LIGHT_GRAY;
this.size = 1.0f;
this.style = LineStyles.DASH;
this.drawXLine = false;
this.drawYLine = false;
this.top = false;
}
public static Color getColorForValue(double value, int alpha, boolean logarithmic, double minValue, double maxValue,
Color minColor, Color maxColor) {
if (Double.isNaN(value)) {
return Color.LIGHT_GRAY;
}
// map value to [0,1]
if (minValue == maxValue) {
value = 0.5;
} else if (logarithmic) {
value = (Math.log(value) - Math.log(minValue)) / (Math.log(maxValue) - Math.log(minValue));
} else {
value = (value - minValue) / (maxValue - minValue);
}
Color MIN_LEGEND_COLOR = minColor;
Color MAX_LEGEND_COLOR = maxColor;
float[] minCol = Color.RGBtoHSB(MIN_LEGEND_COLOR.getRed(), MIN_LEGEND_COLOR.getGreen(), MIN_LEGEND_COLOR.getBlue(),
null);
float[] maxCol = Color.RGBtoHSB(MAX_LEGEND_COLOR.getRed(), MAX_LEGEND_COLOR.getGreen(), MAX_LEGEND_COLOR.getBlue(),
null);
double hColorDiff = maxCol[0] - minCol[0];
double sColorDiff = maxCol[1] - minCol[1];
double bColorDiff = maxCol[2] - minCol[2];
Color color = new Color(Color.HSBtoRGB((float) (minCol[0] + hColorDiff * value), (float) (minCol[1] + value
* sColorDiff), (float) (minCol[2] + value * bColorDiff)));
if (alpha < 255) {
color = DataStructureUtils.setColorAlpha(color, alpha);
}
return color;
}
private AttributedString createUndecoratedString(AttributedString prototypeString,
String[] text) {
StringBuilder buffer = new StringBuilder();
for (String string : text) {
buffer.append(string).append(" ");
}
return new AttributedString(buffer.toString(), Color.LIGHT_GRAY,
prototypeString.getFontMetrics(0));
}
@Override
protected JButton createIncreaseButton(int orientation)
{
thumbColor = Color.GRAY;
thumbLightShadowColor = new Color(0, 0, 0, 0);
thumbDarkShadowColor = new Color(0, 0, 0, 0);
thumbHighlightColor = Color.GRAY;
trackColor = new Color(57, 57, 57);
trackHighlightColor = Color.GRAY;
return new BasicArrowButton(BasicArrowButton.SOUTH,
Color.GRAY, Color.GRAY, new Color(57, 57, 57), Color.LIGHT_GRAY);
}
protected JComponent createColorPicker() {
Color[] colors = {Color.BLACK,
Color.DARK_GRAY,
Color.GRAY,
Color.LIGHT_GRAY,
Color.WHITE,
Color.CYAN,
Color.BLUE,
Color.MAGENTA,
Color.YELLOW,
Color.ORANGE,
Color.RED,
Color.PINK,
Color.GREEN};
JPanel colorsPanel = new JPanel(new GridLayout(-1, 6, 4, 4));
colorsPanel.setOpaque(false);
for (Color color : colors) {
ColorLabel colorLabel = new ColorLabel(color);
colorLabel.setDisplayName(ColorCodes.getName(color));
colorLabel.setHoverEnabled(true);
colorLabel.setMaximumSize(colorLabel.getPreferredSize());
colorLabel.setMinimumSize(colorLabel.getPreferredSize());
colorLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
setSelectedColor(colorLabel.getColor());
}
});
colorsPanel.add(colorLabel);
}
return colorsPanel;
}
/**
* Draws indicator in case the annotation text overflows on the y axis.
*
* @param g
* the graphics context to draw upon
* @param loc
* the location of the annotation
* @param printing
* if we are currently printing
*/
private void drawOverflowIndicator(final Graphics2D g, final Rectangle2D loc, final boolean printing) {
if (printing) {
// never draw them for printing
return;
}
Graphics2D g2 = (Graphics2D) g.create();
int size = 20;
int xOffset = 10;
int yOffset = 10;
int stepSize = size / 4;
int dotSize = 3;
int x = (int) loc.getMaxX() - size - xOffset;
int y = (int) loc.getMaxY() - size - yOffset;
GradientPaint gp = new GradientPaint(x, y, Color.WHITE, x, y + size * 1.5f, Color.LIGHT_GRAY);
g2.setPaint(gp);
g2.fillRect(x, y, size, size);
g2.setColor(Color.BLACK);
g2.drawRect(x, y, size, size);
g2.fillOval(x + stepSize, y + stepSize * 2, dotSize, dotSize);
g2.fillOval(x + stepSize * 2, y + stepSize * 2, dotSize, dotSize);
g2.fillOval(x + stepSize * 3, y + stepSize * 2, dotSize, dotSize);
g2.dispose();
}
@Override
public boolean apply(EdgeRenderingProperty p) {
NodeRenderingProperty node1 = p.node1;
NodeRenderingProperty node2 = p.node2;
if (node1.isSelected() && node2.isSelected()) {
// both ends of the edge is selected.
p.targetStrokeColor = Color.DARK_GRAY;
} else if (node1.isSelected()) {
// edges to the child of the selected node in blue
p.targetStrokeColor = Color.RED;
} else if (node2.isSelected()) {
// edges to the parent of the selected node in red
p.targetStrokeColor = Color.BLUE;
} else if (p.overriddenStrokeColor != null) {
p.targetStrokeColor = p.overriddenStrokeColor;
// TODO(yohann): Reimplement this with help from plugins
/*
} else if (containerFinder.matchForward(p.edge.getRelation())
|| containerFinder.matchBackward(p.edge.getRelation())) {
// not picked, draw container edges with distinctive color
p.targetStrokeColor = Color.GRAY;
*/
} else {
p.targetStrokeColor = Color.LIGHT_GRAY;
}
return true;
}
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException
{
//calcMeans();
// Create JFreeChart Dataset
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset( );
HashMap<String, ArrayList<Double> > measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
for (Map.Entry<String, ArrayList<Double> > measure : measuresFirst.entrySet())
{
String measureName = measure.getKey();
//Double measureValue = measure.getValue();
dataset.clear();
for (Map.Entry<String, HashMap<String, ArrayList<Double> >> entry : algorithmMeasures.entrySet())
{
String alg = entry.getKey();
ArrayList<Double> measureValues = entry.getValue().get(measureName);
// Parse algorithm name to show it correctly
String aName = alg.substring(0, alg.length()-1);
int startAlgName = aName.lastIndexOf("/");
aName = aName.substring(startAlgName + 1);
dataset.add(measureValues, aName, measureName);
}
// Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
final CategoryAxis xAxis = new CategoryAxis("Algorithm");
final NumberAxis yAxis = new NumberAxis("Value");
yAxis.setAutoRangeIncludesZero(false);
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
// Black and White
int numItems = algorithmMeasures.size();
for(int i=0;i<numItems;i++)
{
Color color = Color.DARK_GRAY;
if(i%2 == 1)
{
color = Color.LIGHT_GRAY;
}
renderer.setSeriesPaint(i, color);
renderer.setSeriesOutlinePaint(i, Color.BLACK);
}
renderer.setMeanVisible(false);
renderer.setFillBox(false);
renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
Font font = new Font("SansSerif", Font.BOLD, 10);
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
//StandardChartTheme.createLegacyTheme().apply(jchart);
int width = 640 * 2; /* Width of the image */
int height = 480 * 2; /* Height of the image */
// JPEG
File chart = new File( outName + "_" + measureName + "_boxplot.jpg" );
ChartUtilities.saveChartAsJPEG( chart , jchart , width , height );
// SVG
SVGGraphics2D g2 = new SVGGraphics2D(width, height);
Rectangle r = new Rectangle(0, 0, width, height);
jchart.draw(g2, r);
File BarChartSVG = new File( outName + "_" + measureName + "_boxplot.svg" );
SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
}
}
/**
* Create the image that will be animated. This image may be an actual
* image (duke.gif), or some graphics (a variation on a black filled
* rectangle) that are rendered into an image. The contents
* of this image are dependent upon the runtime toggles that have been
* set when this method is called.
*/
void createAnimationImage() {
GraphicsConfiguration gc = getGraphicsConfiguration();
image = gc.createCompatibleImage(imageW, imageH, Transparency.TRANSLUCENT);
Graphics2D gImg = image.createGraphics();
if (useImage) {
try {
URL url = getClass().getResource("images/duke.gif");
Image originalImage = ImageIO.read(url);
gImg.drawImage(originalImage, 0, 0, imageW, imageH, null);
} catch (Exception e) {}
} else {
// use graphics
Color graphicsColor;
if (alterColor) {
graphicsColor = Color.LIGHT_GRAY;
} else {
graphicsColor = Color.BLACK;
}
gImg.setColor(graphicsColor);
gImg.fillRect(0, 0, imageW, imageH);
if (useAA) {
// Antialiasing hack - just draw a fading-out border around the
// rectangle
gImg.setComposite(AlphaComposite.Src);
int red = graphicsColor.getRed();
int green = graphicsColor.getRed();
int blue = graphicsColor.getRed();
gImg.setColor(new Color(red, green, blue, 50));
gImg.drawRect(0, 0, imageW - 1, imageH - 1);
gImg.setColor(new Color(red, green, blue, 100));
gImg.drawRect(1, 1, imageW - 3, imageH - 3);
gImg.setColor(new Color(red, green, blue, 150));
gImg.drawRect(2, 2, imageW - 5, imageH - 5);
gImg.setColor(new Color(red, green, blue, 200));
gImg.drawRect(3, 3, imageW - 7, imageH - 7);
gImg.setColor(new Color(red, green, blue, 225));
gImg.drawRect(4, 4, imageW - 9, imageH - 9);
}
}
gImg.dispose();
}
public static Color color(byte material) {
if (material == TRAP)
return Color.LIGHT_GRAY;
else
return Color.BLACK;
}
public static Color color(byte material) {
if (material == TRAP)
return Color.LIGHT_GRAY;
else
return Color.BLACK;
}
public UncheckedImageWidget(Scene scene, int size) {
super(scene, Color.LIGHT_GRAY, size, size);
setBackground(Color.WHITE);
setBorder(BorderFactory.createLineBorder(1, Color.GRAY));
setOpaque(true);
}
public static Color color(byte material) {
if (material == TRAP)
return Color.LIGHT_GRAY;
else
return Color.BLACK;
}
@Override
public Object[] createLookAndFeelCustomizationKeysAndValues() {
if (ThemeValue.functioning()) {
return new Object[] {
//XXX once the JDK team has integrated support for standard
//UIManager keys into 1.5 (not there as of b47), these can
//probably be deleted, resulting in a performance improvement:
"control", control,
"controlHighlight", new ThemeValue (Region.PANEL, ThemeValue.LIGHT, Color.LIGHT_GRAY), //NOI18N
"controlShadow", new ThemeValue (Region.PANEL, ThemeValue.DARK, Color.DARK_GRAY), //NOI18N
"controlDkShadow", new ThemeValue (Region.PANEL, ThemeValue.BLACK, Color.BLACK), //NOI18N
"controlLtHighlight", new ThemeValue (Region.PANEL, ThemeValue.WHITE, Color.WHITE), //NOI18N
"textText", new ThemeValue (Region.PANEL, ColorType.TEXT_FOREGROUND, Color.BLACK), //NOI18N
"text", new ThemeValue (Region.PANEL, ColorType.TEXT_BACKGROUND, Color.GRAY), //NOI18N
"tab_unsel_fill", control, //NOI18N
"SplitPane.dividerSize", new Integer (2), //NOI18N
SYSTEMFONT, controlFont, //NOI18N
USERFONT, controlFont, //NOI18N
MENUFONT, controlFont, //NOI18N
LISTFONT, controlFont, //NOI18N
"Label.font", controlFont, //NOI18N
"Panel.font", controlFont, //NOI18N
// workaround: GTKLookAndFeel FileChooser is unusable, cannot
// choose a dir and doesn't look native anyway. We force MetalFileChooserUI
"FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI", // NOI18N
"FileView.computerIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeComputerIcon(), // NOI18N
"FileView.hardDriveIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeHardDriveIcon(), // NOI18N
"FileView.floppyDriveIcon", javax.swing.plaf.metal.MetalIconFactory.getTreeFloppyDriveIcon(), // NOI18N
"FileChooser.newFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserNewFolderIcon(), // NOI18N
"FileChooser.upFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserUpFolderIcon(), // NOI18N
"FileChooser.homeFolderIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserHomeFolderIcon(), // NOI18N
"FileChooser.detailsViewIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserDetailViewIcon(), // NOI18N
"FileChooser.listViewIcon", javax.swing.plaf.metal.MetalIconFactory.getFileChooserListViewIcon(), // NOI18N
"FileChooser.usesSingleFilePane", Boolean.TRUE, // NOI18N
"FileChooser.ancestorInputMap", // NOI18N
new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancelSelection", // NOI18N
"F2", "editFileName", // NOI18N
"F5", "refresh", // NOI18N
"BACK_SPACE", "Go Up", // NOI18N
"ENTER", "approveSelection", // NOI18N
"ctrl ENTER", "approveSelection" // NOI18N
}),
// special tree icons - only for property sheet
"Tree.gtk_expandedIcon", new GTKExpandedIcon(),
"Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
};
} else {
Object[] result = new Object[] {
TOOLBAR_UI, new UIDefaults.ProxyLazyValue("org.netbeans.swing.plaf.gtk.GtkToolbarUI"), //NOI18N
// special tree icons - only for property sheet
"Tree.gtk_expandedIcon", new GTKExpandedIcon(),
"Tree.gtk_collapsedIcon", new GTKCollapsedIcon(),
};
return result;
}
}
/**
* Construct a Border object that draws a light gray line on 0, 1, 2, 3, or all
* 4 sides of the component. Note: it paints the borders top, bottom, left, then
* right.
*
* @param top - true if we want to draw a Color.LIGHT_GRAY border line above the
* component
* @param left - true if we want to draw a Color.LIGHT_GRAY border line to the
* left of the component
* @param bottom - true if we want to draw a Color.LIGHT_GRAY border line below
* the component
* @param right - true if we want to draw a Color.LIGHT_GRAY border line to the
* right of the component
*/
public OurBorder(boolean top, boolean left, boolean bottom, boolean right) {
this.top = top ? Color.LIGHT_GRAY : null;
this.left = left ? Color.LIGHT_GRAY : null;
this.bottom = bottom ? Color.LIGHT_GRAY : null;
this.right = right ? Color.LIGHT_GRAY : null;
}