/** * Returns TextMetrics, which includes an approximate value for * height. As close as we can estimate it at this time. * * @param context * @return TextMetric or null if the text is empty or null */ public double getLineHeight(final Context2D context) { return getBoundingBoxForString("Mg").getHeight(); }
public double getLabelHeight() { return label.getBoundingBox().getHeight(); }
@Override public BoundingBox getBoundingBox() { double wide = 0; double high = 0; for (final BoundingBox bbox : m_frames) { wide = Math.max(wide, bbox.getWidth()); high = Math.max(high, bbox.getHeight()); } return new BoundingBox(0, 0, wide, high); }
public static final IPrimitive<?> setScaleToFit(final IPrimitive<?> prim, final double wide, final double high, final BoundingBox bbox) { prim.setScale(wide / bbox.getWidth(), high / bbox.getHeight()); return prim; }
public static final IPrimitive<?> setScaleToFit(final IPrimitive<?> prim, final double wide, final double high, final BoundingBox bbox) { prim.setScale(wide / bbox.getWidth(), high / bbox.getHeight()); return prim; }
private double[] getChildRelativeCoordinates(final BoundingBox bb) { final double bbx = bb.getX(); final double bby = bb.getY(); final double bbw = bb.getWidth(); final double bbh = bb.getHeight(); final double x = -bbx - (bbw / 2); final double y = -bby - (bbh / 2); return new double[] { x, y }; }
public AutoGrid build() { assert null != boundingBox; final double max = isHorizontal(direction) ? boundingBox.getWidth() : boundingBox.getHeight(); return new AutoGrid(pad, size, direction, max); } }
private ToolboxImpl updateGridSize() { final BoundingBox boundingBox = shapeBoundingBoxSupplier.get(); final double margin = getGrid().getMargin() * 2; return setGridSize(boundingBox.getWidth() + margin, boundingBox.getHeight() + margin); }
@Override public BoxDecorator setBoundingBox(final BoundingBox boundingBox) { final double offset = -(padding / 2); rect(decorator, boundingBox.getWidth() + padding, boundingBox.getHeight() + padding, DECORATOR_CORNER_RADIUS) .setX(offset) .setY(offset); return this; }
public static Point2D findCenter(final BoundingBox box) { return new Point2D(box.getX() + (box.getWidth() / 2), box.getY() + (box.getHeight() / 2)); }
public static void scale(final Shape shape, final double width, final double height) { final BoundingBox bb = shape.getBoundingBox(); final double[] scale = getScaleFactor(bb.getWidth(), bb.getHeight(), width, height); shape.setScale(scale[0], scale[1]); }
private double getTotalHeight(WiresShape ws) { double height = ws.getPath().getBoundingBox().getHeight(); for (WiresShape child : ws.getChildShapes()) { height += (getTotalHeight(child) + PADDING_Y); } return height; } }
void refresh() { final BoundingBox bbox = getPath().getBoundingBox(); resize(bbox.getWidth(), bbox.getHeight(), true); }
@Override public void layout(final WiresContainer container) { double y = PADDING_Y; if (container instanceof WiresShape) { y = y + ((WiresShape) container).getPath().getBoundingBox().getHeight(); } for (WiresShape ws : container.getChildShapes()) { ws.setLocation(new Point2D(PADDING_X, y)); y = y + getTotalHeight(ws) + PADDING_Y; } }
@Override protected final boolean apply(final Context2D context) { context.beginPath(); context.rect(m_bbox.getX(), m_bbox.getY(), m_bbox.getWidth(), m_bbox.getHeight()); context.clip(); return true; } }
public BoundingPoints(BoundingBox bbox) { double x = bbox.getX(); double y = bbox.getY(); double w = bbox.getWidth(); double h = bbox.getHeight(); m_array.push(new Point2D(x + 0, y + 0)); m_array.push(new Point2D(x + w, y + 0)); m_array.push(new Point2D(x + w, y + h)); m_array.push(new Point2D(x + 0, y + h)); }
private Point2D calculateAbsCandidateLocation(final WiresShape shape, final WiresMagnet shapeMagnet) { final Point2D trgLocation = new Point2D(shapeMagnet.getX(), shapeMagnet.getY()); final BoundingBox shapeBB = shape.getPath().getBoundingBox(); final BoundingBox box = shape.getPath().getBoundingBox(); final double newX = trgLocation.getX() - shapeBB.getMinX() - (box.getWidth() / 2); final double newY = trgLocation.getY() - shapeBB.getMinY() - (box.getHeight() / 2); return new Point2D(newX, newY); }
private Point2D calculateAbsCandidateLocation(final WiresShape shape, final WiresMagnet shapeMagnet) { final Point2D trgLocation = new Point2D(shapeMagnet.getX(), shapeMagnet.getY()); final BoundingBox shapeBB = shape.getPath().getBoundingBox(); final BoundingBox box = shape.getPath().getBoundingBox(); final double newX = trgLocation.getX() - shapeBB.getMinX() - (box.getWidth() / 2); final double newY = trgLocation.getY() - shapeBB.getMinY() - (box.getHeight() / 2); return new Point2D(newX, newY); }
public final String toJSONString() { final JSONObject object = new JSONObject(); object.put("x", new JSONNumber(getX())); object.put("y", new JSONNumber(getY())); object.put("width", new JSONNumber(getWidth())); object.put("height", new JSONNumber(getHeight())); return object.toString(); }
public WiresShape(final MultiPath path, final LayoutContainer layoutContainer) { super(layoutContainer.getGroup()); m_path = path; m_ctrls = null; m_resizable = true; m_innerLayoutContainer = layoutContainer; m_innerLayoutContainer.getGroup().setEventPropagationMode(EventPropagationMode.FIRST_ANCESTOR); m_innerLayoutContainer.add(m_path); final BoundingBox box = m_path.refresh().getBoundingBox(); m_innerLayoutContainer.setOffset(new Point2D(box.getX(), box.getY())).setSize(box.getWidth(), box.getHeight()).execute(); }