Example usage for java.awt.geom Rectangle2D getMaxY

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

Introduction

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

Prototype

public double getMaxY() 

Source Link

Document

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

Usage

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

/**
 * Draws the circle./*from w w  w.ja  v a  2s  .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:gda.plots.DataMagnifierWindow.java

/**
 * The SimplePlot will call this method when the Rectangle to be magnified has changed.
 * /*  ww  w  .  jav a2s . co m*/
 * @param magnifyRectangle
 *            the Rectangle to be magnified
 */
@Override
public void update(Rectangle2D magnifyRectangle) {

    // The magnifyRectangle will be in Java coordinates, need to calculate
    // the axis limits required. This mechanism was copied from the zooming
    // methods within JFreeChart.

    double hLower = 0.0;
    double hUpper = 0.0;
    double vLower = 0.0;
    double vUpper = 0.0;
    double a;
    double b;
    Rectangle2D scaledDataArea;
    if (magnifyRectangle != null) {
        scaledDataArea = simplePlot.getScreenDataArea();
        hLower = (magnifyRectangle.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        hUpper = (magnifyRectangle.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        vLower = (scaledDataArea.getMaxY() - magnifyRectangle.getMaxY()) / scaledDataArea.getHeight();
        vUpper = (scaledDataArea.getMaxY() - magnifyRectangle.getMinY()) / scaledDataArea.getHeight();

        Range r = simplePlot.getChart().getXYPlot().getDomainAxis().getRange();
        a = r.getLowerBound() + hLower * r.getLength();
        b = r.getLowerBound() + hUpper * r.getLength();
        Range newR = new Range(Math.min(a, b), Math.max(a, b));
        magnifiedPlot.getDomainAxis().setRange(newR);

        r = simplePlot.getChart().getXYPlot().getRangeAxis().getRange();
        a = r.getLowerBound() + vLower * r.getLength();
        b = r.getLowerBound() + vUpper * r.getLength();
        newR = new Range(Math.min(a, b), Math.max(a, b));
        magnifiedPlot.getRangeAxis().setRange(newR);

        repaint();
    }
}

From source file:it.unibo.alchemist.model.implementations.linkingrules.ConnectionBeam.java

@Override
public Neighborhood<T> computeNeighborhood(final Node<T> center, final Environment<T> env) {
    final Neighborhood<T> normal = super.computeNeighborhood(center, env);
    if (oenv == null) {
        if (!(env instanceof Environment2DWithObstacles<?, ?>)) {
            return normal;
        }// www.  j  av  a 2s .c  om
        oenv = (Environment2DWithObstacles<?, ?>) env;
        obstacles.reset();
        oenv.getObstacles().forEach((obs) -> {
            /*
             * Doubles are prone to approximation errors. Use nextAfter to get rid of them
             */
            final Rectangle2D bounds = obs.getBounds2D();
            final double mx = nextAfter(bounds.getMinX(), java.lang.Double.NEGATIVE_INFINITY);
            final double my = nextAfter(bounds.getMinY(), java.lang.Double.NEGATIVE_INFINITY);
            final double ex = nextUp(bounds.getMaxX());
            final double ey = nextUp(bounds.getMaxY());
            obstacles.add(new Area(new Rectangle2D.Double(mx, my, ex - mx, ey - my)));
        });
    }
    if (!normal.isEmpty()) {
        final Position cp = env.getPosition(center);
        final List<Node<T>> neighs = normal.getNeighbors().stream().filter((neigh) -> {
            final Position np = env.getPosition(neigh);
            return !oenv.intersectsObstacle(cp, np) || projectedBeamOvercomesObstacle(cp, np);
        }).collect(ArrayList::new, (l, el) -> l.add(el), (l1, l2) -> l1.addAll(l2));
        return Neighborhoods.make(env, center, neighs);
    }
    return normal;
}

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);//from  w w w .  j a v a 2s.co m
        getDomainAxis().setRange(imageDataBounds.getMinX(), imageDataBounds.getMaxX());
        getRangeAxis().setRange(imageDataBounds.getMinY(), imageDataBounds.getMaxY());
    }
}

From source file:peakml.util.jfreechart.FastSpectrumPlot.java

@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {//from   www  . j  a v a2 s  . co  m
    // add the plot area to the info (used amongst other by the axis for zooming)
    if (info != null)
        info.setPlotArea(area);

    // add the insets (if any)
    RectangleInsets insets = getInsets();
    insets.trim(area);

    // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming)
    AxisSpace space = new AxisSpace();
    space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space);
    space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space);

    Rectangle2D dataArea = space.shrink(area, null);
    if (info != null)
        info.setDataArea(dataArea);

    // flood fill the whole area with the background color
    drawBackground(g2, dataArea);

    // draw the axis
    xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info);

    // sanity check
    if (dataseries.size() == 0)
        return;

    // clip the draw area
    Shape originalclip = g2.getClip();
    g2.clip(dataArea);

    // draw all the values
    for (Data data : dataseries) {
        int xpos = (int) xaxis.valueToJava2D(data.mass, dataArea, RectangleEdge.BOTTOM);
        int ypos = (int) yaxis.valueToJava2D(data.intensity, dataArea, RectangleEdge.LEFT);
        g2.drawLine(xpos, (int) yaxis.valueToJava2D(0, dataArea, RectangleEdge.LEFT), xpos, ypos);

        // draw the label
        if (data.description != null && data.description.length() != 0) {
            g2.setColor(Color.RED);
            g2.drawLine(xpos + 2, ypos - 2, xpos + 15, ypos - 15);
            g2.setColor(Color.BLACK);
            g2.drawString(data.description, xpos + 17, ypos - 17);
        }
    }

    // reset
    g2.setClip(originalclip);
}

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);
        }//from   ww w.  j  a  v a 2 s.  c  o m
    }
    return foundData;
}

From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java

public static Shape translateChartShape(Shape shape, Rectangle2D imageArea, JFreeChart chart) {
    if (shape instanceof Line2D) {
        Line2D line = (Line2D) shape;
        double length = line.getP1().distance(line.getP2());
        if (length == 0) {
            Point2D point = line.getP1();
            Point2D newPoint = ChartMaskingUtilities.translateChartPoint(point, imageArea, chart);
            Shape oShape = ShapeUtilities.createDiagonalCross(5f, 0.2f);
            //             Shape oShape = ShapeUtilities.createRegularCross(3f, 0.5f);
            Shape newShape = ShapeUtilities.createTranslatedShape(oShape, newPoint.getX(), newPoint.getY());
            return newShape;
        } else if (length < 1e-6) {
            if (line.getP1().getX() == line.getP2().getX()) {
                double newX = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getX();
                Line2D newLine = new Line2D.Double(newX, imageArea.getMinY(), newX, imageArea.getMaxY());
                return newLine;
            } else {
                double newY = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getY();
                Line2D newLine = new Line2D.Double(imageArea.getMinX(), newY, imageArea.getMaxX(), newY);
                return newLine;
            }//w  w w .j a va2 s. c o  m
        }
        Line2D newShape = (Line2D) line.clone();
        Point2D newP1 = translateChartPoint(line.getP1(), imageArea, chart);
        Point2D newP2 = translateChartPoint(line.getP2(), imageArea, chart);
        newShape.setLine(newP1, newP2);
        return newShape;
    } else if (shape instanceof RectangularShape) {
        RectangularShape rect = (RectangularShape) shape;
        RectangularShape newShape = (RectangularShape) rect.clone();
        Rectangle2D bound = rect.getBounds2D();
        Point2D start = new Point2D.Double(bound.getMinX(), bound.getMinY());
        Point2D end = new Point2D.Double(bound.getMaxX(), bound.getMaxY());
        Point2D screenStart = translateChartPoint(start, imageArea, chart);
        Point2D screenEnd = translateChartPoint(end, imageArea, chart);
        newShape.setFrame(new Rectangle2D.Double(Math.min(screenStart.getX(), screenEnd.getX()),
                Math.min(screenStart.getY(), screenEnd.getY()), Math.abs(screenStart.getX() - screenEnd.getX()),
                Math.abs(screenStart.getY() - screenEnd.getY())));
        return newShape;
    } else {
        return shape;
    }
}

From source file:peakml.util.jfreechart.LognAxis.java

@Override
public double java2DToValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) {
    Range range = getRange();/*from www . j  a  va  2  s.co  m*/
    double axisMin = log(range.getLowerBound());
    double axisMax = log(range.getUpperBound());

    double min = 0.0, max = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        min = plotArea.getX();
        max = plotArea.getMaxX();
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        min = plotArea.getMaxY();
        max = plotArea.getMinY();
    }

    if (isInverted())
        return pow(axisMax - ((java2DValue - min) / (max - min)) * (axisMax - axisMin));
    else
        return pow(axisMin + ((java2DValue - min) / (max - min)) * (axisMax - axisMin));
}

From source file:peakml.util.jfreechart.LognAxis.java

@Override
public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) {
    Range range = getRange();// w ww  .j av a 2 s .c om
    double axisMin = log(range.getLowerBound());
    double axisMax = log(range.getUpperBound());

    double min = 0.0, max = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        min = plotArea.getMinX();
        max = plotArea.getMaxX();
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        min = plotArea.getMaxY();
        max = plotArea.getMinY();
    }

    value = log(value);
    if (isInverted())
        return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min));
    else
        return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min));
}

From source file:Clip.java

/**
 * @see java.lang.Object#equals(java.lang.Object)
 *//*from w  w  w .jav a  2s.  c  o  m*/
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;
    }
}