List of usage examples for java.awt BasicStroke getLineJoin
public int getLineJoin()
From source file:Main.java
public static void main(String[] args) { BasicStroke stroke = new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.1F); System.out.println(stroke.getLineJoin()); }
From source file:Main.java
/** * Serialises a <code>Stroke</code> object. This code handles the * <code>BasicStroke</code> class which is the only <code>Stroke</code> * implementation provided by the JDK (and isn't directly * <code>Serializable</code>). * * @param stroke the stroke object (<code>null</code> permitted). * @param stream the output stream (<code>null</code> not permitted). * * @throws IOException if there is an I/O error. *//*from w w w. j a va2 s . co m*/ public static void writeStroke(final Stroke stroke, final ObjectOutputStream stream) throws IOException { if (stream == null) { throw new IllegalArgumentException("Null 'stream' argument."); } if (stroke != null) { stream.writeBoolean(false); if (stroke instanceof BasicStroke) { final BasicStroke s = (BasicStroke) stroke; stream.writeObject(BasicStroke.class); stream.writeFloat(s.getLineWidth()); stream.writeInt(s.getEndCap()); stream.writeInt(s.getLineJoin()); stream.writeFloat(s.getMiterLimit()); stream.writeObject(s.getDashArray()); stream.writeFloat(s.getDashPhase()); } else { stream.writeObject(stroke.getClass()); stream.writeObject(stroke); } } else { stream.writeBoolean(true); } }
From source file:Main.java
public static void writeStroke(Stroke aStroke, ObjectOutputStream out) throws IOException { if (aStroke instanceof Serializable) { out.writeBoolean(true);// w w w .j av a 2 s . c om out.writeBoolean(true); out.writeObject(aStroke); } else if (aStroke instanceof BasicStroke) { out.writeBoolean(true); out.writeBoolean(false); BasicStroke s = (BasicStroke) aStroke; float[] dash = s.getDashArray(); if (dash == null) { out.write(0); } else { out.write(dash.length); for (int i = 0; i < dash.length; i++) { out.writeFloat(dash[i]); } } out.writeFloat(s.getLineWidth()); out.writeInt(s.getEndCap()); out.writeInt(s.getLineJoin()); out.writeFloat(s.getMiterLimit()); out.writeFloat(s.getDashPhase()); } else { out.writeBoolean(false); } }
From source file:Java2DUtils.java
/** * This function provides a way to cancel the effects of the zoom on a particular Stroke. * All the stroke values (as line width, dashes, etc...) are divided by the zoom factor. * This allow to have essentially a fixed Stroke independent by the zoom. * The returned Stroke is a copy./*from w ww.j av a 2 s . c o m*/ * Remember to restore the right stroke in the graphics when done. * * It works only with instances of BasicStroke * * zoom is the zoom factor. */ public static Stroke getInvertedZoomedStroke(Stroke stroke, double zoom) { if (stroke == null || !(stroke instanceof BasicStroke)) return stroke; BasicStroke bs = (BasicStroke) stroke; float[] dashArray = bs.getDashArray(); float[] newDashArray = null; if (dashArray != null) { newDashArray = new float[dashArray.length]; for (int i = 0; i < newDashArray.length; ++i) { newDashArray[i] = (float) (dashArray[i] / zoom); } } BasicStroke newStroke = new BasicStroke((float) (bs.getLineWidth() / zoom), bs.getEndCap(), bs.getLineJoin(), bs.getMiterLimit(), //(float)(bs.getMiterLimit() / zoom), newDashArray, (float) (bs.getDashPhase() / zoom)); return newStroke; }
From source file:edu.umass.cs.iesl.pdf2meta.cli.extract.pdfbox.pagedrawer.StrokePath.java
/** * S stroke the path.// www . java 2 s . com * @param operator The operator that is being executed. * @param arguments List * * @throws java.io.IOException If an error occurs while processing the font. */ public void process(PDFOperator operator, List<COSBase> arguments) throws IOException { ///dwilson 3/19/07 refactor try { GraphicsAwarePDFStreamEngine drawer = (GraphicsAwarePDFStreamEngine) context; float lineWidth = (float) context.getGraphicsState().getLineWidth(); Matrix ctm = context.getGraphicsState().getCurrentTransformationMatrix(); if (ctm != null && ctm.getXScale() > 0) { lineWidth = lineWidth * ctm.getXScale(); } BasicStroke stroke = (BasicStroke) drawer.getStroke(); if (stroke == null) { drawer.setStroke(new BasicStroke(lineWidth)); } else { drawer.setStroke(new BasicStroke(lineWidth, stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase())); } drawer.strokePath(); } catch (Exception exception) { log.warn(exception, exception); } }
From source file:net.sf.jasperreports.customizers.marker.AbstractMarkerCustomizer.java
protected BasicStroke getStroke(Float strokeWidth) { BasicStroke basicStroke = new BasicStroke(strokeWidth); StrokeStyleEnum strokeStyle = StrokeStyleEnum.getByName(getProperty(PROPERTY_STROKE_STYLE)); if (strokeStyle != null) { switch (strokeStyle) { case SOLID: { //do nothing; already created stroke is good break; }/*from w ww.java 2 s . co m*/ case DOTTED: { basicStroke = new BasicStroke(basicStroke.getLineWidth(), basicStroke.getEndCap(), basicStroke.getLineJoin(), basicStroke.getMiterLimit(), new float[] { 1.0f, 1.0f }, basicStroke.getDashPhase()); break; } case DASHED: { basicStroke = new BasicStroke(basicStroke.getLineWidth(), basicStroke.getEndCap(), basicStroke.getLineJoin(), basicStroke.getMiterLimit(), new float[] { 10.0f, 10.0f }, basicStroke.getDashPhase()); break; } } } return basicStroke; }
From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java
/** * Returns the stroke used to outline data items. The default * implementation passes control to the/*from w w w . ja v a2 s. c om*/ * {@link #lookupSeriesOutlineStroke(int)} method. You can override this * method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * @return The stroke (never <code>null</code>). */ @Override public Stroke getItemOutlineStroke(int row, int column) { Number z = dataset.getZ(row, column); BasicStroke stroke = DEFAULT_OUTLINE_STROKE; if (shouldHighlight(row, column)) { stroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); } if (z == null) { stroke = new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), new float[] { 5.0f, 5.0f }, 0.0f); } return stroke; }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * Modifies the line thickness or point size in the last dataset. The * size is applied to all series in the dataset. * /* w w w. jav a 2 s. c o m*/ * @param size the size * @return a reference to this {@code Plot} instance */ public Plot withSize(float size) { if (chart.getPlot() instanceof XYPlot) { XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(currentDataset); if (renderer instanceof XYDotRenderer) { ((XYDotRenderer) renderer).setDotWidth((int) (size * 2)); ((XYDotRenderer) renderer).setDotHeight((int) (size * 2)); } else if (renderer.getBaseStroke() instanceof BasicStroke) { BasicStroke oldStroke = (BasicStroke) renderer.getBaseStroke(); BasicStroke newStroke = new BasicStroke(size, oldStroke.getEndCap(), oldStroke.getLineJoin(), oldStroke.getMiterLimit(), oldStroke.getDashArray(), oldStroke.getDashPhase()); renderer.setBaseStroke(newStroke); } else { renderer.setBaseStroke(new BasicStroke(size, 1, 1)); } } return this; }
From source file:SWTGraphics2D.java
/** * Sets the stroke for this graphics context. For now, this implementation * only recognises the {@link BasicStroke} class. * * @param stroke the stroke (<code>null</code> not permitted). * * @see #getStroke()/* w ww . j a va 2 s .co m*/ */ public void setStroke(Stroke stroke) { if (stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) stroke; // linewidth this.gc.setLineWidth((int) bs.getLineWidth()); // line join switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL: this.gc.setLineJoin(SWT.JOIN_BEVEL); break; case BasicStroke.JOIN_MITER: this.gc.setLineJoin(SWT.JOIN_MITER); break; case BasicStroke.JOIN_ROUND: this.gc.setLineJoin(SWT.JOIN_ROUND); break; } // line cap switch (bs.getEndCap()) { case BasicStroke.CAP_BUTT: this.gc.setLineCap(SWT.CAP_FLAT); break; case BasicStroke.CAP_ROUND: this.gc.setLineCap(SWT.CAP_ROUND); break; case BasicStroke.CAP_SQUARE: this.gc.setLineCap(SWT.CAP_SQUARE); break; } // set the line style to solid by default this.gc.setLineStyle(SWT.LINE_SOLID); // apply dash style if any float[] dashes = bs.getDashArray(); if (dashes != null) { int[] swtDashes = new int[dashes.length]; for (int i = 0; i < swtDashes.length; i++) { swtDashes[i] = (int) dashes[i]; } this.gc.setLineDash(swtDashes); } } else { throw new RuntimeException("Can only handle 'Basic Stroke' at present."); } }
From source file:org.jfree.experimental.swt.SWTGraphics2D.java
/** * Sets the stroke for this graphics context. For now, this implementation * only recognises the {@link BasicStroke} class. * * @param stroke the stroke (<code>null</code> not permitted). * * @see #getStroke()/*from w w w . jav a 2 s . c o m*/ */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } if (stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) stroke; this.gc.setLineWidth((int) bs.getLineWidth()); this.gc.setLineJoin(toSwtLineJoin(bs.getLineJoin())); this.gc.setLineCap(toSwtLineCap(bs.getEndCap())); // set the line style to solid by default this.gc.setLineStyle(SWT.LINE_SOLID); // apply dash style if any float[] dashes = bs.getDashArray(); if (dashes != null) { int[] swtDashes = new int[dashes.length]; for (int i = 0; i < swtDashes.length; i++) { swtDashes[i] = (int) dashes[i]; } this.gc.setLineDash(swtDashes); } } else { throw new RuntimeException("Can only handle 'Basic Stroke' at present."); } }