cox.jmatt.java.MathTools.markup.svg
Class DrawableContainerTag

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.Tag
      extended by cox.jmatt.java.MathTools.markup.svg.StyleTag
          extended by cox.jmatt.java.MathTools.markup.svg.DrawableContainerTag
Direct Known Subclasses:
ClipTag, GroupTag, MarkerTag, MaskTag, PatternTag

public abstract class DrawableContainerTag
extends StyleTag

This class provides the abstract superclass for the SVG tags that can contain other tags (container tags) and the methods to add those tags quickly, easily, and conveniently (drawable). These include but are not limited to the grouping tags: <g>, <symbol>, <defs>, and <svg>. DCTag contains the necessary methods to add tags where they need to be and to handle the content from all subclasses.

The <defs> block (tag) is handled implicitly. Since it contains CSS stylesheets, groups, and symbols it is handled internally and never exposed. All elements that should go there do.

Note on default methods: This class extends StyleTag, therefore it inherits all the methods to set default style and transform values. These methods should not be used!! Each ContainerTag should be customized individually, not by default! None of the methods is specifically blocked, so they can be used if truly necessary, but such necessity should represent only the most extreme cases!


Nested Class Summary
 
Nested classes/interfaces inherited from class cox.jmatt.java.MathTools.markup.svg.StyleTag
StyleTag.TagKeys
 
Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.Tag
myTagName
 
Constructor Summary
protected DrawableContainerTag(StyleTag.TagKeys pKey)
          Subclass constructor necessary for StyleTag functionality.
 
Method Summary
protected  void _addContent(java.lang.String pContent)
          Add something to the internal content.
protected  void _addCSS(java.lang.String pRule)
          Add a rule to the CSS stylesheet.
protected  void _addDef(java.lang.String pDef)
          Add something to the <defs> block, followed by a newline.
protected  java.lang.String _content()
          Collect and present all the necessary content elements and other goodies in proper order and in proper form.
protected  void _setContent(java.lang.String pContent)
          This method is only implemented to clear content.
protected  void _setDesc(java.lang.String pDesc)
          Protected method to set the <desc> tag, which is also maintained here.
protected  void _setOBUS(java.lang.String pAttr, boolean isUserSpace)
          Method to set an attribute value to 'objectBoundingBox' (false) or 'userSpaceOnUse' (true).
protected  void _setPAR(java.lang.String par)
          Set the 'preserveAspectRatio=' attribute on tags that can take it.
protected  void _setTitle(java.lang.String pTitle)
          Method to set the <title< tag, which is maintained here but protected for only those tags where it is allowed.
protected  void _setViewBox(java.lang.String pBox)
          Method to set the 'viewBox=' attribute, for those tags that need it.
 DrawableContainerTag add(StyleTag pTag)
          Add a StyleTag to the internal content.
 DrawableContainerTag addRaw(java.lang.String pTagString)
          Add a pre-String'ed tag to the internal content.
 DrawableContainerTag drawCircle(java.lang.Double X1, java.lang.Double Y1, java.lang.Double pRadius)
          Add a <circle> tag to the current contents.
 DrawableContainerTag drawEllipse(java.lang.Double X1, java.lang.Double Y1, java.lang.Double radX, java.lang.Double radY)
          Add an <ellipse> tag to the current contents.
 DrawableContainerTag drawLine(java.lang.Double X1, java.lang.Double Y1, java.lang.Double X2, java.lang.Double Y2)
          Add a <line> tag to the current contents.
 DrawableContainerTag drawPath(java.lang.String pPath)
          Add a pre-defined <path> to the current content.
 DrawableContainerTag drawPoint(double X1, double Y1)
          Add a point to the current graphic.
 DrawableContainerTag drawPolygon(java.lang.String pPoints)
          Add a polygon to the current tag.
 DrawableContainerTag drawPolyline(java.lang.String pPoints)
          Add a polyline to the current tag.
 DrawableContainerTag drawRectangle(java.lang.Double X1, java.lang.Double Y1, java.lang.Double pWidth, java.lang.Double pHeight)
          Add a <rectangle> tag to the current contents.
 DrawableContainerTag drawRectangle(java.lang.Double X1, java.lang.Double Y1, java.lang.Double pWidth, java.lang.Double pHeight, java.lang.Double radX, java.lang.Double radY)
          Add a rounded <rectangle> tag.
 DrawableContainerTag drawText(java.lang.Double X1, java.lang.Double Y1, java.lang.String pText)
          Add text to the current contents.
 
Methods inherited from class cox.jmatt.java.MathTools.markup.svg.StyleTag
_configureTag, _enableCopy, canHaveDefs, isInDefs, setDefaultPen, setDefaultStyle, setDefaultTransform, setPen, setStyle, setTransform
 
Methods inherited from class cox.jmatt.java.MathTools.markup.Tag
_addAttribute, _addAttributes, _addNAttribute, _asBoolean, _asDouble, _asInt, _attributes, _clampNAttribute, _clampNAttribute, _fixKey, _setEnableXMLTag, badPizza, closeTag, configureTag, configureTagFromGlobalPizza, makeTag, openTag, reset, setID, toString, validString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DrawableContainerTag

protected DrawableContainerTag(StyleTag.TagKeys pKey)
Subclass constructor necessary for StyleTag functionality.

Method Detail

_setContent

protected void _setContent(java.lang.String pContent)
This method is only implemented to clear content. Any value other than null or blank is ignored, and those two merely clear all content!

Overrides:
_setContent in class Tag

_content

protected java.lang.String _content()
Collect and present all the necessary content elements and other goodies in proper order and in proper form. Newlines are inserted where appropriate along with descriptive comments.

Overrides:
_content in class Tag

_setTitle

protected void _setTitle(java.lang.String pTitle)
Method to set the <title< tag, which is maintained here but protected for only those tags where it is allowed. Setting null or blank clears it.


_setDesc

protected void _setDesc(java.lang.String pDesc)
Protected method to set the <desc> tag, which is also maintained here.


_setViewBox

protected void _setViewBox(java.lang.String pBox)

Method to set the 'viewBox=' attribute, for those tags that need it. The argument is String, so care should be used in setting it.

The viewBox is set via a String of four space-separated numbers. The first two represent the minimum x- and y-values for the viewport, the last two are its maxima. This establishes the 'user coordinates' used for all other tags, so set carefully! It is generally best to set the viewBox once only and on the root <svg> tag. These values should also be set to a convenient number, like 100 user units per whatever unit is used on the root tag. So, for U.S. letter-sized paper (8.5 in. by 11 in.) the viewBox is '0 0 850 1100'.


_setOBUS

protected void _setOBUS(java.lang.String pAttr,
                        boolean isUserSpace)
Method to set an attribute value to 'objectBoundingBox' (false) or 'userSpaceOnUse' (true). Since several attributes can have these values, the name of attribute is also supplied.

Parameters:
pAttr - The attribute whose value is 'objectBoundingBox' or 'userSpaceOnUse'.
isUserSpace - true for 'userSpaceOnUse' false for 'objectBoundingBox'.

_setPAR

protected void _setPAR(java.lang.String par)

Set the 'preserveAspectRatio=' attribute on tags that can take it. This method expects a one-, two-, or three-character String. Each character causes the following actions:

Other characters have no effect, nor does the order in which the characters occur. The first three specifiers determine what to do when an image overlaps its bounding box. The remaining characters determine what to do if 'meet' or 'slice' is specified. Setting an 'x' specifier automatically sets the same 'y' specifier unless 'y' is already set. Setting a 'y' does not affect the 'x'.


_addCSS

protected void _addCSS(java.lang.String pRule)
Add a rule to the CSS stylesheet. Protected for the <svg> tag. A newline is appended after each rule. Ignored if null or blank.


_addDef

protected void _addDef(java.lang.String pDef)
Add something to the <defs> block, followed by a newline. Ignored if null or blank.


_addContent

protected void _addContent(java.lang.String pContent)
Add something to the internal content. Null or blank is ignored.


add

public DrawableContainerTag add(StyleTag pTag)

Add a StyleTag to the internal content. If the tag is null nothing happens. This method automatically detects tags that must appear in the <defs> block and puts them there, others go to content. If 'pTag' is supposed to appear only in the <defs> block and the subclass adding it does not have one the tag is ignored. The tags are converted to String when added so changing them afterward will not affect the data added.

Technically, a group tag ('<g>') should appear in the definitions but it can appear in the body of the document. In order to do this groupTagInstance.toString() must be added via the addRaw() method. This also applies to other such tags: defs-block-inclusion takes priority.


addRaw

public DrawableContainerTag addRaw(java.lang.String pTagString)
Add a pre-String'ed tag to the internal content. Use this method carefully: the only safety feature is disregarding null or blank arguments!


drawLine

public DrawableContainerTag drawLine(java.lang.Double X1,
                                     java.lang.Double Y1,
                                     java.lang.Double X2,
                                     java.lang.Double Y2)
Add a <line> tag to the current contents. The line is from (X1, Y1) to (X2, Y2).


drawCircle

public DrawableContainerTag drawCircle(java.lang.Double X1,
                                       java.lang.Double Y1,
                                       java.lang.Double pRadius)
Add a <circle> tag to the current contents. The center is (X1, Y1) and the radius pRadius.


drawPoint

public DrawableContainerTag drawPoint(double X1,
                                      double Y1)
Add a point to the current graphic. It appears at (X1, Y1). Default point configuration is settable in MathDrawSVG.


drawEllipse

public DrawableContainerTag drawEllipse(java.lang.Double X1,
                                        java.lang.Double Y1,
                                        java.lang.Double radX,
                                        java.lang.Double radY)
Add an <ellipse> tag to the current contents. The center is (X1, Y1) and the radii are radX and radY.


drawRectangle

public DrawableContainerTag drawRectangle(java.lang.Double X1,
                                          java.lang.Double Y1,
                                          java.lang.Double pWidth,
                                          java.lang.Double pHeight)
Add a <rectangle> tag to the current contents. The upper left corner is (X1, Y1) with width pWidth and height pHeight.


drawRectangle

public DrawableContainerTag drawRectangle(java.lang.Double X1,
                                          java.lang.Double Y1,
                                          java.lang.Double pWidth,
                                          java.lang.Double pHeight,
                                          java.lang.Double radX,
                                          java.lang.Double radY)
Add a rounded <rectangle> tag. The upper left corner is (X1, Y1) with width pWidth and height pHeight; radX and radY are the corner radii.


drawText

public DrawableContainerTag drawText(java.lang.Double X1,
                                     java.lang.Double Y1,
                                     java.lang.String pText)
Add text to the current contents. The anchor point is (X1, Y1) and the text is 'pText'. Null or blank text is ignored.


drawPath

public DrawableContainerTag drawPath(java.lang.String pPath)
Add a pre-defined <path> to the current content. Ignored if null or blank.


drawPolygon

public DrawableContainerTag drawPolygon(java.lang.String pPoints)
Add a polygon to the current tag. The argument should be a String with an even number of space-separated (numeric) values. Ignored if null or blank.


drawPolyline

public DrawableContainerTag drawPolyline(java.lang.String pPoints)
Add a polyline to the current tag. Argument per addPolygon().