Below is a screen snapshot of the
Shape Editor Demo
that uses a
PathList
to specify the MOVE, LINE, QUAD, CUBIC, and CLOSE path segments that
constitute the path for the shape. The path segment data on the left
hand side is reflected in the shape structure painted on the right
hand side.
The source code for the Shape Editor Demo is available at
ShapeEditor.java.
The
PathListView
occupies the top half of the
left column and includes the sub-panels titled with
"Winding Rule" and "Path Node List". The "Winding Rule"
sub-panel simply has 2 radio buttons to select the winding
rule.
The "Path Node List" uses a
SimpleArrayPanel
to collect the
PathNode
items for the
PathList
The
buttons signal insert path node view and the
buttons signal delete path node view.
The buttons to the right of a particular
PathNodeView
insert
or delete that view while the buttons below insert or delete
at the end of the list. You may also set the total number of
path node views at once and then fill in the views one-by-one.
The five
PathNode
segment types that may be entered interactively in a
PathNodeView
are as follows.
MOVE[x1;y1]LINE[x1;y1]QUAD[x1;y1;x2;y2]CUBIC[x1;y1;x2;y2;x3;y3]CLOSE[]
The x,y values are float but there is no need to append
the "f" required internally in Java.
The Shape corresponding to the
PathList
that is represented
is rendered into the graphics window based on the other settings
in the GUI (colors, stroke thickness, and grid choice).
The code uses tools provided in the
PathList
class.
The path may be edited by dragging the vertex and control dots with
the mouse.
It is also possible to save and read back a
PathList
to and from a text file using the save and read buttons.