use of java.awt.geom.Rectangle2D in project binnavi by google.
the class ZoomHelpers method getMinimumZoom.
/**
* Calculates the smallest valid zoom level.
*
* @return The smallest valid zoom level.
*/
public static double getMinimumZoom(final Graph2DView view) {
double zoomlevel = view.getZoom();
if (zoomlevel < 0) {
zoomlevel = 1;
}
final Point2D viewPoint = view.getViewPoint2D();
final Rectangle2D box = view.getGraph2D().getBoundingBox();
// why? => to gain the
view.zoomToArea(box.getX(), box.getY(), box.getWidth(), box.getHeight());
// minimum zoom level
// in the next line
final double minZoom = view.getZoom();
// why? => to reset the original zoom level after the minimum zoom
view.setZoom(zoomlevel);
// level was calulated
// why? => to reset the original view
view.setViewPoint2D(viewPoint.getX(), viewPoint.getY());
// point
return minZoom - (minZoom / 2);
}
use of java.awt.geom.Rectangle2D in project android_frameworks_base by DirtyUnicorns.
the class Path_Delegate method fillBounds.
/**
* Fills the given {@link RectF} with the path bounds.
* @param bounds the RectF to be filled.
*/
public void fillBounds(RectF bounds) {
Rectangle2D rect = mPath.getBounds2D();
bounds.left = (float) rect.getMinX();
bounds.right = (float) rect.getMaxX();
bounds.top = (float) rect.getMinY();
bounds.bottom = (float) rect.getMaxY();
}
use of java.awt.geom.Rectangle2D in project android_frameworks_base by DirtyUnicorns.
the class BidiRenderer method render.
/**
* Renders the text to the right of the bounds with the given font.
* @param font The font to render the text with.
*/
private void render(int start, int limit, Font font, int flag, float[] advances, int advancesIndex, boolean draw) {
FontRenderContext frc;
if (mGraphics != null) {
frc = mGraphics.getFontRenderContext();
} else {
frc = Toolkit.getDefaultToolkit().getFontMetrics(font).getFontRenderContext();
// Metrics obtained this way don't have anti-aliasing set. So,
// we create a new FontRenderContext with anti-aliasing set.
frc = new FontRenderContext(font.getTransform(), mPaint.isAntiAliased(), frc.usesFractionalMetrics());
}
GlyphVector gv = font.layoutGlyphVector(frc, mText, start, limit, flag);
int ng = gv.getNumGlyphs();
int[] ci = gv.getGlyphCharIndices(0, ng, null);
if (advances != null) {
for (int i = 0; i < ng; i++) {
int adv_idx = advancesIndex + ci[i];
advances[adv_idx] += gv.getGlyphMetrics(i).getAdvanceX();
}
}
if (draw && mGraphics != null) {
mGraphics.drawGlyphVector(gv, mBounds.right, mBaseline);
}
// Update the bounds.
Rectangle2D awtBounds = gv.getLogicalBounds();
RectF bounds = awtRectToAndroidRect(awtBounds, mBounds.right, mBaseline);
// coordinates from the bounds as an offset.
if (Math.abs(mBounds.right - mBounds.left) == 0) {
mBounds = bounds;
} else {
mBounds.union(bounds);
}
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class StyledSpaceAdvance method test.
static void test(int sz) {
Font reg = new Font(name, Font.PLAIN, sz);
Font bold = new Font(name, Font.BOLD, sz);
//System.out.println("reg="+reg);
//System.out.println("bold="+bold);
FontRenderContext frc = new FontRenderContext(null, false, false);
if (reg.getFontName(Locale.ENGLISH).equals(name) && bold.getFontName(Locale.ENGLISH).equals(name)) {
Rectangle2D rb = reg.getStringBounds(" ", frc);
Rectangle2D bb = bold.getStringBounds(" ", frc);
if (bb.getWidth() > rb.getWidth() + 1.01f) {
System.err.println("reg=" + reg + " bds = " + rb);
System.err.println("bold=" + bold + " bds = " + bb);
throw new RuntimeException("Advance difference too great.");
}
} else {
System.out.println("Skipping test because fonts aren't as expected");
}
}
use of java.awt.geom.Rectangle2D in project jdk8u_jdk by JetBrains.
the class Path2DCopyConstructor method testGetBounds.
static void testGetBounds(Path2D pathA, Path2D pathB) {
final Rectangle rA = pathA.getBounds();
final Rectangle rB = pathB.getBounds();
if (!rA.equals(rB)) {
throw new IllegalStateException("Bounds are not equals [" + rA + "|" + rB + "] !");
}
final Rectangle2D r2dA = pathA.getBounds2D();
final Rectangle2D r2dB = pathB.getBounds2D();
if (!equalsRectangle2D(r2dA, r2dB)) {
throw new IllegalStateException("Bounds2D are not equals [" + r2dA + "|" + r2dB + "] !");
}
log("testGetBounds: passed.");
}
Aggregations