|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.paulhertz.aifile.AIFileWriter
public class AIFileWriter
Provides a useful subset of Adobe Illustrator 7.0 file tags. If you don't want to bother working with this
class directly, use BezShape
and its subclasses, PointText
,
DocumentComponent
and the other classes based on
DisplayComponent
.
These have a draw()
method to draw to the Processing window and a
write(PrintWriter pw)
method to write their geometry or text and formatting to an Illustrator file.
DocumentComponent
can act both as a display list and an export
tool: writing to an AI file can be as simple as one line of code.
This class provides markup specified by the Adobe Illustrator 7.0 specification, the last public specification
of the Adobe Illustrator format. The full spec can be downloaded from Adobe.
The setTransparency
markup is not
supported by the AI7.0 spec; however, it seems fully functional. See
AIFileWriter.useTransparency
for
further information on how to enable transparency for graphics. Markup to show and hide objects
was new in AI 10, but is included here.
See Adobe Illustrator 7.0 file for detailed information on the Adobe Illustrator 7.0 file format.
import net.paulhertz.aifile.*; import java.awt.Rectangle; import java.io.PrintWriter; /** * January 29, 2012 3:03:31 PM CST * June 25, 2013, modified for IgnoCodeLib 0.3 release * Uses low level code that ignores new features in new release (and in old release). * Sample code for IgnoCodeLib 0.2 Processing library by Paul Hertz * This example provides low level code, for the curious. IgnoCodeLib graphics of class BezShape * and its subclasses can draw to an Adobe Illustrator file just by calling their draw() method. * This example shows how to write line and curve paths to Adobe Illustrator by calling path * operators directly. Also demonstrates color output to an AI file, including transparency. * Transparency markup is not supported in the AI7.0 specification, but it seems to work. * Note that in Illustrator transparency affects the entire shape, both fill and stroke, * unlike Processing, where fill and stroke can have separate transparency values. This * means the most recent transparency value, whether of fill or stroke, will affect the * whole shape in AI. */ float xCenter; float yCenter; PrintWriter output; String aiFilename = "directOutput.ai"; /** true if we are saving to a file, false otherwise */ boolean saveToFile; /** graphics state flag: true if shapes should be filled, false otherwise */ boolean filled; /** graphics state flag: true if shapes should be stroked, false otherwise */ boolean stroked; /** graphics state flag: true if shapes should be closed, false otherwise */ boolean closed; /** graphics state flag: true if colors should be transparent, false otherwise */ boolean transparent; /** graphics state: the current fill color */ color currentFill; /** graphics state: the current stroke color */ color currentStroke; /** graphics state: the current stroke weight */ float currentWeight; public void setup() { size(400, 400); background(255); smooth(); xCenter = width/2; yCenter = height/2; saveToFile = false; println("Type 's' to save file"); } public void draw() { doDrawing(); } void doDrawing() { setClosed(); setNoStroke(); setFill(color(233, 47, 233)); bezCircle(xCenter, yCenter, 150, 5); setFill(color(47, 233, 233)); bezCircle(xCenter, yCenter, 100, 5); setFill(color(233, 233, 47)); bezCircle(xCenter, yCenter, 50, 5); // 50% transparency stroke setStroke(color(55, 89, 144, 127)); setWeight(8); // 50% transparency fill setFill(color(233, 0, 0, 127)); int x = 200; int y = 300; float rot = PI/6; float ang = getAngle(x - xCenter, y - yCenter) + rot; bezTriangle(x, y, 50, ang); x = 200; y = 100; ang = getAngle(x - xCenter, y - yCenter) + rot; bezTriangle(x, y, 50, ang); x = 100; y = 200; ang = getAngle(x - xCenter, y - yCenter) + rot; bezTriangle(x, y, 50, ang); x = 300; y = 200; ang = getAngle(x - xCenter, y - yCenter) + rot; bezTriangle(x, y, 50, ang); setClosed(); setNoStroke(); // opaque blue circle in upper left corner setFill(color(47, 123, 233, 255)); bezCircle(50, 50, 25, 4); // yellow circle in lower left corner setFill(color(233, 233, 47)); bezCircle(50, height - 50, 15, 4); // green circle in lower right corner setFill(color(29, 233, 68)); bezCircle(width - 50, height - 50, 30, 4); // red circle in upper right corner, transparent stroke setStroke(color(0, 0, 0, 127)); setFill(color(233, 76, 68)); bezCircle(width - 50, 50, 35, 4); } /** * Sets the current fill color, sets graphics state variable filled to true * @param fillColor the fill color to set */ void setFill(color fillColor) { currentFill = fillColor; filled = true; fill(fillColor); } /** * Sets graphics state variable filled to false. */ void setNoFill() { filled = false; noFill(); } /** * Sets the current stroke color, sets graphics state variable stroked to true * @param fillColor the fill color to set */ void setStroke(color strokeColor) { currentStroke = strokeColor; stroked = true; stroke(strokeColor); } /** * Sets graphics state variable stroked to false. */ void setNoStroke() { stroked = false; noStroke(); } /** * Sets the current weight. * @param weight the weight to set. */ void setWeight(int weight) { currentWeight = weight; strokeWeight(weight); } /** * Sets the graphics state variable closed to true. Shapes draw while * closed is true will be closed when output to Adobe Illustrator. */ void setClosed() { closed = true; } /** * Sets the graphics state variable closed to false. Shapes draw while * closed is false will be open when output to Adobe Illustrator. */ void setOpen() { closed = false; } public void keyPressed() { if (key == 's' || key == 'S') { saveAI(); } } /** * Saves drawing to an Adobe Illustrator file. */ public void saveAI() { println("saving Adobe Illustrator file " + aiFilename + "..."); output = createWriter(aiFilename); AIFileWriter.writeHeader(output, "Direct Output", "Ignotus", "ignoStudio", 612, 792, new Rectangle(width, height)); AIFileWriter.writeState(output); AIFileWriter.setFill(0.0, output); AIFileWriter.setStroke(0.0, output); saveToFile = true; doDrawing(); saveToFile = false; AIFileWriter.writeTrailer(output); output.flush(); output.close(); } /** * Given magnitudes dx and dy return the angle of rotation measured * clockwise from 0, degrees in radians * @param dx displacement on x-axis * @param dy displacement on y-axis * @return float value representing angle to vector (dx, dy) in radians. */ float getAngle(float dx, float dy) { double ang; if (dx != 0) { ang = Math.atan(Math.abs(dy/dx)); } else if (dy != 0) { ang = PI / 2; } else { ang = 0; } if (dx < 0) { if (dy < 0) { ang = ang + PI; } else { ang = PI - ang; } } else if (dy < 0) { ang = 2 * PI - ang; } return (float) ang; } /** * @param pin the x and y coordinates of a point as a two-member array of float * @param xTrans translation on x-axis * @param yTrans translation on y-axis * @return the translated point as a new two-member array of float */ float[] translateCoord(float[] pin, float xTrans, float yTrans) { float[] pout = new float[2]; pout[0] = pin[0] + xTrans; pout[1] = pin[1] + yTrans; return pout; } /** * Rotate vector or point (dx,dy) through an angle, degrees in radians, * rotation is counterclockwise from the coordinate axis * @param dx displacement on x-axis * @param dy displacement on y-axis * @param theta angle to rotate, in radians * @return the rotated point (dx, dy) as a two-member array of float */ float[] rotateCoord(float dx, float dy, float theta) { float sintheta = sin(theta); float costheta = cos(theta); float[] newPoint = new float[2]; newPoint[0] = dx * costheta - dy * sintheta; newPoint[1] = dx * sintheta + dy * costheta; return newPoint; } /** * Draw a triangle centered on xctr, yctr, with radius radius, rotated by ang radians. * If global variable saveToFile is true, will output triangle geometry to an * open Adobe Illustrator file pointed to by global variable output. * @param xctr x-coordinate of center of triangle * @param yctr y-coordinate of center of triangle * @param radius radius of circumcircle of triangle * @param ang angle to rotate triangle, in radians */ void bezTriangle(float xctr, float yctr, float radius, float ang) { float x0, y0, x1, y1, x2, y2; float k = 2.23606797749979f; // sqrt(5) float yinc = radius/k; float xinc = 2 * yinc; x0 = 0; y0 = -radius; x1 = xinc; y1 = yinc; x2 = -xinc; y2 = y1; float[] pt0 = { x0, y0 }; pt0 = translateCoord(rotateCoord(x0, y0, ang), xctr, yctr); float[] pt1 = { x1, y1 }; pt1 = translateCoord(rotateCoord(x1, y1, ang), xctr, yctr); float[] pt2 = { x2, y2 }; pt2 = translateCoord(rotateCoord(x2, y2, ang), xctr, yctr); triangle(pt0[0], pt0[1], pt1[0], pt1[1], pt2[0], pt2[1]); if (saveToFile) { int pathOp = setAttributes(); AIFileWriter.psMoveTo(pt0[0], pt0[1], output); AIFileWriter.psLineTo(pt1[0], pt1[1], output); AIFileWriter.psLineTo(pt2[0], pt2[1], output); AIFileWriter.psLineTo(pt0[0], pt0[1], output); AIFileWriter.paintPath(pathOp, output); } } /** * Draw a circle with sectors number of Bezier curves, centered on xctr, yctr * If global variable saveToFile is true, will output circle geometry to an * open Adobe Illustrator file pointed to by global variable output. * @param xctr x-coordinate of center of circle * @param yctr y-coordinate of center of circle * @param radius radius of circumcircle of circle * @param sectors number of Bezier curve segments in which the circle is divided. */ void bezCircle(float xctr, float yctr, float radius, int sectors) { // kappa, constant for calculating Bezier control points for a circle float kappa = 0.5522847498f; float k = 4 * kappa / sectors; float d = k * radius; float ax1, ay1, cx1, cy1, cx2, cy2, ax2, ay2; float[] cp1 = new float[2]; float[] cp2 = new float[2]; float[] ap2 = new float[2]; ax1 = 0; ay1 = radius; cx1 = d; cy1 = radius; cp2 = rotateCoord(-d, radius, -TWO_PI/sectors); ap2 = rotateCoord(0, radius, -TWO_PI/sectors); cx2 = cp2[0]; cy2 = cp2[1]; ax2 = ap2[0]; ay2 = ap2[1]; beginShape(); vertex(ax1 + xctr, ay1 + yctr); bezierVertex(cx1 + xctr, cy1 + yctr, cx2 + xctr, cy2 + yctr, ax2 + xctr, ay2 + yctr); int pathOp = 0; if (saveToFile) { pathOp = setAttributes(); AIFileWriter.psMoveTo(ax1 + xctr, ay1 + yctr, output); AIFileWriter.psCurveTo(cx1 + xctr, cy1 + yctr, cx2 + xctr, cy2 + yctr, ax2 + xctr, ay2 + yctr, output); } for (int i = 1; i < sectors; i++) { cp1 = rotateCoord(cx1, cy1, i * -TWO_PI/sectors); cp2 = rotateCoord(cx2, cy2, i * -TWO_PI/sectors); ap2 = rotateCoord(ax2, ay2, i * -TWO_PI/sectors); bezierVertex(cp1[0] + xctr, cp1[1] + yctr, cp2[0] + xctr, cp2[1] + yctr, ap2[0] + xctr, ap2[1] + yctr); if (saveToFile) { AIFileWriter.psCurveTo(cp1[0] + xctr, cp1[1] + yctr, cp2[0] + xctr, cp2[1] + yctr, ap2[0] + xctr, ap2[1] + yctr, output); } } endShape(); if (saveToFile) { AIFileWriter.paintPath(pathOp, output); if (transparent) { AIFileWriter.noTransparency(output); } } } /** * Uses graphics state variables to determine the path operator to output to an Adobe Illustrator file, * sets current transparency in open Adobe Illustrator file pointed to by global variable output. * Unlike Processing, Illustrator sets transparency for fill and stroke together. * This method will write a transparent Illustrator object if the fill is transparent, * otherwise it writes an opaque object. * The path operator indicates whether current geometry is stroked, filled, open or closed. * @return AI path operator as an int */ int setAttributes() { int pathOp = 0; boolean transparentFill = false; boolean transparentStroke = false; if (filled) { int[] colors = argbComponents(currentFill); if (colors[0] < 255) { AIFileWriter.setTransparency(colors[0]/255.0, output); transparentFill = true; transparent = true; } else if (transparent) { AIFileWriter.setTransparency(1, output); transparent = false; } AIFileWriter.setRGBFill(colors[1]/255.0, colors[2]/255.0, colors[3]/255.0, output); pathOp += AIFileWriter.FILL; } if (stroked) { int[] colors = argbComponents(currentStroke); if (colors[0] < 255) { transparentStroke = true; if (!transparentFill) println("Fill is opaque; ignoring transparent stroke"); } AIFileWriter.setRGBStroke(colors[1]/255.0, colors[2]/255.0, colors[3]/255.0, output); pathOp += AIFileWriter.STROKE; AIFileWriter.setWeight(currentWeight, output); } if (closed) { pathOp += AIFileWriter.CLOSE; } return pathOp; } /** * @param argb a Processing color as a 32-bit integer * @return an array of integers in the range 0..255 for each color component: {A, R, G, B} */ public int[] argbComponents(int argb) { int[] comp = new int[4]; comp[0] = (argb >> 24) & 0xFF; // alpha comp[1] = (argb >> 16) & 0xFF; // Faster way of getting red(argb) comp[2] = (argb >> 8) & 0xFF; // Faster way of getting green(argb) comp[3] = argb & 0xFF; // Faster way of getting blue(argb) return comp; }
Field Summary | |
---|---|
static int |
CLOSE
Binary flag for closed path operators. |
static char |
CLOSED_FILLED
Closed and filled path operator. |
static char |
CLOSED_FILLED_STROKED
Closed, filled, and stroked path operator. |
static char |
CLOSED_STROKED
Closed and stroked path operator. |
static int |
FILL
Binary flag for filled path operators. |
static DecimalFormat |
fourPlaces
A number formatter: call fourPlaces.format(Number) to return a String with four decimal places. |
static char |
NONPRINTING_CLOSED
Closed and non-printing (invisible) path operator. |
static char |
NONPRINTING_OPEN
Open and non-printing (invisible) path operator. |
static char |
OPEN_FILLED
Open and filled path operator. |
static char |
OPEN_FILLED_STROKED
Open, filled, and stroked path operator. |
static char |
OPEN_STROKED
Open and stroked path operator. |
static int |
STROKE
Binary flag for stroked path operators. |
Constructor Summary | |
---|---|
AIFileWriter()
|
Method Summary | |
---|---|
static void |
beginLayer(String layerName,
int colorIndex,
boolean isVisible,
boolean isLocked,
PrintWriter pw)
Writes begin layer operator "%AI5_BeginLayer" and various parameters to output. |
static void |
beginLayer(String layerName,
int colorIndex,
PrintWriter pw)
Writes begin layer operator "%AI5_BeginLayer" and various parameters to output. |
static void |
beginPalette(PrintWriter pw)
Writes open palette tag and opening tags of color list to output. |
static void |
closeGroup(PrintWriter pw)
Writes a close group operator "U" to output. |
static String |
currentDate()
|
static void |
customObject(String tagIdentifier,
String tagValue,
PrintWriter pw)
Writes a user-defined custom object to the file, in the format / |
static void |
endLayer(PrintWriter pw)
Writes end layer operator "LB" to output. |
static void |
endPalette(PrintWriter pw)
Writes closing color list tags and close palette tag to output. |
static String |
getHeader(String title)
Returns an abbreviated Adobe Illustrator header as a String |
static String |
getHeader(String title,
String creator,
String org,
int width,
int height,
Rectangle bbox)
Creates an abbreviated Adobe Illustrator header with user-supplied arguments and returns it as a String. |
static String |
getState()
Creates Adobe Illustrator 3.0 initial graphics state and returns it as a String. |
static String |
getTrailer()
Creates an Adobe Illustrator 3.0 abbreviated trailer and returns it as a String. |
static void |
noTransparency(PrintWriter pw)
If you set transparency, either set it for every object, or reset it to totally opaque by calling noTransparency. |
static void |
openGroup(PrintWriter pw)
Writes an open group operator "u" to output. |
static void |
paintPath(char pathOp,
PrintWriter pw)
Closes a series of path construction operations with the appropriate operator. |
static void |
paintPath(int pathIndex,
PrintWriter pw)
Closes a series of path construction operations with the appropriate operator stored in gPathOps, {'N', 'n', 'S', 's', 'F', 'f', 'B', 'b'}. |
static void |
paletteCMYKCell(CMYKColor shade,
PrintWriter pw)
Writes CMYK color values to palette to output. |
static void |
paletteCMYKCell(double[] shade,
PrintWriter pw)
Writes CMYK color values to palette to output. |
static void |
paletteCMYKCell(double c,
double m,
double y,
double k,
PrintWriter pw)
Writes CMYK color values to palette to output. |
static void |
paletteGrayCell(double shade,
PrintWriter pw)
Writes grayscale color value to palette to output. |
static void |
paletteRGBCell(double[] shade,
PrintWriter pw)
Writes RGB color values to palette. |
static void |
paletteRGBCell(double r,
double g,
double b,
PrintWriter pw)
Writes RGB color values to palette to output. |
static void |
paletteRGBCell(RGBColor shade,
PrintWriter pw)
Writes RGB color values to palette to output. |
static void |
psCurveTo(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
PrintWriter pw)
Writes current point and "c" operator to output. |
static void |
psLineTo(double x,
double y,
PrintWriter pw)
Writes current point and "L" operator to output. |
static void |
psMoveTo(double[] pt,
PrintWriter pw)
Writes current point and "m" operator to output. |
static void |
psMoveTo(double x,
double y,
PrintWriter pw)
Writes current point and "m" operator to output. |
static void |
psMoveTo(Point2D pt,
PrintWriter pw)
Writes current point and "m" operator to output. |
static void |
setCMYKFill(CMYKColor shade,
PrintWriter pw)
Writes CMYK fill value and fill operator "k" to output. |
static void |
setCMYKFill(double[] shade,
PrintWriter pw)
Writes CMYK fill value and fill operator "k" to output. |
static void |
setCMYKFill(double c,
double m,
double y,
double k,
PrintWriter pw)
Writes CMYK fill value and fill operator "k" to output. |
static void |
setCMYKStroke(CMYKColor shade,
PrintWriter pw)
Writes CMYK stroke value and fill operator "K" to output. |
static void |
setCMYKStroke(double[] shade,
PrintWriter pw)
Writes CMYK stroke value and fill operator "K" to output. |
static void |
setCMYKStroke(double c,
double m,
double y,
double k,
PrintWriter pw)
Writes CMYK stroke value and fill operator "K" to output. |
static void |
setDashPattern(double[] pattern,
PrintWriter pw)
Sets the current dash pattern. |
static void |
setFill(double shade,
PrintWriter pw)
Writes grayscale fill value and fill operator "g" to output. |
static void |
setLineAttributes(int linecap,
int linejoin,
int miterLimit,
PrintWriter pw)
Sets linecap and linejoin styles, sets miter limit for lines. |
static void |
setLocked(boolean isLocked,
PrintWriter pw)
1 A (lock) and 0 A (unlock) control locking of objects. |
static void |
setRGBFill(double[] shade,
PrintWriter pw)
Writes RGB fill value and fill operator "Xa" to output. |
static void |
setRGBFill(double r,
double g,
double b,
PrintWriter pw)
Writes RGB fill value and fill operator "Xa" to output. |
static void |
setRGBFill(RGBColor shade,
PrintWriter pw)
Writes RGB fill value and fill operator "Xa" to output. |
static void |
setRGBStroke(double[] shade,
PrintWriter pw)
Writes RGB stroke value and fill operator "XA" to output. |
static void |
setRGBStroke(double r,
double g,
double b,
PrintWriter pw)
Writes RGB stroke value and fill operator "XA" to output. |
static void |
setRGBStroke(RGBColor shade,
PrintWriter pw)
Writes RGB stroke value and fill operator "XA" to output. |
static void |
setStroke(double shade,
PrintWriter pw)
Writes grayscale stroke value and stroke operator "G" to output. |
static void |
setTransparency(double trans,
PrintWriter pw)
Writes current opacity to an Illustrator file (not part of the AI7 spec). |
static void |
setUseTransparency(boolean useTransparency)
Pass a value of true to enable transparency when exporting to Adobe Illustrator, default is false. |
static void |
setVisible(boolean isVisible,
PrintWriter pw)
As of AI 10, visibility of objects is set by 0 Xw (show) and 1 Xw (hide). |
static void |
setWeight(double weight,
PrintWriter pw)
Writes weight (in points) and weight operator "w" to output. |
static void |
textObject(PointText pt,
PrintWriter pw)
Writes the tag structure for a PointText instance to output. |
static boolean |
useTransparency()
|
static void |
writeHeader(PrintWriter pw,
String title)
Writes an abbreviated Adobe Illustrator header to a PrintWriter. |
static void |
writeHeader(PrintWriter pw,
String title,
String creator,
String org,
int width,
int height,
Rectangle bbox)
Writes an abbreviated Adobe Illustrator header with user-supplied arguments to a PrintWriter. |
static void |
writeState(PrintWriter pw)
Writes Adobe Illustrator 3.0 initial graphics state. |
static void |
writeTrailer(PrintWriter pw)
Writes Adobe Illustrator 3.0 abbreviated trailer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FILL
public static final int STROKE
public static final int CLOSE
public static final char CLOSED_FILLED_STROKED
public static final char OPEN_FILLED_STROKED
public static final char CLOSED_FILLED
public static final char OPEN_FILLED
public static final char CLOSED_STROKED
public static final char OPEN_STROKED
public static final char NONPRINTING_CLOSED
public static final char NONPRINTING_OPEN
public static DecimalFormat fourPlaces
Constructor Detail |
---|
public AIFileWriter()
Method Detail |
---|
public static void writeHeader(PrintWriter pw, String title)
pw
- PrintWriter
for file outputtitle
- String
that will appear as window titlepublic static String getHeader(String title)
title
- String
that will appear as window title
public static void writeHeader(PrintWriter pw, String title, String creator, String org, int width, int height, Rectangle bbox)
pw
- PrintWriter
for file outputtitle
- String
that will appear as window titlecreator
- String
name of document creatororg
- String
name of organizationwidth
- int
, width of document art boardheight
- int
, height of document art boardbbox
- Rectangle
bounding rectangle of artworkpublic static String getHeader(String title, String creator, String org, int width, int height, Rectangle bbox)
title
- String
that will appear as window titlecreator
- String
name of document creatororg
- String
name of organizationwidth
- int
, width of document art boardheight
- int
, height of document art boardbbox
- Rectangle
bounding rectangle of artwork
public static String currentDate()
public static void writeState(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static String getState()
tag values default A [0,1] if subsequent objects are unlocked, 1 if they are locked 0 R [0, 1] if stroke does not overprint, 1 if stroke overprints 0 G 0..1 stroke gray value, 0 = black, 1 = white 0 i 0..100, 0 = automatically set by Illustrator 0 J [0, 1, 2], linecap: 0 = butt end, 1 = round, 2 = square 0 J [0, 1, 2] linejoin: 0 = mitered, 1 = round, 2 = beveled 0 w positive real value, line width 1 M real number > 1, miter limit: ratio of miter length/line width 4 d array of values for dashes and gaps, phase of dash pattern []0 D [0, 1] winding order tag, 0 = clockwise, 1 = counterclockwise 0
public static void writeTrailer(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static String getTrailer()
String
containing an AI 3.0 trailer.public static void openGroup(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static void closeGroup(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static void beginLayer(String layerName, int colorIndex, PrintWriter pw)
layerName
- String
, name of layercolorIndex
- int
, index to color associated with layerpw
- PrintWriter
for file outputpublic static void beginLayer(String layerName, int colorIndex, boolean isVisible, boolean isLocked, PrintWriter pw)
layerName
- String
, name of layercolorIndex
- int
, index to color associated with layerisVisible
- true if layer is visible, false otherwiseisLocked
- true if layer is not enabled, false otherwisepw
- PrintWriter
for file outputpublic static void endLayer(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static void setLineAttributes(int linecap, int linejoin, int miterLimit, PrintWriter pw)
linecap
- 0 = butt end, 1 = round, 2 = squarelinejoin
- 0 = mitered, 1 = round, 2 = beveledmiterLimit
- miter limit: ratio of miter length/line width, in range 1..10, default 4pw
- PrintWriter
for file outputpublic static void setDashPattern(double[] pattern, PrintWriter pw)
pattern
- an array of number pairs representing dashes and gapspw
- PrintWriter
for file outputpublic static void setFill(double shade, PrintWriter pw)
shade
- double
in range 0.0..1.0, grayscale valuepw
- PrintWriter
for file outputpublic static void setStroke(double shade, PrintWriter pw)
shade
- double
in range 0.0..1.0, grayscale valuepw
- PrintWriter
for file outputpublic static void setCMYKFill(double c, double m, double y, double k, PrintWriter pw)
c
- cyan component (0..1)m
- magenta component (0..1)y
- yellow component (0..1)k
- black component (0..1)pw
- PrintWriter
for file outputpublic static void setCMYKFill(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void setCMYKFill(CMYKColor shade, PrintWriter pw)
shade
- a CMYKColor instancepw
- PrintWriter
for file outputpublic static void setCMYKStroke(double c, double m, double y, double k, PrintWriter pw)
c
- cyan component (0..1)m
- magenta component (0..1)y
- yellow component (0..1)k
- black component (0..1)pw
- PrintWriter
for file outputpublic static void setCMYKStroke(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void setCMYKStroke(CMYKColor shade, PrintWriter pw)
shade
- a CMYKColor instancepw
- PrintWriter
for file outputpublic static void setRGBFill(double r, double g, double b, PrintWriter pw)
r
- red component (0..1)g
- green component (0..1)b
- blue component (0..1)pw
- PrintWriter
for file outputpublic static void setRGBFill(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void setRGBFill(RGBColor shade, PrintWriter pw)
shade
- an RGBColor instancepw
- PrintWriter
for file outputpublic static void setRGBStroke(double r, double g, double b, PrintWriter pw)
r
- red component (0..1)g
- green component (0..1)b
- blue component (0..1)pw
- PrintWriter
for file outputpublic static void setRGBStroke(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void setRGBStroke(RGBColor shade, PrintWriter pw)
shade
- a RGBColor instancepw
- PrintWriter
for file outputpublic static void setWeight(double weight, PrintWriter pw)
weight
- stroke weight (positive decimal value)pw
- PrintWriter
for file outputpublic static boolean useTransparency()
public static void setUseTransparency(boolean useTransparency)
setTransparency(double, PrintWriter)
.
useTransparency
- public static void setTransparency(double trans, PrintWriter pw)
trans
- transparency value, in the range 0..1pw
- PrintWriter
for file outputpublic static void noTransparency(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static void setVisible(boolean isVisible, PrintWriter pw)
write()
methods of these components.
isVisible
- true if subsequent components are visible, false otherwisepw
- PrintWriter
for file outputpublic static void setLocked(boolean isLocked, PrintWriter pw)
write()
methods of these components.
isLocked
- true if subsequent components are visible, false otherwisepw
- PrintWriter
for file outputpublic static void beginPalette(PrintWriter pw)
endPalette
pw
- PrintWriter
for file outputpublic static void endPalette(PrintWriter pw)
pw
- PrintWriter
for file outputpublic static void paletteGrayCell(double shade, PrintWriter pw)
shade
- double
in range 0.0..1.0, grayscale valuepw
- PrintWriter
for file outputpublic static void paletteCMYKCell(double c, double m, double y, double k, PrintWriter pw)
c
- cyan component (0..1)m
- magenta component (0..1)y
- yellow component (0..1)k
- black component (0..1)pw
- PrintWriter
for file outputpublic static void paletteCMYKCell(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void paletteCMYKCell(CMYKColor shade, PrintWriter pw)
shade
- a CMYKColor instancepw
- PrintWriter
for file outputpublic static void paletteRGBCell(double r, double g, double b, PrintWriter pw)
r
- red component (0..1)g
- green component (0..1)b
- blue component (0..1)pw
- PrintWriter
for file outputpublic static void paletteRGBCell(double[] shade, PrintWriter pw)
shade
- an array of four double
s in the range (0..1)pw
- PrintWriter
for file outputpublic static void paletteRGBCell(RGBColor shade, PrintWriter pw)
shade
- a RGBColor instancepw
- PrintWriter
for file outputpublic static void psMoveTo(double x, double y, PrintWriter pw)
x
- x coordinatey
- y coordinatepw
- PrintWriter
for file outputpublic static void psMoveTo(double[] pt, PrintWriter pw)
pt
- array of two double values, x and y coordinatespw
- PrintWriter
for file outputpublic static void psMoveTo(Point2D pt, PrintWriter pw)
pt
- a Java Point2D instancepw
- PrintWriter
for file outputpublic static void psLineTo(double x, double y, PrintWriter pw)
x
- x coordinatey
- y coordinatepw
- PrintWriter
for file outputpublic static void psCurveTo(double x1, double y1, double x2, double y2, double x3, double y3, PrintWriter pw)
x1
- control point 1 x coordinatey1
- control point 1 y coordinatex2
- control point 2 x coordinatey2
- control point 2 y coordinatex3
- end point x coordinatey3
- end point y coordinatepw
- PrintWriter
for file outputpublic static void paintPath(int pathIndex, PrintWriter pw)
paintPath
method, that accepts
character constant.
fill stroke close b 1 1 1 closed filled and stroked path B 1 1 0 open filled and stroked path f 1 0 1 closed filled path F 1 0 0 open filled path s 0 1 1 closed stroked path S 0 1 0 open stroked path n 0 0 1 non-printing closed path N 0 0 0 non-printing open path
pathIndex
- an int in the range (0..7)pw
- PrintWriter
for file outputpublic static void paintPath(char pathOp, PrintWriter pw)
pathOp
- a char
in {'N', 'n', 'S', 's', 'F', 'f', 'B', 'b'}
It is simpler just to use one of the supplied constants CLOSED_FILLED_STROKED, OPEN_FILLED_STROKED, CLOSED_FILLED, OPEN_FILLED, CLOSED_STROKED, OPEN_STROKED, NONPRINTING_CLOSED, NONPRINTING_OPEN
pw
- PrintWriter
for file outputpublic static void customObject(String tagIdentifier, String tagValue, PrintWriter pw)
tagIdentifier
- a String
to identify the custom objecttagValue
- a String
that is assigned to the object as its valuepw
- PrintWriter
for file outputpublic static void textObject(PointText pt, PrintWriter pw)
pt
- a PointText instancepw
- PrintWriter for file output
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |