List of usage examples for java.awt BasicStroke BasicStroke
@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" }) public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
From source file:Main.java
public static Stroke getDotStroke() { int w = 1;//from w ww. j a v a 2 s . co m float[] dash = { 1, 3 }; float dash_phase = 1; return new BasicStroke(w, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, dash, dash_phase); }
From source file:Main.java
public static Stroke getDotStroke2() { int w = 1;//ww w .ja v a 2 s. c o m float[] dash = { 6, 3 }; float dash_phase = 2; return new BasicStroke(w, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, dash, dash_phase); }
From source file:Main.java
public static Stroke readStroke(ObjectInputStream in) throws IOException, ClassNotFoundException { boolean wroteStroke = in.readBoolean(); if (wroteStroke) { boolean serializedStroke = in.readBoolean(); if (serializedStroke) { return (Stroke) in.readObject(); } else {//from w w w . j a v a 2 s . c om float[] dash = null; int dashLength = in.read(); if (dashLength != 0) { dash = new float[dashLength]; for (int i = 0; i < dashLength; i++) { dash[i] = in.readFloat(); } } float lineWidth = in.readFloat(); int endCap = in.readInt(); int lineJoin = in.readInt(); float miterLimit = in.readFloat(); float dashPhase = in.readFloat(); return new BasicStroke(lineWidth, endCap, lineJoin, miterLimit, dash, dashPhase); } } else { return null; } }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0);/* w w w .j a v a 2s .co m*/ g2.setStroke(stroke); g2.setPaint(Color.black); g2.draw(new Rectangle2D.Float(10, 20, 30, 40)); }
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, new float[] { 3, 1 }, 0);//from w w w. j a va 2s .c om g2.setStroke(stroke); g2.setPaint(Color.black); g2.draw(new Rectangle2D.Float(10, 10, 200, 200)); }
From source file:LinesDashes3.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; float[] dash3 = { 4f, 0f, 2f }; BasicStroke bs3 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash3, 2f); g2d.setStroke(bs3);/*ww w .j av a 2 s. com*/ g2d.drawLine(20, 60, 250, 60); }
From source file:LinesDashes4.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; float[] dash4 = { 4f, 4f, 1f }; BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4, 2f); g2d.setStroke(bs4);// w w w. j a v a 2 s . co m g2d.drawLine(20, 20, 250, 20); }
From source file:LinesDashes2.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.drawLine(20, 40, 250, 40);// w ww . j a v a 2s. c om float[] dash2 = { 1f, 1f, 1f }; BasicStroke bs2 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash2, 2f); g2d.setStroke(bs2); g2d.drawLine(20, 20, 250, 20); }
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 w w .j ava2s. c o 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: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);/*from w ww . j ava 2 s . com*/ BasicStroke bs1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f); //BasicStroke bs2 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash2,2f); //float[] dash3 = { 4f, 0f, 2f }; //BasicStroke bs3 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash3,2f); //float[] dash4 = { 4f, 4f, 1f }; //BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,2f); g2d.setStroke(bs1); g2d.drawLine(20, 80, 250, 80); }