net.paulhertz.aifile
Class GroupComponent

java.lang.Object
  extended by net.paulhertz.aifile.DisplayComponent
      extended by net.paulhertz.aifile.GroupComponent
All Implemented Interfaces:
Visitable

public class GroupComponent
extends DisplayComponent

Groups together geometry (BezShape), text (PointText) and nested groups within a layer or another group. Components in a group are displayed and written to file with the most recently added component first (last in first out).


Constructor Summary
GroupComponent()
          PApplet used for calls to the Processing environment is obtained from IgnoCodeLib, which must be correctly initialized in setup.
GroupComponent(PApplet parent)
           
 
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
 void add(DisplayComponent component)
          Adds a component to children of this component.
 void draw()
          Draws geometry or text to the Processing window.
 void draw(PGraphics pg)
          Draws a component to a supplied PGraphics.
 boolean isTerminal()
           
 void transform(Matrix3 matx)
          Transforms geometry of shapes and location of text using the supplied matrix.
 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
children, get, hide, id, isLocked, isVisible, iterator, parentComponent, remove, setLocked, setParentComponent, setVisible, show
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupComponent

public GroupComponent()
PApplet used for calls to the Processing environment is obtained from IgnoCodeLib, which must be correctly initialized in setup. If IgnoCodeLib does not have a reference to a PApplet, it throws a NullPointerException.


GroupComponent

public GroupComponent(PApplet parent)
Parameters:
parent - PApplet used for calls to the Processing environment, notably for drawing
Method Detail

add

public void add(DisplayComponent component)
Adds a component to children of this component. Overrides DisplayComponent. Throws an UnsupportedOperationException if an attempt is made to add a DocumentComponent or a LayerComponent. Permits nested groups.

Specified by:
add in class DisplayComponent
Parameters:
component - DisplayComponent to add to this component's children

add

public void add(ArrayList<? extends DisplayComponent> comps)
Adds all components in a list to this component

Specified by:
add in class DisplayComponent
Parameters:
comps - an ArrayList of DisplayComponents

draw

public void draw()
Description copied from class: DisplayComponent
Draws geometry or text to the Processing window. Component must be flagged as visible (the default).

Specified by:
draw in class DisplayComponent

draw

public void draw(PGraphics pg)
Description copied from class: DisplayComponent
Draws a component to a supplied PGraphics. Except for the document component, a component must be visible (the default) to draw. Structural components simply iterate over their children. Graphic components should call beginShape and endShape on their own. It's up to the user to call beginDraw() and endDraw() on the PGraphics instance.

Specified by:
draw in class DisplayComponent
Parameters:
pg - a PGraphics instance

isTerminal

public boolean isTerminal()
Specified by:
isTerminal in class DisplayComponent
Returns:
true if this is a terminal (leaf) component, false if it is a composite component (i.e. a component that can add sub-components to a children array)

write

public void write(PrintWriter pw)
Description copied from class: DisplayComponent
Writes an Adobe Illustrator 7.0 file format encoding structure, geometry and text.

Specified by:
write in class DisplayComponent
Parameters:
pw - a PrintWriter for file output.

transform

public void transform(Matrix3 matx)
Description copied from class: DisplayComponent
Transforms geometry of shapes and location of text using the supplied matrix.

Specified by:
transform in class DisplayComponent
Parameters:
matx - a Matrix3 that encapsulates an affine geometric transform.

accept

public void accept(ComponentVisitor visitor)
Description copied from interface: Visitable
Accepts a ComponentVisitor that traverses a document structure tree.

When called from an object that implements the Visitable interface:

  1. each visited object passes a reference to itself back to the visitor
  2. each visited object calls 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.

Parameters:
visitor - a ComponentVisitor

accept

public void accept(ComponentVisitor visitor,
                   boolean order)
Description copied from interface: Visitable
Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder.

Parameters:
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.


Processing library IgnoCodeLib by Paul Hertz. (C) 2013