List of usage examples for java.awt Color darker
public Color darker()
From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphNode.java
/** * Draw a GraphNode as a rectangle with a name * * @param g The Java2D Graphics/* w ww. j a v a2s . c o m*/ * @param col The color to draw */ public void drawNode(final Graphics2D g, final Color col) { final int x = displayPosition.x; final int y = displayPosition.y; g.setFont(g.getFont().deriveFont(Font.BOLD, 11)); final FontMetrics metrics = g.getFontMetrics(); final String name = node.getId(); final Rectangle2D rect = metrics.getStringBounds(name, g); final int stringWidth = (int) rect.getWidth(); setSize(Math.max(stringWidth, 50) + 10, 25); int step = 4; int alpha = 96; for (int i = 0; i < step; ++i) { g.setColor(new Color(0, 0, 0, alpha - (32 * i))); g.drawLine(x + i + 1, y + nodeHeight + i, x + nodeWidth + i - 1, y + nodeHeight + i); g.drawLine(x + nodeWidth + i, y + i, x + nodeWidth + i, y + nodeHeight + i); } Shape clipShape = new Rectangle(x, y, nodeWidth, nodeHeight); g.setComposite(AlphaComposite.SrcAtop); g.setPaint(new GradientPaint(x, y, col, x + nodeWidth, y + nodeHeight, col.darker())); g.fill(clipShape); g.setColor(Color.blue); g.draw3DRect(x, y, nodeWidth - 1, nodeHeight - 1, true); g.setColor(Color.BLACK); g.drawString(name, x + (nodeWidth - stringWidth) / 2, y + 15); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.grid.LinePointCollector.java
private static final void drawHandles(final Graphics g, final int[] x, final int[] y, final int pointRectWidth, final int selection) { final Color oldColor = g.getColor(); g.setColor(oldColor.darker()); // int sizeOuter = 4; final int halfRectWidth = pointRectWidth / 2; if (selection < 0) { for (int i = 0; i < y.length; i++) { g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth); }//from ww w.jav a 2s. com } else { int i; for (i = 0; i < selection; i++) { g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth); } // is is now selection g.drawOval(x[i] - pointRectWidth, y[i] - pointRectWidth, pointRectWidth + pointRectWidth, pointRectWidth + pointRectWidth); i++; for (; i < y.length; i++) { g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth); } } g.setColor(oldColor); }
From source file:test.uk.co.modularaudio.util.swing.texttoggle.TestUseTextToggle.java
public void go() throws Exception { final JFrame testFrame = new JFrame("TestFrame"); testFrame.setSize(new Dimension(300, 300)); testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container contentPane = testFrame.getContentPane(); final MigLayoutStringHelper msh = new MigLayoutStringHelper(); msh.addLayoutConstraint("fill"); msh.addLayoutConstraint("gap 0"); msh.addLayoutConstraint("insets 0"); contentPane.setLayout(msh.createMigLayout()); final Color BACKGROUND_COLOR = Color.BLACK; final Color SCOPE_BODY = new Color(75, 131, 155); final Color SCOPE_AXIS_DETAIL = SCOPE_BODY.darker().darker(); final Color selectedTextColor = SCOPE_BODY; final Color unselectedTextColor = SCOPE_AXIS_DETAIL; final Color borderColor = SCOPE_AXIS_DETAIL; final Color backgroundColor = BACKGROUND_COLOR; final ToggleReceiver testReceiver = new ToggleReceiver() { @Override//from w ww . j a va 2 s . c o m public void receiveToggle(final int toggleId, final boolean active) { log.trace("Received a toggle of " + toggleId + " to " + active); } }; final TextToggle tt = new TextToggle("Bi Polar", "Uni Polar", selectedTextColor, unselectedTextColor, backgroundColor, borderColor, true, true, testReceiver, -1); contentPane.add(tt, "grow"); testFrame.pack(); testFrame.addWindowListener(new WindowListener() { @Override public void windowOpened(final WindowEvent e) { } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } @Override public void windowClosing(final WindowEvent e) { log.trace("Window closing. Value of control is \"" + tt.getControlValue() + "\""); } @Override public void windowClosed(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { log.trace("Showing test frame"); testFrame.setVisible(true); } }); }
From source file:tufts.vue.LWComponent.java
public static Color getContrastColor(Color c) { if (c != null) { if (c.equals(Color.black)) return Color.darkGray; else/*from www.ja v a2 s . co m*/ return c.darker(); } else { return DEBUG.BOXES ? Color.red : Color.gray; } }