Example usage for java.awt.geom Point2D.Float Point2D.Float

List of usage examples for java.awt.geom Point2D.Float Point2D.Float

Introduction

In this page you can find the example usage for java.awt.geom Point2D.Float Point2D.Float.

Prototype

Point2D.Float

Source Link

Usage

From source file:tufts.vue.LWComponent.java

/** @return our shape, full transformed into map coords and ultimate scale when drawn at 100% map zoom
 * this is used for portal clipping, and will be imperfect for some scaled shapes, such as RountRect's
 * This only works for raw shapes that are RectangularShapes -- other Shape types just return the bounding
 * box in map coordinates (e.g., a link shape)
 *//*from w  w w  .  j a v a  2s  .c o m*/
public RectangularShape getMapShape() {
    // Will not work for shapes like RoundRect when scaled -- e..g, corner scaling will be off

    final Shape s = getZeroShape();
    //        if (getMapScale() != 1f && s instanceof RectangularShape) { // todo: do if any transform, not just scale
    if (s instanceof RectangularShape) {
        // todo: cache this: only need to updaate if location, size or scale changes
        // (Also, on the scale or location change of any parent!)
        RectangularShape rshape = (RectangularShape) s;
        rshape = (RectangularShape) rshape.clone();
        AffineTransform a = getZeroTransform();
        Point2D.Float loc = new Point2D.Float();
        a.transform(loc, loc);
        rshape.setFrame(loc.x, loc.y, rshape.getWidth() * a.getScaleX(), rshape.getHeight() * a.getScaleY());
        //System.out.println("TRANSFORMED SHAPE: " + rshape + " for " + this);
        return rshape;
    } else {
        return getMapBounds();
    }
}

From source file:tufts.vue.LWComponent.java

/**
 * fit and center us into the given frame
 * @param borderGap: if positive, a fixed amount of pixels, if NEGATIVE, the % of viewport size to leave as a margin
 *///from ww w  .j  a v a  2  s  .c  o m
public void drawFit(DrawContext dc, Rectangle2D frame, int borderGap) {
    final Point2D.Float offset = new Point2D.Float();
    final Size size = new Size(frame);
    final double zoom = ZoomTool.computeZoomFit(size, borderGap, addStrokeToBounds(getZeroBounds(), 0), offset);
    if (DEBUG.PDF)
        out("drawFit into " + fmt(frame) + " zoom " + zoom);
    dc.g.translate(-offset.x + frame.getX(), -offset.y + frame.getY());
    dc.g.scale(zoom, zoom);
    dc.setClipOptimized(false);
    drawZero(dc);
}