List of usage examples for java.awt Color RED
Color RED
To view the source code for java.awt Color RED.
Click Source Link
From source file:Hypnosis1.java
public Hypnosis1(int numberOfSegments) { int numberOfCoordinates = numberOfSegments * 4 + 2; coordinates = new int[numberOfCoordinates]; deltas = new int[numberOfCoordinates]; for (int i = 0; i < numberOfCoordinates; i++) { coordinates[i] = (int) (Math.random() * 300); deltas[i] = (int) (Math.random() * 4 + 3); if (deltas[i] > 4) deltas[i] = -(deltas[i] - 3); }// w w w . ja v a 2 s . c o m paint = new GradientPaint(0, 0, Color.blue, 20, 10, Color.red, true); Thread t = new Thread(this); t.start(); }
From source file:org.jfree.chart.demo.XYBlockChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D);/* w ww. jav a2s .c o m*/ dateaxis.setUpperMargin(0.0D); dateaxis.setInverted(true); NumberAxis numberaxis = new NumberAxis("Hour"); numberaxis.setUpperMargin(0.0D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); xyblockrenderer.setBlockWidth(86400000D); xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white); lookuppaintscale.add(0.5D, Color.red); lookuppaintscale.add(1.5D, Color.green); lookuppaintscale.add(2.5D, Color.blue); lookuppaintscale.add(3.5D, Color.yellow); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" }); symbolaxis.setRange(0.5D, 4.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D)); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setAxisOffset(5D); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:Main.java
@Override public void paintComponent(Graphics g) { int margin = 10; Dimension dim = getSize();//www .j ava 2 s.co m super.paintComponent(g); g.setColor(Color.red); g.fillRect(margin, margin, dim.width - margin * 2, dim.height - margin * 2); }
From source file:GradientPaintEllipse.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int x = 5;//from w w w . j av a 2s . c o m int y = 7; // fill Ellipse2D.Double GradientPaint redtowhite = new GradientPaint(x, y, Color.red, 200, y, Color.white); g2.setPaint(redtowhite); g2.fill(new Ellipse2D.Double(x, y, 200, 200)); g2.setPaint(Color.black); g2.drawString("Filled Ellipse2D", x, 250); }
From source file:MainClass.java
public void paint(Graphics g) { int fontSize = 20; g.setFont(new Font("TimesRoman", Font.PLAIN, fontSize)); FontMetrics fm = g.getFontMetrics(); String s = "www.java2s.com"; int stringWidth = fm.stringWidth(s); int w = 200;// w ww. ja va 2 s .co m int h = 200; int x = (w - stringWidth) / 2; int baseline = fm.getMaxAscent() + (h - (fm.getAscent() + fm.getMaxDecent())) / 2; int ascent = fm.getMaxAscent(); int descent = fm.getMaxDecent(); int fontHeight = fm.getMaxAscent() + fm.getMaxDecent(); g.setColor(Color.white); g.fillRect(x, baseline - ascent, stringWidth, fontHeight); g.setColor(Color.gray); g.drawLine(x, baseline, x + stringWidth, baseline); g.setColor(Color.red); g.drawLine(x, baseline + descent, x + stringWidth, baseline + descent); g.setColor(Color.blue); g.drawLine(x, baseline - ascent, x + stringWidth, baseline - ascent); g.setColor(Color.black); g.drawString(s, x, baseline); }
From source file:Main.java
public void paint(Graphics g) { int fontSize = 20; Font font = new Font("TimesRoman", Font.PLAIN, fontSize); g.setFont(font);/*from w ww .ja v a2s. c o m*/ FontMetrics fm = g.getFontMetrics(font); String s = "www.java2s.com"; int stringWidth = fm.stringWidth(s); int w = 200; int h = 200; int x = (w - stringWidth) / 2; int baseline = fm.getMaxAscent() + (h - (fm.getAscent() + fm.getMaxDecent())) / 2; int ascent = fm.getMaxAscent(); int descent = fm.getMaxDecent(); int fontHeight = fm.getMaxAscent() + fm.getMaxDecent(); g.setColor(Color.white); g.fillRect(x, baseline - ascent, stringWidth, fontHeight); g.setColor(Color.gray); g.drawLine(x, baseline, x + stringWidth, baseline); g.setColor(Color.red); g.drawLine(x, baseline + descent, x + stringWidth, baseline + descent); g.setColor(Color.blue); g.drawLine(x, baseline - ascent, x + stringWidth, baseline - ascent); g.setColor(Color.black); g.drawString(s, x, baseline); }
From source file:RedGreenBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Insets insets = getBorderInsets(c); Color horizontalColor;/*from w w w. j av a2 s . c om*/ if (c.isEnabled()) { boolean pressed = false; if (c instanceof AbstractButton) { ButtonModel model = ((AbstractButton) c).getModel(); pressed = model.isPressed(); } if (pressed) { horizontalColor = Color.RED; } else { horizontalColor = Color.GREEN; } } else { horizontalColor = Color.LIGHT_GRAY; } g.setColor(horizontalColor); g.fillRect(0, 0, width, insets.top); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red); g.drawLine(0, 0, getWidth(), getHeight()); g.drawLine(getWidth(), 0, 0, getHeight()); }
From source file:Main.java
public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); Color color = getBackground(); if (source == yellowButton) color = Color.yellow;//from w w w . j a va2s. c o m else if (source == blueButton) color = Color.blue; else if (source == redButton) color = Color.red; setBackground(color); repaint(); }
From source file:GradientPaintDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);//from w ww .j a v a2 s . co m int x = 5; int y = 7; // fill RoundRectangle2D.Double GradientPaint redtowhite = new GradientPaint(x, y, Color.red, 200, y, Color.blue); g2.setPaint(redtowhite); g2.fill(new RoundRectangle2D.Double(x, y, 200, 200, 10, 10)); g2.setPaint(Color.black); g2.drawString("Filled RoundRectangle2D", x, 250); }