use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class TextLine method getOutline.
public Shape getOutline(AffineTransform tx) {
GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
dstShape.append(tlc.getOutline(locs[n], locs[n + 1]), false);
}
if (tx != null) {
dstShape.transform(tx);
}
return dstShape;
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class CompositeStrike method getGlyphVectorOutline.
/* The physical font slot for each glyph is encoded in the glyph ID
* To be as efficient as possible we find a run of glyphs from the
* same slot and create a temporary array of these glyphs decoded
* to the slot. The slot font is then queried for the GeneralPath
* for that run of glyphs. GeneralPaths from each run are appended
* to create the shape for the whole glyph array.
*/
GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {
GeneralPath path = null;
GeneralPath gp;
int glyphIndex = 0;
int[] tmpGlyphs;
while (glyphIndex < glyphs.length) {
int start = glyphIndex;
int slot = glyphs[glyphIndex] >>> 24;
while (glyphIndex < glyphs.length && (glyphs[glyphIndex + 1] >>> 24) == slot) {
glyphIndex++;
}
int tmpLen = glyphIndex - start + 1;
tmpGlyphs = new int[tmpLen];
for (int i = 0; i < tmpLen; i++) {
tmpGlyphs[i] = glyphs[i] & SLOTMASK;
}
gp = getStrikeForSlot(slot).getGlyphVectorOutline(tmpGlyphs, x, y);
if (path == null) {
path = gp;
} else if (gp != null) {
path.append(gp, false);
}
}
if (path == null) {
return new GeneralPath();
} else {
return path;
}
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class FileFontStrike method getGlyphOutline.
GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
GeneralPath gp = null;
ConcurrentHashMap<Integer, GeneralPath> outlineMap = null;
if (outlineMapRef != null) {
outlineMap = outlineMapRef.get();
if (outlineMap != null) {
gp = (GeneralPath) outlineMap.get(glyphCode);
}
}
if (gp == null) {
gp = fileFont.getGlyphOutline(pScalerContext, glyphCode, 0, 0);
if (outlineMap == null) {
outlineMap = new ConcurrentHashMap<Integer, GeneralPath>();
outlineMapRef = new WeakReference<ConcurrentHashMap<Integer, GeneralPath>>(outlineMap);
}
outlineMap.put(glyphCode, gp);
}
// mutable!
gp = (GeneralPath) gp.clone();
if (x != 0f || y != 0f) {
gp.transform(AffineTransform.getTranslateInstance(x, y));
}
return gp;
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class StandardGlyphVector method getGlyphLogicalBounds.
public Shape getGlyphLogicalBounds(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
Shape[] lbcache;
if (lbcacheRef == null || (lbcache = (Shape[]) lbcacheRef.get()) == null) {
lbcache = new Shape[glyphs.length];
lbcacheRef = new SoftReference(lbcache);
}
Shape result = lbcache[ix];
if (result == null) {
setFRCTX();
initPositions();
// !!! ought to return a rectangle2d for simple cases, though the following works for all
// get the position, the tx offset, and the x,y advance and x,y adl. The
// shape is the box formed by adv (width) and adl (height) offset by
// the position plus the tx offset minus the ascent.
ADL adl = new ADL();
GlyphStrike gs = getGlyphStrike(ix);
gs.getADL(adl);
Point2D.Float adv = gs.strike.getGlyphMetrics(glyphs[ix]);
float wx = adv.x;
float wy = adv.y;
float hx = adl.descentX + adl.leadingX + adl.ascentX;
float hy = adl.descentY + adl.leadingY + adl.ascentY;
float x = positions[ix * 2] + gs.dx - adl.ascentX;
float y = positions[ix * 2 + 1] + gs.dy - adl.ascentY;
GeneralPath gp = new GeneralPath();
gp.moveTo(x, y);
gp.lineTo(x + wx, y + wy);
gp.lineTo(x + wx + hx, y + wy + hy);
gp.lineTo(x + hx, y + hy);
gp.closePath();
result = new DelegatingShape(gp);
lbcache[ix] = result;
}
return result;
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class GraphicComponent method handleGetOutline.
public Shape handleGetOutline(float x, float y) {
double[] matrix = { 1, 0, 0, 1, x, y };
if (graphicCount == 1) {
AffineTransform tx = new AffineTransform(matrix);
return graphic.getOutline(tx);
}
GeneralPath gp = new GeneralPath();
for (int i = 0; i < graphicCount; ++i) {
AffineTransform tx = new AffineTransform(matrix);
gp.append(graphic.getOutline(tx), false);
matrix[4] += graphicAdvance;
}
return gp;
}
Aggregations