List of usage examples for java.awt Color Color
public Color(ColorSpace cspace, float[] components, float alpha)
From source file:MouseMoveScale.java
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setColor(new Color(0, 0, 200)); g2d.fill(myRect);/*from w w w .j a v a2s. co m*/ }
From source file:graphviewer.MyTransformer.java
public MyTransformer(ArrayList<GraphNode> list, int numberOfScc) { this.list = list; /** Color Palette, Excel (#chart) */ this.colors.add(new Color(0, 0, 0)); this.colors.add(new Color(255, 255, 255)); this.colors.add(new Color(255, 0, 0)); this.colors.add(new Color(0, 255, 0)); this.colors.add(new Color(0, 0, 255)); this.colors.add(new Color(255, 255, 0)); this.colors.add(new Color(255, 0, 255)); this.colors.add(new Color(0, 255, 255)); this.colors.add(new Color(128, 0, 0)); this.colors.add(new Color(0, 128, 0)); this.colors.add(new Color(0, 0, 128)); this.colors.add(new Color(128, 128, 0)); this.colors.add(new Color(128, 0, 128)); this.colors.add(new Color(0, 128, 128)); this.colors.add(new Color(192, 192, 192)); this.colors.add(new Color(128, 128, 128)); this.colors.add(new Color(153, 153, 255)); this.colors.add(new Color(153, 51, 102)); this.colors.add(new Color(255, 255, 204)); this.colors.add(new Color(204, 255, 255)); this.colors.add(new Color(102, 0, 102)); this.colors.add(new Color(255, 128, 128)); this.colors.add(new Color(0, 102, 204)); this.colors.add(new Color(204, 204, 255)); this.colors.add(new Color(0, 0, 128)); this.colors.add(new Color(255, 0, 255)); this.colors.add(new Color(255, 255, 0)); this.colors.add(new Color(0, 255, 255)); this.colors.add(new Color(128, 0, 128)); this.colors.add(new Color(128, 0, 0)); this.colors.add(new Color(0, 128, 128)); this.colors.add(new Color(0, 0, 255)); this.colors.add(new Color(0, 204, 255)); this.colors.add(new Color(204, 255, 255)); this.colors.add(new Color(204, 255, 204)); this.colors.add(new Color(255, 255, 153)); this.colors.add(new Color(153, 204, 255)); this.colors.add(new Color(255, 153, 204)); this.colors.add(new Color(204, 153, 255)); this.colors.add(new Color(255, 204, 153)); this.colors.add(new Color(51, 102, 255)); this.colors.add(new Color(51, 204, 204)); this.colors.add(new Color(153, 204, 0)); this.colors.add(new Color(255, 204, 0)); this.colors.add(new Color(255, 153, 0)); this.colors.add(new Color(255, 102, 0)); this.colors.add(new Color(102, 102, 153)); this.colors.add(new Color(150, 150, 150)); this.colors.add(new Color(0, 51, 102)); this.colors.add(new Color(51, 153, 102)); this.colors.add(new Color(0, 51, 0)); this.colors.add(new Color(51, 51, 0)); this.colors.add(new Color(153, 51, 0)); this.colors.add(new Color(153, 51, 102)); this.colors.add(new Color(51, 51, 153)); this.colors.add(new Color(51, 51, 51)); /** if number of scc is bigger than 56 choose a random color */ if (numberOfScc > 56) { Random a = new Random(); for (int i = 56; i < numberOfScc; i++) { this.colors.add(new Color(a.nextInt(255), a.nextInt(255), a.nextInt(255))); }//w w w .j av a 2 s .c o m } }
From source file:net.sourceforge.processdash.ui.web.reports.DashboardChartDefaults.java
public static void initialize() { // install the legacy theme for chart colors ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // turn off shadows on bar charts by default BarRenderer.setDefaultShadowsVisible(false); XYBarRenderer.setDefaultShadowsVisible(false); // the standard set of colors includes yellow, which is nearly // impossible to see on a white background. Replace those yellows with // variations on orange. DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[3] = Color.orange; DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[18] = new Color(215, 170, 0); DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[31] = new Color(255, 200, 128); }
From source file:Main.java
/** * Creates a new <code>Color</code> that is a brighter version of this * <code>Color</code>. This method is the same implementation * java.awt.Color#brighter is usind except it has a configurable factor. * The java.awt.Color default facotr is 0.7 * @return a new <code>Color</code> object that is * a brighter version of this <code>Color</code>. * @see java.awt.Color#darker//from w ww .j a v a2 s . c o m */ public static Color brighterColor(Color color, double factor) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); /* From 2D group: * 1. black.brighter() should return grey * 2. applying brighter to blue will always return blue, brighter * 3. non pure color (non zero rgb) will eventually return white */ int i = (int) (1.0 / (1.0 - factor)); if (r == 0 && g == 0 && b == 0) { return new Color(i, i, i); } if (r > 0 && r < i) r = i; if (g > 0 && g < i) g = i; if (b > 0 && b < i) b = i; return new Color(Math.min((int) (r / factor), 255), Math.min((int) (g / factor), 255), Math.min((int) (b / factor), 255)); }
From source file:Main.java
/** * Create a shade of gray with the given degree of darkness. {@code 0.0f} corresponds to white; * {@code 1.0f} corresponds to black./*from w ww.j av a 2s.c o m*/ */ public static Color gray(float degree) { float x = 1.0f - degree; return new Color(x, x, x); }
From source file:LayeredPaneDemo2.java
public LayeredPaneDemo2() { super("Custom MDI: Part III"); setSize(570, 400);/* ww w . j a v a 2s .c o m*/ getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); // VERY IMPORTANT!! ImageIcon ii = new ImageIcon("earth.jpg"); InnerFrame[] frames = new InnerFrame[5]; for (int i = 0; i < 5; i++) { frames[i] = new InnerFrame("InnerFrame " + i); frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200); frames[i].getContentPane().add(new JScrollPane(new JLabel(ii))); getLayeredPane().add(frames[i]); } WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); ImageIcon image = new ImageIcon("spiral.gif"); setIconImage(image.getImage()); addWindowListener(l); setVisible(true); }
From source file:com.polivoto.vistas.Editor.java
/** * Ventana Editor - configura el color de las preguntas. *//*from w w w . j ava 2 s.com*/ public Editor(JSONArray js) { initComponents(); for (int i = 0; i < js.length(); i++) { try { JPanel panel = new JPanel(new GridLayout(0, 2, 10, 10)); panel.setBackground(new Color(255, 255, 255)); jTabbedPane.add(panel, "Pregunta " + (i + 1)); JLabel lab1 = new JLabel( "Pregunta " + (i + 1) + ": " + ((JSONObject) js.get(i)).getString("pregunta"), JLabel.LEFT); lab1.setFont(new Font("Roboto", 1, 18)); lab1.setForeground(new Color(134, 36, 31)); panel.add(lab1); panel.add(new JLabel("")); JSONArray jarr = ((JSONObject) js.get(i)).getJSONArray("opciones"); for (int j = 0; j < jarr.length(); j++) { JLabel lab2 = new JLabel("Opcin " + (j + 1) + ": " + jarr.getString(j), JLabel.LEFT); JButton colBut = new JButton("Seleccionar color de la opcin"); colBut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jFrame1.setVisible(true); } }); lab2.setFont(new Font("Roboto", 1, 15)); lab2.setForeground(new Color(0, 0, 0)); panel.add(lab2); panel.add(colBut); } } catch (JSONException ex) { Logger.getLogger(AnalistaLocal.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.jml.main.Graph.java
public void drawScatterPlot(String title, XYDataset xYDataset) { JFreeChart chart = ChartFactory.createScatterPlot(title, "X axis label", "Y axis label", xYDataset); XYPlot plot = chart.getXYPlot();/*from w w w . j ava 2 s . c o m*/ Random random = new Random(); for (int i = 0; i < dataset.getSeriesCount(); ++i) { plot.getRenderer().setSeriesPaint(i, new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))); } panel = new ChartPanel(chart); this.add(panel); this.pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
From source file:org.jfree.chart.demo.MarkerDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeTickBandPaint(new Color(240, 240, 240)); PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005)); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class, new SimpleDateFormat("HH")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("dd-MMM")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);/*ww w .ja v a 2 s.c o m*/ ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setRange(0.0D, 100D); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.green); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F)); ValueMarker valuemarker = new ValueMarker(80D); valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.red); valuemarker.setStroke(new BasicStroke(2.0F)); valuemarker.setLabel("Temperature Threshold"); valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); valuemarker.setLabelPaint(Color.red); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); xyplot.addRangeMarker(valuemarker); Hour hour = new Hour(18, 30, 6, 2005); Hour hour1 = new Hour(20, 30, 6, 2005); double d = hour.getFirstMillisecond(); double d1 = hour1.getFirstMillisecond(); IntervalMarker intervalmarker = new IntervalMarker(d, d1); intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); intervalmarker.setPaint(new Color(150, 150, 255)); intervalmarker.setLabel("Automatic Cooling"); intervalmarker.setLabelFont(new Font("SansSerif", 0, 11)); intervalmarker.setLabelPaint(Color.blue); intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND); ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F)); ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F)); xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND); xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND); return jfreechart; }
From source file:Main.java
public Main() { mainPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); mainPanel.setLayout(null);// w w w . j a v a2 s .com MyMouseAdapter myMouseAdapter = new MyMouseAdapter(); for (int i = 0; i < LABEL_STRINGS.length; i++) { JLabel label = new JLabel(LABEL_STRINGS[i], SwingConstants.CENTER); label.setSize(new Dimension(LBL_WIDTH, LBL_HEIGHT)); label.setOpaque(true); Random random = new Random(); label.setLocation(random.nextInt(WIDTH - LBL_WIDTH), random.nextInt(HEIGHT - LBL_HEIGHT)); label.setBackground( new Color(150 + random.nextInt(105), 150 + random.nextInt(105), 150 + random.nextInt(105))); label.addMouseListener(myMouseAdapter); label.addMouseMotionListener(myMouseAdapter); mainPanel.add(label); } }