List of usage examples for java.awt BasicStroke getDashPhase
public float getDashPhase()
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java
private Stroke transformStroke(final Stroke stroke) { if (!(stroke instanceof BasicStroke)) { return stroke; }//from ww w.j a va 2 s. com final BasicStroke st = (BasicStroke) stroke; final float scale = (float) Math.sqrt(Math.abs(transform.getDeterminant())); final float[] dash = st.getDashArray(); if (dash != null) { final int dashLength = dash.length; for (int k = 0; k < dashLength; ++k) { dash[k] *= scale; } } return new BasicStroke(st.getLineWidth() * scale, st.getEndCap(), st.getLineJoin(), st.getMiterLimit(), dash, st.getDashPhase() * scale); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java
private void setStrokeDiff(final Stroke newStroke, final Stroke oldStroke) { if (newStroke == oldStroke) { return;//from w w w . j a v a 2 s. co m } if (!(newStroke instanceof BasicStroke)) { return; } final BasicStroke nStroke = (BasicStroke) newStroke; final boolean oldOk = (oldStroke instanceof BasicStroke); BasicStroke oStroke = null; if (oldOk) { oStroke = (BasicStroke) oldStroke; } if (!oldOk || nStroke.getLineWidth() != oStroke.getLineWidth()) { cb.setLineWidth(nStroke.getLineWidth()); } if (!oldOk || nStroke.getEndCap() != oStroke.getEndCap()) { switch (nStroke.getEndCap()) { case BasicStroke.CAP_BUTT: cb.setLineCap(0); break; case BasicStroke.CAP_SQUARE: cb.setLineCap(2); break; default: cb.setLineCap(1); } } if (!oldOk || nStroke.getLineJoin() != oStroke.getLineJoin()) { switch (nStroke.getLineJoin()) { case BasicStroke.JOIN_MITER: cb.setLineJoin(0); break; case BasicStroke.JOIN_BEVEL: cb.setLineJoin(2); break; default: cb.setLineJoin(1); } } if (!oldOk || nStroke.getMiterLimit() != oStroke.getMiterLimit()) { cb.setMiterLimit(nStroke.getMiterLimit()); } final boolean makeDash; if (oldOk) { if (nStroke.getDashArray() != null) { if (nStroke.getDashPhase() != oStroke.getDashPhase()) { makeDash = true; } else if (!Arrays.equals(nStroke.getDashArray(), oStroke.getDashArray())) { makeDash = true; } else { makeDash = false; } } else if (oStroke.getDashArray() != null) { makeDash = true; } else { makeDash = false; } } else { makeDash = true; } if (makeDash) { final float[] dash = nStroke.getDashArray(); if (dash == null) { cb.setLiteral("[]0 d\n"); } else { cb.setLiteral('['); final int lim = dash.length; for (int k = 0; k < lim; ++k) { cb.setLiteral(dash[k]); cb.setLiteral(' '); } cb.setLiteral(']'); cb.setLiteral(nStroke.getDashPhase()); cb.setLiteral(" d\n"); } } }