Example usage for java.awt.geom Rectangle2D getMinY

List of usage examples for java.awt.geom Rectangle2D getMinY

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getMinY.

Prototype

public double getMinY() 

Source Link

Document

Returns the smallest Y coordinate of the framing rectangle of the Shape in double precision.

Usage

From source file:org.n52.server.io.EESGenerator.java

@Override
public RepresentationResponse producePresentation(DesignOptions options) throws GeneratorException {
    ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection());
    String chartUrl = createChart(options, renderingInfo);

    Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea();
    for (Axis axis : renderer.getAxisMapping().values()) {
        axis.setMaxY(plotArea.getMaxY());
        axis.setMinY(plotArea.getMinY());
    }/*from   w w w  . j  av  a2  s .c  o  m*/

    ImageEntity[] entities = {};
    if (!this.isOverview) {
        LOGGER.debug("Produced EES diagram " + chartUrl);
        entities = createImageEntities(renderingInfo.getEntityCollection());
    } else {
        LOGGER.debug("Produced EES Overview diagram " + chartUrl);
    }

    Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(),
            plotArea.getMaxY());
    return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping());
}

From source file:eu.hydrologis.jgrass.charting.impl.LineDrawer.java

/**
 * Draws the circle.//from www.  jav a 2 s. c  o  m
 * 
 * @param g2 the graphics device.
 * @param area the area in which to draw.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
    } else {
        g2.setPaint(Color.black);
        g2.setStroke(new BasicStroke(1.0f));
    }

    Line2D line = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY());
    g2.draw(line);
}

From source file:org.fhcrc.cpl.viewer.quant.gui.LogRatioHistMouseListener.java

/**
 * Undraw the previous selected region (if it was drawn), calculate the new regions, draw again, save
 * the points, and draw the numeric ratio in its little box
 * @param e//ww w  .  j ava2s .  c om
 */
public void mouseDragged(MouseEvent e) {

    if (this.selectedRegionStart == null || e.getX() < this.selectedRegionStart.getX()) {
        return;
    }

    if (this.selectedRegion != null)
        drawOrUndrawRegion();

    // Erase the previous zoom rectangle (if any)...
    Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea();

    this.selectedRegion = new Rectangle2D.Double(this.selectedRegionStart.getX(), scaledDataArea.getMinY(),
            Math.min(Math.abs(e.getX() - selectedRegionStart.getX()),
                    _chartPanel.getWidth() - this.selectedRegionStart.getX()),
            scaledDataArea.getHeight());
    transformAndSaveSelectedRegion();

    // Draw the new zoom rectangle...
    drawOrUndrawRegion();

    lastMousedRatio = Rounder.round(Math.exp(transformMouseXValue(e.getX())), 2);
    drawRatioInBox(getChartPanelGraphics());
}

From source file:org.esa.beam.visat.toolviews.stat.XYImagePlot.java

@Override
public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, PlotRenderingInfo info,
        CrosshairState crosshairState) {
    final boolean foundData = super.render(g2, dataArea, index, info, crosshairState);
    if (image != null) {
        final int dx1 = (int) dataArea.getMinX();
        final int dy1 = (int) dataArea.getMinY();
        final int dx2 = (int) dataArea.getMaxX();
        final int dy2 = (int) dataArea.getMaxY();

        synchronized (imageLock) {
            final Rectangle rectangle = getImageSourceArea();
            final int sx1 = rectangle.x;
            final int sy1 = rectangle.y;
            final int sx2 = sx1 + rectangle.width - 1;
            final int sy2 = sy1 + rectangle.height - 1;
            g2.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
        }/* ww w.  j a v a  2  s  . c om*/
    }
    return foundData;
}

From source file:ro.cs.products.landsat.LandsatSearch.java

@Override
public void setAreaOfInterest(Polygon2D polygon) {
    super.setAreaOfInterest(polygon);
    final Rectangle2D bounds2D = polygon.getBounds2D();
    this.keyValues.add(new BasicNameValuePair("upperLeftCornerLatitude", String.valueOf(bounds2D.getMaxY())));
    this.keyValues.add(new BasicNameValuePair("lowerRightCornerLatitude", String.valueOf(bounds2D.getMinY())));
    this.keyValues.add(new BasicNameValuePair("lowerLeftCornerLongitude", String.valueOf(bounds2D.getMinX())));
    this.keyValues.add(new BasicNameValuePair("upperRightCornerLongitude", String.valueOf(bounds2D.getMaxX())));
}

From source file:edu.uci.ics.jung.visualization.util.VertexShapeFactory.java

/**
 * Returns a regular <code>num_sides</code>-sided 
 * <code>Polygon</code> whose bounding 
 * box's width and height are defined by this instance's size and
 * aspect ratio functions for this vertex.
 * @param num_sides the number of sides of the polygon; must be >= 3.
 *//*from   w  ww  .  jav a 2  s .c  o  m*/
public Shape getRegularPolygon(V v, int num_sides) {
    if (num_sides < 3)
        throw new IllegalArgumentException("Number of sides must be >= 3");
    Rectangle2D frame = getRectangle(v);
    float width = (float) frame.getWidth();
    float height = (float) frame.getHeight();

    // generate coordinates
    double angle = 0;
    thePolygon.reset();
    thePolygon.moveTo(0, 0);
    thePolygon.lineTo(width, 0);
    double theta = (2 * Math.PI) / num_sides;
    for (int i = 2; i < num_sides; i++) {
        angle -= theta;
        float delta_x = (float) (width * Math.cos(angle));
        float delta_y = (float) (width * Math.sin(angle));
        Point2D prev = thePolygon.getCurrentPoint();
        thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
    }
    thePolygon.closePath();

    // scale polygon to be right size, translate to center at (0,0)
    Rectangle2D r = thePolygon.getBounds2D();
    double scale_x = width / r.getWidth();
    double scale_y = height / r.getHeight();
    float translationX = (float) (r.getMinX() + r.getWidth() / 2);
    float translationY = (float) (r.getMinY() + r.getHeight() / 2);

    AffineTransform at = AffineTransform.getScaleInstance(scale_x, scale_y);
    at.translate(-translationX, -translationY);

    Shape shape = at.createTransformedShape(thePolygon);
    return shape;
}

From source file:edu.uci.ics.jung.visualization.util.VertexShapeFactory.java

/**
 * Returns a regular <code>Polygon</code> of <code>num_points</code>
 * points whose bounding /*from w  w  w  .  j av a2  s  .c  o m*/
 * box's width and height are defined by this instance's size and
 * aspect ratio functions for this vertex.
 * @param num_points the number of points of the polygon; must be >= 5.
 */
public Shape getRegularStar(V v, int num_points) {
    if (num_points < 5)
        throw new IllegalArgumentException("Number of sides must be >= 5");
    Rectangle2D frame = getRectangle(v);
    float width = (float) frame.getWidth();
    float height = (float) frame.getHeight();

    // generate coordinates
    double theta = (2 * Math.PI) / num_points;
    double angle = -theta / 2;
    thePolygon.reset();
    thePolygon.moveTo(0, 0);
    float delta_x = width * (float) Math.cos(angle);
    float delta_y = width * (float) Math.sin(angle);
    Point2D prev = thePolygon.getCurrentPoint();
    thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
    for (int i = 1; i < num_points; i++) {
        angle += theta;
        delta_x = width * (float) Math.cos(angle);
        delta_y = width * (float) Math.sin(angle);
        prev = thePolygon.getCurrentPoint();
        thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
        angle -= theta * 2;
        delta_x = width * (float) Math.cos(angle);
        delta_y = width * (float) Math.sin(angle);
        prev = thePolygon.getCurrentPoint();
        thePolygon.lineTo((float) prev.getX() + delta_x, (float) prev.getY() + delta_y);
    }
    thePolygon.closePath();

    // scale polygon to be right size, translate to center at (0,0)
    Rectangle2D r = thePolygon.getBounds2D();
    double scale_x = width / r.getWidth();
    double scale_y = height / r.getHeight();

    float translationX = (float) (r.getMinX() + r.getWidth() / 2);
    float translationY = (float) (r.getMinY() + r.getHeight() / 2);

    AffineTransform at = AffineTransform.getScaleInstance(scale_x, scale_y);
    at.translate(-translationX, -translationY);

    Shape shape = at.createTransformedShape(thePolygon);
    return shape;
}

From source file:Bounce.java

/**
 * Moves the ball to the next position, reversing direction if it hits one of
 * the edges/*from w w w.ja v a2 s.  com*/
 */
public void move(Rectangle2D bounds) {
    x += dx;
    y += dy;
    if (x < bounds.getMinX()) {
        x = bounds.getMinX();
        dx = -dx;
    }
    if (x + XSIZE >= bounds.getMaxX()) {
        x = bounds.getMaxX() - XSIZE;
        dx = -dx;
    }
    if (y < bounds.getMinY()) {
        y = bounds.getMinY();
        dy = -dy;
    }
    if (y + YSIZE >= bounds.getMaxY()) {
        y = bounds.getMaxY() - YSIZE;
        dy = -dy;
    }
}

From source file:Clip.java

/**
 * @see java.lang.Object#equals(java.lang.Object)
 *///from   w w  w. ja va  2 s. com
public boolean equals(Object o) {
    if (o instanceof Rectangle2D) {
        Rectangle2D r = (Rectangle2D) o;
        return (r.getMinX() == clip[0] && r.getMinY() == clip[1] && r.getMaxX() == clip[6]
                && r.getMaxY() == clip[7]);
    } else if (o instanceof Clip) {
        Clip r = (Clip) o;
        if (r.status == status) {
            if (status == Clip.INUSE)
                return (r.clip[0] == clip[0] && r.clip[1] == clip[1] && r.clip[6] == clip[6]
                        && r.clip[7] == clip[7]);
            else
                return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

From source file:org.esa.beam.visat.toolviews.stat.XYImagePlot.java

public void setImageDataBounds(Rectangle2D imageDataBounds) {
    synchronized (imageLock) {
        this.imageDataBounds = (Rectangle2D) imageDataBounds.clone();
        DefaultXYDataset xyDataset = new DefaultXYDataset();
        xyDataset.addSeries("Image Data Bounds",
                new double[][] { { imageDataBounds.getMinX(), imageDataBounds.getMaxX() },
                        { imageDataBounds.getMinY(), imageDataBounds.getMaxY() } });
        setDataset(xyDataset);/*  w ww . j  a  v a  2  s .  c om*/
        getDomainAxis().setRange(imageDataBounds.getMinX(), imageDataBounds.getMaxX());
        getRangeAxis().setRange(imageDataBounds.getMinY(), imageDataBounds.getMaxY());
    }
}