Java Code Examples for java.awt.BasicStroke#getDashPhase()
The following examples show how to use
java.awt.BasicStroke#getDashPhase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DummyGraphics2d.java From lams with GNU General Public License v2.0 | 6 votes |
public void setStroke(Stroke s) { String l; if (s instanceof BasicStroke) { BasicStroke bs = (BasicStroke)s; l = "setStroke(Stoke):" + "\n s = BasicStroke(" + "\n dash[]: "+Arrays.toString(bs.getDashArray()) + "\n dashPhase: "+bs.getDashPhase() + "\n endCap: "+bs.getEndCap() + "\n lineJoin: "+bs.getLineJoin() + "\n width: "+bs.getLineWidth() + "\n miterLimit: "+bs.getMiterLimit() + "\n )"; } else { l = "setStroke(Stoke):" + "\n s = " + s; } log.println( l ); g2D.setStroke( s ); }
Example 2
Source File: BasicStrokeWriteHandler.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Performs the writing of a single object. * * @param tagName the tag name. * @param object the object ({@link BasicStroke} expected). * @param writer the writer. * @param mPlexAttribute ?? * @param mPlexValue ?? * * @throws IOException if there is an I/O problem. * @throws XMLWriterException if there is a problem with the writer. */ public void write(final String tagName, final Object object, final XMLWriter writer, final String mPlexAttribute, final String mPlexValue) throws IOException, XMLWriterException { final BasicStroke stroke = (BasicStroke) object; final float[] dashArray = stroke.getDashArray(); final float dashPhase = stroke.getDashPhase(); final int endCap = stroke.getEndCap(); final int lineJoin = stroke.getLineJoin(); final float lineWidth = stroke.getLineWidth(); final float miterLimit = stroke.getMiterLimit(); final AttributeList attribs = new AttributeList(); if (mPlexAttribute != null) { attribs.setAttribute(mPlexAttribute, mPlexValue); } attribs.setAttribute("type", "basic"); attribs.setAttribute("endCap", String.valueOf(endCap)); attribs.setAttribute("lineJoin", String.valueOf(lineJoin)); attribs.setAttribute("lineWidth", String.valueOf(lineWidth)); attribs.setAttribute("miterLimit", String.valueOf(miterLimit)); if (dashArray != null) { attribs.setAttribute("dashArray", toString(dashArray)); attribs.setAttribute("dashPhase", String.valueOf(dashPhase)); } writer.writeTag(tagName, attribs, true); }
Example 3
Source File: PdfGraphics2D.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private Stroke transformStroke( final Stroke stroke ) { if ( !( stroke instanceof BasicStroke ) ) { return stroke; } 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 ); }
Example 4
Source File: BasicStrokeValueConverter.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public String toAttributeValue( final Object o ) throws BeanException { if ( o instanceof BasicStroke == false ) { throw new BeanException(); } final BasicStroke s = (BasicStroke) o; final float lineWidth = s.getLineWidth(); final int lineJoin = s.getLineJoin(); final float dashPhase = s.getDashPhase(); final int endCap = s.getEndCap(); final float mitterLimit = s.getMiterLimit(); final float[] dashArray = s.getDashArray(); final StringBuilder b = new StringBuilder(); if ( dashArray != null ) { for ( int i = 0; i < dashArray.length; i++ ) { if ( i != 0 ) { b.append( "," ); } b.append( dashArray[i] ); } } return String.format( Locale.US, "BasicStroke:%f:%d:%f:%d:%f:%s", lineWidth, lineJoin, dashPhase, endCap, mitterLimit, b.toString() ); }
Example 5
Source File: EdgeEditor.java From pdfxtk with Apache License 2.0 | 6 votes |
static Stroke setLineWidth(Stroke s, float lw) { if(s instanceof BasicStroke) { BasicStroke b = (BasicStroke)s; float[] da = b.getDashArray(); if(da != null) { float[] dsa = new float[da.length]; for(int i = 0; i < dsa.length; i++) dsa[i] = da[i] * (lw / b.getLineWidth()); da = dsa; } return new BasicStroke(lw, b.getEndCap(), b.getLineJoin(), b.getMiterLimit(), da, b.getDashPhase()); } else return s; }
Example 6
Source File: PdfGraphics2D.java From gcs with Mozilla Public License 2.0 | 5 votes |
private Stroke transformStroke(Stroke stroke) { if (!(stroke instanceof BasicStroke)) { return stroke; } BasicStroke st = (BasicStroke) stroke; float scale = (float) Math.sqrt(Math.abs(transform.getDeterminant())); float dash[] = st.getDashArray(); if (dash != null) { for (int k = 0; k < dash.length; ++k) { dash[k] *= scale; } } return new BasicStroke(st.getLineWidth() * scale, st.getEndCap(), st.getLineJoin(), st.getMiterLimit(), dash, st.getDashPhase() * scale); }
Example 7
Source File: PdfGraphics2D.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
private Stroke transformStroke(Stroke stroke) { if (!(stroke instanceof BasicStroke)) return stroke; BasicStroke st = (BasicStroke)stroke; float scale = (float)Math.sqrt(Math.abs(transform.getDeterminant())); float dash[] = st.getDashArray(); if (dash != null) { for (int k = 0; k < dash.length; ++k) dash[k] *= scale; } return new BasicStroke(st.getLineWidth() * scale, st.getEndCap(), st.getLineJoin(), st.getMiterLimit(), dash, st.getDashPhase() * scale); }
Example 8
Source File: LineFormat.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public BasicStroke getStroke() { BasicStroke stroke = style.getStroke(); if (stroke != null) { float[] scaledDashArray = getScaledDashArray(); BasicStroke scaledStroke = new BasicStroke(this.getWidth(), stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), scaledDashArray, stroke.getDashPhase()); return scaledStroke; } else { return null; } }
Example 9
Source File: EdgeEditor.java From pdfxtk with Apache License 2.0 | 5 votes |
static Stroke setEndCap(Stroke s, int cap) { if(s instanceof BasicStroke) { BasicStroke b = (BasicStroke)s; return new BasicStroke(b.getLineWidth(), cap, b.getLineJoin(), b.getMiterLimit(), b.getDashArray(), b.getDashPhase()); } else return s; }
Example 10
Source File: TVector.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Overrides TPoint setStroke method. * * @param stroke the desired stroke */ public void setStroke(BasicStroke stroke) { if(stroke==null) { return; } this.stroke = new BasicStroke(stroke.getLineWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 8, stroke.getDashArray(), stroke.getDashPhase()); }
Example 11
Source File: PDFGraphics.java From jpexs-decompiler with GNU General Public License v3.0 | votes |
private Stroke transformStroke(Stroke stroke) { if (!(stroke instanceof BasicStroke)) return stroke; BasicStroke st = (BasicStroke)stroke; float scale = (float)Math.sqrt(Math.abs(transform.getDeterminant())); float dash[] = st.getDashArray(); if (dash != null) { for (int k = 0; k < dash.length; ++k) dash[k] *= scale; } return new BasicStroke(st.getLineWidth() * scale, st.getEndCap(), st.getLineJoin(), st.getMiterLimit(), dash, st.getDashPhase() * scale); }