|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcox.jmatt.java.MathTools.markup.Tag
cox.jmatt.java.MathTools.markup.svg.StyleTag
cox.jmatt.java.MathTools.markup.svg.TextTag
public class TextTag
This class handles the SVG <text> tag. Some SVG tags have content, others may have child tags, but the <text> tag can have both, and at the same time. For that reason adding content and child tags to this element requires special attention. All content, whether text or child elements, is kept and output in the order in which it is entered. Child tags are converted to String as soon as they are added and may be interspersed with text content.
The two SVG elements this tag can contain are <tspan> and <textPath>. The former is handled via the TSpanTag
class and
has quite a few configurable options. The latter consists of text content, one mandatory argument and one optional so it is handled internally.
This class has the usual default methods for transforms and styling, hence its subclass TSpanTag
does as well. These should NOT be used in
the subclass, though, since it is techincally this class' responsibility. They are left unaltered, though, in case they are needed.
Text presentation has unique concerns outside other SVG elements. For that reason, styling text should be done via a TextPen
. This has all the
options of a standard StylePen
(which is its superclass) along with text-specific methods and options. TextPen
s are optimized for
text and for this class.
TextTag
is not limited to TextPen
s though! If an ordinary StylePen
will do the job there is no reason not
to use one! All of the Pen
classes are really just a thin veneer over CSS styling, so any pen can work anywhere. Use as needed and where needed.
There are no such concerns with TransformPen
, though. It is actually closer to structure than presentation (for MathTools' purposes) so it is
the only one of its kind.
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 | |
---|---|
|
TextTag()
Standard constructor for a blank tag. |
|
TextTag(java.lang.Double pX,
java.lang.Double pY,
java.lang.String pText)
Full constructor including initial text. |
protected |
TextTag(StyleTag.TagKeys pKey)
Protected constructor for subclassing. |
Method Summary | |
---|---|
protected java.lang.String |
_content()
Overridden to retrieve the String content from internal storage. |
protected void |
_setContent(java.lang.String pContent)
Overridden to handle tag content. |
TextTag |
addText(java.lang.String pText)
Add raw text content to the tag. |
TextTag |
addText(TSpanTag pTag)
Add a TSpanTag to the tag content. |
TextTag |
addTextPath(java.lang.String pURI,
java.lang.String pText,
java.lang.Double pOffset)
Add a <textpath> element. |
TextTag |
copyOf()
Copy this class. |
TextTag |
setData(java.lang.Double pX,
java.lang.Double pY,
java.lang.String pText)
Set all necessary data in the tag. |
TextTag |
setLengthAdjust(boolean pGlyphs)
Set the adjustment method for increasing or decreasing text length. |
TextTag |
setLocation(java.lang.Double pX,
java.lang.Double pY)
Set the X- and Y-coordinates of this tag. |
TextTag |
setTextLength(java.lang.Double pValue)
Set (or clear) a limit on the length of the text. |
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 |
---|
public TextTag()
public TextTag(java.lang.Double pX, java.lang.Double pY, java.lang.String pText)
protected TextTag(StyleTag.TagKeys pKey)
Method Detail |
---|
public TextTag setData(java.lang.Double pX, java.lang.Double pY, java.lang.String pText)
protected java.lang.String _content()
_content
in class Tag
protected void _setContent(java.lang.String pContent)
_setContent
in class Tag
pContent
- The content to set or null to clear it.public TextTag copyOf()
public TextTag addText(java.lang.String pText)
public TextTag addText(TSpanTag pTag)
TSpanTag
to the tag content. It will be on its own line and all necessary escaping is done automatically.
public TextTag addTextPath(java.lang.String pURI, java.lang.String pText, java.lang.Double pOffset)
Add a <textpath> element. The path URI and text must not be null or empty. The text is XML-escaped before it is added. The pOffset parameter describes where along the path the text should start. If it is null or blank it is ignored.
Working with the offset requires a bit of explanation. The value given is of type double to allow both whole-number user-units and percentages. The way this works is as follows: If the absolute value of 'pStartOffset' is between zero and one it is converted to an integer percent with the '%' sign appended. If the absolute value is greater than one it is assumed to be user units and is stringified as-is.
The <textpant> element, since it has little to configure, is added as a part of the <text> tag and treated as a String with benefits. No attributes other than the ones specified, URI and offset, are available nor should be needed. The tag itself has a newline prepended before and appended afterward so it will appear on its own line.
pURI
- The URI to the <path> tag along which the text is written.pText
- The text to write along the path. Must not be null or empty.pOffset
- The distance down the path the text is to start. Ignored if null or empty.public TextTag setTextLength(java.lang.Double pValue)
public TextTag setLengthAdjust(boolean pGlyphs)
pGlyphs
- true to include glyphs in length adustment, false to use spacing only.public TextTag setLocation(java.lang.Double pX, java.lang.Double pY)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |