Methods Summary |
---|
public void | add(com.sun.perseus.model.ElementNode element)Appends an element at the end of the list
super.add(element);
ElementNodeProxy proxy = firstProxy;
while (proxy != null) {
proxy.proxiedChildAdded(element);
proxy = proxy.nextProxy;
}
|
protected void | addProxy(ElementNodeProxy proxy)Adds a proxy to this node. When this node is modified, the
ElementNodeProxy 's corresponding modification
methods will be called so that modifications also gets reported
on the proxy.
if (proxy == null) {
throw new NullPointerException();
}
if (firstProxy == null) {
firstProxy = proxy;
lastProxy = proxy;
} else {
lastProxy.nextProxy = proxy;
proxy.prevProxy = lastProxy;
lastProxy = proxy;
}
|
protected static java.lang.String | alignToStringTrait(int align)Converts an align value to a preserveAspectRatio string trait
value.
switch (align) {
case StructureNode.ALIGN_XMIDYMID:
return SVGConstants.SVG_IMAGE_PRESERVE_ASPECT_RATIO_DEFAULT_VALUE;
default:
return SVGConstants.SVG_NONE_VALUE;
}
|
protected org.w3c.dom.DOMException | animationError(java.lang.String targetId, java.lang.String traitNamespace, java.lang.String traitName, java.lang.String targetNamespace, java.lang.String targetName, java.lang.String animationId, java.lang.String animationNamespace, java.lang.String animationLocalName, java.lang.String errorDescription)
return new DOMException(DOMException.INVALID_STATE_ERR,
Messages.formatMessage
(Messages.ERROR_INVALID_ANIMATION_CONFIGURATION,
new String[] {targetId,
traitNamespace,
traitName,
targetNamespace,
targetName,
animationId,
animationNamespace,
animationLocalName,
animationLocalName,
errorDescription}));
|
public void | appendTextChild(java.lang.String text)By default, appending a text child does not do anything.
|
protected ElementNodeProxy | buildExpandedProxy()
if (buildingProxy) {
// We ran into a circular reference.
throw new IllegalStateException();
}
buildingProxy = true;
ElementNodeProxy proxy = buildProxy();
proxy.expand();
buildingProxy = false;
return proxy;
|
ElementNodeProxy | buildProxy()
return new ElementNodeProxy(this);
|
final void | checkNCName(java.lang.String name)Checks if the input trait name is valid and throws a DOMException
with error code NOT_SUPPORTED_ERR if not.
if (name == null || name.length() == 0) {
throw unsupportedTrait(name);
}
// We should really validate that the name has the conforming syntax
// But this slows down the load time considerably.
//
// NCName ::= (Letter | '_') (NCNameChar)*
// NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar
// | Extender
|
protected void | checkPositive(java.lang.String name, float value)Throws a DOMException if the input float trait value is
strictly negative.
if (value < 0) {
throw illegalTraitValue(name, Float.toString(value));
}
|
protected void | checkWriteLoading(java.lang.String name)Throws a DOMException if the element is not loading, i.e., if
its loaded field is set to true.
if (loaded && isInDocumentTree()) {
throw readOnlyTraitError(name);
}
|
final boolean | conditionEquals(int index, java.lang.String[] conditionValue)Returns true if the condition at the given index is equal to the input
value.
if (conditionValue == null) {
return (conditionalAttributes == null)
||
(conditionalAttributes[index] == null);
} else {
return (conditionalAttributes != null)
&&
(equal(conditionalAttributes[index], conditionValue));
}
|
TraitAnim | createTraitAnimImpl(java.lang.String traitName)To be overridden by derived classes. Should create the proper
TraitAnim type for the given trait in the anonymous namespace.
//
// If the trait is supported but the element did not create
// a TraitAnim in its implementation of createTraitAnimImpl,
// it means the trait is not animatable.
//
if (supportsTrait(traitName)) {
throw notAnimatable(null,
traitName);
}
return new StringTraitAnim(this, NULL_NS, traitName);
|
TraitAnim | createTraitAnimNS(java.lang.String traitNamespace, java.lang.String traitName)Implementation method.
Creates a TraitAnim for the requested trait. This method does not
check whether or not there is an existing TraitAnim for the trait.
Instead, it creates a new TraitAnim and associates it with the
given trait. After this call, any call to getSafeTraitAnimNS or
getTraitAnimNS will return this new object.
if (traitNamespace == null || traitNamespace.length() == 0) {
traitNamespace = NULL_NS;
}
TraitAnim traitAnim = null;
if (NULL_NS == traitNamespace) {
traitAnim = createTraitAnimImpl(traitName);
} else {
traitAnim = createTraitAnimNSImpl(traitNamespace, traitName);
}
if (traitAnimsNS == null) {
traitAnimsNS = new Hashtable();
}
Hashtable nsTraitAnims = (Hashtable) traitAnimsNS.get(traitNamespace);
if (nsTraitAnims == null) {
nsTraitAnims = new Hashtable();
traitAnimsNS.put(traitNamespace, nsTraitAnims);
}
nsTraitAnims.put(traitName, traitAnim);
return traitAnim;
|
TraitAnim | createTraitAnimNSImpl(java.lang.String traitNamespace, java.lang.String traitName)To be overridden by derived classes. Should create the proper
TraitAnim type for the given trait in the desired namespace.
//
// If the trait is supported but the element did not create
// a TraitAnim in its implementation of createTraitAnimImpl,
// it means the trait is not animatable.
//
if (supportsTraitNS(traitNamespace, traitName)) {
throw notAnimatable(traitNamespace,
traitName);
}
return new StringTraitAnim(this, traitNamespace, traitName);
|
public static boolean | equal(java.lang.Object objA, java.lang.Object objB)
if (objA == objB) {
return true;
}
if (objA == null || objB == null) {
return false;
}
return objA.equals(objB);
|
public static boolean | equal(float[] faa, float[] fab)
if (faa == fab) {
return true;
}
if (faa == null || fab == null || faa.length != fab.length) {
return false;
}
int n = faa.length;
for (int i = 0; i < n; i++) {
if (faa[i] != fab[i]) {
return false;
}
}
return true;
|
public static boolean | equal(java.lang.String[] saa, java.lang.String[] sab)
if (saa == sab) {
return true;
}
if (saa == null || sab == null || saa.length != sab.length) {
return false;
}
int n = saa.length;
for (int i = 0; i < n; i++) {
if (!equal(saa[i], sab[i])) {
return false;
}
}
return true;
|
public static boolean | equal(int[][] iaa, int[][] iab)
if (iaa == iab) {
return true;
}
if (iaa == null || iab == null || iaa.length != iab.length) {
return false;
}
int n = iaa.length;
for (int i = 0; i < n; i++) {
if (iaa[i] != iab[i]) {
if (iaa[i] == null || iab[i] == null
|| iaa[i].length != iab[i].length) {
return false;
}
int m = iaa[i].length;
for (int j = 0; j < m; j++) {
if (iaa[i][j] != iab[i][j]) {
return false;
}
}
}
}
return true;
|
public static boolean | equal(float[][] faa, float[][] fab)
if (faa == fab) {
return true;
}
if (faa == null || fab == null || faa.length != fab.length) {
return false;
}
int n = faa.length;
for (int i = 0; i < n; i++) {
if (faa[i] != fab[i]) {
if (faa[i] == null || fab[i] == null
|| faa[i].length != fab[i].length) {
return false;
}
int m = faa[i].length;
for (int j = 0; j < m; j++) {
if (faa[i][j] != fab[i][j]) {
return false;
}
}
}
}
return true;
|
protected java.lang.String | fontStylesToStringTrait(int styles)Converts a FontFace's font-styles to a String trait.
if (styles == FontFace.FONT_STYLE_ALL) {
return SVGConstants.CSS_ALL_VALUE;
}
StringBuffer sb = new StringBuffer();
if ((styles & TextNode.FONT_STYLE_NORMAL) != 0) {
sb.append(SVGConstants.CSS_NORMAL_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((styles & TextNode.FONT_STYLE_ITALIC) != 0) {
sb.append(SVGConstants.CSS_ITALIC_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((styles & TextNode.FONT_STYLE_OBLIQUE) != 0) {
sb.append(SVGConstants.CSS_OBLIQUE_VALUE);
sb.append(SVGConstants.COMMA);
}
if (sb.length() > 0) {
return sb.toString().substring(0, sb.length() - 1);
}
return sb.toString();
|
protected java.lang.String | fontWeightsToStringTrait(int weight)Converts an FontFace's font-weights to a String trait.
if (weight == FontFace.FONT_WEIGHT_ALL) {
return SVGConstants.CSS_ALL_VALUE;
}
StringBuffer sb = new StringBuffer();
if ((weight & TextNode.FONT_WEIGHT_100) != 0) {
sb.append(SVGConstants.CSS_100_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_200) != 0) {
sb.append(SVGConstants.CSS_200_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_300) != 0) {
sb.append(SVGConstants.CSS_300_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_400) != 0) {
sb.append(SVGConstants.CSS_400_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_500) != 0) {
sb.append(SVGConstants.CSS_500_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_600) != 0) {
sb.append(SVGConstants.CSS_600_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_700) != 0) {
sb.append(SVGConstants.CSS_700_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_800) != 0) {
sb.append(SVGConstants.CSS_800_VALUE);
sb.append(SVGConstants.COMMA);
}
if ((weight & TextNode.FONT_WEIGHT_900) != 0) {
sb.append(SVGConstants.CSS_900_VALUE);
sb.append(SVGConstants.COMMA);
}
if (sb.length() > 0) {
return sb.toString().substring(0, sb.length() - 1);
}
return sb.toString();
|
public final java.lang.String | getAttribute(java.lang.String name)Returns the requested attribute.
checkNCName(name);
name = name.intern();
return getTraitImpl(name);
|
public final java.lang.String | getAttributeNS(java.lang.String namespaceURI, java.lang.String name)Returns the requested attribute in the specified namespace.
if (namespaceURI == null || namespaceURI.length() == 0) {
return getAttribute(name);
}
checkNCName(name);
namespaceURI = namespaceURI.intern();
name = name.intern();
return getTraitNSImpl(namespaceURI, name);
|
java.lang.String[] | getConditionalAttribute(int index)Returns the value of the conditional attribute with the given
index.
if (conditionalAttributes != null) {
return conditionalAttributes[index];
} else {
return null;
}
|
public java.lang.String[][] | getDefaultTraits()
return null;
|
public ModelNode | getFirstComputedExpandedChild()Some node types (such as ElementNodeProxy ) have
expanded children that they compute in some specific
way depending on the implementation.
return null;
|
public org.w3c.dom.Element | getFirstElementChild()
return (Element) firstChild;
|
ModelNode | getFirstExpandedChild()By default, an ElementNode has no expanded content, so this
returns null.
return null;
|
public final float | getFloatTrait(java.lang.String name)
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
return getFloatTraitImpl(name);
}
// Get the computed value from the trait animation.
return parseFloatTrait(name, anim.getTrait(TRAIT_TYPE_FLOAT));
|
float | getFloatTraitImpl(java.lang.String name)
throw unsupportedTraitType(name, TRAIT_TYPE_FLOAT);
|
public java.lang.String | getId()
return id;
|
public org.w3c.dom.Element | getLastElementChild()
return (Element) lastChild;
|
ModelNode | getLastExpandedChild()By default, an ElementNode has no expanded content, so this
returns null.
return null;
|
public final org.w3c.dom.svg.SVGMatrix | getMatrixTrait(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}.
The returned object is a copy of the actual trait value and will not
change ifthe corresponding trait changes.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
return getMatrixTraitImpl(name);
}
// Get the computed value from the trait animation
SVGMatrix m =
parseTransformTrait(name, anim.getTrait(TRAIT_TYPE_SVG_MATRIX));
if (m == null) {
m = new Transform(1, 0, 0, 1, 0, 0);
}
return m;
|
org.w3c.dom.svg.SVGMatrix | getMatrixTraitImpl(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}.
The returned object is a copy of the actual trait value and will not
change ifthe corresponding trait changes.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_MATRIX);
|
public java.lang.String | getNamespaceURI()
return SVGConstants.SVG_NAMESPACE_URI;
|
public org.w3c.dom.Element | getNextElementSibling()
// Casting is safe here because ElementNodes can only have ElementNode
// siblings.
return (Element) nextSibling;
|
public boolean | getPaintNeedsLoad()
return paintNeedsLoad;
|
public org.w3c.dom.Node | getParentNode()Returns the parent Node of this Node .
return (Node) parent;
|
public final org.w3c.dom.svg.SVGPath | getPathTrait(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. The
returned object is a copy of the actual trait value and will not change
if the corresponding trait changes.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
return getPathTraitImpl(name);
}
// Get the computed value from the trait animation.
return parsePathTrait(name, anim.getTrait(TRAIT_TYPE_SVG_PATH));
|
org.w3c.dom.svg.SVGPath | getPathTraitImpl(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. The
returned object is a copy of the actual trait value and will not change
if the corresponding trait changes.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_PATH);
|
public org.w3c.dom.Element | getPreviousElementSibling()
// Casting is safe here because ElementNodes can only have ElementNode
// siblings.
return (Element) prevSibling;
|
public final org.w3c.dom.svg.SVGRGBColor | getRGBColorTrait(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGRGBColor
SVGRGBColor}. The returned object is a copy of the trait value and will
not change if the corresponding trait changes. If the actual trait value
is not an RGBColor (i.e. "none"), this method will return null.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
return getRGBColorTraitImpl(name);
}
// Get the computed value from the trait animation
return toSVGRGBColor(
name,
parseColorTrait(name, anim.getTrait(TRAIT_TYPE_SVG_RGB_COLOR)));
|
org.w3c.dom.svg.SVGRGBColor | getRGBColorTraitImpl(java.lang.String name)Returns the trait value as {@link org.w3c.dom.svg.SVGRGBColor
SVGRGBColor}. The returned object is a copy of the trait value and will
not change if the corresponding trait changes. If the actual trait value
is not an RGBColor (i.e. "none"), this method will return null.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_RGB_COLOR);
|
public final org.w3c.dom.svg.SVGRect | getRectTrait(java.lang.String name)
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
return getRectTraitImpl(name);
}
// Get the computed value from the trait animation.
return toSVGRect(toViewBox(name, anim.getTrait(TRAIT_TYPE_SVG_RECT)));
|
org.w3c.dom.svg.SVGRect | getRectTraitImpl(java.lang.String name)
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_RECT);
|
public java.lang.String[] | getRequiredExtensions()The node will only render if the required extension is supported
by Perseus.
return getConditionalAttribute(REQUIRED_EXTENSIONS_INDEX);
|
public java.lang.String[] | getRequiredFeatures()The node will only render if the required feature is
supported by Perseus.
return getConditionalAttribute(REQUIRED_FEATURES_INDEX);
|
public java.lang.String[] | getRequiredTraits()
return null;
|
public java.lang.String[][] | getRequiredTraitsNS()
return null;
|
TraitAnim | getSafeTraitAnimNS(java.lang.String traitNamespace, java.lang.String traitName)
TraitAnim traitAnim = getTraitAnimNS(traitNamespace, traitName);
if (traitAnim == null) {
traitAnim = createTraitAnimNS(traitNamespace, traitName);
}
return traitAnim;
|
java.lang.String | getSpecifiedTraitImpl(java.lang.String traitName)Returns the specified trait value as String. In SVG Tiny only certain
traits can be obtained as a String value. Syntax of the returned String
matches the syntax of the corresponding attribute. This element is
exactly equivalent to {@link org.w3c.dom.svg.SVGElement#getTraitNS
getTraitNS} with namespaceURI set to null.
The method is meant to be overridden by derived classes. The
implementation pattern is that derived classes will override the method
and call their super class' implementation. If the ElementNode
implementation is called, it means that the trait is either not supported
or that it cannot be seen as a String.
return getTraitImpl(traitName);
|
java.lang.String | getSpecifiedTraitNSImpl(java.lang.String traitNamespace, java.lang.String traitName)Returns the specified trait value as String. In SVG Tiny only certain
traits can be obtained as a String value. Syntax of the returned String
matches the syntax of the corresponding attribute. This element is
exactly equivalent to {@link org.w3c.dom.svg.SVGElement#getTraitNS
getTraitNS} with namespaceURI set to null.
The method is meant to be overridden by derived classes. The
implementation pattern is that derived classes will override the method
and call their super class' implementation. If the ElementNode
implementation is called, it means that the trait is either not supported
or that it cannot be seen as a String.
if (traitNamespace == null || traitNamespace == NULL_NS) {
return getSpecifiedTraitImpl(traitName);
}
// Only xml:base behaves differently because the computed value
// may be different from the specified value.
if (SVGConstants.XML_NAMESPACE_URI == traitNamespace
&&
SVGConstants.XML_BASE_ATTRIBUTE_LOCAL_NAME == traitName) {
return uriBase;
}
return getTraitNSImpl(traitNamespace, traitName);
|
public java.lang.String[] | getSystemLanguage()The node will only render if the Perseus user language matches
one of the values in this comma separated list. A null value is a
match.
return getConditionalAttribute(SYSTEM_LANGUAGE_INDEX);
|
public final java.lang.String | getTrait(java.lang.String traitName)The traits supported by default are: externalResourcesRequired,
xml:base, xml:space, requiredFeatures, requiredExtensions and
systemLanguage.
Returns the trait value as String. In SVG Tiny only certain traits can be
obtained as a String value. Syntax of the returned String matches the
syntax of the corresponding attribute. This element is exactly equivalent
to {@link org.w3c.dom.svg.SVGElement#getTraitNS getTraitNS} with
namespaceURI set to null.
The method is meant to be overridden by derived classes. The
implementation pattern is that derived classes will override the method
and call their super class' implementation. If the ElementNode
implementation is called, it means that the trait is either not supported
or that it cannot be seen as a String.
traitName = intern(traitName);
if (!supportsTrait(traitName)) {
throw unsupportedTrait(traitName);
}
TraitAnim anim = getTraitAnimNS(NULL_NS, traitName);
if (anim == null || !anim.active) {
return getTraitImpl(traitName);
}
// Get the computed trait value from the trait animation.
return anim.getTrait(TRAIT_TYPE_STRING);
|
public java.lang.String[][] | getTraitAliases()
return null;
|
TraitAnim | getTraitAnimNS(java.lang.String traitNamespace, java.lang.String traitName)
if (traitName == null) {
throw new NullPointerException();
}
if (traitAnimsNS == null) {
return null;
}
if (traitNamespace == null || traitNamespace.length() == 0) {
traitNamespace = NULL_NS;
}
Hashtable nsTraitAnims = (Hashtable) traitAnimsNS.get(traitNamespace);
if (nsTraitAnims != null) {
return (TraitAnim) nsTraitAnims.get(traitName);
}
return null;
|
public java.lang.String | getTraitImpl(java.lang.String name)The traits supported by default are: externalResourcesRequired,
xml:base, xml:space, requiredFeatures, requiredExtensions and
systemLanguage.
Returns the trait value as String. In SVG Tiny only certain traits can be
obtained as a String value. Syntax of the returned String matches the
syntax of the corresponding attribute. This element is exactly equivalent
to {@link org.w3c.dom.svg.SVGElement#getTraitNS getTraitNS} with
namespaceURI set to null.
The method is meant to be overridden by derived classes. The
implementation pattern is that derived classes will override the method
and call their super class' implementation. If the ElementNode
implementation is called, it means that the trait is either not supported
or that it cannot be seen as a String.
if (SVGConstants.SVG_ID_ATTRIBUTE == name) {
return getId();
} else
if (SVGConstants.SVG_REQUIRED_FEATURES_ATTRIBUTE == name) {
return toStringTrait(getRequiredFeatures(), " ");
} else
if (SVGConstants.SVG_REQUIRED_EXTENSIONS_ATTRIBUTE == name) {
return toStringTrait(getRequiredExtensions(), " ");
} else
if (SVGConstants.SVG_SYSTEM_LANGUAGE_ATTRIBUTE == name) {
return toStringTrait(getSystemLanguage(), ",");
} else {
if (!supportsTrait(name)) {
if (name == null) {
throw unsupportedTrait(name);
}
String unknownTraitValue =
ownerDocument.getUnknownTraitsNS(this, NULL_NS, name);
if (unknownTraitValue != null) {
return unknownTraitValue;
} else {
return "";
}
} else {
throw unsupportedTraitType(name, TRAIT_TYPE_STRING);
}
}
|
public final java.lang.String | getTraitNS(java.lang.String namespaceURI, java.lang.String name)Same as {@link org.w3c.dom.svg.SVGElement#getTrait getTrait}, but for
namespaced traits. Parameter name must be a non-qualified trait name,
i.e. without prefix.
if (namespaceURI == null) {
return getTrait(name);
}
name = intern(name);
namespaceURI = intern(namespaceURI);
if (!supportsTraitNS(namespaceURI, name)) {
throw unsupportedTraitNS(name, namespaceURI);
}
StringTraitAnim anim = (StringTraitAnim) getTraitAnimNS(namespaceURI,
name);
if (anim == null || !anim.active) {
return getTraitNSImpl(namespaceURI, name);
}
return anim.getTrait(TRAIT_TYPE_STRING);
|
java.lang.String | getTraitNSImpl(java.lang.String namespaceURI, java.lang.String name)Same as {@link org.w3c.dom.svg.SVGElement#getTrait getTrait}, but for
namespaced traits. Parameter name must be a non-qualified trait name,
i.e. without prefix.
if (SVGConstants.PERSEUS_NAMESPACE_URI == namespaceURI) {
if (SVGConstants.PERSEUS_CHILDREN_REQUIRED_ATTRIBUTE == name) {
if (paintNeedsLoad) {
return SVGConstants.SVG_TRUE_VALUE;
} else {
return SVGConstants.SVG_FALSE_VALUE;
}
}
} else if (SVGConstants.XML_NAMESPACE_URI == namespaceURI) {
if (SVGConstants.XML_BASE_ATTRIBUTE_LOCAL_NAME == name) {
return getURIBase();
} else
if (SVGConstants.XML_SPACE_ATTRIBUTE_LOCAL_NAME == name) {
switch (getXMLSpace()) {
case XML_SPACE_DEFAULT:
return SVGConstants.XML_DEFAULT_VALUE;
case XML_SPACE_PRESERVE:
default:
return SVGConstants.XML_PRESERVE_VALUE;
}
}
}
if (!supportsTraitNS(namespaceURI, name)) {
String unknownTraitValue =
ownerDocument.getUnknownTraitsNS(this, namespaceURI, name);
if (unknownTraitValue != null) {
return unknownTraitValue;
}
return "";
} else {
throw unsupportedTraitTypeNS(name, namespaceURI, TRAIT_TYPE_STRING);
}
|
public java.lang.String | getURIBase()The node's URI base to use to resolve URI references
If a URI base value was set on this node, then that value
is returned. Otherwise, this method returns the parent's
URI base.
if (uriBase == null) {
if (parent != null) {
return parent.getURIBase();
}
return null;
} else {
if (uriBase.indexOf(":") != -1 || parent == null) {
// This is not a relative URI, we can return this
// value
// - or -
// There is no parent, return this relative URI
// as the baseURI
return uriBase;
} else {
// There is no scheme in this node's uri base.
// We concatenate the uriBase to the one of the
// parent.
// This is done according to RFC 2396
// (http://www.faqs.org/rfcs/rfc2396.html)
String parentURIBase = parent.getURIBase();
if (parentURIBase != null) {
int lastSlashIndex = parentURIBase.lastIndexOf('/");
if (lastSlashIndex != -1) {
parentURIBase
= parentURIBase.substring(0, lastSlashIndex);
}
return parentURIBase + '/" + uriBase;
} else {
return uriBase;
}
}
}
|
public int | getXMLSpace()Defines how the node handles white spaces. Note that
if the value is set to null, the node should return
the value of its parent, as the xml:space attribute is
inherited.
if (xmlSpace != XML_SPACE_INHERIT) {
return xmlSpace;
} else {
ModelNode ancestor = parent;
while (ancestor != null) {
if (ancestor instanceof ElementNode) {
return ((ElementNode) parent).getXMLSpace();
}
ancestor = ancestor.parent;
}
return XML_SPACE_DEFAULT;
}
|
org.w3c.dom.DOMException | illegalTraitValue(java.lang.String name, java.lang.String value)
return new DOMException(
DOMException.INVALID_ACCESS_ERR,
Messages.formatMessage(
Messages.ERROR_INVALID_TRAIT_VALUE,
new String[] {
name,
value,
getLocalName() + "(" + getId() + ")",
getNamespaceURI()
}));
|
protected org.w3c.dom.DOMException | illegalTraitValue(java.lang.String name, java.lang.String namespaceURI, java.lang.String value)
return illegalTraitValue(name + "(" + namespaceURI + ")",
value);
|
public static java.lang.String | intern(java.lang.String str)Utility method.
if (str == null) {
return null;
}
return str.intern();
|
protected void | modifiedNode()Used to notify the UpdateListener , if any, of
a completed node modification
UpdateListener updateListener = getUpdateListener();
if (updateListener != null) {
updateListener.modifiedNode(this);
}
// See comment in #modifyingNode.
ElementNodeProxy proxy = firstProxy;
while (proxy != null) {
proxy.modifiedProxied();
proxy = proxy.nextProxy;
}
|
protected void | modifyingNode()Used to notify the UpdateListener , if any, of
an upcoming node modification
UpdateListener updateListener = getUpdateListener();
if (updateListener != null) {
updateListener.modifyingNode(this);
}
// During progressive rendering, a proxy may be hooked into
// the tree while the referenced node is not. This is why we
// need to notify proxies even if the node is not hooked into
// the tree yet.
ElementNodeProxy proxy = firstProxy;
while (proxy != null) {
proxy.modifyingProxied();
proxy = proxy.nextProxy;
}
|
public abstract com.sun.perseus.model.ElementNode | newInstance(DocumentNode doc)Used by DocumentNode to create a new instance from
a prototype ElementNode .
|
void | nodeHookedInDocumentTree()When an Element is hooked into the document tree, it needs
to register as an identified node if it does have an id.
super.nodeHookedInDocumentTree();
if (id != null) {
ownerDocument.addIdentifiedNode(this);
}
|
org.w3c.dom.DOMException | notAnimatable(java.lang.String traitNamespace, java.lang.String traitName)
return new DOMException(DOMException.NOT_SUPPORTED_ERR,
Messages.formatMessage
(Messages.ERROR_TRAIT_NOT_ANIMATABLE,
new String[] {traitNamespace,
traitName,
getLocalName(),
getNamespaceURI()}));
|
protected final Time | parseClockTrait(java.lang.String traitName, java.lang.String value)Parses the input value and converts it to a Time value.
if (SVGConstants.SVG_INDEFINITE_VALUE.equals(value)) {
return Time.INDEFINITE;
}
try {
return new Time(ownerDocument.clockParser.parseClock(value));
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(traitName, value);
}
|
protected final com.sun.perseus.j2d.RGB | parseColorTrait(java.lang.String traitName, java.lang.String value)Parses the input value and converts it to an RGB value
try {
return ownerDocument.colorParser.parseColor(value);
} catch (IllegalArgumentException e) {
throw illegalTraitValue(traitName, value);
}
|
public final float[] | parseFloatArrayTrait(java.lang.String traitName, java.lang.String value)Utility method. This should be used for XML attribute values converted
to float arrays.
return parseFloatArrayTrait(traitName, value, ',");
|
public final float[] | parseFloatArrayTrait(java.lang.String traitName, java.lang.String value, char sep)Utility method. This should be used for XML attribute values converted
to float arrays.
try {
return ownerDocument.numberListParser.parseNumberList(value, sep);
} catch (IllegalArgumentException e) {
e.printStackTrace();
throw illegalTraitValue(traitName, value);
}
|
protected final float | parseFloatTrait(java.lang.String name, java.lang.String value)Parses the input value and converts it to a float value.
try {
return ownerDocument.lengthParser.parseNumber(value);
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
public java.lang.String[] | parseFontFamilyTrait(java.lang.String name, java.lang.String value)Parses the input value assuming it has the folloing syntax:
Value: [ | ] [, [ |
]]*
if (value == null) {
throw illegalTraitValue(name, value);
}
SimpleTokenizer st = new SimpleTokenizer(value, SVGConstants.COMMA_STR);
String[] fontFamily = new String[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
fontFamily[i] = st.nextToken();
// Remove leading and trailing white spaces
fontFamily[i] = fontFamily[i].trim();
//
// Now, take care of quotes
//
// <!> NOTE
//
// According to the CSS spec., if font family values are not
// quoted, then the spaces should be consolidated. The following
// code does not do that.
//
if (fontFamily[i].length() > 0) {
if (fontFamily[i].charAt(0) == '\'") {
// If there is a trailing quote, remove the quotes
if (fontFamily[i].charAt(fontFamily[i].length() - 1)
==
'\'") {
fontFamily[i] =
fontFamily[i].substring(1,
fontFamily[i].length() - 1);
}
}
}
i++;
}
return fontFamily;
|
public final int | parseFontStylesTrait(java.lang.String name, java.lang.String value)CSS 2 Specification (section 15.3.2) and SVG 1.1 specification
(20.8.3):
all | [ normal | italic | oblique ] [, [normal | italic | oblique] ]*
if (value == null) {
throw illegalTraitValue(name, value);
}
if (SVGConstants.CSS_ALL_VALUE.equals(value)) {
return FontFace.FONT_STYLE_ALL;
}
SimpleTokenizer st = new SimpleTokenizer(value, SVGConstants.COMMA_STR);
if (st.countTokens() < 1) {
throw illegalTraitValue(name, value);
}
int styles = 0;
while (st.hasMoreTokens()) {
String t = st.nextToken().trim();
if (SVGConstants.CSS_NORMAL_VALUE.equals(t)) {
styles |= TextNode.FONT_STYLE_NORMAL;
} else if (SVGConstants.CSS_ITALIC_VALUE.equals(t)) {
styles |= TextNode.FONT_STYLE_ITALIC;
} else if (SVGConstants.CSS_OBLIQUE_VALUE.equals(t)) {
styles |= TextNode.FONT_STYLE_OBLIQUE;
} else {
throw illegalTraitValue(name, value);
}
}
return styles;
|
protected final int | parseFontWeightsTrait(java.lang.String name, java.lang.String value)CSS 2 specification ((section 15.3.2) and SVG 1.1 specification
(20.8.3):
all | [normal | bold |100 | 200 | 300 | 400 | 500 | 600 |
700 | 800 | 900] [, [normal | bold |100 | 200 | 300 |
400 | 500 | 600 | 700 | 800 | 900]]*
if (value == null) {
throw illegalTraitValue(name, value);
}
if (SVGConstants.CSS_ALL_VALUE.equals(value)) {
return FontFace.FONT_WEIGHT_ALL;
}
SimpleTokenizer st = new SimpleTokenizer(value, SVGConstants.COMMA_STR);
if (st.countTokens() < 1) {
throw illegalTraitValue(name, value);
}
int weights = 0;
while (st.hasMoreTokens()) {
String t = st.nextToken().trim();
if (SVGConstants.CSS_NORMAL_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_NORMAL;
} else if (SVGConstants.CSS_BOLD_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_BOLD;
} else if (SVGConstants.CSS_100_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_100;
} else if (SVGConstants.CSS_200_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_200;
} else if (SVGConstants.CSS_300_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_300;
} else if (SVGConstants.CSS_400_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_400;
} else if (SVGConstants.CSS_500_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_500;
} else if (SVGConstants.CSS_600_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_600;
} else if (SVGConstants.CSS_700_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_700;
} else if (SVGConstants.CSS_800_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_800;
} else if (SVGConstants.CSS_900_VALUE.equals(t)) {
weights |= TextNode.FONT_WEIGHT_900;
} else {
throw illegalTraitValue(name, value);
}
}
return weights;
|
protected final float | parseLengthTrait(java.lang.String name, java.lang.String value, boolean isHorizontal)Parses the input value and converts it to a float.
try {
Length l = ownerDocument.lengthParser.parseLength(value);
switch (l.unit) {
case Length.SVG_LENGTHTYPE_NUMBER:
return l.value;
case Length.SVG_LENGTHTYPE_IN:
return (l.value * 25.4f / ownerDocument.getPixelMMSize());
case Length.SVG_LENGTHTYPE_CM:
return (l.value * 10f / ownerDocument.getPixelMMSize());
case Length.SVG_LENGTHTYPE_MM:
return (l.value / ownerDocument.getPixelMMSize());
case Length.SVG_LENGTHTYPE_PT:
return (l.value * 25.4f /
(72f * ownerDocument.getPixelMMSize()));
case Length.SVG_LENGTHTYPE_PC:
return (l.value * 25.4f /
(6f * ownerDocument.getPixelMMSize()));
case Length.SVG_LENGTHTYPE_PERCENTAGE:
if (isHorizontal) {
return ownerDocument.width * l.value / 100f;
} else {
return ownerDocument.height * l.value / 100f;
}
default:
// This should never happen.
throw new Error();
}
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
protected final Time | parseMinMaxClock(java.lang.String traitName, java.lang.String value, boolean isMin)Parses the input value and converts it to a Time value. If there
is a syntax error or if the value is invalid for the given usage
(has to be [0, infinite[ for min, and ]0, infinite[ for max,
then the default is used. For min, the default is 0. For max, the
default is 'indefinite'
if (SVGConstants.SVG_INDEFINITE_VALUE.equals(value)) {
return Time.INDEFINITE;
}
if (value == null) {
throw illegalTraitValue(traitName, value);
}
try {
long v = ownerDocument.clockParser.parseClock(value);
if (v < 0) {
throw new IllegalArgumentException();
}
if (v == 0 && !isMin) {
throw new IllegalArgumentException();
}
return new Time(v);
} catch (IllegalArgumentException iae) {
if (isMin) {
return new Time(0);
}
return Time.INDEFINITE;
}
|
protected final com.sun.perseus.j2d.PaintServer | parsePaintTrait(java.lang.String traitName, com.sun.perseus.j2d.PaintTarget paintTarget, java.lang.String value)Parses the input value and converts it to a Paint value
if (value == null) {
throw illegalTraitValue(traitName, value);
}
if (value.startsWith("url(#")) {
if (value.length() < 7
||
value.charAt(value.length() - 1) != ')") {
throw illegalTraitValue(traitName, value);
}
String idRef = value.substring(5, value.length() - 1);
return PaintServerReference.resolve(ownerDocument,
paintTarget,
traitName,
idRef);
} else {
try {
return ownerDocument.colorParser.parseColor(value);
} catch (IllegalArgumentException e) {
throw illegalTraitValue(traitName, value);
}
}
|
protected final com.sun.perseus.j2d.Path | parsePathTrait(java.lang.String name, java.lang.String value)Parses the input value and converts it to a Path value.
try {
return ownerDocument.pathParser.parsePath(value);
} catch (IllegalArgumentException iae) {
DOMException de = illegalTraitValue(name, value);
if (!loaded) {
ownerDocument.setDelayedException(de);
return ownerDocument.pathParser.getPath();
} else {
throw de;
}
}
|
protected final com.sun.perseus.j2d.Path | parsePointsTrait(java.lang.String name, java.lang.String value)Parses the input points value and converts it to a Path value.
try {
return ownerDocument.pathParser.parsePoints(value);
} catch (IllegalArgumentException iae) {
DOMException de = illegalTraitValue(name, value);
if (!loaded) {
ownerDocument.setDelayedException(de);
return ownerDocument.pathParser.getPath();
} else {
throw de;
}
}
|
protected final float[] | parsePositiveFloatArrayTrait(java.lang.String name, java.lang.String value)Parses the input value and converts it to a float array value.
try {
SimpleTokenizer st = new SimpleTokenizer(value, ", ");
float[] da = null;
int n = st.countTokens();
float totalLength = 0;
if ((n % 2) == 0) {
da = new float[n];
for (int i = 0; i < da.length; i++) {
da[i] = ownerDocument
.lengthParser.parseNumber(st.nextToken());
if (Float.isNaN(da[i]) || da[i] < 0) {
// The CSS number was invalid.
// Do not set the value
throw new IllegalArgumentException();
}
totalLength += da[i];
}
} else {
da = new float[2 * n];
for (int i = 0; i < n; i++) {
da[i] = ownerDocument
.lengthParser.parseNumber(st.nextToken());
da[n + i] = da[i];
if (Float.isNaN(da[i]) || da[i] < 0) {
// The CSS number was invalid.
// Do not set the value
throw new IllegalArgumentException();
}
totalLength += da[i];
}
}
if (totalLength > 0) {
return da;
} else {
return null;
}
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
} catch (NullPointerException iae) {
throw illegalTraitValue(name, value);
}
|
protected final float | parsePositiveFloatTrait(java.lang.String name, java.lang.String value)Parses the input value and converts it to a positive float value.
try {
float v = ownerDocument.lengthParser.parseNumber(value);
if (v < 0) {
throw new IllegalArgumentException();
}
return v;
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
protected final float | parsePositiveLengthTrait(java.lang.String name, java.lang.String value, boolean isHorizontal)Parses the input value and converts it to a float.
float v = parseLengthTrait(name, value, isHorizontal);
if (v < 0) {
throw illegalTraitValue(name, value);
}
return v;
|
protected final java.lang.String[] | parseStringArrayTrait(java.lang.String name, java.lang.String value, java.lang.String seperators)Parses the input value and converts it to a String array.
// Don't accept null trait values.
if (value == null) {
throw illegalTraitValue(name, value);
}
SimpleTokenizer st = new SimpleTokenizer(value, seperators);
int n = st.countTokens();
String[] result = new String[n];
for (int i = 0; i < n; i++) {
result[i] = st.nextToken().trim().intern();
}
return result;
|
protected final com.sun.perseus.j2d.Transform | parseTransformTrait(java.lang.String name, java.lang.String value)Parses the input value and converts it to an Transform value.
try {
return ownerDocument.transformListParser.parseTransformList(value);
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
protected final int[][] | parseUnicodeRangeTrait(java.lang.String name, java.lang.String value)Parses the input value, assuming a unicode range syntax, as for the
<hkern> element's u1 and u2 attributes.
try {
return ownerDocument.unicodeParser.parseUnicode(value);
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
protected void | preValidate()Invoked before an element is added to the document tree, to let the
element perform any validation it needs. For example, the use element
overrides this method to check that its reference is resolved.
Note that the validate() method defined in some element implementations
is meant to perform validation after the nodes has been inserted into the
document tree.
// By default, do nothing.
|
ModelNode | proxyNodeHitAt(float[] pt, ElementNodeProxy proxy)Returns the ModelNode , if any, hit by the
point at coordinate x/y in the proxy tree starting at
proxy.
return null;
|
protected org.w3c.dom.DOMException | readOnlyTraitError(java.lang.String name)
return new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
Messages.formatMessage
(Messages.ERROR_READ_ONLY_TRAIT,
new String[] {name,
getLocalName(),
getNamespaceURI()}));
|
protected void | recomputeProxyTransformState()Recomputes the transform cache on proxy nodes.
ElementNodeProxy proxy = firstProxy;
while (proxy != null) {
proxy.recomputeTransformState();
proxy = proxy.nextProxy;
}
|
void | removeProxy(ElementNodeProxy proxy)Removes a proxy from this node. If the input proxy is null,
or is not an existing proxy, this does nothing.
if (proxy == null || firstProxy == null) {
return;
}
// The proxy may be the first one, the last
// one, or in the middle
if (proxy == firstProxy) {
firstProxy = proxy.nextProxy;
}
if (proxy == lastProxy) {
lastProxy = proxy.prevProxy;
}
if (proxy.prevProxy != null) {
proxy.prevProxy.nextProxy = proxy.nextProxy;
}
if (proxy.nextProxy != null) {
proxy.nextProxy.prevProxy = proxy.prevProxy;
}
|
public final void | setAttribute(java.lang.String name, java.lang.String value)Adds a new attribute.
checkNCName(name);
if (value == null) {
throw illegalTraitValue(name, value);
}
name = name.intern();
setTraitImpl(name, value);
|
public final void | setAttributeNS(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)Adds a new attribute.
if (namespaceURI == null || namespaceURI.length() == 0) {
setAttribute(name, value);
return;
}
checkNCName(name);
if (value == null) {
throw illegalTraitValue(name, namespaceURI, value);
}
namespaceURI = namespaceURI.intern();
name = name.intern();
setTraitNSImpl(namespaceURI, name, value);
|
void | setConditionalAttribute(int index, java.lang.String[] newValue)Sets the new value for the given conditional attribute.
if (conditionEquals(index, newValue)) {
return;
}
modifyingNode();
if (newValue == null) {
if (conditionalAttributes != null) {
conditionalAttributes[index] = null;
}
} else {
if (conditionalAttributes == null) {
conditionalAttributes =
new String[CONDITIONAl_ATTRIBUTES_LENGTH][];
}
conditionalAttributes[index]
= newValue;
}
switch (index) {
case REQUIRED_FEATURES_INDEX:
{
computeCanRenderRequiredFeaturesBit(newValue);
ElementNodeProxy p = firstProxy;
while (p != null) {
p.computeCanRenderRequiredFeaturesBit(newValue);
p = p.nextProxy;
}
}
break;
case REQUIRED_EXTENSIONS_INDEX:
{
computeCanRenderRequiredExtensionsBit(newValue);
ElementNodeProxy p = firstProxy;
while (p != null) {
p.computeCanRenderRequiredExtensionsBit(newValue);
p = p.nextProxy;
}
}
break;
default:
{
computeCanRenderSystemLanguageBit(newValue);
ElementNodeProxy p = firstProxy;
while (p != null) {
p.computeCanRenderSystemLanguageBit(newValue);
p = p.nextProxy;
}
}
break;
}
modifiedNode();
|
void | setFloatArrayTrait(java.lang.String name, float[][] value)Set the trait value as float.
throw new Error(name);
|
public final void | setFloatTrait(java.lang.String name, float value)Set the trait value as float.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setFloatTraitImpl(name, value);
} else {
anim.setTrait(Float.toString(value), TRAIT_TYPE_FLOAT);
}
|
void | setFloatTraitImpl(java.lang.String name, float value)Set the trait value as a float.
throw unsupportedTraitType(name, TRAIT_TYPE_FLOAT);
|
public void | setId(java.lang.String newId)
// Null ids are disallowed.
if (newId == null) {
throw new NullPointerException();
}
// If the id was already set, we cannot let it be modified.
if (id != null) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
Messages.formatMessage
(Messages.ERROR_CANNOT_MODIFY_ID,
new String[] {newId,
id,
getLocalName(),
getNamespaceURI()}));
}
// Now, check if there is any element with that id already.
if (ownerDocument.getElementByIdAll(newId) != null) {
ElementNode duplicateElement =
(ElementNode) ownerDocument.getElementByIdAll(newId);
throw new DOMException(
DOMException.INVALID_ACCESS_ERR,
Messages.formatMessage(
Messages.ERROR_DUPLICATE_ID_VALUE,
new String[] {
newId,
getLocalName(),
getNamespaceURI(),
duplicateElement.getLocalName(),
duplicateElement.getNamespaceURI()
}));
}
modifyingNode();
id = newId;
// We only declare the id in the global document
// scope, i.e., we only consider the id to be
// resolved, once the element is loaded, i.e., ready
// to render. If the element is not loaded,
// see the buildComplete method: it adds the element
// to the list of identified nodes when loaded is
// set to true.
if (loaded && isInDocumentTree()) {
ownerDocument.addIdentifiedNode(this);
} else {
ownerDocument.reserveId(this);
}
modifiedNode();
|
public final void | setMatrixTrait(java.lang.String name, org.w3c.dom.svg.SVGMatrix matrix)Set the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}.
Values in SVGMarix are copied in the trait so subsequent changes to the
givenSVGMatrix have no effect on the value of the trait.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
if (matrix == null) {
throw illegalTraitValue(name, null);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setMatrixTraitImpl(name, new Transform(matrix));
} else {
anim.setTrait(toStringTrait((Transform) matrix),
TRAIT_TYPE_SVG_MATRIX);
}
|
void | setMatrixTraitImpl(java.lang.String name, com.sun.perseus.j2d.Transform matrix)Set the trait value as {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}.
Values in SVGMarix are copied in the trait so subsequent changes to the
givenSVGMatrix have no effect on the value of the trait.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_MATRIX);
|
public final void | setPathTrait(java.lang.String name, org.w3c.dom.svg.SVGPath path)Set the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. Values in
SVGPath are copied in the trait so subsequent changes to the given
SVGPath have no effect on the value of the trait.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
if (path == null) {
throw illegalTraitValue(name, null);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setPathTraitImpl(name, path);
} else {
if (path == null) {
throw illegalTraitValue(name, null);
}
anim.setTrait(((Path) path).toString(),
TRAIT_TYPE_SVG_PATH);
}
|
void | setPathTraitImpl(java.lang.String name, org.w3c.dom.svg.SVGPath path)Set the trait value as {@link org.w3c.dom.svg.SVGPath SVGPath}. Values in
SVGPath are copied in the trait so subsequent changes to the given
SVGPath have no effect on the value of the trait.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_PATH);
|
public void | setPreferedPaintNeedsLoad(boolean paintNeedsLoad)
this.paintNeedsLoad = paintNeedsLoad;
|
public final void | setRGBColorTrait(java.lang.String name, org.w3c.dom.svg.SVGRGBColor color)Set the trait value as {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
if (color == null) {
throw illegalTraitValue(name, null);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setRGBColorTraitImpl(name, color);
} else {
anim.setTrait(color.toString(),
TRAIT_TYPE_SVG_RGB_COLOR);
}
|
void | setRGBColorTraitImpl(java.lang.String name, org.w3c.dom.svg.SVGRGBColor color)Set the trait value as {@link org.w3c.dom.svg.SVGRGBColor SVGRGBColor}.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_RGB_COLOR);
|
public final void | setRectTrait(java.lang.String name, org.w3c.dom.svg.SVGRect rect)Set the trait value as {@link org.w3c.dom.svg.SVGRect SVGRect}. Values in
SVGRect are copied in the trait so subsequent changes to the given
SVGRect have no effect on the value of the trait.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setRectTraitImpl(name, rect);
} else {
if (rect == null) {
throw illegalTraitValue(name, null);
}
float[] vb =
{rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()};
anim.setTrait(toStringTrait(vb), TRAIT_TYPE_SVG_RECT);
}
|
public void | setRectTraitImpl(java.lang.String name, org.w3c.dom.svg.SVGRect rect)Set the trait value as {@link org.w3c.dom.svg.SVGRect SVGRect}. Values in
SVGRect are copied in the trait so subsequent changes to the given
SVGRect have no effect on the value of the trait.
throw unsupportedTraitType(name, TRAIT_TYPE_SVG_RECT);
|
public void | setRequiredExtensions(java.lang.String[] newRequiredExtensions)The node will only render if the requiredExtensions string
evaluates to true. A null value evaluates to true.
setConditionalAttribute(REQUIRED_EXTENSIONS_INDEX,
newRequiredExtensions);
|
public void | setRequiredFeatures(java.lang.String[] newRequiredFeatures)The node will only render if the requiredFeatures string
evaluates to true. A null value will evaluate to true.
setConditionalAttribute(REQUIRED_FEATURES_INDEX, newRequiredFeatures);
|
public void | setSystemLanguage(java.lang.String[] newSystemLanguage)The node will only render if the Perseus user language matches
one of the values in this comma separated list. A null value is
a match.
setConditionalAttribute(SYSTEM_LANGUAGE_INDEX, newSystemLanguage);
|
public final void | setTrait(java.lang.String name, java.lang.String value)The traits supported by default are: externalResourcesRequired,
xml:base, xml:space, requiredFeatures, requiredExtensions and
systemLanguage.
name = intern(name);
if (!supportsTrait(name)) {
throw unsupportedTrait(name);
}
if (value == null) {
throw illegalTraitValue(name, value);
}
TraitAnim anim = (TraitAnim) getTraitAnimNS(NULL_NS, name);
if (anim == null || !anim.active) {
setTraitImpl(name, value);
} else {
anim.setTrait(value, TRAIT_TYPE_STRING);
}
|
public void | setTraitImpl(java.lang.String name, java.lang.String value)The traits supported by default are: externalResourcesRequired,
xml:base, xml:space, requiredFeatures, requiredExtensions and
systemLanguage.
if (SVGConstants.SVG_ID_ATTRIBUTE == name) {
try {
setId(value);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
throw illegalTraitValue(name, value);
}
} else if (SVGConstants.SVG_REQUIRED_FEATURES_ATTRIBUTE == name) {
if (value == null) {
throw illegalTraitValue(name, value);
}
setRequiredFeatures(parseStringArrayTrait(name, value, " "));
} else if (SVGConstants.SVG_REQUIRED_EXTENSIONS_ATTRIBUTE == name) {
if (value == null) {
throw illegalTraitValue(name, value);
}
setRequiredExtensions(parseStringArrayTrait(name, value, " "));
} else if (SVGConstants.SVG_SYSTEM_LANGUAGE_ATTRIBUTE == name) {
if (value == null) {
throw illegalTraitValue(name, value);
}
setSystemLanguage(parseStringArrayTrait(name, value, ","));
} else {
// The trait is not handled by this element as a string.
// There are two situations. If this trait is supported
// by the element, then it means that the String type is
// not supported for the trait, and the following throws an
// exception. Otherwise, this means the trait is just unknown,
// and it goes into the generic trait map.
if (supportsTrait(name)) {
throw unsupportedTraitType(name, TRAIT_TYPE_STRING);
} else {
if (name == null) {
throw unsupportedTrait(name);
}
if (value == null) {
throw illegalTraitValue(name, value);
}
ownerDocument.setUnknownTraitsNS(this, NULL_NS, name, value);
}
}
|
public final void | setTraitNS(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
if (namespaceURI == null || namespaceURI.length() == 0) {
setTrait(name, value);
return;
}
namespaceURI = intern(namespaceURI);
name = intern(name);
if (!supportsTraitNS(namespaceURI, name)) {
throw unsupportedTraitNS(name, namespaceURI);
}
StringTraitAnim anim =
(StringTraitAnim) getTraitAnimNS(namespaceURI, name);
if (anim == null || !anim.active) {
setTraitNSImpl(namespaceURI, name, value);
} else {
anim.setTrait(value, TRAIT_TYPE_STRING);
}
|
public void | setTraitNSImpl(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)Same as {@link org.w3c.dom.svg.SVGElement#setTrait setTrait}, but for
namespaced traits. Parameter name must be a non-qualified trait name,
i.e. without prefix.
if (SVGConstants.PERSEUS_NAMESPACE_URI == namespaceURI) {
if (SVGConstants.PERSEUS_CHILDREN_REQUIRED_ATTRIBUTE == name) {
if (SVGConstants.SVG_TRUE_VALUE.equals(value)) {
setPreferedPaintNeedsLoad(true);
return;
} else if (SVGConstants.SVG_FALSE_VALUE.equals(value)) {
setPreferedPaintNeedsLoad(false);
return;
} else {
throw illegalTraitValue(namespaceURI, name, value);
}
}
} else if (SVGConstants.XML_NAMESPACE_URI == namespaceURI) {
if (SVGConstants.XML_BASE_ATTRIBUTE_LOCAL_NAME == name) {
if (value == null) {
throw illegalTraitValue(name, value);
}
setURIBase(value);
} else if (SVGConstants.XML_SPACE_ATTRIBUTE_LOCAL_NAME == name) {
if (SVGConstants.XML_DEFAULT_VALUE.equals(value)
||
(value != null && value.length() == 0)) {
setXMLSpace(XML_SPACE_DEFAULT);
return;
} else if (SVGConstants.XML_PRESERVE_VALUE.equals(value)) {
setXMLSpace(XML_SPACE_PRESERVE);
return;
} else {
throw illegalTraitValue(name, value);
}
}
}
// The trait is not handled by this element as a string.
// There are two situations. If this trait is supported
// by the element, then it means that the String type is
// not supported for the trait which should never happen
// because all traits have to be supported as a string.
// So that causes an internal error.
// Otherwise, this means the trait is just unknown,
// and it goes into the generic trait map.
if (supportsTraitNS(name, value)) {
throw new Error();
}
// Trait is unknown, treat as a generic string trait.
ownerDocument.setUnknownTraitsNS(this, namespaceURI, name, value);
|
public void | setURIBase(java.lang.String newUriBase)
if (equal(newUriBase, uriBase)) {
return;
}
modifyingNode();
uriBase = newUriBase;
modifiedNode();
|
public void | setXMLSpace(int newXmlSpace)Controls how the node handles white spaces
if (newXmlSpace == xmlSpace) {
return;
}
switch (newXmlSpace) {
case XML_SPACE_DEFAULT:
case XML_SPACE_PRESERVE:
case XML_SPACE_INHERIT:
modifyingNode();
xmlSpace = newXmlSpace;
modifiedNode();
break;
default:
throw new IllegalArgumentException();
}
|
boolean | supportsTrait(java.lang.String traitName)
if (SVGConstants.SVG_ID_ATTRIBUTE == traitName
||
SVGConstants.SVG_REQUIRED_FEATURES_ATTRIBUTE == traitName
||
SVGConstants.SVG_REQUIRED_EXTENSIONS_ATTRIBUTE == traitName
||
SVGConstants.SVG_SYSTEM_LANGUAGE_ATTRIBUTE == traitName) {
return true;
}
return false;
|
boolean | supportsTraitNS(java.lang.String namespaceURI, java.lang.String traitName)
if (SVGConstants.PERSEUS_NAMESPACE_URI == namespaceURI
&&
SVGConstants.PERSEUS_CHILDREN_REQUIRED_ATTRIBUTE == traitName) {
return true;
} else if (SVGConstants.XML_NAMESPACE_URI == namespaceURI
&&
(SVGConstants.XML_BASE_ATTRIBUTE_LOCAL_NAME == traitName
||
SVGConstants.XML_SPACE_ATTRIBUTE_LOCAL_NAME == traitName)) {
return true;
}
if (namespaceURI == null) {
return supportsTrait(traitName);
} else {
return false;
}
|
float[][] | toAnimatedFloatArray(float v)Converts the input float value to an animated float array trait.
return new float[][] {{v}};
|
float[][] | toAnimatedFloatArray(float[] a)Converts the input float[] array to an animated float array trait.
float[][] v = new float[a.length][];
// This assumes that each value in the input array are separate
// components.
for (int i = 0; i < a.length; i++) {
v[i] = new float[] {a[i]};
}
return v;
|
float[][] | toAnimatedFloatArray(com.sun.perseus.j2d.Path path)Utility method to convert a Path to an animatable float array.
return new float[][] {path.getData()};
|
protected com.sun.perseus.j2d.RGB | toRGB(java.lang.String name, float[][] v)Converts an animated float[][] value into an AWT color value.
if (v != null) {
return new RGB((int) v[0][0], (int) v[0][1], (int) v[0][2]);
} else {
return null;
}
|
protected java.lang.String | toRGBString(java.lang.String name, float[][] v)Converts an animated float[][] value into an String rgb value.
if (v != null) {
return "rgb(" + ((int) v[0][0]) + "," + ((int) v[0][1]) + ","
+ ((int) v[0][2]) + ")";
} else {
return "none";
}
|
protected org.w3c.dom.svg.SVGMatrix | toSVGMatrixTrait(com.sun.perseus.j2d.Transform transform)Helper method. Converts the input Transform
to an SVGMatrix trait value.
if (transform == null) {
return new Transform(1, 0, 0, 1, 0, 0);
} else {
return new Transform(transform);
}
|
protected org.w3c.dom.svg.SVGRGBColor | toSVGRGBColor(java.lang.String traitName, com.sun.perseus.j2d.PaintServer paint)Converts an J2D RGB to an SVG DOM RGBColor
if (paint == null) {
return null;
}
if (!(paint instanceof SVGRGBColor)) {
throw unsupportedTraitType(traitName, TRAIT_TYPE_SVG_RGB_COLOR);
}
return (SVGRGBColor) paint;
|
protected org.w3c.dom.svg.SVGRect | toSVGRect(float[][] viewBox)Converts a viewBox array to an SVGRect value.
if (viewBox == null) {
return null;
}
SVGRect r = new Box(viewBox[0][0],
viewBox[0][1],
viewBox[1][0],
viewBox[2][0]);
return r;
|
public java.lang.String | toString()
if (getId() != null && getId().length() > 0) {
return "ElementNode[" + getId() + "] [" + super.toString() + "]";
} else {
return super.toString();
}
|
java.lang.String | toString(com.sun.perseus.j2d.PaintServer paintServer)Conversts the input PaintServer value to a String trait value.
if (paintServer == null) {
return SVGConstants.CSS_NONE_VALUE;
}
return paintServer.toString();
|
protected java.lang.String | toStringTrait(java.lang.String[] array)Converts a Java String array to a trait string array with the format:
"str1, str2, .., strN"
return toStringTrait(array, ",");
|
protected java.lang.String | toStringTrait(java.lang.String[] array, java.lang.String sep)Converts a Java String array to a trait string array with the format:
"str1, str2, .., strN"
if (array == null || array.length < 1) {
return "";
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length - 1; i++) {
sb.append(array[i]);
sb.append(sep);
}
sb.append(array[array.length - 1]);
return sb.toString();
|
protected java.lang.String | toStringTrait(float[] array)Helper method. Converts the input array value to a string trait value.
return toStringTrait(array, ',");
|
protected java.lang.String | toStringTrait(float[] array, char sep)Helper method. Converts the input array value to a string trait value.
if (array == null) {
return SVGConstants.CSS_NONE_VALUE;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length - 1; i++) {
sb.append(array[i]);
sb.append(sep);
}
sb.append(array[array.length - 1]);
return sb.toString();
|
protected java.lang.String | toStringTrait(float[][] array)Helper method. Convertst the input array of float arrays into a
string trait value.
if (array == null || array.length == 0) {
return "";
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length - 1; j++) {
sb.append(array[i][j]);
sb.append(SVGConstants.COMMA);
}
sb.append(array[i][array[i].length - 1]);
sb.append(SVGConstants.SEMI_COLON);
}
String value = sb.toString();
// Trim trailing ';'
return value.substring(0, value.length() - 1);
|
protected static java.lang.String | toStringTrait(com.sun.perseus.j2d.Transform transform)Helper method. Converts the input Transform
to a string trait value.
if (transform == null) {
return Transformable.IDENTITY_TRANSFORM_TRAIT;
} else {
StringBuffer sb = new StringBuffer();
sb.append("matrix(");
sb.append(transform.getComponent(0));
sb.append(",");
sb.append(transform.getComponent(1));
sb.append(",");
sb.append(transform.getComponent(2));
sb.append(",");
sb.append(transform.getComponent(3));
sb.append(",");
sb.append(transform.getComponent(4));
sb.append(",");
sb.append(transform.getComponent(5));
sb.append(")");
return sb.toString();
}
|
java.lang.String | toStringTrait(java.lang.String traitName, float[][] value)Converts the input float array value to a String value.
throw new Error(traitName);
|
protected java.lang.String | toStringTraitQuote(java.lang.String[] array)Converts a Java String array to a trait string array with the format:
"str1, str2, .., strN". In addition, the string values are put inside
single quotes if there are spaces in the string values. This is needed
for values such as the CSS 2 font-family attribute.
if (array == null || array.length < 1) {
return "";
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length - 1; i++) {
if (array[i].indexOf(' ") != -1) {
sb.append('\'");
sb.append(array[i]);
sb.append('\'");
} else {
sb.append(array[i]);
}
sb.append(',");
}
if (array[array.length - 1].indexOf(' ") != -1) {
sb.append('\'");
sb.append(array[array.length - 1]);
sb.append('\'");
} else {
sb.append(array[array.length - 1]);
}
return sb.toString();
|
float[] | toTraitFloatArray(float[][] value)Converts an animated float array to a trait float array value.
This is used for multi-component trait values, such as
stroke-dasharray, or the text's x, y or rotate values.
float[] v = new float[value.length];
for (int i = 0; i < v.length; i++) {
v[i] = value[i][0];
}
return v;
|
protected float[][] | toViewBox(java.lang.String name, java.lang.String value)Converts an comma seperated list of floats to a viewBox array
if (value == null) {
throw illegalTraitValue(name, value);
}
try {
return ownerDocument.viewBoxParser.parseViewBox(value);
} catch (IllegalArgumentException iae) {
throw illegalTraitValue(name, value);
}
|
protected void | unhookChildrenQuiet()Utility method. Unhooks the children.
super.unhookChildrenQuiet();
// Need to clear the expanded content on proxies
ElementNodeProxy proxy = firstProxy;
while (proxy != null) {
proxy.unhookExpandedQuiet();
proxy = proxy.nextProxy;
}
|
protected void | unhookExpandedQuiet()Utility method. Unhooks the expanded content.
// No expanded content by default.
|
protected java.lang.String | unicodeRangeToStringTrait(int[][] u)Helper method. Converts the input unicode range into a String
trait, with the following syntax:
"U+b1-e1,U+b2-e2,...,U+bn-en"
if (u == null) {
return null;
}
if (u.length == 0) {
return SVGConstants.EMPTY;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < u.length - 1; i++) {
if (u[i] == null || u[i].length != 2) {
throw new IllegalArgumentException();
}
sb.append("U+");
sb.append(Integer.toHexString(u[i][0]));
sb.append('-");
sb.append(Integer.toHexString(u[i][1]));
sb.append(',");
}
if (u[u.length - 1] == null || u[u.length - 1].length != 2) {
throw new IllegalArgumentException();
}
sb.append("U+");
sb.append(Integer.toHexString(u[u.length - 1][0]));
sb.append('-");
sb.append(Integer.toHexString(u[u.length - 1][1]));
return sb.toString();
|
protected org.w3c.dom.DOMException | unsupportedTrait(java.lang.String name)
return new DOMException(DOMException.NOT_SUPPORTED_ERR,
Messages.formatMessage
(Messages.ERROR_UNSUPPORTED_TRAIT,
new String[] {name,
null,
getLocalName(),
getNamespaceURI()}));
|
protected org.w3c.dom.DOMException | unsupportedTraitNS(java.lang.String name, java.lang.String namespaceURI)
return new DOMException(DOMException.NOT_SUPPORTED_ERR,
Messages.formatMessage
(Messages.ERROR_UNSUPPORTED_TRAIT,
new String[] {name,
namespaceURI,
getLocalName(),
getNamespaceURI()}));
|
protected org.w3c.dom.DOMException | unsupportedTraitType(java.lang.String name, java.lang.String type)
if (name == null) {
return unsupportedTrait(name);
}
return new DOMException(DOMException.TYPE_MISMATCH_ERR,
Messages.formatMessage
(Messages.ERROR_TRAIT_TYPE_MISMATCH,
new String[] {name,
type,
getLocalName(),
getNamespaceURI()}));
|
protected org.w3c.dom.DOMException | unsupportedTraitTypeNS(java.lang.String name, java.lang.String namespaceURI, java.lang.String type)
return new DOMException(DOMException.TYPE_MISMATCH_ERR,
Messages.formatMessage
(Messages.ERROR_TRAIT_TYPE_NS_MISMATCH,
new String[] {name,
namespaceURI,
type,
getLocalName(),
getNamespaceURI()}));
|
float[][] | validateFloatArrayTrait(java.lang.String traitName, java.lang.String value, java.lang.String reqNamespaceURI, java.lang.String reqLocalName, java.lang.String reqTraitNamespace, java.lang.String reqTraitName)Validates the input trait value.
// Throw an error because this should _never_ happen, as a float
// array anim should only happen on a known trait. If validation is
// requested, the element implementation should know the trait.
throw new Error();
|
java.lang.String | validateTraitNS(java.lang.String namespaceURI, java.lang.String traitName, java.lang.String value, java.lang.String reqNamespaceURI, java.lang.String reqLocalName, java.lang.String reqTraitNamespace, java.lang.String reqTraitName)Validates the input trait value.
/*
throw new InternalError(
"Trying to validate unknown trait: " +
"namespaceURI : " + namespaceURI + "\n" +
"traitName : " + traitName + "\n" +
"value : " + value + "\n" +
"reqNamespaceURI : " + reqNamespaceURI + "\n" +
"reqLocalName : " + reqLocalName + "\n" +
"reqTraitNamespace : " + reqTraitNamespace + "\n" +
"reqTraitName : " + reqTraitName);
*/
return value;
|