AndroidTextLayout(String text, TextFormat format, AndroidFont font, Paint.FontMetrics metrics, float width, float height) { // Android doesn't provide a way to get precise text bounds, so we half-ass it, woo! super(text, format, new Rectangle(0, 0, width, height), height); this.font = font; this.metrics = metrics; }
AndroidTextLayout(String text, TextFormat format, AndroidFont font, Paint.FontMetrics metrics, float width) { // Android doesn't provide a way to get precise text bounds, so we half-ass it, woo! super(text, format, new Rectangle(0, 0, width, -metrics.ascent+metrics.descent)); this.font = font; this.metrics = metrics; }
@Override // from interface IRectangle public Rectangle clone () { return new Rectangle(this); }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float maxX = _coords[0], maxY = _coords[1]; float minX = _coords[0], minY = _coords[1]; for (int i = 0; i < _coordsSize;) { minX = Math.min(minX, _coords[i]); maxX = Math.max(maxX, _coords[i++]); minY = Math.min(minY, _coords[i]); maxY = Math.max(maxY, _coords[i++]); } return new Rectangle(minX, minY, maxX - minX, maxY - minY); }
@Override // from interface IShape public Rectangle bounds (Rectangle target) { float maxX = _coords[0], maxY = _coords[1]; float minX = _coords[0], minY = _coords[1]; for (int i = 0; i < _coordsSize;) { minX = Math.min(minX, _coords[i]); maxX = Math.max(maxX, _coords[i++]); minY = Math.min(minY, _coords[i]); maxY = Math.max(maxY, _coords[i++]); } return new Rectangle(minX, minY, maxX - minX, maxY - minY); }
/** * Creates a text block with the supplied {@code lines}. */ public TextBlock (TextLayout[] lines) { this.lines = lines; this.bounds = getBounds(lines, new Rectangle()); }
/** * Creates a text block with the supplied {@code lines}. */ public TextBlock (TextLayout[] lines) { this.lines = lines; this.bounds = getBounds(lines, new Rectangle()); }
@Override // from interface IRectangle public Rectangle union (IRectangle r) { Rectangle rect = new Rectangle(this); rect.add(r); return rect; }
/** * Creates a text block with the supplied {@code lines}. */ public TextBlock (TextLayout[] lines) { this.lines = lines; this.bounds = getBounds(lines, new Rectangle()); }
private static Rectangle computeBounds (TextLayout layout) { Rectangle2D bounds = layout.getBounds(); // the y position of the bounds includes a negative ascent, but we don't want that showing up // in our bounds since we render from 0 rather than from the baseline return new Rectangle((float)bounds.getX(), (float)bounds.getY() + layout.getAscent(), (float)bounds.getWidth(), (float)bounds.getHeight()); } }
private static Rectangle computeBounds (TextLayout layout) { Rectangle2D bounds = layout.getBounds(); // the y position of the bounds includes a negative ascent, but we don't want that showing up // in our bounds since we render from 0 rather than from the baseline return new Rectangle((float)bounds.getX(), (float)bounds.getY() + layout.getAscent(), (float)bounds.getWidth(), (float)bounds.getHeight()); } }
private static Rectangle computeBounds (TextLayout layout) { Rectangle2D bounds = layout.getBounds(); // the y position of the bounds includes a negative ascent, but we don't want that showing up // in our bounds since we render from 0 rather than from the baseline return new Rectangle((float)bounds.getX(), (float)bounds.getY() + layout.getAscent(), (float)bounds.getWidth(), (float)bounds.getHeight()); } }
/** * Parses custom float[][] array generated the {@code FramePacker} tool. */ protected static Frame[] parseFrames (float[][] meta) { Frame[] frames = new Frame[(meta.length-1)/2]; for (int ii = 0, mm = 1; ii < frames.length; ii++) { frames[ii] = new Frame(new Point(meta[mm][0], meta[mm++][1]), new Rectangle(meta[mm][0], meta[mm][1], meta[mm][2], meta[mm++][3])); } return frames; }
/** Hides the native widgets under the given screen area, using platform clipping if * supported. The PlayN layers underneath the area should show through. Pointer events should * also not interact with the native widgets within the area. * @param area the new area to hide, in screen coordinates, or null to show all */ public void hideNativeOverlays (IRectangle area) { if ((_hidden == null && area == null) || (_hidden != null && _hidden.equals(area))) return; _hidden = area == null ? null : new Rectangle(area); updateHidden(); }
@Override // from interface IRectangle public Rectangle intersection (float rx, float ry, float rw, float rh) { float x1 = Math.max(x(), rx); float y1 = Math.max(y(), ry); float x2 = Math.min(maxX(), rx + rw); float y2 = Math.min(maxY(), ry + rh); return new Rectangle(x1, y1, x2 - x1, y2 - y1); }
HtmlTextLayout(String text, TextFormat format, HtmlFontMetrics metrics, float width) { super(text, format, new Rectangle(0, 0, metrics.adjustWidth(width), metrics.height), metrics.ascent()+metrics.descent()); this.metrics = metrics; }
/** * Computes the total bounds of the layer hierarchy rooted at {@code root}. * The returned Rectangle will be in {@code root}'s coordinate system. */ public static Rectangle totalBounds (Layer root) { // account for root's origin Rectangle r = new Rectangle(root.originX(), root.originY(), 0, 0); addBounds(root, root, r, new Point()); return r; }
public Block (Graphics gfx, String text, TextStyle style, TextWrap wrap, TextBlock.Align align) { super(gfx, text, style); assert wrap != null && align != null; this.wrap = wrap; this.align = align; _layouts = gfx.layoutText(text, style, wrap); _bounds = TextBlock.getBounds(_layouts, new Rectangle()); _bounds.width = style.effect.adjustWidth(_bounds.width); _bounds.height = style.effect.adjustHeight(_bounds.height); }
private static Rectangle computeBounds(CTFont font, CGRect bounds) { // the y coordinate of bounds is a little tricky: iOS reports y as the number of pixels to // below the baseline that the text extends (the descent, but precisely for this text, not the // font's "maximum" descent) and the value is negative (due to the inverted coordinate system); // so we have to do some math to recover the desired y value which is the number of pixels // below the top-left of the line bounding box float ascent = (float)font.getAscent(); return new Rectangle((float)bounds.getMinX(), ascent - (float)(bounds.getHeight() + bounds.getMinY()), (float)bounds.getWidth(), (float)bounds.getHeight()); } }
private static Rectangle computeBounds(RoboFont font, CGRect bounds) { // the y coordinate of bounds is a little tricky: iOS reports y as the number of pixels to // below the baseline that the text extends (the descent, but precisely for this text, not the // font's "maximum" descent) and the value is negative (due to the inverted coordinate system); // so we have to do some math to recover the desired y value which is the number of pixels // below the top-left of the line bounding box float ascent = (float)font.ctFont.getAscent(); return new Rectangle((float)bounds.getMinX(), ascent - (float)(bounds.getHeight() + bounds.getMinY()), (float)bounds.getWidth(), (float)bounds.getHeight()); } }