Methods Summary |
---|
private void | clearLayoutFlags(int clearFlags)Clear desired flags in layout flags describing the state.
layoutFlags &= ~clearFlags;
|
public boolean | equals(java.awt.font.GlyphVector glyphVector)Checks whether given GlyphVector equals to this GlyphVector.
if (glyphVector == this){
return true;
}
if (glyphVector != null) {
if (!(glyphVector.getFontRenderContext().equals(this.vectorFRC) &&
glyphVector.getFont().equals(this.font))){
return false;
}
try {
boolean eq = true;
for (int i = 0; i < getNumGlyphs(); i++) {
int idx = i*2;
eq = (((CommonGlyphVector)glyphVector).visualPositions[idx] == this.visualPositions[idx]) &&
(((CommonGlyphVector)glyphVector).visualPositions[idx+1] == this.visualPositions[idx+1]) &&
(glyphVector.getGlyphCharIndex(i) == this.getGlyphCharIndex(i));
if (eq){
AffineTransform trans = glyphVector.getGlyphTransform(i);
if (trans == null){
eq = (this.glsTransforms[i] == null);
}else{
eq = this.glsTransforms[i].equals(trans);
}
}
if (!eq){
return false;
}
}
return eq;
} catch (ClassCastException e) {
}
}
return false;
|
public char | getChar(int index)Returns char with the specified index.
return this.charVector[index];
|
public java.awt.Font | getFont()Returns the Font parameter of this GlyphVector
return this.font;
|
public java.awt.font.FontRenderContext | getFontRenderContext()Returns the FontRenderContext parameter of this GlyphVector.
return this.vectorFRC;
|
public char | getGlyphChar(int glyphIndex)Returns a character value of the specified glyph.
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IllegalArgumentException(Messages.getString("awt.43")); //$NON-NLS-1$
}
return this.charVector[glyphIndex];
|
public int | getGlyphCharIndex(int glyphIndex)Returns character index of the specified glyph.
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IllegalArgumentException(Messages.getString("awt.43")); //$NON-NLS-1$
}
if ((this.layoutFlags & Font.LAYOUT_RIGHT_TO_LEFT) != 0) {
return this.charVector.length - glyphIndex - 1;
}
return glyphIndex;
|
public int[] | getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns an array of numEntries character indices for the specified glyphs.
if ((beginGlyphIndex < 0) || (beginGlyphIndex >= this.getNumGlyphs())) {
// awt.44=beginGlyphIndex is out of vector's range
throw new IllegalArgumentException(Messages.getString("awt.44")); //$NON-NLS-1$
}
if ((numEntries < 0)
|| ((numEntries + beginGlyphIndex) > this.getNumGlyphs())) {
// awt.45=numEntries is out of vector's range
throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
}
if (codeReturn == null) {
codeReturn = new int[numEntries];
}
for (int i = 0; i < numEntries; i++) {
codeReturn[i] = this.getGlyphCharIndex(i + beginGlyphIndex);
}
return codeReturn;
|
public int | getGlyphCode(int glyphIndex)Returns glyph code of the specified glyph.
if (glyphIndex >= this.vector.length || glyphIndex < 0) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
return this.vector[glyphIndex].getGlyphCode();
|
public int[] | getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)Returns an array of glyphcodes for the specified glyphs.
if ((beginGlyphIndex < 0) || ((numEntries + beginGlyphIndex) > this.getNumGlyphs())) {
// awt.44=beginGlyphIndex is out of vector's range
throw new IndexOutOfBoundsException(Messages.getString("awt.44")); //$NON-NLS-1$
}
if (numEntries < 0) {
// awt.45=numEntries is out of vector's range
throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
}
if (codeReturn == null) {
codeReturn = new int[numEntries];
}
for (int i = beginGlyphIndex; i < beginGlyphIndex + numEntries; i++) {
codeReturn[i-beginGlyphIndex] = this.vector[i].getGlyphCode();
}
return codeReturn;
|
public java.awt.font.GlyphJustificationInfo | getGlyphJustificationInfo(int glyphIndex)Returns a justification information for the glyph with specified glyph
index.
// TODO : Find out the source of Justification info
if (true) {
throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
}
return null;
|
public java.awt.Shape | getGlyphLogicalBounds(int glyphIndex)Returns the logical bounds of the specified glyph within this CommonGlyphVector.
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())){
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
Glyph glyph = this.vector[glyphIndex];
float x0 = visualPositions[glyphIndex*2];
float y0 = visualPositions[glyphIndex*2+1];
float advanceX = glyph.getGlyphPointMetrics().getAdvanceX();
GeneralPath gp = new GeneralPath();
gp.moveTo(0, -ascent - leading);
gp.lineTo(advanceX ,-ascent - leading);
gp.lineTo(advanceX, descent);
gp.lineTo(0, descent);
gp.lineTo(0, -ascent - leading);
gp.closePath();
/* Applying GlyphVector font transform */
AffineTransform at = (AffineTransform)this.transform.clone();
/* Applying Glyph transform */
AffineTransform glyphTransform = getGlyphTransform(glyphIndex);
if (glyphTransform != null){
at.concatenate(glyphTransform);
}
/* Applying translation to actual visual bounds */
at.preConcatenate(AffineTransform.getTranslateInstance(x0, y0));
gp.transform(at);
return gp;
|
public java.awt.font.GlyphMetrics | getGlyphMetrics(int glyphIndex)Returns the metrics of the specified glyph.
if ((glyphIndex < 0) || ((glyphIndex) >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
// TODO: is there a sence in GlyphMetrics
// if certain glyph or Font has a transform??
return this.vector[glyphIndex].getGlyphMetrics();
|
public java.awt.Shape | getGlyphOutline(int glyphIndex)Returns a Shape that encloses specified glyph.
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
if (gvShapes[glyphIndex] == null) {
gvShapes[glyphIndex] = vector[glyphIndex].getShape();
}
GeneralPath gp = (GeneralPath)((GeneralPath)gvShapes[glyphIndex]).clone();
/* Applying GlyphVector font transform */
AffineTransform at = (AffineTransform)this.transform.clone();
/* Applying Glyph transform */
AffineTransform glyphAT = getGlyphTransform(glyphIndex);
if (glyphAT != null){
at.preConcatenate(glyphAT);
}
int idx = glyphIndex << 1;
gp.transform(at);
gp.transform(AffineTransform.getTranslateInstance(visualPositions[idx], visualPositions[idx+1]));
return gp;
|
public java.awt.Rectangle | getGlyphPixelBounds(int glyphIndex, java.awt.font.FontRenderContext frc, float x, float y)Returnes the pixel bounds of the specified glyph within GlyphVector
rendered at the specified x,y location.
// TODO : need to be implemented with FontRenderContext
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
int idx = glyphIndex << 1;
if (vector[glyphIndex].getWidth() == 0){
AffineTransform fontTransform = this.transform;
double xOffs = x + visualPositions[idx] + fontTransform.getTranslateX();
double yOffs = y + visualPositions[idx+1] + fontTransform.getTranslateY();
return new Rectangle((int)xOffs, (int)yOffs, 0, 0);
}
GeneralPath shape = (GeneralPath)this.getGlyphOutline(glyphIndex);
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
if (frc != null){
at.concatenate(frc.getTransform());
}
shape.transform(at);
Rectangle bounds = shape.getBounds();
return new Rectangle((int)bounds.getX(), (int)bounds.getY(),
(int)bounds.getWidth()-1, (int)bounds.getHeight()-1);
|
public java.awt.geom.Point2D | getGlyphPosition(int glyphIndex)Returns the position of the specified glyph relative to the origin of
this GlyphVector
if ((glyphIndex > vector.length) || (glyphIndex < 0)) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
int index = glyphIndex << 1;
Point2D pos = new Point2D.Float(visualPositions[index], visualPositions[index+1]);
// For last position we don't have to transform !!
if(glyphIndex==vector.length){
return pos;
}
AffineTransform at = getGlyphTransform(glyphIndex);
if ((at == null) || (at.isIdentity())){
return pos;
}
pos.setLocation(pos.getX() + at.getTranslateX(), pos.getY() + at.getTranslateY());
return pos;
|
public float[] | getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)Returns an array of numEntries glyphs positions from beginGlyphIndex
glyph in Glyph Vector.
int len = (this.getNumGlyphs()+1) << 1;
beginGlyphIndex *= 2;
numEntries *= 2;
if ((beginGlyphIndex < 0) || ((numEntries + beginGlyphIndex) > len)) {
// awt.44=beginGlyphIndex is out of vector's range
throw new IndexOutOfBoundsException(Messages.getString("awt.44")); //$NON-NLS-1$
}
if (numEntries < 0) {
// awt.45=numEntries is out of vector's range
throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
}
if (positionReturn == null) {
positionReturn = new float[numEntries];
}
System.arraycopy(visualPositions, beginGlyphIndex, positionReturn, 0, numEntries);
return positionReturn;
|
public java.awt.geom.AffineTransform | getGlyphTransform(int glyphIndex)Returns the affine transform of the specified glyph.
if ((glyphIndex >= this.vector.length) || (glyphIndex < 0)) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
return this.glsTransforms[glyphIndex];
|
public java.awt.Shape | getGlyphVisualBounds(int glyphIndex)Returns the visual bounds of the specified glyph.
if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
int idx = glyphIndex << 1;
AffineTransform fontTransform = this.transform;
double xOffs = fontTransform.getTranslateX();
double yOffs = fontTransform.getTranslateY();
if (vector[glyphIndex].getWidth() == 0){
return new Rectangle2D.Float((float)xOffs, (float)yOffs, 0, 0);
}
AffineTransform at = AffineTransform.getTranslateInstance(xOffs, yOffs);
AffineTransform glyphTransform = getGlyphTransform(glyphIndex);
if (transform.isIdentity() && ((glyphTransform == null) || glyphTransform.isIdentity())){
Rectangle2D blackBox = vector[glyphIndex].getGlyphMetrics().getBounds2D();
at.translate(visualPositions[idx], visualPositions[idx+1]);
return(at.createTransformedShape(blackBox));
}
GeneralPath shape = (GeneralPath)this.getGlyphOutline(glyphIndex);
shape.transform(at);
return shape.getBounds2D();
|
public int | getLayoutFlags()Returns flags describing the state of the GlyphVector.
return layoutFlags;
|
public java.awt.geom.Rectangle2D | getLogicalBounds()Returns the logical bounds of this GlyphVector
// XXX: for transforms where an angle between basis vectors is not 90 degrees
// Rectanlge2D class doesn't fit as Logical bounds. For this reason we use
// only non-transformed bounds!!
float x = visualPositions[0];
float width = visualPositions[visualPositions.length-2];
double scaleY = transform.getScaleY();
Rectangle2D bounds = new Rectangle2D.Float(x, (float)((-this.ascent-this.leading)*scaleY), width, (float)(this.height*scaleY));
return bounds;
|
public int | getNumGlyphs()Returns the number of glyphs in this Glyph Vector
return vector.length;
|
public java.awt.Shape | getOutline(float x, float y)Returns a Shape that is the outline representation of this GlyphVector
rendered at the specified x,y coordinates.
GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
for (int i = 0; i < this.vector.length; i++) {
GeneralPath outline = (GeneralPath)getGlyphOutline(i);
/* Applying translation to actual visual bounds */
outline.transform(AffineTransform.getTranslateInstance(x, y));
gp.append(outline, false);
}
return gp;
|
public java.awt.Shape | getOutline()Returns a Shape that is the outline representation of this GlyphVector.
return this.getOutline(0, 0);
|
public java.awt.Rectangle | getPixelBounds(java.awt.font.FontRenderContext frc, float x, float y)Returnes the pixel bounds of this GlyphVector rendered at the
specified x,y location with the given FontRenderContext.
double xM, yM, xm, ym;
double minX = 0;
double minY = 0;
double maxX = 0;
double maxY = 0;
for (int i = 0; i < this.getNumGlyphs(); i++) {
Rectangle glyphBounds = this.getGlyphPixelBounds(i, frc, 0, 0);
xm = glyphBounds.getMinX();
ym = glyphBounds.getMinY();
xM = glyphBounds.getMaxX();
yM = glyphBounds.getMaxY();
if (i == 0) {
minX = xm;
minY = ym;
maxX = xM;
maxY = yM;
}
if (minX > xm) {
minX = xm;
}
if (minY > ym) {
minY = ym;
}
if (maxX < xM) {
maxX = xM;
}
if (maxY < yM) {
maxY = yM;
}
}
return new Rectangle((int)(minX + x), (int)(minY + y), (int)(maxX - minX), (int)(maxY - minY));
|
public java.awt.geom.Rectangle2D | getVisualBounds()Returns the visual bounds of this GlyphVector.
The visual bounds is the bounds of the total outline of
this GlyphVector.
float xM, yM, xm, ym;
float minX = 0;
float minY = 0;
float maxX = 0;
float maxY = 0;
boolean firstIteration = true;
for (int i = 0; i < this.getNumGlyphs(); i++) {
Rectangle2D bounds = this.getGlyphVisualBounds(i).getBounds2D();
if (bounds.getWidth() == 0){
continue;
}
xm = (float)bounds.getX();
ym = (float)bounds.getY();
xM = (float)(xm + bounds.getWidth());
yM = ym + (float) bounds.getHeight();
if (firstIteration) {
minX = xm;
minY = ym;
maxX = xM;
maxY = yM;
firstIteration = false;
} else {
if (minX > xm) {
minX = xm;
}
if (minY > ym) {
minY = ym;
}
if (maxX < xM) {
maxX = xM;
}
if (maxY < yM) {
maxY = yM;
}
}
}
return (this.getNumGlyphs() != 0) ? new Rectangle2D.Float(minX, minY,
(maxX - minX), (maxY - minY)) : null;
|
public void | performDefaultLayout()Assigns default positions to each glyph in this GlyphVector.
System.arraycopy(logicalPositions, 0, visualPositions, 0, logicalPositions.length);
// Set position changes flag to zero
clearLayoutFlags(GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
void | setDefaultPositions()Set array of logical positions of the glyphs to
default with their default advances and height.
int len = getNumGlyphs();
// First [x,y] is set into [0,0] position
// for this reason start index is 1
for (int i=1; i <= len; i++ ){
int idx = i << 1;
float advanceX = vector[i-1].getGlyphPointMetrics().getAdvanceX();
float advanceY = vector[i-1].getGlyphPointMetrics().getAdvanceY();
defaultPositions[idx] = defaultPositions[idx-2] + advanceX;
defaultPositions[idx+1] = defaultPositions[idx-1] + advanceY;
}
transform.transform(defaultPositions, 0, logicalPositions, 0, getNumGlyphs()+1);
|
public void | setGlyphPosition(int glyphIndex, java.awt.geom.Point2D newPos)Sets new position to the specified glyph.
if ((glyphIndex > vector.length) || (glyphIndex < 0)) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
float x = (float)newPos.getX();
float y = (float)newPos.getY();
int index = glyphIndex << 1;
if ((x != visualPositions[index]) || (y != visualPositions[index + 1])){
visualPositions[index] = x;
visualPositions[index+1] = y;
layoutFlags = layoutFlags | FLAG_HAS_POSITION_ADJUSTMENTS;
}
|
public void | setGlyphPositions(int beginGlyphIndex, int numEntries, float[] setPositions)Set numEntries elements of the visualPositions array from beginGlyphIndex
of numEntries glyphs positions from beginGlyphIndex glyph in Glyph Vector.
int len = (this.getNumGlyphs()+1) << 1;
beginGlyphIndex *= 2;
numEntries *= 2;
if ((beginGlyphIndex < 0) || ((numEntries + beginGlyphIndex) > len)) {
// awt.44=beginGlyphIndex is out of vector's range
throw new IndexOutOfBoundsException(Messages.getString("awt.44")); //$NON-NLS-1$
}
if (numEntries < 0) {
// awt.45=numEntries is out of vector's range
throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
}
System.arraycopy(setPositions, 0, visualPositions, beginGlyphIndex, numEntries);
layoutFlags = layoutFlags & FLAG_HAS_POSITION_ADJUSTMENTS;
|
public void | setGlyphPositions(float[] setPositions)Set elements of the visualPositions array.
int len = (this.getNumGlyphs()+1) << 1;
if (len != setPositions.length){
// awt.46=length of setPositions array differs from the length of positions array
throw new IllegalArgumentException(Messages.getString("awt.46")); //$NON-NLS-1$
}
System.arraycopy(setPositions, 0, visualPositions, 0, len);
layoutFlags = layoutFlags & FLAG_HAS_POSITION_ADJUSTMENTS;
|
public void | setGlyphTransform(int glyphIndex, java.awt.geom.AffineTransform trans)Sets new transform to the specified glyph.
if ((glyphIndex >= vector.length) || (glyphIndex < 0)) {
// awt.43=glyphIndex is out of vector's limits
throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
}
if ((trans == null) || (trans.isIdentity())) {
glsTransforms[glyphIndex] = null;
} else {
glsTransforms[glyphIndex] = new AffineTransform(trans);
layoutFlags = layoutFlags | FLAG_HAS_TRANSFORMS;
}
|