use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class GraphicComponent method handleGetVisualBounds.
public Rectangle2D handleGetVisualBounds() {
Rectangle2D bounds = graphic.getBounds();
float width = (float) bounds.getWidth() + graphicAdvance * (graphicCount - 1);
return new Rectangle2D.Float((float) bounds.getX(), (float) bounds.getY(), width, (float) bounds.getHeight());
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class GraphicComponent method handleGetCharVisualBounds.
public Rectangle2D handleGetCharVisualBounds(int index) {
Rectangle2D bounds = graphic.getBounds();
// don't modify their rectangle, just in case they don't copy
Rectangle2D.Float charBounds = new Rectangle2D.Float();
charBounds.setRect(bounds);
charBounds.x += graphicAdvance * index;
return charBounds;
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class StandardGlyphVector method getGlyphMetrics.
public GlyphMetrics getGlyphMetrics(int ix) {
if (ix < 0 || ix >= glyphs.length) {
throw new IndexOutOfBoundsException("ix = " + ix);
}
Rectangle2D vb = getGlyphVisualBounds(ix).getBounds2D();
Point2D pt = getGlyphPosition(ix);
vb.setRect(vb.getMinX() - pt.getX(), vb.getMinY() - pt.getY(), vb.getWidth(), vb.getHeight());
Point2D.Float adv = getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y, vb, GlyphMetrics.STANDARD);
return gm;
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method validateCompClip.
protected void validateCompClip() {
int origClipState = clipState;
if (usrClip == null) {
clipState = CLIP_DEVICE;
clipRegion = devClip;
} else if (usrClip instanceof Rectangle2D) {
clipState = CLIP_RECTANGULAR;
if (usrClip instanceof Rectangle) {
clipRegion = devClip.getIntersection((Rectangle) usrClip);
} else {
clipRegion = devClip.getIntersection(usrClip.getBounds());
}
} else {
PathIterator cpi = usrClip.getPathIterator(null);
int[] box = new int[4];
ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
try {
sr.setOutputArea(devClip);
sr.appendPath(cpi);
sr.getPathBox(box);
Region r = Region.getInstance(box);
r.appendSpans(sr);
clipRegion = r;
clipState = r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE;
} finally {
sr.dispose();
}
}
if (origClipState != clipState && (clipState == CLIP_SHAPE || origClipState == CLIP_SHAPE)) {
validFontInfo = false;
invalidatePipe();
}
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method intersectRectShape.
/*
* Intersect a Rectangle with a Shape by the simplest method,
* attempting to produce a simplified result.
* The boolean arguments keep1 and keep2 specify whether or not
* the first or second shapes can be modified during the operation
* or whether that shape must be "kept" unmodified.
*/
Shape intersectRectShape(Rectangle2D r, Shape s, boolean keep1, boolean keep2) {
if (s instanceof Rectangle2D) {
Rectangle2D r2 = (Rectangle2D) s;
Rectangle2D outrect;
if (!keep1) {
outrect = r;
} else if (!keep2) {
outrect = r2;
} else {
outrect = new Rectangle2D.Float();
}
double x1 = Math.max(r.getX(), r2.getX());
double x2 = Math.min(r.getX() + r.getWidth(), r2.getX() + r2.getWidth());
double y1 = Math.max(r.getY(), r2.getY());
double y2 = Math.min(r.getY() + r.getHeight(), r2.getY() + r2.getHeight());
if (((x2 - x1) < 0) || ((y2 - y1) < 0))
// Width or height is negative. No intersection.
outrect.setFrameFromDiagonal(0, 0, 0, 0);
else
outrect.setFrameFromDiagonal(x1, y1, x2, y2);
return outrect;
}
if (r.contains(s.getBounds2D())) {
if (keep2) {
s = cloneShape(s);
}
return s;
}
return intersectByArea(r, s, keep1, keep2);
}
Aggregations