List of usage examples for java.awt Color darker
public Color darker()
From source file:Main.java
public static void main(String[] args) { Color myColor = Color.RED; JLabel label = new JLabel("First Name"); label.setForeground(myColor.darker()); JFrame frame = new JFrame(); frame.add(label);//from w ww . j a v a 2 s . c om frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java
/** * @param chart/*from w ww . j a va2 s.c o m*/ * @return */ private static XYAreaRenderer getMountainRenderer(final AbstractChart chart) { final XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setOutline(true); for (int i = 0; i < chart.getColors().size(); i++) { final Color c = chart.getColors().get(i); renderer.setSeriesPaint(i, c); renderer.setSeriesOutlinePaint(i, c.darker()); renderer.setSeriesOutlineStroke(i, LineStyle.THICK.getStroke()); } return renderer; }
From source file:ExtendedParagraphExample.java
public static void createDocumentStyles(StyleContext sc) { Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); // Create and add the main document style Style mainStyle = sc.addStyle(mainStyleName, defaultStyle); StyleConstants.setLeftIndent(mainStyle, 16); StyleConstants.setRightIndent(mainStyle, 16); StyleConstants.setFirstLineIndent(mainStyle, 16); StyleConstants.setFontFamily(mainStyle, "serif"); StyleConstants.setFontSize(mainStyle, 12); // Create and add the constant width style Style cwStyle = sc.addStyle(charStyleName, null); StyleConstants.setFontFamily(cwStyle, "monospaced"); StyleConstants.setForeground(cwStyle, Color.white); // Create and add the heading style Style heading2Style = sc.addStyle(heading2StyleName, null); StyleConstants.setForeground(heading2Style, Color.red); StyleConstants.setFontSize(heading2Style, 16); StyleConstants.setFontFamily(heading2Style, "serif"); StyleConstants.setBold(heading2Style, true); StyleConstants.setLeftIndent(heading2Style, 8); StyleConstants.setFirstLineIndent(heading2Style, 0); // Create and add the extended para styles Style paraStyle = sc.addStyle(paraStyleName, null); Color bgColor = Color.gray; ExtendedStyleConstants.setParagraphBackground(paraStyle, bgColor); ExtendedStyleConstants.setParagraphBorder(paraStyle, BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(bgColor.brighter(), bgColor.darker()), BorderFactory.createEmptyBorder(4, 4, 4, 4)))); }
From source file:canreg.client.analysis.Tools.java
public static void setPiePlotColours(JFreeChart chart, int numberOfSections, Color baseColor) { Color color = baseColor;//ww w . ja va 2s . co m PiePlot plot = (PiePlot) chart.getPlot(); for (int i = 0; i < numberOfSections; i++) { try { plot.setSectionOutlinePaint(plot.getDataset().getKey(i), baseColor.darker().darker().darker()); color = darken(color); plot.setSectionPaint(plot.getDataset().getKey(i), color); } catch (java.lang.IndexOutOfBoundsException ex) { // not data for all the categories - that is fine Logger.getLogger(TopNChartTableBuilder.class.getName()).log(Level.INFO, null, ex); } } }
From source file:guineu.modules.visualization.intensityboxplot.IntensityBoxPlotDrawingSupplier.java
public Paint getNextPaint() { // get new color from the default supplier Color baseColor = (Color) super.getNextPaint(); // ban colors that are too bright int colorSum = baseColor.getRed() + baseColor.getGreen() + baseColor.getBlue(); if (colorSum > 520) baseColor = baseColor.darker(); return baseColor; }
From source file:TreeLinkTest.java
/** * This piece of hackery is needed since one cant really draw things from a * layout manager. Call this if you want to draw lines between components. */// w w w. j ava 2 s. c o m public void paintLines(Graphics g, Color bg) { Color dk = bg.darker(); Color br = bg.brighter(); root.paintLines(g, dk, br); }
From source file:edu.ku.brc.ui.GradiantButton.java
/** * Draws the button body//from w w w .java 2 s .c o m * @param g2 the graphics to be painted into * @param w the width of the control * @param h the height of the control * @param color the of the background */ protected void drawButtonBody(Graphics2D g2, int w, int h, Color color) { // draw the button body Color grad_top = color.brighter(); Color grad_bot = color.darker(); GradientPaint bg = new GradientPaint(new Point(0, 0), grad_top, new Point(0, h), grad_bot); g2.setPaint(bg); g2.fillRect(0, 0, w, h); }
From source file:AppletMenuBarDemo.java
/** * This method is called to draw tell the component to redraw itself. If we * were implementing a Swing component, we'd override paintComponent() * instead//from ww w . j av a2 s . com */ public void paint(Graphics g) { if (remeasure) measure(); // Remeasure everything first, if needed // Figure out Y coordinate to draw at Dimension size = getSize(); int baseline = size.height - margins.bottom - descent; // Set the font to draw with g.setFont(getFont()); // Loop through the labels int nummenus = labels.size(); for (int i = 0; i < nummenus; i++) { // Set the drawing color. Highlight the current item if ((i == highlightedItem) && (highlightColor != null)) g.setColor(getHighlightColor()); else g.setColor(getForeground()); // Draw the menu label at the position computed in measure() g.drawString((String) labels.elementAt(i), startPositions[i], baseline); } // Now draw a groove at the bottom of the menubar. Color bg = getBackground(); g.setColor(bg.darker()); g.drawLine(0, size.height - 2, size.width, size.height - 2); g.setColor(bg.brighter()); g.drawLine(0, size.height - 1, size.width, size.height - 1); }
From source file:com.artnaseef.jmeter.report.ResultCodesStackedReport.java
/** * Adjust one color for the chart given the map of color assignments already applied, the chart grouping * (i.e. category or row value), and the starting color for the group. * * @param adjustMap state of adjustments already made. * @param group the color grouping for which to assign a color. * @param startColor initial color to use in the group. * @return//from w w w .ja v a 2 s. c om */ protected Color adjustColor(Map<Integer, Integer> adjustMap, int group, Color startColor) { Color result = startColor; Integer count = adjustMap.get(group); if (count == null) { adjustMap.put(group, 1); } else { int cur = 0; while (cur < count) { result = result.darker(); cur++; } adjustMap.put(group, count + 1); } return result; }
From source file:edu.ku.brc.specify.plugins.latlon.DDDDPanel.java
/** * Creates the UI for the panel./*from ww w . j a v a2 s. c o m*/ * @param colDef the JGoodies column definition * @param latCols the number of columns for the latitude control * @param lonCols the number of columns for the longitude control * @param cbxIndex the column index of the combobox * @return return the builder */ protected PanelBuilder createUI(final String colDef, final int latCols, final int lonCols, final int cbxIndex, final boolean asDDIntegers) { latitudeDD = asDDIntegers ? createTextField(Integer.class, latCols, 0, 90, latTFs) : createTextField(Double.class, latCols, 0.0, 90.0, latTFs); longitudeDD = asDDIntegers ? createTextField(Integer.class, lonCols, 0, 180, lonTFs) : createTextField(Double.class, lonCols, 0.0, 180.0, lonTFs); textFields.addAll(latTFs); textFields.addAll(lonTFs); PanelBuilder builder = new PanelBuilder(new FormLayout(colDef, "p, 1px, p, c:p:g")); CellConstraints cc = new CellConstraints(); latitudeDir = createDirComboxbox(true); longitudeDir = createDirComboxbox(false); JComponent latDir; JComponent lonDir; if (isViewMode) { latitudeDirTxt = new JTextField(2); longitudeDirTxt = new JTextField(2); setControlSize(latitudeDirTxt); setControlSize(longitudeDirTxt); ViewFactory.changeTextFieldUIForDisplay(latitudeDirTxt, false); ViewFactory.changeTextFieldUIForDisplay(longitudeDirTxt, false); latDir = latitudeDirTxt; lonDir = longitudeDirTxt; } else { latDir = latitudeDir; lonDir = longitudeDir; } builder.add(latLabel = createI18NFormLabel("Latitude", SwingConstants.RIGHT), cc.xy(1, 1)); builder.add(latitudeDD, cc.xy(3, 1)); builder.add(latDir, cc.xy(cbxIndex, 1)); builder.add(lonLabel = createI18NFormLabel("Longitude", SwingConstants.RIGHT), cc.xy(1, 3)); builder.add(longitudeDD, cc.xy(3, 3)); builder.add(lonDir, cc.xy(cbxIndex, 3)); builder.setBorder(BorderFactory.createEmptyBorder(4, 2, 0, 2)); PanelBuilder pb = new PanelBuilder(new FormLayout(colDef, "p, 1px, p, p"), this); PanelBuilder txtPanelPB = new PanelBuilder(new FormLayout("5px,p,5px,p,2px,p", "p, 4px, p")); latitudeTF = new JTextField(15); longitudeTF = new JTextField(15); if (!isViewMode) { Color bg = getBackground(); txtPanelPB.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(1, 1, 1, 3)); txtPanelPB.add(latitudeTF, cc.xy(4, 1)); txtPanelPB.add(createI18NLabel("SOURCE"), cc.xy(6, 1)); txtPanelPB.add(longitudeTF, cc.xy(4, 3)); txtPanelPB.add(createI18NLabel("SOURCE"), cc.xy(6, 3)); txtPanelPB.setBorder(BorderFactory.createEmptyBorder(4, 2, 0, 2)); } latitudeTF.setEditable(false); longitudeTF.setEditable(false); pb.add(builder.getPanel(), cc.xy(1, 1)); pb.add(txtPanelPB.getPanel(), cc.xy(3, 1)); textFields.addAll(latTFs); textFields.addAll(lonTFs); return builder; }