|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.paulhertz.aifile.DisplayComponent
net.paulhertz.aifile.PointText
public class PointText
Implements an Adobe Illustrator 7.0 Point Text object with a subset of the available tags. Provides methods to set the fill, stroke, and stroke weight of the text, although these are part of the graphics state and not part of the text object itself. Be aware that they will remain in effect in the file until they are changed.
Field Summary | |
---|---|
int |
objectType
text object type, default 0, other types unsupported as yet |
Constructor Summary | |
---|---|
PointText()
PApplet used for calls to the Processing environment is obtained from IgnoCodeLib , which must be correctly initialized in setup. |
|
PointText(double tx,
double ty,
String text)
Creates a new PointText displaced (ty,ty) from the origin (0,0). |
|
PointText(PApplet parent)
Creates a new PointText at (0,0). |
|
PointText(PApplet parent,
double tx,
double ty,
String text)
Creates a new PointText displaced (ty,ty) from the origin (0,0). |
Method Summary | |
---|---|
void |
accept(ComponentVisitor visitor)
Accepts a ComponentVisitor that traverses a document structure tree. |
void |
accept(ComponentVisitor visitor,
boolean order)
Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder. |
void |
add(ArrayList<? extends DisplayComponent> comps)
Adds all components in a list to this component, throws an UnsupportedOperationException if component is terminal. |
void |
add(DisplayComponent component)
Adds a component to children of this component, throws an UnsupportedOperationException if component is terminal. |
int |
alignment()
|
ArrayList<DisplayComponent> |
children()
|
void |
draw()
Draws geometry or text to the Processing window. |
void |
draw(PGraphics pg)
Draws a component to a supplied PGraphics. |
int |
fillColor()
|
int |
fillOpacity()
|
String |
fontname()
|
DisplayComponent |
get(int index)
Returns the component at index from the children of this component, throws an UnsupportedOperationException if component is terminal. |
PFont |
getFont()
|
int |
getObjectType()
|
boolean |
isTerminal()
|
Iterator<DisplayComponent> |
iterator()
Returns an iterator over children, throws an UnsupportedOperationException if component is terminal. |
double |
leading()
|
void |
loadFont(String name)
|
double[] |
matrix()
|
String |
outputString()
|
double |
paragraphLeading()
|
String |
pFontname()
|
boolean |
remove(DisplayComponent component)
Removes a component from children of this component, throws an UnsupportedOperationException if component is terminal. |
int |
render()
|
void |
setAlignment(int alignment)
|
void |
setFillColor(int newFillColor)
|
void |
setFillColor(RGBColor newFillColor)
|
void |
setFillOpacity(int opacity)
Sets opacity of current fill color. |
void |
setFont(PFont font)
Sets the Processing font to the supplied PFont. |
void |
setFont(String fontname,
String pFontname,
double weight,
double leading)
|
void |
setFontname(String fontname)
|
void |
setLeading(double leading)
|
void |
setMatrix(double[] matrix)
|
void |
setMatrix(Matrix3 matx)
Uses a Matrix3 to set the internal matrix used by Adobe Illustrator. |
void |
setNoFill()
|
void |
setNoStroke()
|
void |
setParagraphLeading(double paragraphLeading)
|
void |
setPFontname(String pFontname)
|
void |
setRender(int render)
Sets the render mode of text, generally safe to stick with the default 0, or with 1 or 2. |
void |
setSize(double size)
|
void |
setStartPt(double startPt)
|
void |
setStrokeColor(int newStrokeColor)
|
void |
setStrokeColor(RGBColor newStrokeColor)
|
void |
setStrokeOpacity(int opacity)
Sets opacity of current stroke color. |
void |
setText(String text)
|
void |
setTx(double tx)
|
void |
setTy(double ty)
|
void |
setUseTransparency(boolean useTransparency)
|
void |
setWeight(float newWeight)
|
double |
size()
|
double |
startPt()
|
int |
strokeColor()
|
int |
strokeOpacity()
|
String |
text()
|
void |
transform(Matrix3 matx)
Illustrator will display the transformed text. |
double |
tx()
|
double |
ty()
|
boolean |
useTransparency()
|
float |
weight()
|
void |
write(PrintWriter pw)
Writes an Adobe Illustrator 7.0 file format encoding structure, geometry and text. |
Methods inherited from class net.paulhertz.aifile.DisplayComponent |
---|
hide, id, isLocked, isVisible, parentComponent, setLocked, setParentComponent, setVisible, show |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int objectType
Constructor Detail |
---|
public PointText(PApplet parent)
public PointText()
IgnoCodeLib
, which must be correctly initialized in setup.
If IgnoCodeLib does not have a reference to a PApplet, it throws a NullPointerException.
Creates a new PointText at (0,0).
public PointText(PApplet parent, double tx, double ty, String text)
parent
- PApplet used for calls to the Processing environment.tx
- x translationty
- y translationtext
- the textpublic PointText(double tx, double ty, String text)
IgnoCodeLib
, which must be correctly initialized in setup.
If IgnoCodeLib does not have a reference to a PApplet, it throws a NullPointerException.
tx
- x translationty
- y translationtext
- the textMethod Detail |
---|
public double[] matrix()
public void setMatrix(double[] matrix)
matrix
- the matrix to set, concatenated with CTM (current transformation matrix).
It's generally safe to use the default values 1 0 0 1 tx ty.
An exact explanation of what the matrix represents may be found in Adobe's Postscript Language
Reference Manual, section 4.3.3 Matrix Representation and Manipulation (page 201).
Briefly, if a transformation matrix is represented as:
a b 0
c d 0
tx ty 1
then the representation in the Adobe Illustrator file omits the third column, thus:
a b c d tx ty
The net.paulhertz.geom.Matrix3 class provides utility methods for concatenating transforms
and can be used to derive useful values for the matrix.public void setMatrix(Matrix3 matx)
matx
- a Matrix3 that encapsulates a transform. Third column is ignored.public double tx()
public void setTx(double tx)
tx
- translation along x-axis to setpublic double ty()
public void setTy(double ty)
ty
- the translation along y-axis to setpublic double startPt()
public void setStartPt(double startPt)
startPt
- the startPt to set, only meaningful for text on a path, where it indicates a position on the path.public String text()
public void setText(String text)
text
- the text to setpublic int render()
public void setRender(int render)
render
- the render to set
0 Ñ filled text
1 Ñ stroked text
2 Ñ filled and stroked text
3 Ñ invisible text
4 Ñ masked and filled text
5 Ñ masked and stroked text
6 Ñ masked, filled, and stroked text
7 Ñ masked (only) text
8 Ñ filled text followed by render mode 9 (pattern prototype only)
9 Ñ stroked text (preceded by render mode 8 text, pattern prototype only)public String fontname()
public void setFontname(String fontname)
fontname
- the fontname to set. If no font is supplied, Illustrator uses its default font.
You may need to determine AI's naming conventions by inspecting a legacy file format in a text editor.
Typical names include:
MyriadPro-Regular, Helvetica, Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Tekton-Bold, etc.
These will be bracketed by the appropriate tags when written to file.public String pFontname()
public void setPFontname(String pFontname)
pFontname
- the Processing font to use. See http://processing.org/reference/text_.htmlpublic void loadFont(String name)
name
- the name of the .vlw file to usepublic PFont getFont()
public void setFont(PFont font)
font
- the font to setpublic double size()
public void setSize(double size)
size
- the size to set, in pointspublic double leading()
public void setLeading(double leading)
leading
- the leading between lines, in pointspublic void setFont(String fontname, String pFontname, double weight, double leading)
fontname
- name of the font used in IllustratorpFontname
- name of the font used in Processingweight
- font weight (size in points)leading
- leading between lines, commonly 1.25 * weightpublic double paragraphLeading()
public void setParagraphLeading(double paragraphLeading)
paragraphLeading
- the leading between paragraphs, in points (default 0 = auto)public int alignment()
public void setAlignment(int alignment)
alignment
- the alignment to set
0Ñleft aligned
1Ñcenter aligned
2Ñright aligned
3Ñjustified (right and left)
4Ñjustified including last linepublic int getObjectType()
public int fillColor()
public void setFillColor(int newFillColor)
public void setFillColor(RGBColor newFillColor)
public void setNoFill()
public int strokeColor()
public void setStrokeColor(int newStrokeColor)
public void setStrokeColor(RGBColor newStrokeColor)
public void setNoStroke()
public void setFillOpacity(int opacity)
opacity
- a number in the range 0..255. Value is not checked!public int fillOpacity()
public void setStrokeOpacity(int opacity)
opacity
- a number in the range 0..255. Value is not checked!public int strokeOpacity()
public boolean useTransparency()
public void setUseTransparency(boolean useTransparency)
public float weight()
public void setWeight(float newWeight)
public String outputString()
public void add(DisplayComponent component)
DisplayComponent
UnsupportedOperationException
if component is terminal.
add
in class DisplayComponent
component
- DisplayComponent to add to this component's children
UnsupportedOperationException,
- this is a terminal componentpublic void add(ArrayList<? extends DisplayComponent> comps)
DisplayComponent
UnsupportedOperationException
if component is terminal.
add
in class DisplayComponent
comps
- an ArrayList of DisplayComponents
UnsupportedOperationException,
- this is a terminal componentpublic boolean remove(DisplayComponent component)
DisplayComponent
UnsupportedOperationException
if component is terminal.
remove
in class DisplayComponent
component
- DisplayComponent to remove from this component's children
UnsupportedOperationException,
- this is a terminal componentpublic DisplayComponent get(int index)
DisplayComponent
UnsupportedOperationException
if component is terminal.
Throws an IndexOutOfBoundsException
if index is out of range (index < 0 || index >= size).
get
in class DisplayComponent
index
- index to component
UnsupportedOperationException,
- this is a terminal componentpublic Iterator<DisplayComponent> iterator()
DisplayComponent
UnsupportedOperationException
if component is terminal.
iterator
in class DisplayComponent
UnsupportedOperationException,
- this is a terminal componentpublic ArrayList<DisplayComponent> children()
children
in class DisplayComponent
public boolean isTerminal()
isTerminal
in class DisplayComponent
public void draw()
DisplayComponent
draw
in class DisplayComponent
public void draw(PGraphics pg)
DisplayComponent
draw
in class DisplayComponent
pg
- a PGraphics instancepublic void write(PrintWriter pw)
DisplayComponent
write
in class DisplayComponent
pw
- a PrintWriter for file output.public void transform(Matrix3 matx)
transform
in class DisplayComponent
matx
- a Matrix3 that encapsulates an affine geometric transform.DisplayComponent.transform(net.paulhertz.geom.Matrix3)
public void accept(ComponentVisitor visitor)
Visitable
When called from an object that implements the Visitable
interface:
accept( visitor )
on all its children
The reference is passed back to the visitor through a method of the form
visitor.visit<ComponentClassName>( this );
See ComponentVisitor
The order of steps 1 and 2 determines if traversal of the composite structure is preorder or postorder. As shown above, it's preorder. Depending on what you want to do, one traversal may be better suited than the other. Preorder visits parents first, postorder visits children first.
visitor
- a ComponentVisitor
public void accept(ComponentVisitor visitor, boolean order)
Visitable
visitor
- a ComponentVisitor
order
- boolean to determine if traversal is preorder or postorder
accept( visitor )
should implement the default order of traversal,
accept( visitor, <false>
) should implement the other order.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |