List of usage examples for java.awt Graphics2D setStroke
public abstract void setStroke(Stroke s);
From source file:ArcDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);// ww w. j av a 2 s . c o m int x = 5; int y = 7; g2.setStroke(wideStroke); g2.draw(new Arc2D.Double(x, y, 200, 200, 90, 135, Arc2D.OPEN)); g2.drawString("Arc2D", x, 250); }
From source file:LinesDashes1.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; float[] dash1 = { 2f, 0f, 2f }; g2d.drawLine(20, 40, 250, 40);/*w ww . j a v a2 s . co m*/ BasicStroke bs1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f); g2d.setStroke(bs1); g2d.drawLine(20, 80, 250, 80); }
From source file:EllipseDemo2D.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 a 2 s. c o m int x = 5; int y = 7; g2.setStroke(stroke); g2.draw(new Ellipse2D.Double(x, y, 200, 200)); g2.drawString("Ellipse2D", x, 250); }
From source file:RectangleDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*from www. j a va 2 s. com*/ int x = 5; int y = 7; g2.setStroke(stroke); g2.draw(new Rectangle2D.Double(x, y, 200, 200)); g2.drawString("Rectangle2D", x, 250); }
From source file:DashedRectangleDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);// www. j a v a2s. co m int x = 5; int y = 7; g2.setStroke(dashed); g2.draw(new RoundRectangle2D.Double(x, y, 200, 200, 10, 10)); g2.drawString("RoundRectangle2D", x, 250); }
From source file:com.bdb.weather.display.current.WindDirPointer.java
/** * Draws the pointer.// w w w. j a v a2 s .c om * * @param g2 The graphics target. * @param plot The plot. * @param frame The dial's reference frame. * @param view The dial's view. */ @Override public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(Color.blue); g2.setStroke(new BasicStroke(1.0f)); DialScale scale = plot.getScaleForDataset(getDatasetIndex()); double value = plot.getValue(getDatasetIndex()); double angle = scale.valueToAngle(value % 360.0); Rectangle2D outerRect = DialPlot.rectangleByRadius(frame, outerRadius, outerRadius); Rectangle2D innerRect = DialPlot.rectangleByRadius(frame, outerRadius - innerOffset, outerRadius - innerOffset); g2.setPaint(getOutlinePaint()); Arc2D arc1 = new Arc2D.Double(outerRect, angle - (ARC_LENGTH / 2), ARC_LENGTH, Arc2D.OPEN); g2.draw(arc1); Arc2D arc2 = new Arc2D.Double(innerRect, angle, 0.0, Arc2D.OPEN); GeneralPath gp = new GeneralPath(); gp.moveTo(arc1.getStartPoint().getX(), arc1.getStartPoint().getY()); gp.lineTo(arc2.getStartPoint().getX(), arc2.getStartPoint().getY()); gp.lineTo(arc1.getEndPoint().getX(), arc1.getEndPoint().getY()); g2.draw(gp); if (fill) { g2.setPaint(getFillPaint()); g2.fill(gp); } }
From source file:no.met.jtimeseries.chart.XYWindArrowRenderer.java
private void drawCircle(Graphics2D g) { g.setStroke(new BasicStroke(1)); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.drawOval(-arrowHeight / 2, -arrowHeight / 2, arrowHeight, arrowHeight); }
From source file:de.h_da.fbi.rfid.gui.UHF_GUI.java
public void paintComponent(Graphics g) { super.paint(g); Graphics2D g2 = (Graphics2D) g; Line2D line = new Line2D.Double(300, 300, 80, 80); g2.setStroke(new BasicStroke(4)); g2.draw(line);/* w w w . j a va 2s. co m*/ }
From source file:eu.hydrologis.jgrass.charting.impl.LineDrawer.java
/** * Draws the circle.//ww w . j a v a 2s .c om * * @param g2 the graphics device. * @param area the area in which to draw. */ public void draw(Graphics2D g2, Rectangle2D area) { if (this.outlinePaint != null && this.outlineStroke != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.outlineStroke); } else { g2.setPaint(Color.black); g2.setStroke(new BasicStroke(1.0f)); } Line2D line = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY()); g2.draw(line); }
From source file:Main.java
public void drawImage() { Graphics2D g = img.createGraphics(); RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHints(hints);/*from w ww.j a v a 2s. co m*/ g.setStroke(new BasicStroke(4)); for (Ellipse2D shape : shapes) { g.setColor(Color.blue); g.fill(shape); if (shape.contains(mouse)) { g.setColor(Color.RED); } else { g.setColor(Color.YELLOW); } g.draw(shape); } l.setIcon(new ImageIcon(img)); g.dispose(); }