Java Reference
In-Depth Information
%dimensions;>
You could conceivably omit the top-left corner coordinates because they are the same as the position for
the sketch element. However, including them enables you to reconstruct the bounding rectangle object with
no dependency on the position field having been reconstructed previously.
The XML Element for a Rectangle Element in a Sketch
You can define a rectangle very similarly to a line because it is defined by its position, which corresponds
to the top-left corner, plus a rectangle at the origin with a width and height. The width and height attributes
are specified by a parameter entity because you are able to use this in the XML element for a rectangle. A
rectangle also has a color in which it is to be drawn, a rotation angle, and a bounding rectangle. Here's how
this looks in the DTD:
<!ELEMENT rectangle (color, position, bounds)>
<!ATTLIST rectangle
angle CDATA #REQUIRED
%dimensions;
>
As with a line, the rotation angle is specified by an attribute, as are the width and height of the Rect-
angle2D.Double object.
The XML Element for a Circle Element in a Sketch
The <circle> element is no more difficult. It has a position and the Ellipse2D.Double object has a width
and a height, but these are the same, being the diameter of the circle. Like other elements, it has a color, a
rotation angle (remember, we rotate circles about the top-left corner of the enclosing rectangle in Sketcher),
and a bounding rectangle. You can define it like this:
<!ELEMENT circle (color, position, bounds)>
<!ATTLIST circle
angle CDATA #REQUIRED
diameter CDATA #REQUIRED
>
The XML Element for a Curve Element in a Sketch
The <curve> element is a little more complicated because it's defined by an arbitrary number of points, but
it's still quite easy:
<!ELEMENT curve (color, position, bounds, point+)>
<!ATTLIST curve angle CDATA #REQUIRED>
<!ELEMENT point EMPTY>
<!ATTLIST point %coordinates;>
The start point of the curve is defined by the <position> element, and the GeneralPath object that
defines a curve includes at least one <point> element in addition to the origin, which is specified by the +
operator. The <point> element just has attributes for the coordinate pair.
Search WWH ::




Custom Search