List of usage examples for java.awt Graphics2D setStroke
public abstract void setStroke(Stroke s);
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(Color.black);/*from w w w .j a va2 s. com*/ g2.setStroke(new BasicStroke(8)); g2.draw(new Ellipse2D.Double(20, 20, 50, 50)); }
From source file:ala.soils2sat.DrawingUtils.java
public static void drawRoundedRect(Graphics g, int left, int top, int right, int bottom) { Graphics2D g2d = (Graphics2D) g; g.drawLine(left + cornerSize, top, right - cornerSize, top); g.drawLine(left + cornerSize, bottom, right - cornerSize, bottom); g.drawLine(left, top + cornerSize, left, bottom - cornerSize); g.drawLine(right, top + cornerSize, right, bottom - cornerSize); final Object previousAntiAliasingHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Stroke previousStroke = g2d.getStroke(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); try {/*from w ww . j a v a2s . c o m*/ g.drawLine(left, top + cornerSize, left + cornerSize, top); g.drawLine(left, bottom - cornerSize, left + cornerSize, bottom); g.drawLine(right, top + cornerSize, right - cornerSize, top); g.drawLine(right, bottom - cornerSize, right - cornerSize, bottom); } finally { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, previousAntiAliasingHint); g2d.setStroke(previousStroke); } }
From source file:DashedStrokeDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; float dash[] = { 10.0f }; g2.setStroke(new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f)); g2.setPaint(Color.blue);//from ww w. j a v a 2s .co m Rectangle r = new Rectangle(5, 5, 200, 200); g2.draw(r); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); g2.setStroke(bs); g.drawLine(30, 20, 270, 20);//w ww . ja v a2 s . co m }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); g2.setStroke(bs); g.drawLine(30, 20, 270, 20);//from ww w . j a v a 2 s . c om }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); g2.setStroke(bs); g.drawLine(30, 20, 270, 20);//from w ww .ja va 2 s. co m }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.1F); g2.setStroke(stroke); g2.setPaint(Color.black);/* ww w. java 2 s. c om*/ g2.draw(new Rectangle2D.Float(10, 10, 200, 200)); }
From source file:org.evors.rs.kjunior.SimulatedKJunior.java
@Override public void render(Graphics2D g2) { g2.setStroke(bstroke); g2.setColor(Color.RED);// w w w . j ava2s. c om float[] input = getInput(); for (int i = 0; i < NUM_IRs; i++) { Line IR = Line.fromPolarVec(getIRBase(irAngles[i]), irAngles[i], input[i]); g2.draw(IR.toLine2D()); } g2.setColor(new Color(45, 45, 45)); g2.fill(getShape().toJava2DShape()); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; float strokeThickness = 5.0f; BasicStroke stroke = new BasicStroke(strokeThickness); g2d.setStroke(stroke); g2d.draw(new Rectangle(20, 20, 200, 200)); }
From source file:Overlap.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double x = 15, y = 50, w = 70, h = 70; Ellipse2D e = new Ellipse2D.Double(x, y, w, h); g2.setStroke(new BasicStroke(8)); Color smokeyColor = new Color(128, 128, 128, 128); g2.setPaint(smokeyColor);//from w w w. ja v a 2s . co m g2.fill(e); g2.draw(e); e.setFrame(x + 100, y, w, h); g2.setPaint(Color.black); g2.draw(e); g2.setPaint(Color.gray); g2.fill(e); e.setFrame(x + 200, y, w, h); g2.setPaint(Color.gray); g2.fill(e); g2.setPaint(Color.black); g2.draw(e); }