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

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.Tag
      extended by cox.jmatt.java.MathTools.markup.svg.StyleTag
Direct Known Subclasses:
CircleTag, DrawableContainerTag, EllipseTag, GradientTag, LineTag, PathTag, PolygonTag, RectangleTag, TextTag, UseTag

public class StyleTag
extends Tag

This class provides the basic machinery for the other SVG tags. It provides the mechanism for default styles and attributes the SVG implementation needs beyond what Tag supplies.

Every SVG tag class has default values for such things as style attributes, StylePens, and transformations. The TagKeys enum keeps up with this information and supplies it as needed. All the methods to set defaults are here; only the tag-critical methods are in the individual tag classes.


Nested Class Summary
static class StyleTag.TagKeys
          This enum is used internally by the SVG classes to store defaults and other such information.
 
Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.Tag
myTagName
 
Constructor Summary
protected StyleTag(StyleTag.TagKeys pTagKey)
          This is the protected constructor used to build all SVG tags.
 
Method Summary
protected  void _configureTag(java.lang.String pPrefix, java.util.Properties pPizza)
          This method establishes the pattern for pizza-configuring SVG package classes.
protected  void _enableCopy()
          After calling this method, the next instantiation of a subclass (only) will instead produce a copy.
 boolean canHaveDefs()
          Specify whether or not this subclass can have a <defs> block.
 boolean isInDefs()
          Specify whether or not this subclass should be within a <defs> block.
 void setDefaultPen(int pPen)
          Set the default pen number for this type of tag.
 void setDefaultStyle(StylePen pPen)
          Set the default 'style=' attribute for this type of tag.
 void setDefaultTransform(TransformPen pPen)
          Set the default transformations for this type of tag.
 void setPen(int pPen)
          Set the StylePen number to be used for the tag.
 void setStyle(StylePen pPen)
          Set the 'style=' attribute for this tag.
 void setTransform(TransformPen pPen)
          Set the transform(s) for this tag.
 
Methods inherited from class cox.jmatt.java.MathTools.markup.Tag
_addAttribute, _addAttributes, _addNAttribute, _asBoolean, _asDouble, _asInt, _attributes, _clampNAttribute, _clampNAttribute, _content, _fixKey, _setContent, _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

StyleTag

protected StyleTag(StyleTag.TagKeys pTagKey)
This is the protected constructor used to build all SVG tags. The argument is a TagKeys constant, which contains all necessary information about the tag's name and its current default settings. If subclassing, never, never, NEVER call this constructor with null!

Method Detail

setPen

public void setPen(int pPen)
Set the StylePen number to be used for the tag. Any number less than -1 becomes -1 and disables the StylePen.


setStyle

public void setStyle(StylePen pPen)
Set the 'style=' attribute for this tag. The argument is given as a StylePen but it is converted to String as soon as it is set. Changing the data in the StylePen after calling this method will not affect the data here. If pPen is null the tag's StylePen is set to null and disabled.

Parameters:
pPen - The StylePen to apply to this tag.

setTransform

public void setTransform(TransformPen pPen)
Set the transform(s) for this tag. This method calls toString() on the supplied TransformPen so any changes to the pen afterward will not affect the transforms already set.

Parameters:
pPen - The TransformPen containing the desired transforms.

_configureTag

protected void _configureTag(java.lang.String pPrefix,
                             java.util.Properties pPizza)

This method establishes the pattern for pizza-configuring SVG package classes. The only configurable attributes are ID and pen number but they can apply to any other tag class that calls this method. The 'pPrefix' String is for anything prepended to the prefixes described below. This allows different tag classes to have different configuration lines in the overall pizza.

The configuration options available from this method are:

This is the pattern that is used for each configurable tag class. It has a tag-specific prefix for each identifier, so when the tag prefix is prepended to 'Style.pen' and this method called, the pen number will be set. This is done to allow maximum flexibility in configuring these classes. If the prefix is null or blank it is ignored but the keys listed above are still checked. If 'pPizza' is null or empty this method returns silently.

Parameters:
pPrefix - The String prefix to prepend when extracting key values. If it does not end with a dot one will be supplied.
pPizza - The Properties object used to configure the class.

setDefaultPen

public void setDefaultPen(int pPen)
Set the default pen number for this type of tag. This remains in effect until changed. Any number less than -1 becomes -1 and disables numbered style pens by default.


setDefaultStyle

public void setDefaultStyle(StylePen pPen)
Set the default 'style=' attribute for this type of tag. Setting null disables it.


setDefaultTransform

public void setDefaultTransform(TransformPen pPen)
Set the default transformations for this type of tag. Setting null clears them.


_enableCopy

protected final void _enableCopy()

After calling this method, the next instantiation of a subclass (only) will instead produce a copy. This should ONLY be used in a copying method!

        public StyleTagSubclass copyOf() {
          _enableCopy();
          return new StyleTagSubclass();
        }
      
Only the first instantiation after this method is called creates a copy; the data set is cleared when accessed. This method uses _getContent() to set the content of the copied tag and the subsequent constructor calls _setContent().


canHaveDefs

public boolean canHaveDefs()
Specify whether or not this subclass can have a <defs> block.


isInDefs

public boolean isInDefs()
Specify whether or not this subclass should be within a <defs> block.