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:IteratorTest.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; String s = "Java Source and Support"; Dimension d = getSize();//from ww w. j av a 2 s . c o m g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font serifFont = new Font("Serif", Font.PLAIN, 48); Font sansSerifFont = new Font("Monospaced", Font.PLAIN, 48); AttributedString as = new AttributedString(s); as.addAttribute(TextAttribute.FONT, serifFont); as.addAttribute(TextAttribute.FONT, sansSerifFont, 2, 5); as.addAttribute(TextAttribute.FOREGROUND, Color.red, 5, 6); as.addAttribute(TextAttribute.FOREGROUND, Color.red, 16, 17); g2.drawString(as.getIterator(), 40, 80); }
From source file:org.jfree.chart.demo.XYBlockChartDemo3.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setLowerMargin(0.0D);/* w ww.ja v a 2 s . co m*/ numberaxis.setUpperMargin(0.0D); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setInverted(true); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black); lookuppaintscale.add(0.5D, Color.green); lookuppaintscale.add(1.5D, Color.orange); lookuppaintscale.add(2.5D, Color.red); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setForegroundAlpha(0.66F); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" }); symbolaxis.setRange(0.5D, 3.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setAxisOffset(5D); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:Main.java
@Override protected void paintComponent(Graphics window) { super.paintComponent(window); Graphics2D twoDGraph = (Graphics2D) window; if (time % 2 == 0) { twoDGraph.setColor(Color.RED); } else {/*from w w w . j a v a 2s .c o m*/ twoDGraph.setColor(Color.GREEN); } twoDGraph.fillOval(100, 100, 600, 600); time++; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.RED); g2d.drawLine(getWidth() / 2, 0, getWidth() / 2, getHeight()); g2d.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2); Font font = new Font("Arial", Font.BOLD, 48); g2d.setFont(font);//w w w .j a v a2 s . co m FontMetrics fm = g2d.getFontMetrics(); int x = ((getWidth() - fm.stringWidth(text)) / 2); int y = ((getHeight() - fm.getHeight()) / 2) + fm.getAscent(); g2d.setColor(Color.BLACK); g2d.drawString(text, x, y); g2d.dispose(); }
From source file:LineMetricsIllustration.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Serif", Font.PLAIN, 72); g2.setFont(font);/*w w w.j a v a 2 s .c o m*/ String s = "Java Source and Support"; float x = 50, y = 150; // Draw the baseline. FontRenderContext frc = g2.getFontRenderContext(); float width = (float) font.getStringBounds(s, frc).getWidth(); Line2D baseline = new Line2D.Float(x, y, x + width, y); g2.setPaint(Color.red); g2.draw(baseline); // Draw the ascent. LineMetrics lm = font.getLineMetrics(s, frc); Line2D ascent = new Line2D.Float(x, y - lm.getAscent(), x + width, y - lm.getAscent()); g2.draw(ascent); // Draw the descent. Line2D descent = new Line2D.Float(x, y + lm.getDescent(), x + width, y + lm.getDescent()); g2.draw(descent); // Draw the leading. Line2D leading = new Line2D.Float(x, y + lm.getDescent() + lm.getLeading(), x + width, y + lm.getDescent() + lm.getLeading()); g2.draw(leading); // Render the string. g2.setPaint(Color.black); g2.drawString(s, x, y); }
From source file:com.github.errantlinguist.latticevisualiser.StatePaintTransformer.java
/** * // ww w . ja v a2s .c o m * @return A map of {@link StateType StateTypes} to {@link Color Colors} for * deriving the colour used to draw the vertex representing a state. */ static final ImmutableMap<StateType, Color> makeColorMap() { final ImmutableMap.Builder<StateType, Color> builder = ImmutableMap.builder(); builder.put(StateType.INITIAL, Color.CYAN); builder.put(StateType.FINAL, Color.MAGENTA); builder.put(StateType.GOAL, Color.RED); builder.put(StateType.INTERMEDIATE, Color.GREEN); return builder.build(); }
From source file:FilledArc.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int x = 5;//from www.ja v a 2s .c om int y = 7; // fill Arc2D g2.setPaint(Color.red); g2.fill(new Arc2D.Double(x, y, 200, 200, 90, 135, Arc2D.OPEN)); g2.setPaint(Color.black); g2.drawString("Filled Arc2D", x, 250); }
From source file:FilledRectangleDemo2D.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 w w .ja v a2s.c o m*/ int x = 5; int y = 7; g2.setPaint(Color.red); g2.fill(new Rectangle2D.Double(x, y, 200, 200)); g2.setPaint(Color.black); g2.drawString("Filled Rectangle2D", x, 250); }
From source file:ClipBetweenRectangleEllipse2D.java
public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g; int w = getSize().width; int h = getSize().height; Ellipse2D e = new Ellipse2D.Float(w / 4.0f, h / 4.0f, w / 2.0f, h / 2.0f); g2.setClip(e);//from ww w . j a va 2 s. com g2.setColor(Color.red); g2.fillRect(0, 0, w, h); Rectangle r = new Rectangle(w / 2, h / 2, w / 2, h / 2); g2.clip(r); g2.setColor(Color.green); g2.fillRect(0, 0, w, h); }
From source file:Main.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;//from w w w . j a v a 2 s. c o 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); }