Fields Summary |
---|
public static final float | DEFAULT_HORIZONTAL_ADVANCE_XBy default, use the parent Font's advance |
protected com.sun.perseus.j2d.Path | dThe Path representing the outline of this glyph |
protected float | horizontalAdvanceXThis glyph's horizontal advance.
A negative value means that the parent Font value should be used |
protected float | computedHorizontalAdvanceXThe computed glyph's horizontal advance. If this glyphs
advance is set, then this is equal to the glyph's advance.
Otherwise, this is the grand-parent font's advance if there
is one. |
protected float | originThe computed glyph origin. |
protected float | emSquareScaleThe em square scale factor. |
protected String | unicodeThe unicode character, or sequence of unicode character, that
this glyph represents. If null, then this Glyph can be used to
represent missing glyphs for arbitrary unicode values. |
protected String[] | glyphNameSet of glyph names. May be null. |
protected String | localNameThis glyph's local name. |
Methods Summary |
---|
com.sun.perseus.j2d.Box | addNodeBBox(com.sun.perseus.j2d.Box bbox, com.sun.perseus.j2d.Transform t)
return addShapeBBox(bbox, d, t);
|
protected com.sun.perseus.j2d.Tile | addRenderingTile(com.sun.perseus.j2d.Tile tile, com.sun.perseus.j2d.TextRenderingProperties trp, com.sun.perseus.j2d.Transform t)
if (d != null) {
if (trp.getStroke() == null) {
// No stroking on the shape, we can use the geometrical bounding
// box.
Box renderingBox = addNodeBBox(null, t);
if (renderingBox != null) {
if (tile == null) {
tile = new Tile();
tile.snapBox(renderingBox);
} else {
tile.addSnapBox(renderingBox);
}
}
} else {
// Need to account for stroking, with a more costly operation
// to compute the stroked bounds.
Object strokedPath = PathSupport.getStrokedPath(d, trp);
if (tile == null) {
tile = new Tile();
PathSupport.computeStrokedPathTile(tile, strokedPath, t);
} else {
Tile st = new Tile();
PathSupport.computeStrokedPathTile(st, strokedPath, t);
tile.addTile(st);
}
}
}
return tile;
|
protected void | applyInverseTransform(com.sun.perseus.j2d.Transform tx)
tx.mTranslate(origin, 0);
tx.mScale(1 / emSquareScale, -1 / emSquareScale);
|
protected void | applyTransform(com.sun.perseus.j2d.Transform tx)
tx.mScale(emSquareScale, -emSquareScale);
tx.mTranslate(-origin, 0);
|
public int | getCharAt(int i)It is the responsibility of the caller to check that the
requested index is between the unicode's value index range
(i.e., between 0 and unicode.length())
return unicode.charAt(i);
|
public com.sun.perseus.j2d.Path | getD()
return d;
|
public java.lang.String[] | getGlyphName()Returns this glyph's name(s)
return glyphName;
|
public float | getHorizontalAdvanceX()
return computedHorizontalAdvanceX;
|
public int | getLength()
if (unicode == null) {
return 1;
}
return unicode.length();
|
public java.lang.String | getLocalName()
return localName;
|
public float | getTextHorizontalAdvanceX()
return computedHorizontalAdvanceX * emSquareScale;
|
public java.lang.String | getTraitImpl(java.lang.String name)Supported traits: d, horiz-adv-x
if (SVGConstants.SVG_D_ATTRIBUTE == name) {
if (d == null) {
return "";
} else {
return d.toString();
}
} else if (SVGConstants.SVG_HORIZ_ADV_X_ATTRIBUTE == name) {
return Float.toString(getHorizontalAdvanceX());
} else if (SVGConstants.SVG_UNICODE_ATTRIBUTE == name) {
if (unicode == null) {
return "";
}
return unicode;
} else if (SVGConstants.SVG_GLYPH_NAME_ATTRIBUTE == name) {
return toStringTrait(getGlyphName());
}
return super.getTraitImpl(name);
|
public java.lang.String | getUnicode()
return unicode;
|
public boolean | isHit(float[] pt, com.sun.perseus.j2d.TextRenderingProperties trp)A Glyph is hit if the Path it paints is
hit by the given point.
if (d == null) {
return false;
}
// If the node is filled, see if the shape is hit
if (trp.getFill() != null) {
if (PathSupport.isHit(d, trp.getFillRule(), pt[0], pt[1])) {
return true;
}
}
// Test detection on the edge if the stroke color
// is set.
if (trp.getStroke() != null) {
Object strokedPath = PathSupport.getStrokedPath(d, trp);
if (PathSupport.isStrokedPathHit(strokedPath, trp.getFillRule(),
pt[0], pt[1])) {
return true;
}
}
return false;
|
public ElementNode | newInstance(DocumentNode doc)Used by DocumentNode to create a new instance from
a prototype Glyph .
return new Glyph(doc, localName);
|
public void | setD(com.sun.perseus.j2d.Path newD)
if (equal(newD, d)) {
return;
}
this.d = newD;
|
public void | setEmSquareScale(float newEmSquareScale)Sets the emSquareScale. See the Font's list method adding
children: when the FontFace is set, the Font sets the em square
transform on all its children. When a Glyph is
set, and if there is a FontFace already, the em square transform
is set as well.
if (newEmSquareScale == emSquareScale) {
return;
}
emSquareScale = newEmSquareScale;
|
public void | setGlyphName(java.lang.String[] glyphName)Sets this glyph's name(s). May be null.
if (equal(glyphName, this.glyphName)) {
return;
}
this.glyphName = glyphName;
|
public void | setHorizontalAdvanceX(float newHorizontalAdvanceX)Sets the horizontal advance along the x axis. This is
in the em square coordinate space.
if (newHorizontalAdvanceX == horizontalAdvanceX) {
return;
}
this.horizontalAdvanceX = newHorizontalAdvanceX;
if (newHorizontalAdvanceX == -1
&&
parent != null
&& parent instanceof Font) {
computedHorizontalAdvanceX
= ((Font) parent).getHorizontalAdvanceX();
origin = ((Font) parent).getHorizontalOriginX();
} else {
computedHorizontalAdvanceX = newHorizontalAdvanceX;
}
|
public void | setParent(ModelNode parent)Override set parent to capture the default advance
super.setParent(parent);
if (parent != null && parent instanceof Font) {
if (horizontalAdvanceX == -1) {
computedHorizontalAdvanceX
= ((Font) parent).getHorizontalAdvanceX();
}
origin = ((Font) parent).getHorizontalOriginX();
} else {
origin = 0;
}
|
public void | setTraitImpl(java.lang.String name, java.lang.String value)Supported traits: d, horiz-adv-x
if (SVGConstants.SVG_D_ATTRIBUTE == name) {
checkWriteLoading(name);
setD(parsePathTrait(name, value));
} else if (SVGConstants.SVG_HORIZ_ADV_X_ATTRIBUTE == name) {
checkWriteLoading(name);
setHorizontalAdvanceX(parsePositiveFloatTrait(name, value));
} else if (SVGConstants.SVG_UNICODE_ATTRIBUTE == name) {
checkWriteLoading(name);
if (value == null) {
throw illegalTraitValue(name, value);
}
setUnicode(value);
} else if (SVGConstants.SVG_GLYPH_NAME_ATTRIBUTE == name) {
checkWriteLoading(name);
setGlyphName(parseStringArrayTrait(name, value,
SVGConstants.COMMA_STR));
} else {
super.setTraitImpl(name, value);
}
|
public void | setUnicode(java.lang.String newUnicode)
if (equal(newUnicode, unicode)) {
return;
}
this.unicode = newUnicode;
|
boolean | supportsTrait(java.lang.String traitName)Supported traits: d, horiz-adv-x
if (SVGConstants.SVG_D_ATTRIBUTE == traitName
||
SVGConstants.SVG_HORIZ_ADV_X_ATTRIBUTE == traitName
||
SVGConstants.SVG_GLYPH_NAME_ATTRIBUTE == traitName
||
SVGConstants.SVG_UNICODE_ATTRIBUTE == traitName) {
return true;
}
return super.supportsTrait(traitName);
|
public java.lang.String | toString()
return "com.sun.perseus.model.Glyph[" + unicode + "]";
|