Methods Summary |
---|
com.sun.perseus.j2d.Box | addBBox(com.sun.perseus.j2d.Box bbox, com.sun.perseus.j2d.Transform t)
ModelNode c = getFirstChildNode();
while (c != null) {
if (c.contributeBBox()) {
bbox = c.addBBox(bbox, c.appendTransform(t, null));
}
c = c.nextSibling;
}
return bbox;
|
ElementNodeProxy | buildProxy()
return new StructureNodeProxy(this);
|
int | computeFontWeight(int refPackedFontWeight, int relFontWeight)Handles the 'bolder' and 'lighter' values as follows:
- bolder computes to font-weight + 300. If the result
is more than 900, then the computed value is 900.
- lighter computes to font-weight - 300. If the result
is less than 100, then the comuted value is 100.
*NOTE*
This is not exactly implementing the CSS2 specification for bolder but
that part of the CSS 2 specification is known to be
underspecified. Handling of 'bolder' is being respecified for CSS
2.1. Furthermore, the CSS 2 specification does not address the needs for
SVG Fonts well. For example, if you have the following fonts in the font
data base:
font A: Arial, 100 to 500
font B: Arial, 600 to 900
element 1: font-family="Arial" font-weight="normal"
|
+ - element 2: font-family="Arial" font-weight="bolder"
font-weight for element 1 is 400. The font weight for element B should be
that of the font for which there is a next bolder weight. In our
example, it is font A which has font weight 500. However, it is not the
desired behavior in most cases.
Secondly, the SVG Font format allows non consecutive font-weight values
in the element. For example:
font C: Arial, 100,900
font D: Arial, 200,400
While this does not make a lot of sense, it is possible to specify such
fonts and it is unclear what the behavior of bolder should be in that
case. It seems that taking the matching font which has the most distance
from the current font-weight could work, but that would be limiting
'bolder' to a one step change....
The approach taken in the Perseus implementation is such that bolder will
work for common cases with common Font specifications.
// Handle bolder and lighter
if (relFontWeight == FONT_WEIGHT_BOLDER) {
setMarker(FONT_WEIGHT_BOLDER_MARKER);
clearMarker(FONT_WEIGHT_LIGHTER_MARKER);
switch (refPackedFontWeight) {
case FONT_WEIGHT_100_IMPL:
return FONT_WEIGHT_400_IMPL;
case FONT_WEIGHT_200_IMPL:
return FONT_WEIGHT_500_IMPL;
case FONT_WEIGHT_300_IMPL:
return FONT_WEIGHT_600_IMPL;
case FONT_WEIGHT_400_IMPL:
return FONT_WEIGHT_700_IMPL;
case FONT_WEIGHT_500_IMPL:
return FONT_WEIGHT_800_IMPL;
case FONT_WEIGHT_600_IMPL:
case FONT_WEIGHT_700_IMPL:
case FONT_WEIGHT_800_IMPL:
case FONT_WEIGHT_900_IMPL:
default:
return FONT_WEIGHT_900_IMPL;
}
} else if (relFontWeight == FONT_WEIGHT_LIGHTER) {
setMarker(FONT_WEIGHT_LIGHTER_MARKER);
clearMarker(FONT_WEIGHT_BOLDER_MARKER);
switch (refPackedFontWeight) {
default:
case FONT_WEIGHT_100_IMPL:
case FONT_WEIGHT_200_IMPL:
case FONT_WEIGHT_300_IMPL:
case FONT_WEIGHT_400_IMPL:
return FONT_WEIGHT_100_IMPL;
case FONT_WEIGHT_500_IMPL:
return FONT_WEIGHT_200_IMPL;
case FONT_WEIGHT_600_IMPL:
return FONT_WEIGHT_300_IMPL;
case FONT_WEIGHT_700_IMPL:
return FONT_WEIGHT_400_IMPL;
case FONT_WEIGHT_800_IMPL:
return FONT_WEIGHT_500_IMPL;
case FONT_WEIGHT_900_IMPL:
return FONT_WEIGHT_600_IMPL;
}
}
clearMarker(FONT_WEIGHT_BOLDER_MARKER);
clearMarker(FONT_WEIGHT_LIGHTER_MARKER);
switch (relFontWeight) {
default:
case FONT_WEIGHT_100:
return FONT_WEIGHT_100_IMPL;
case FONT_WEIGHT_200:
return FONT_WEIGHT_200_IMPL;
case FONT_WEIGHT_300:
return FONT_WEIGHT_300_IMPL;
case FONT_WEIGHT_400:
return FONT_WEIGHT_400_IMPL;
case FONT_WEIGHT_500:
return FONT_WEIGHT_500_IMPL;
case FONT_WEIGHT_600:
return FONT_WEIGHT_600_IMPL;
case FONT_WEIGHT_700:
return FONT_WEIGHT_700_IMPL;
case FONT_WEIGHT_800:
return FONT_WEIGHT_800_IMPL;
case FONT_WEIGHT_900:
return FONT_WEIGHT_900_IMPL;
}
|
TraitAnim | createTraitAnimImpl(java.lang.String traitName)
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == traitName) {
return new FloatTraitAnim(this, traitName, TRAIT_TYPE_FLOAT);
} else if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == traitName
||
SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == traitName) {
return new StringTraitAnim(this, NULL_NS, traitName);
} else {
return super.createTraitAnimImpl(traitName);
}
|
java.lang.String | fontStyleToStringTrait(int fontStyle)Converts the input font-style value to a string trait value.
switch (fontStyle) {
case StructureNode.FONT_STYLE_NORMAL_IMPL:
return SVGConstants.CSS_NORMAL_VALUE;
case StructureNode.FONT_STYLE_OBLIQUE_IMPL:
return SVGConstants.CSS_OBLIQUE_VALUE;
case StructureNode.FONT_STYLE_ITALIC_IMPL:
default:
return SVGConstants.CSS_ITALIC_VALUE;
}
|
java.lang.String | fontWeightToStringTrait(int fontWeight)Converts the input font-style value to a string trait value.
switch (fontWeight) {
case StructureNode.FONT_WEIGHT_100_IMPL:
return SVGConstants.CSS_100_VALUE;
case StructureNode.FONT_WEIGHT_200_IMPL:
return SVGConstants.CSS_200_VALUE;
case StructureNode.FONT_WEIGHT_300_IMPL:
return SVGConstants.CSS_300_VALUE;
case StructureNode.FONT_WEIGHT_400_IMPL:
return SVGConstants.CSS_400_VALUE;
case StructureNode.FONT_WEIGHT_500_IMPL:
return SVGConstants.CSS_500_VALUE;
case StructureNode.FONT_WEIGHT_600_IMPL:
return SVGConstants.CSS_600_VALUE;
case StructureNode.FONT_WEIGHT_700_IMPL:
return SVGConstants.CSS_700_VALUE;
case StructureNode.FONT_WEIGHT_800_IMPL:
return SVGConstants.CSS_800_VALUE;
case StructureNode.FONT_WEIGHT_900_IMPL:
default:
return SVGConstants.CSS_900_VALUE;
}
|
public org.w3c.dom.svg.SVGRect | getBBox()
return addBBox(null, null);
|
public static void | getFittingTransform(float ix, float iy, float iw, float ih, float ox, float oy, float ow, float oh, int align, com.sun.perseus.j2d.Transform result)Utility method: computes the transform needed to fit the input
box into the given output box for the given input alignment
property.
float inAR = iw / ih;
float outAR = ow / oh;
// Move to output box location (ox,oy)
result.mTranslate(ox, oy);
if (align == ALIGN_NONE) {
// Scale without preserving aspect ratio
result.mScale(ow / iw, oh / ih);
// Move to (0,0)
result.mTranslate(-ix, -iy);
} else if (inAR < outAR) {
float sf = oh / ih;
result.mScale(sf);
result.mTranslate(-ix - (iw - ow * ih / oh) / 2, -iy);
} else {
float sf = ow / iw;
result.mScale(sf);
result.mTranslate(-ix, -iy - (ih - oh * iw / ow) / 2);
}
|
protected float | getFloatPropertyState(int propertyIndex)Returns the value for the given float property.
switch (propertyIndex) {
case PROPERTY_FONT_SIZE:
return fontSize;
default:
return super.getFloatPropertyState(propertyIndex);
}
|
float | getFloatTraitImpl(java.lang.String name)Supported float traits: font-size
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
return getFontSize();
} else {
return super.getFloatTraitImpl(name);
}
|
public java.lang.String[] | getFontFamily()
return fontFamily;
|
public float | getFontSize()
return fontSize;
|
public int | getFontStyle()
switch (pack & FONT_STYLE_MASK) {
case FONT_STYLE_NORMAL_IMPL:
return FONT_STYLE_NORMAL;
case FONT_STYLE_ITALIC_IMPL:
return FONT_STYLE_ITALIC;
default:
return FONT_STYLE_OBLIQUE;
}
|
public int | getFontWeight()
switch (pack & FONT_WEIGHT_MASK) {
case FONT_WEIGHT_100_IMPL:
return FONT_WEIGHT_100;
case FONT_WEIGHT_200_IMPL:
return FONT_WEIGHT_200;
case FONT_WEIGHT_300_IMPL:
return FONT_WEIGHT_300;
case FONT_WEIGHT_400_IMPL:
return FONT_WEIGHT_400;
case FONT_WEIGHT_500_IMPL:
return FONT_WEIGHT_500;
case FONT_WEIGHT_600_IMPL:
return FONT_WEIGHT_600;
case FONT_WEIGHT_700_IMPL:
return FONT_WEIGHT_700;
case FONT_WEIGHT_800_IMPL:
return FONT_WEIGHT_800;
case FONT_WEIGHT_900_IMPL:
return FONT_WEIGHT_900;
case FONT_WEIGHT_LIGHTER_IMPL:
return FONT_WEIGHT_LIGHTER;
default:
return FONT_WEIGHT_BOLDER;
}
|
public int | getNumberOfProperties()
return GraphicsNode.NUMBER_OF_PROPERTIES
+ TextNode.NUMBER_OF_PROPERTIES;
|
protected int | getPackedPropertyState(int propertyIndex)Returns the value for the given packed property.
switch (propertyIndex) {
case TextNode.PROPERTY_FONT_STYLE:
return pack & StructureNode.FONT_STYLE_MASK;
case TextNode.PROPERTY_FONT_WEIGHT:
return pack & StructureNode.FONT_WEIGHT_MASK;
case TextNode.PROPERTY_TEXT_ANCHOR:
return pack & StructureNode.TEXT_ANCHOR_MASK;
default:
return super.getPackedPropertyState(propertyIndex);
}
|
protected java.lang.Object | getPropertyState(int propertyIndex)Returns the value for the given property.
switch (propertyIndex) {
case PROPERTY_FONT_FAMILY:
return fontFamily;
default:
return super.getPropertyState(propertyIndex);
}
|
public org.w3c.dom.svg.SVGRect | getScreenBBox()
// There is no screen bounding box if the element is not hooked
// into the main tree.
if (!inDocumentTree()) {
return null;
}
return addBBox(null, txf);
|
java.lang.String | getSpecifiedTraitImpl(java.lang.String name)Supported traits: font-family, font-size, font-style, font-weight,
text-anchor.
if ((SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == name
&&
isInherited(PROPERTY_FONT_FAMILY))
||
(SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name
&&
isInherited(PROPERTY_FONT_SIZE))
||
(SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == name
&&
isInherited(PROPERTY_FONT_STYLE))
||
(SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == name
&&
isInherited(PROPERTY_FONT_WEIGHT))
||
(SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == name
&&
isInherited(PROPERTY_TEXT_ANCHOR))) {
return SVGConstants.CSS_INHERIT_VALUE;
} else {
return super.getSpecifiedTraitImpl(name);
}
|
public int | getTextAnchor()
switch (pack & TEXT_ANCHOR_MASK) {
case TEXT_ANCHOR_START_IMPL:
return TEXT_ANCHOR_START;
case TEXT_ANCHOR_MIDDLE_IMPL:
return TEXT_ANCHOR_MIDDLE;
default:
return TEXT_ANCHOR_END;
}
|
public java.lang.String | getTraitImpl(java.lang.String name)Supported traits: font-family, font-size, font-style, font-weight,
text-anchor.
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == name) {
return toStringTraitQuote(getFontFamily());
} else if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
return Float.toString(getFontSize());
} else if (SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == name) {
return fontStyleToStringTrait(pack & FONT_STYLE_MASK);
} else if (SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == name) {
return fontWeightToStringTrait(pack & FONT_WEIGHT_MASK);
} else if (SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == name) {
return textAnchorToStringTrait(pack & TEXT_ANCHOR_MASK);
} else {
return super.getTraitImpl(name);
}
|
protected boolean | isFloatPropertyState(int propertyIndex, float propertyValue)Checks the state of the float property value.
switch (propertyIndex) {
case TextNode.PROPERTY_FONT_SIZE:
return fontSize == propertyValue;
default:
return super.isFloatPropertyState(propertyIndex, propertyValue);
}
|
protected boolean | isPackedPropertyState(int propertyIndex, int propertyValue)Checks the state of the property value.
switch (propertyIndex) {
case TextNode.PROPERTY_FONT_STYLE:
return (propertyValue
==
(pack & StructureNode.FONT_STYLE_MASK));
case TextNode.PROPERTY_FONT_WEIGHT:
return (propertyValue
==
(pack & StructureNode.FONT_WEIGHT_MASK));
case TextNode.PROPERTY_TEXT_ANCHOR:
return (propertyValue
==
(pack & StructureNode.TEXT_ANCHOR_MASK));
default:
return super.isPackedPropertyState(propertyIndex, propertyValue);
}
|
protected boolean | isPropertyState(int propertyIndex, java.lang.Object propertyValue)Checks the state of the property value.
switch (propertyIndex) {
case TextNode.PROPERTY_FONT_FAMILY:
return fontFamily == propertyValue;
default:
return super.isPropertyState(propertyIndex, propertyValue);
}
|
public ModelNode | nodeHitAt(float[] pt)Returns the ModelNode , if any, hit by the
point at coordinate x/y.
// If a node does not render, it is never hit
if (canRenderState != 0) {
return null;
}
// Check for a hit on children
return nodeHitAt(getLastChildNode(), pt);
|
public void | paint(com.sun.perseus.j2d.RenderGraphics rg)Paints this node into the input RenderGraphics . By default,
a StructureNode only renders its regular (DOM) children and
it does not perform any rendering itself.
if (canRenderState != 0) {
return;
}
paint(getFirstChildNode(), rg);
|
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.
// If a node does not render, it is never hit
if (canRenderState != 0) {
return null;
}
// Check for a hit on expanded children
return nodeHitAt(proxy.getLastExpandedChild(), pt);
|
void | recomputeInheritedProperties()Recomputes all inherited properties.
super.recomputeInheritedProperties();
ModelNode p = ownerDocument;
if (parent != null) {
p = parent;
}
recomputePropertyState(PROPERTY_FONT_FAMILY,
p.getPropertyState(PROPERTY_FONT_FAMILY));
recomputeFloatPropertyState(PROPERTY_FONT_SIZE,
p.getFloatPropertyState(PROPERTY_FONT_SIZE));
recomputePackedPropertyState(PROPERTY_FONT_STYLE,
p.getPackedPropertyState(PROPERTY_FONT_STYLE));
recomputePackedPropertyState(PROPERTY_FONT_WEIGHT,
p.getPackedPropertyState(PROPERTY_FONT_WEIGHT));
recomputePackedPropertyState(PROPERTY_TEXT_ANCHOR,
p.getPackedPropertyState(PROPERTY_TEXT_ANCHOR));
|
protected void | recomputePackedPropertyState(int propertyIndex, int parentPropertyValue)Recomputes the given packed property's state given the new parent
property.
if (propertyIndex != PROPERTY_FONT_WEIGHT) {
super.recomputePackedPropertyState(propertyIndex,
parentPropertyValue);
} else {
// We do not need to recompute the fontWeight value if:
// - the fontWeight is _not_ inherited & not relative (i.e. lighter
// or bolder)
// or
// - the property is inherited but the new parent property computed
// value is the same as the current value & the bolder and lighter
// markes are in the same state
boolean isBolder = isMarkerSet(FONT_WEIGHT_BOLDER_MARKER);
boolean isLighter = isMarkerSet(FONT_WEIGHT_LIGHTER_MARKER);
if ((!isInherited(propertyIndex)
&&
!isBolder
&&
!isLighter)
||
isPackedPropertyState(propertyIndex, parentPropertyValue)) {
return;
}
int packedFontWeight = parentPropertyValue;
if (isBolder) {
packedFontWeight = computeFontWeight(parentPropertyValue,
FONT_WEIGHT_BOLDER);
} else if (isLighter) {
packedFontWeight = computeFontWeight(parentPropertyValue,
FONT_WEIGHT_LIGHTER);
}
setPackedPropertyState(propertyIndex, packedFontWeight);
propagatePackedPropertyState(propertyIndex, parentPropertyValue);
}
|
void | setComputedFontFamily(java.lang.String[] newFontFamily)
this.fontFamily = newFontFamily;
|
void | setComputedFontSize(float newFontSize)
this.fontSize = newFontSize;
|
void | setComputedFontStyle(int newFontStyle)
pack &= ~FONT_STYLE_MASK;
switch (newFontStyle) {
case FONT_STYLE_NORMAL:
pack |= FONT_STYLE_NORMAL_IMPL;
break;
case FONT_STYLE_ITALIC:
pack |= FONT_STYLE_ITALIC_IMPL;
break;
default:
pack |= FONT_STYLE_OBLIQUE_IMPL;
break;
}
|
void | setComputedFontWeight(int newFontWeight)
pack &= ~FONT_WEIGHT_MASK;
pack |= newFontWeight;
|
void | setComputedTextAnchor(int newTextAnchor)Sets the value of the computed text anchor property.
pack &= ~TEXT_ANCHOR_MASK;
switch (newTextAnchor) {
case TEXT_ANCHOR_START:
pack |= TEXT_ANCHOR_START_IMPL;
break;
case TEXT_ANCHOR_MIDDLE:
pack |= TEXT_ANCHOR_MIDDLE_IMPL;
break;
default:
pack |= TEXT_ANCHOR_END_IMPL;
break;
}
|
void | setFloatArrayTrait(java.lang.String name, float[][] value)Set the trait value as float.
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
checkPositive(name, value[0][0]);
setFontSize(value[0][0]);
} else {
super.setFloatArrayTrait(name, value);
}
|
protected void | setFloatPropertyState(int propertyIndex, float propertyValue)Sets the computed value for the given float property.
switch (propertyIndex) {
case PROPERTY_FONT_SIZE:
setComputedFontSize(propertyValue);
break;
default:
super.setFloatPropertyState(propertyIndex, propertyValue);
}
|
public void | setFloatTraitImpl(java.lang.String name, float value)Set the trait value as float.
Supported float traits: font-size.
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
checkPositive(name, value);
setFontSize(value);
} else {
super.setFloatTraitImpl(name, value);
}
|
public void | setFontFamily(java.lang.String[] newFontFamily)
if (!isInherited(PROPERTY_FONT_FAMILY)
&& equal(newFontFamily, fontFamily)) {
return;
}
modifyingNode();
setInheritedQuiet(PROPERTY_FONT_FAMILY, false);
setComputedFontFamily(newFontFamily);
propagatePropertyState(PROPERTY_FONT_FAMILY, newFontFamily);
modifiedNode();
|
public void | setFontSize(float newFontSize)
if (newFontSize < 0) {
throw new IllegalArgumentException();
}
if (!isInherited(PROPERTY_FONT_SIZE) && newFontSize == fontSize) {
return;
}
modifyingNode();
setInheritedQuiet(PROPERTY_FONT_SIZE, false);
setComputedFontSize(newFontSize);
propagateFloatPropertyState(PROPERTY_FONT_SIZE, newFontSize);
modifiedNode();
|
public void | setFontStyle(int newFontStyle)
if (!isInherited(PROPERTY_FONT_STYLE)
&& newFontStyle == getFontStyle()) {
return;
}
modifyingNode();
setInheritedQuiet(PROPERTY_FONT_STYLE, false);
setComputedFontStyle(newFontStyle);
propagatePackedPropertyState(PROPERTY_FONT_STYLE,
pack & FONT_STYLE_MASK);
modifiedNode();
|
public void | setFontWeight(int newFontWeight)
if (!isInherited(PROPERTY_FONT_WEIGHT)
&& newFontWeight == getFontWeight()) {
return;
}
modifyingNode();
setInheritedQuiet(PROPERTY_FONT_WEIGHT, false);
// Font weight is special: we need to account for relative values
// bolder and lighter.
int packedParentFontWeight
= getInheritedPackedPropertyState(PROPERTY_FONT_WEIGHT);
setComputedFontWeight
(computeFontWeight(packedParentFontWeight, newFontWeight));
propagatePackedPropertyState
(PROPERTY_FONT_WEIGHT, pack & FONT_WEIGHT_MASK);
modifiedNode();
|
protected void | setPackedPropertyState(int propertyIndex, int propertyValue)Sets the computed value for the given packed property.
switch (propertyIndex) {
case PROPERTY_FONT_STYLE:
switch (propertyValue) {
case FONT_STYLE_NORMAL_IMPL:
setComputedFontStyle(FONT_STYLE_NORMAL);
break;
case FONT_STYLE_ITALIC_IMPL:
setComputedFontStyle(FONT_STYLE_ITALIC);
break;
case FONT_STYLE_OBLIQUE_IMPL:
default:
setComputedFontStyle(FONT_STYLE_OBLIQUE);
break;
}
break;
case PROPERTY_FONT_WEIGHT:
setComputedFontWeight(propertyValue);
break;
case PROPERTY_TEXT_ANCHOR:
switch (propertyValue) {
case TEXT_ANCHOR_START_IMPL:
setComputedTextAnchor(TEXT_ANCHOR_START);
break;
case TEXT_ANCHOR_MIDDLE_IMPL:
setComputedTextAnchor(TEXT_ANCHOR_MIDDLE);
break;
case TEXT_ANCHOR_END_IMPL:
default:
setComputedTextAnchor(TEXT_ANCHOR_END);
break;
}
break;
default:
super.setPackedPropertyState(propertyIndex, propertyValue);
}
|
protected void | setPropertyState(int propertyIndex, java.lang.Object propertyValue)Sets the computed value for the given property.
switch (propertyIndex) {
case PROPERTY_FONT_FAMILY:
setComputedFontFamily((String[]) propertyValue);
break;
default:
super.setPropertyState(propertyIndex, propertyValue);
}
|
public void | setTextAnchor(int newTextAnchor)
if (!isInherited(PROPERTY_TEXT_ANCHOR)
&& newTextAnchor == getTextAnchor()) {
return;
}
modifyingNode();
setComputedTextAnchor(newTextAnchor);
setInheritedQuiet(PROPERTY_TEXT_ANCHOR, false);
propagatePackedPropertyState(PROPERTY_TEXT_ANCHOR,
pack & TEXT_ANCHOR_MASK);
modifiedNode();
|
public void | setTraitImpl(java.lang.String name, java.lang.String value)Supported traits: font-family, font-size, font-style, font-weight,
text-anchor.
Supported traits: stroke-width, stroke-miterlimit, stroke-dashoffset,
fill-rule, stroke-linejoin, stroke-linecap, display, visibility,
color, fill, stroke, fill-opacity, stroke-opacity, stroke-dasharray
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == name) {
// ======================= font-family ====================== //
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
setInherited(PROPERTY_FONT_FAMILY, true);
} else {
setFontFamily(parseFontFamilyTrait(name, value));
}
} else if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
// ======================= font-size ======================== //
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
setFloatInherited(PROPERTY_FONT_SIZE, true);
} else {
setFontSize(parsePositiveFloatTrait(name, value));
}
} else if (SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == name) {
// ======================= font-style ======================= //
if (SVGConstants.CSS_NORMAL_VALUE.equals(value)) {
setFontStyle(TextProperties.FONT_STYLE_NORMAL);
} else if (SVGConstants.CSS_ITALIC_VALUE.equals(value)) {
setFontStyle(TextProperties.FONT_STYLE_ITALIC);
} else if (SVGConstants.CSS_OBLIQUE_VALUE.equals(value)) {
setFontStyle(TextProperties.FONT_STYLE_OBLIQUE);
} else if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
setPackedInherited(PROPERTY_FONT_STYLE, true);
} else {
throw illegalTraitValue(name, value);
}
} else if (SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == name) {
// ======================= font-weight ======================= //
if (SVGConstants.CSS_100_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_100);
} else if (SVGConstants.CSS_200_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_200);
} else if (SVGConstants.CSS_300_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_300);
} else if (SVGConstants.CSS_400_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_400);
} else if (SVGConstants.CSS_NORMAL_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_NORMAL);
} else if (SVGConstants.CSS_500_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_500);
} else if (SVGConstants.CSS_600_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_600);
} else if (SVGConstants.CSS_700_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_700);
} else if (SVGConstants.CSS_BOLD_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_BOLD);
} else if (SVGConstants.CSS_800_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_800);
} else if (SVGConstants.CSS_900_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_900);
} else if (SVGConstants.CSS_BOLDER_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_BOLDER);
} else if (SVGConstants.CSS_LIGHTER_VALUE.equals(value)) {
setFontWeight(TextNode.FONT_WEIGHT_LIGHTER);
} else if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
setPackedInherited(PROPERTY_FONT_WEIGHT, true);
clearMarker(FONT_WEIGHT_BOLDER_MARKER);
clearMarker(FONT_WEIGHT_LIGHTER_MARKER);
} else {
throw illegalTraitValue(name, value);
}
} else if (SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == name) {
// ======================= text-anchor ====================== //
if (SVGConstants.CSS_START_VALUE.equals(value)) {
setTextAnchor(TextProperties.TEXT_ANCHOR_START);
} else if (SVGConstants.CSS_MIDDLE_VALUE.equals(value)) {
setTextAnchor(TextProperties.TEXT_ANCHOR_MIDDLE);
} else if (SVGConstants.CSS_END_VALUE.equals(value)) {
setTextAnchor(TextProperties.TEXT_ANCHOR_END);
} else if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
setPackedInherited(PROPERTY_TEXT_ANCHOR, true);
} else {
throw illegalTraitValue(name, value);
}
} else {
super.setTraitImpl(name, value);
}
|
boolean | supportsTrait(java.lang.String traitName)Supported traits: font-family, font-size, font-style, font-weight,
text-anchor.
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == traitName
||
SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == traitName
||
SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == traitName) {
return true;
} else {
return super.supportsTrait(traitName);
}
|
java.lang.String | textAnchorToStringTrait(int textAnchor)Converts the input text-anchor value to a string trait value.
switch (textAnchor) {
case StructureNode.TEXT_ANCHOR_START_IMPL:
return SVGConstants.CSS_START_VALUE;
case StructureNode.TEXT_ANCHOR_MIDDLE_IMPL:
return SVGConstants.CSS_MIDDLE_VALUE;
case StructureNode.TEXT_ANCHOR_END_IMPL:
return SVGConstants.CSS_END_VALUE;
default:
// Should _never_ happen.
throw new Error();
}
|
java.lang.String | toStringTrait(java.lang.String name, float[][] value)
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == name) {
return Float.toString(value[0][0]);
} else {
return super.toStringTrait(name, value);
}
|
public 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.
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == traitName) {
return new float[][] {{parsePositiveFloatTrait(traitName, value)}};
} else {
return super.validateFloatArrayTrait(traitName,
value,
reqNamespaceURI,
reqLocalName,
reqTraitNamespace,
reqTraitName);
}
|
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.
if (namespaceURI != null && namespaceURI != NULL_NS) {
return super.validateTraitNS(namespaceURI,
traitName,
value,
reqNamespaceURI,
reqLocalName,
reqTraitNamespace,
reqTraitName);
}
if (SVGConstants.SVG_FONT_SIZE_ATTRIBUTE == traitName) {
throw unsupportedTraitType(traitName, TRAIT_TYPE_FLOAT);
}
if (SVGConstants.SVG_FONT_FAMILY_ATTRIBUTE == traitName) {
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
return toStringTraitQuote
((String[])
getInheritedPropertyState(PROPERTY_FONT_FAMILY));
}
return value;
} else if (SVGConstants.SVG_FONT_STYLE_ATTRIBUTE == traitName) {
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
return fontStyleToStringTrait
(getInheritedPackedPropertyState(PROPERTY_FONT_STYLE));
} else if (!SVGConstants.CSS_NORMAL_VALUE.equals(value)
&&
!SVGConstants.CSS_ITALIC_VALUE.equals(value)
&&
!SVGConstants.CSS_OBLIQUE_VALUE.equals(value)) {
throw illegalTraitValue(traitName, value);
}
return value;
} else if (SVGConstants.SVG_FONT_WEIGHT_ATTRIBUTE == traitName) {
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
return fontWeightToStringTrait
(getInheritedPackedPropertyState(PROPERTY_FONT_WEIGHT));
} else if (SVGConstants.CSS_NORMAL_VALUE.equals(value)) {
return SVGConstants.CSS_400_VALUE;
} else if (SVGConstants.CSS_BOLD_VALUE.equals(value)) {
return SVGConstants.CSS_700_VALUE;
} else if (SVGConstants.CSS_BOLDER_VALUE.equals(value)) {
// We need to base on the parent's animated value.
int packedFontWeight =
getInheritedPackedPropertyState(PROPERTY_FONT_WEIGHT);
int fontWeight
= computeFontWeight(packedFontWeight, FONT_WEIGHT_BOLDER);
return fontWeightToStringTrait(fontWeight);
} else if (SVGConstants.CSS_LIGHTER_VALUE.equals(value)) {
// We need to base on the parent's animated value.
int packedFontWeight =
getInheritedPackedPropertyState(PROPERTY_FONT_WEIGHT);
int fontWeight =
computeFontWeight(packedFontWeight,
FONT_WEIGHT_LIGHTER);
return fontWeightToStringTrait(fontWeight);
} else if (!SVGConstants.CSS_100_VALUE.equals(value)
&&
!SVGConstants.CSS_200_VALUE.equals(value)
&&
!SVGConstants.CSS_300_VALUE.equals(value)
&&
!SVGConstants.CSS_400_VALUE.equals(value)
&&
!SVGConstants.CSS_NORMAL_VALUE.equals(value)
&&
!SVGConstants.CSS_500_VALUE.equals(value)
&&
!SVGConstants.CSS_600_VALUE.equals(value)
&&
!SVGConstants.CSS_700_VALUE.equals(value)
&&
!SVGConstants.CSS_800_VALUE.equals(value)
&&
!SVGConstants.CSS_900_VALUE.equals(value)) {
throw illegalTraitValue(traitName, value);
}
return value;
} else if (SVGConstants.SVG_TEXT_ANCHOR_ATTRIBUTE == traitName) {
if (SVGConstants.CSS_INHERIT_VALUE.equals(value)) {
return textAnchorToStringTrait
(getInheritedPackedPropertyState(PROPERTY_TEXT_ANCHOR));
}
if (!SVGConstants.CSS_START_VALUE.equals(value)
&&
!SVGConstants.CSS_MIDDLE_VALUE.equals(value)
&&
!SVGConstants.CSS_END_VALUE.equals(value)) {
throw illegalTraitValue(traitName, value);
}
return value;
}
return super.validateTraitNS(namespaceURI,
traitName,
value,
reqNamespaceURI,
reqLocalName,
reqTraitNamespace,
reqTraitName);
|