ASF Bugzilla – Attachment 23469 Details for
Bug 47006
[PATCH] Changes necessary for bug #47000
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch with described changes
PSTextPainter-xgc.diff (text/plain), 7.90 KB, created by
Jeremias Maerki
on 2009-04-09 00:24:33 UTC
(
hide
)
Description:
Patch with described changes
Filename:
MIME Type:
Creator:
Jeremias Maerki
Created:
2009-04-09 00:24:33 UTC
Size:
7.90 KB
patch
obsolete
>Index: java2d/ps/PSGraphics2D.java >=================================================================== >--- java2d/ps/PSGraphics2D.java (revision 752822) >+++ java2d/ps/PSGraphics2D.java (working copy) >@@ -503,56 +503,74 @@ > protected void applyStroke(Stroke stroke) { > preparePainting(); > try { >- if (stroke instanceof BasicStroke) { >- BasicStroke bs = (BasicStroke)stroke; >+ applyStroke(stroke, gen); >+ } catch (IOException ioe) { >+ handleIOException(ioe); >+ } >+ } > >- float[] da = bs.getDashArray(); >- if (da != null) { >- gen.write("["); >- for (int count = 0; count < da.length; count++) { >- gen.write(gen.formatDouble(da[count])); >- if (count < da.length - 1) { >- gen.write(" "); >- } >+ /** >+ * Applies a new Stroke object. >+ * @param stroke the Stroke instance >+ * @param gen the PS generator >+ * @throws IOException if an I/O error occurs >+ */ >+ public static void applyStroke(Stroke stroke, final PSGenerator gen) >+ throws IOException { >+ if (stroke instanceof BasicStroke) { >+ BasicStroke basicStroke = (BasicStroke)stroke; >+ >+ float[] da = basicStroke.getDashArray(); >+ if (da != null) { >+ StringBuffer sb = new StringBuffer("["); >+ for (int count = 0; count < da.length; count++) { >+ sb.append(gen.formatDouble(da[count])); >+ if (count < da.length - 1) { >+ sb.append(" "); > } >- gen.write("] "); >- float offset = bs.getDashPhase(); >- gen.writeln(gen.formatDouble(offset) + " setdash"); > } >- int ec = bs.getEndCap(); >- switch (ec) { >- case BasicStroke.CAP_BUTT: >- gen.writeln("0 setlinecap"); >- break; >- case BasicStroke.CAP_ROUND: >- gen.writeln("1 setlinecap"); >- break; >- case BasicStroke.CAP_SQUARE: >- gen.writeln("2 setlinecap"); >- break; >- default: System.err.println("Unsupported line cap: " + ec); >- } >+ sb.append("] "); >+ float offset = basicStroke.getDashPhase(); >+ sb.append(gen.formatDouble(offset)); >+ gen.useDash(sb.toString()); >+ } else { >+ gen.useDash(null); >+ } >+ int ec = basicStroke.getEndCap(); >+ switch (ec) { >+ case BasicStroke.CAP_BUTT: >+ gen.useLineCap(0); >+ break; >+ case BasicStroke.CAP_ROUND: >+ gen.useLineCap(1); >+ break; >+ case BasicStroke.CAP_SQUARE: >+ gen.useLineCap(2); >+ break; >+ default: System.err.println("Unsupported line cap: " + ec); >+ } > >- int lj = bs.getLineJoin(); >- switch (lj) { >- case BasicStroke.JOIN_MITER: >- gen.writeln("0 setlinejoin"); >- float ml = bs.getMiterLimit(); >- gen.writeln(gen.formatDouble(ml >= -1 ? ml : 1) + " setmiterlimit"); >- break; >- case BasicStroke.JOIN_ROUND: >- gen.writeln("1 setlinejoin"); >- break; >- case BasicStroke.JOIN_BEVEL: >- gen.writeln("2 setlinejoin"); >- break; >- default: System.err.println("Unsupported line join: " + lj); >- } >- float lw = bs.getLineWidth(); >- gen.writeln(gen.formatDouble(lw) + " setlinewidth"); >+ int lj = basicStroke.getLineJoin(); >+ switch (lj) { >+ case BasicStroke.JOIN_MITER: >+ gen.useLineJoin(0); >+ float ml = basicStroke.getMiterLimit(); >+ gen.useMiterLimit(ml >= -1 ? ml : 1); >+ break; >+ case BasicStroke.JOIN_ROUND: >+ gen.useLineJoin(1); >+ gen.writeln("1 setlinejoin"); >+ break; >+ case BasicStroke.JOIN_BEVEL: >+ gen.useLineJoin(2); >+ gen.writeln("2 setlinejoin"); >+ break; >+ default: System.err.println("Unsupported line join: " + lj); > } >- } catch (IOException ioe) { >- handleIOException(ioe); >+ float lw = basicStroke.getLineWidth(); >+ gen.useLineWidth(lw); >+ } else { >+ System.err.println("Stroke not supported: " + stroke.toString()); > } > } > >Index: ps/PSGenerator.java >=================================================================== >--- ps/PSGenerator.java (revision 752822) >+++ ps/PSGenerator.java (working copy) >@@ -511,6 +511,28 @@ > } > > /** >+ * Establishes the specified line join style. >+ * @param linejoin the line join style (0, 1 or 2) as defined by the setlinejoin command. >+ * @exception IOException In case of an I/O problem >+ */ >+ public void useLineJoin(int linejoin) throws IOException { >+ if (getCurrentState().useLineJoin(linejoin)) { >+ writeln(linejoin + " setlinejoin"); >+ } >+ } >+ >+ /** >+ * Establishes the specified miter limit. >+ * @param miterlimit the miter limit as defined by the setmiterlimit command. >+ * @exception IOException In case of an I/O problem >+ */ >+ public void useMiterLimit(float miterlimit) throws IOException { >+ if (getCurrentState().useMiterLimit(miterlimit)) { >+ writeln(miterlimit + " setmiterlimit"); >+ } >+ } >+ >+ /** > * Establishes the specified line width. > * @param width the line width as defined by the setlinewidth command. > * @exception IOException In case of an I/O problem >Index: ps/PSState.java >=================================================================== >--- ps/PSState.java (revision 750456) >+++ ps/PSState.java (working copy) >@@ -19,11 +19,11 @@ > > package org.apache.xmlgraphics.ps; > >+import java.awt.Color; >+import java.awt.geom.AffineTransform; > import java.io.IOException; > import java.io.Serializable; > import java.util.List; >-import java.awt.Color; >-import java.awt.geom.AffineTransform; > > /** > * This class holds the current state of the PostScript interpreter. >@@ -41,6 +41,8 @@ > private List transformConcatList = new java.util.ArrayList(); > > private int linecap = 0; >+ private int linejoin = 0; >+ private float miterLimit = 0; > private double linewidth = 1.0f; > private String dashpattern = DEFAULT_DASH; > private Color color = DEFAULT_RGB_COLOR; >@@ -119,6 +121,34 @@ > } > > /** >+ * Establishes the specified line join. >+ * @param value line join (0, 1 or 2) as defined by the setlinejoin command >+ * @return true if the line join changed compared to the previous setting >+ */ >+ public boolean useLineJoin(int value) { >+ if (linejoin != value) { >+ linejoin = value; >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ /** >+ * Establishes the specified miter limit. >+ * @param value the miter limit as defined by the setmiterlimit command >+ * @return true if the miter limit changed compared to the previous setting >+ */ >+ public boolean useMiterLimit(float value) { >+ if (miterLimit != value) { >+ miterLimit = value; >+ return true; >+ } else { >+ return false; >+ } >+ } >+ >+ /** > * Establishes the specified line width. > * @param value line width as defined by the setlinewidth command > * @return true if the line width changed compared to the previous setting
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47006
: 23469