List of usage examples for java.awt Graphics2D setColor
public abstract void setColor(Color c);
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(); Area a2 = new Area(e2); a1.add(a2);/*from w w w . j av a2s.c om*/ g2.setColor(Color.orange); g2.fill(a1); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.add(a2);/*from www . j a v a2s . c om*/ g2.setColor(Color.orange); g2.fill(a1); }
From source file:org.n52.server.io.DiagramGenerator.java
public void createLegend(DesignOptions options, OutputStream out) throws OXFException, IOException { int topMargin = 10; int leftMargin = 30; int iconWidth = 15; int iconHeight = 15; int verticalSpaceBetweenEntries = 20; int horizontalSpaceBetweenIconAndText = 15; DesignDescriptionList ddList = buildUpDesignDescriptionList(options); int width = 800; int height = topMargin + (ddList.size() * (iconHeight + verticalSpaceBetweenEntries)); BufferedImage legendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D legendGraphics = legendImage.createGraphics(); legendGraphics.setColor(Color.white); legendGraphics.fillRect(0, 0, width, height); int offset = 0; for (RenderingDesign dd : ddList.getAllDesigns()) { int yPos = topMargin + offset * iconHeight + offset * verticalSpaceBetweenEntries; // icon:/*from w w w.j a va2 s .co m*/ legendGraphics.setColor(dd.getColor()); legendGraphics.fillRect(leftMargin, yPos, iconWidth, iconHeight); // text: legendGraphics.setColor(Color.black); legendGraphics.drawString(dd.getFeature().getLabel() + " - " + dd.getLabel(), leftMargin + iconWidth + horizontalSpaceBetweenIconAndText, yPos + iconHeight); offset++; } JPEGImageWriteParam p = new JPEGImageWriteParam(null); p.setCompressionMode(JPEGImageWriteParam.MODE_DEFAULT); write(legendImage, FORMAT, out); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2D; g2D = (Graphics2D) g;// w w w . jav a 2s .c o m FontRenderContext frc = g2D.getFontRenderContext(); Font font1 = new Font("Courier", Font.BOLD, 24); String str1 = new String("Java"); TextLayout tl = new TextLayout(str1, font1, frc); g2D.setColor(Color.gray); tl.draw(g2D, 70, 150); }
From source file:MyCanvas.java
public void draw(Graphics g) { Graphics2D g2 = (Graphics2D) g; // Draw the pie chart Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE); arc.setFrame(140, 200, 67, 46);/*w w w.j av a 2 s . c o m*/ arc.setAngleStart(45); arc.setAngleExtent(270); g2.setColor(Color.gray); g2.draw(arc); g2.setColor(Color.red); g2.fill(arc); g2.setColor(Color.black); g2.drawString("Arc2D.PIE", 140, 190); }
From source file:org.n52.oxf.render.sos.TimeSeriesChartRenderer.java
/** * The resulting IVisualization shows a chart which consists a TimeSeries for each FeatureOfInterest * contained in the observationCollection. */// www .j a v a2s. co m public IVisualization renderChart(OXFFeatureCollection observationCollection, ParameterContainer paramCon, int width, int height) { JFreeChart chart = renderChart(observationCollection, paramCon); Plot plot = chart.getPlot(); // draw plot into image: BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); g.setColor(Color.white); g.fillRect(0, 0, width, height); plot.draw(g, new Rectangle2D.Float(0, 0, width, height), null, null, null); return new StaticVisualization(image); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.add(a2);/*from w ww . ja v a 2 s. c o m*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("Union", 20, 140); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.subtract(a2);/*from w ww.j a v a2 s. com*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("subtract", 20, 140); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.PlotInstanceLegendCreator.java
private static Paint createTransparentCheckeredPaint(Color color, int checkerSize) { int s = checkerSize; BufferedImage bufferedImage = new BufferedImage(2 * s, 2 * s, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bufferedImage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias! RenderingHints.VALUE_ANTIALIAS_ON); Color c1 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .8)); Color c2 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .2)); g2.setStroke(new BasicStroke(0)); g2.setPaint(c2);/*from w w w .j a v a 2 s . c o m*/ g2.setColor(c2); g2.fillRect(0, 0, s, s); g2.fillRect(s, s, s, s); g2.setPaint(c1); g2.setColor(c1); g2.fillRect(0, s, s, s); g2.fillRect(s, 0, s, s); // paint with the texturing brush Rectangle2D rect = new Rectangle2D.Double(0, 0, 2 * s, 2 * s); return new TexturePaint(bufferedImage, rect); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0); Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0); Area a1 = new Area(e1); Area a2 = new Area(e2); a1.intersect(a2);/*from w w w. j av a 2 s . c o m*/ g2.setColor(Color.orange); g2.fill(a1); g2.setColor(Color.black); g2.drawString("intersect", 20, 140); }