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:net.sf.maltcms.chromaui.annotations.XYSelectableShapeAnnotation.java

/**
 *
 * @param arg0/*from ww w  . j a va 2s  . c o m*/
 * @param arg1
 * @param arg2
 * @param arg3
 * @param arg4
 * @param arg5
 * @param arg6
 */
@Override
public void draw(Graphics2D arg0, XYPlot arg1, Rectangle2D arg2, ValueAxis arg3, ValueAxis arg4, int arg5,
        PlotRenderingInfo arg6) {
    //System.out.println("Annotation "+toString()+" is active: "+isActive());
    PlotOrientation orientation = arg1.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(arg1.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(arg1.getRangeAxisLocation(), orientation);

    // compute transform matrix elements via sample points. Assume no
    // rotation or shear.
    Rectangle2D bounds = this.s.getBounds2D();
    double x0 = bounds.getMinX();
    double x1 = bounds.getMaxX();
    double xx0 = arg3.valueToJava2D(x0, arg2, domainEdge);
    double xx1 = arg3.valueToJava2D(x1, arg2, domainEdge);
    double m00 = (xx1 - xx0) / (x1 - x0);
    double m02 = xx0 - x0 * m00;

    double y0 = bounds.getMaxY();
    double y1 = bounds.getMinY();
    double yy0 = arg4.valueToJava2D(y0, arg2, rangeEdge);
    double yy1 = arg4.valueToJava2D(y1, arg2, rangeEdge);
    double m11 = (yy1 - yy0) / (y1 - y0);
    double m12 = yy0 - m11 * y0;

    //  create transform & transform shape
    Shape s = null, ch = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        AffineTransform t1 = new AffineTransform(0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
        AffineTransform t2 = new AffineTransform(m11, 0.0f, 0.0f, m00, m12, m02);
        s = t1.createTransformedShape(this.s);
        s = t2.createTransformedShape(s);
        //            ch = t1.createTransformedShape(this.ch);
        //            ch = t2.createTransformedShape(ch);
    } else if (orientation == PlotOrientation.VERTICAL) {
        AffineTransform t = new AffineTransform(m00, 0, 0, m11, m02, m12);
        s = t.createTransformedShape(this.s);
        //            ch = t.createTransformedShape(this.ch);
    }

    if (this.active) {
        arg0.setPaint(this.highlight);
        //            double x = s.getBounds2D().getX();
        //            double y = s.getBounds2D().getY();
        //            double w = s.getBounds2D().getWidth();
        //            double h = s.getBounds2D().getHeight();
        //            Shape e = new Ellipse2D.Double(x, y, w, h);
        arg0.fill(s);
        arg0.setPaint(this.outline);
        arg0.draw(s);
        //            arg0.setStroke(this.stroke);
        //            arg0.draw(ch);
    } else {
        arg0.setPaint(this.fill);
        arg0.fill(s);
        arg0.setPaint(this.outline);
        arg0.draw(s);
    }
    addEntity(arg6, s, arg5, getToolTipText(), getURL());
    this.xyta.draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}

From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java

private void drawDomainGridLine(Graphics2D g2, Rectangle2D dataArea, double value) {

    Range range = domainAxis.getRange();
    if (!range.contains(value)) {
        return;// w ww .  j a va2 s .c  o m
    }

    Line2D line = null;
    double v = domainAxis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM);
    line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());

    g2.setPaint(gridPaint);
    g2.setStroke(gridStroke);
    g2.draw(line);

}

From source file:com.newatlanta.bluedragon.CustomClusteredXYBarRenderer.java

private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar,
        PlotOrientation orientation) {/* w w  w .  j av  a 2  s . c  o m*/
    Point2D result = null;
    double offset = getItemLabelAnchorOffset();
    double x0 = bar.getX() - offset;
    double x1 = bar.getX();
    double x2 = bar.getX() + offset;
    double x3 = bar.getCenterX();
    double x4 = bar.getMaxX() - offset;
    double x5 = bar.getMaxX();
    double x6 = bar.getMaxX() + offset;

    double y0 = bar.getMaxY() + offset;
    double y1 = bar.getMaxY();
    double y2 = bar.getMaxY() - offset;
    double y3 = bar.getCenterY();
    double y4 = bar.getMinY() + offset;
    double y5 = bar.getMinY();
    double y6 = bar.getMinY() - offset;

    if (anchor == ItemLabelAnchor.CENTER) {
        result = new Point2D.Double(x3, y3);
    } else if (anchor == ItemLabelAnchor.INSIDE1) {
        result = new Point2D.Double(x4, y4);
    } else if (anchor == ItemLabelAnchor.INSIDE2) {
        result = new Point2D.Double(x4, y4);
    } else if (anchor == ItemLabelAnchor.INSIDE3) {
        result = new Point2D.Double(x4, y3);
    } else if (anchor == ItemLabelAnchor.INSIDE4) {
        result = new Point2D.Double(x4, y2);
    } else if (anchor == ItemLabelAnchor.INSIDE5) {
        result = new Point2D.Double(x4, y2);
    } else if (anchor == ItemLabelAnchor.INSIDE6) {
        result = new Point2D.Double(x3, y2);
    } else if (anchor == ItemLabelAnchor.INSIDE7) {
        result = new Point2D.Double(x2, y2);
    } else if (anchor == ItemLabelAnchor.INSIDE8) {
        result = new Point2D.Double(x2, y2);
    } else if (anchor == ItemLabelAnchor.INSIDE9) {
        result = new Point2D.Double(x2, y3);
    } else if (anchor == ItemLabelAnchor.INSIDE10) {
        result = new Point2D.Double(x2, y4);
    } else if (anchor == ItemLabelAnchor.INSIDE11) {
        result = new Point2D.Double(x2, y4);
    } else if (anchor == ItemLabelAnchor.INSIDE12) {
        result = new Point2D.Double(x3, y4);
    } else if (anchor == ItemLabelAnchor.OUTSIDE1) {
        result = new Point2D.Double(x5, y6);
    } else if (anchor == ItemLabelAnchor.OUTSIDE2) {
        result = new Point2D.Double(x6, y5);
    } else if (anchor == ItemLabelAnchor.OUTSIDE3) {
        result = new Point2D.Double(x6, y3);
    } else if (anchor == ItemLabelAnchor.OUTSIDE4) {
        result = new Point2D.Double(x6, y1);
    } else if (anchor == ItemLabelAnchor.OUTSIDE5) {
        result = new Point2D.Double(x5, y0);
    } else if (anchor == ItemLabelAnchor.OUTSIDE6) {
        result = new Point2D.Double(x3, y0);
    } else if (anchor == ItemLabelAnchor.OUTSIDE7) {
        result = new Point2D.Double(x1, y0);
    } else if (anchor == ItemLabelAnchor.OUTSIDE8) {
        result = new Point2D.Double(x0, y1);
    } else if (anchor == ItemLabelAnchor.OUTSIDE9) {
        result = new Point2D.Double(x0, y3);
    } else if (anchor == ItemLabelAnchor.OUTSIDE10) {
        result = new Point2D.Double(x0, y5);
    } else if (anchor == ItemLabelAnchor.OUTSIDE11) {
        result = new Point2D.Double(x1, y6);
    } else if (anchor == ItemLabelAnchor.OUTSIDE12) {
        result = new Point2D.Double(x3, y6);
    }

    return result;
}

From source file:com.projity.pm.graphic.pert.PertLayout.java

public void updateBounds() {
    dependencyGraph.updatePertLevels();//from   ww w.  ja v a2s .  c  om

    GraphicConfiguration config = GraphicConfiguration.getInstance();

    Point2D origin = new Point2D.Double(config.getPertXOffset(), config.getPertYOffset());
    Rectangle2D ref = new Rectangle2D.Double(config.getPertXOffset(), config.getPertYOffset(),
            config.getPertCellWidth(), config.getPertCellHeight());
    int row = 0;
    int col = -1;
    setEmpty();
    for (Iterator i = cache.getIterator(); i.hasNext();) {
        GraphicNode current = (GraphicNode) i.next();
        int currentCol = cache.getPertLevel(current) - 1;
        if (currentCol <= col)
            row++;
        col = currentCol;

        TexturedShape texturedShape = findShape(current);
        if (texturedShape == null)
            continue;
        double centerX = origin.getX() + ref.getMaxX() * col + ref.getWidth() / 2;
        double centerY = origin.getY() + ref.getMaxY() * row + ref.getHeight() / 2;
        //System.out.println(centerX+"/"+centerY);
        GeneralPath shape = texturedShape.toGeneralPath(ref.getWidth(), ref.getHeight(),
                centerX - ref.getWidth() / 2, centerY, null);
        current.setPertShape(shape, centerX, centerY);
        Rectangle cellBounds = network.scale(shape.getBounds());
        if (isEmpty())
            bounds.setBounds(cellBounds);
        else
            Rectangle.union(bounds, cellBounds, bounds);
    }
    fireLayoutChanged();
}

From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java

private void chooseROI(Abstract2DMask mask) {
    if (mask != null) {
        roiName.setText(mask.getName());
        if (mask instanceof EllipseMask) {
            shapeLabel.setText(ELLIPSE_SHAPE_LABEL);
        } else {//w w  w  . jav  a  2 s  . c  om
            shapeLabel.setText(RECTANGLE_SHAPE_LABEL);
        }
        if (mask.isInclusive()) {
            inclusiveRadio.setSelected(true);
        } else {
            exclusiveRadio.setSelected(true);
        }
        Rectangle2D bounds = mask.getRectangleFrame();
        xMin.setText(String.valueOf(bounds.getMinX()));
        xMax.setText(String.valueOf(bounds.getMaxX()));
        yMin.setText(String.valueOf(bounds.getMinY()));
        yMax.setText(String.valueOf(bounds.getMaxY()));
        //         xMin.setText(String.format("%.2f", bounds.getMinX()));
        //         xMax.setText(String.format("%.2f", bounds.getMaxX()));
        //         yMin.setText(String.format("%.2f", bounds.getMinY()));
        //         yMax.setText(String.format("%.2f", bounds.getMaxY()));
        deleteButton.setEnabled(true);
    } else {
        roiName.setText(null);
        shapeLabel.setText(null);
        inclusiveRadio.setSelected(false);
        exclusiveRadio.setSelected(false);
        xMin.setText(null);
        xMax.setText(null);
        yMin.setText(null);
        yMax.setText(null);
    }
    applyButton.setEnabled(false);
}

From source file:net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.java

protected TextLine toTextLine(int measureIndex, Rectangle2D measuredBounds) {
    SimpleTextLine textLine = new SimpleTextLine();
    textLine.setAscent((float) -measuredBounds.getY());
    textLine.setDescent((float) (measuredBounds.getMaxY() - fontInfo.fontInfo.leading));
    textLine.setLeading(fontInfo.fontInfo.leading);
    textLine.setCharacterCount(measureIndex - paragraphPosition);
    textLine.setAdvance((float) measuredBounds.getWidth());
    textLine.setLeftToRight(paragraphLeftToRight);

    // update the paragraph position
    paragraphPosition = measureIndex;/* ww w  .j  av a  2 s. c o m*/

    return textLine;
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {

    // if we've been panning, we need to reset now that the mouse is
    // released...
    Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle");
    Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint");
    if (getChartFieldValueByName("panLast") != null) {
        setChartFieldValue((getChartFieldByName("panLast")), null);
        setCursor(Cursor.getDefaultCursor());
    } else if (zoomRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) {
            hZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
            vZoom = (Boolean) getChartFieldValueByName("domainZoomable");
        } else {/*from w  w  w  .  j a  va 2 s  .c o  m*/
            hZoom = (Boolean) getChartFieldValueByName("domainZoomable");
            vZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
        }

        boolean zoomTrigger1 = hZoom && Math
                .abs(e.getX() - zoomPoint.getX()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
        boolean zoomTrigger2 = vZoom && Math
                .abs(e.getY() - zoomPoint.getY()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < zoomPoint.getX())) || (vZoom && (e.getY() < zoomPoint.getY()))) {
                restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY());
                double maxX = screenDataArea.getMaxX();
                double maxY = screenDataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
                } else {
                    x = zoomPoint.getX();
                    y = zoomPoint.getY();
                    w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
                    h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
                zoom(zoomArea);
            }
            setChartFieldValue(getChartFieldByName("zoomPoint"), null);
            setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
        } else {
            // erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            if ((Boolean) getChartFieldValueByName("useBuffer")) {
                repaint();
            } else {
                drawZoomRectangle(g2, true);
            }
            g2.dispose();
            setChartFieldValue(getChartFieldByName("zoomPoint"), null);
            setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
        }

    }

    else if (e.isPopupTrigger()) {
        if (getChartFieldValueByName("popup") != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }

}

From source file:org.jax.maanova.plot.MaanovaChartPanel.java

/**
 * Convert the given rectangle in java2d coordinates to chart coordinates.
 * @param java2DRectangle the rectangle to convert
 * @return the converted rectangle/*from   w  w  w . j  a va2s  .  c  o m*/
 * @throws ClassCastException the plot isn't an XYPlot
 */
public Rectangle2D toChartRectangle(Rectangle2D java2DRectangle) throws ClassCastException {
    XYPlot plot = this.getChart().getXYPlot();
    Rectangle2D dataArea = this.chartRenderingInfo.getPlotInfo().getDataArea();

    double x1 = plot.getDomainAxis().java2DToValue(java2DRectangle.getMinX(), dataArea,
            plot.getDomainAxisEdge());
    double y1 = plot.getRangeAxis().java2DToValue(java2DRectangle.getMinY(), dataArea, plot.getRangeAxisEdge());
    double x2 = plot.getDomainAxis().java2DToValue(java2DRectangle.getMaxX(), dataArea,
            plot.getDomainAxisEdge());
    double y2 = plot.getRangeAxis().java2DToValue(java2DRectangle.getMaxY(), dataArea, plot.getRangeAxisEdge());

    return toNonNegativeWidthHeightRectangle(new Rectangle2D.Double(x1, y1, x2 - x1, y2 - y1));
}

From source file:org.jfree.experimental.chart.axis.LogAxis.java

/**
 * Converts a Java2D coordinate to an axis value, assuming that the
 * axis covers the specified <code>edge</code> of the <code>area</code>.
 * /*from w w  w .j a v a2s  .  c  o m*/
 * @param java2DValue  the Java2D coordinate.
 * @param area  the area.
 * @param edge  the edge that the axis belongs to.
 * 
 * @return A value along the axis scale.
 */
public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) {

    Range range = getRange();
    double axisMin = calculateLog(range.getLowerBound());
    double axisMax = calculateLog(range.getUpperBound());

    double min = 0.0;
    double max = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        min = area.getX();
        max = area.getMaxX();
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        min = area.getMaxY();
        max = area.getY();
    }
    double log = 0.0;
    if (isInverted()) {
        log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin);
    } else {
        log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin);
    }
    return calculateValue(log);
}

From source file:org.jfree.experimental.chart.axis.LogAxis.java

/**
 * Converts a value on the axis scale to a Java2D coordinate relative to 
 * the given <code>area</code>, based on the axis running along the 
 * specified <code>edge</code>.
 * /*from w  w  w.ja  v a 2 s.  c  om*/
 * @param value  the data value.
 * @param area  the area.
 * @param edge  the edge.
 * 
 * @return The Java2D coordinate corresponding to <code>value</code>.
 */
public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) {

    Range range = getRange();
    double axisMin = calculateLog(range.getLowerBound());
    double axisMax = calculateLog(range.getUpperBound());
    value = calculateLog(value);

    double min = 0.0;
    double max = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        min = area.getX();
        max = area.getMaxX();
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        max = area.getMinY();
        min = area.getMaxY();
    }
    if (isInverted()) {
        return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min);
    } else {
        return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min);
    }
}