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.gumtree.vis.hist2d.Hist2DPanel.java

private void changeMaskYMax(double y) {
    Rectangle2D frame = getSelectedMask().getRectangleFrame();
    getSelectedMask().setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), Math.min(frame.getMinY(), y),
            frame.getWidth(), Math.abs(frame.getMinY() - y)));
}

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

private void changeMaskXMax(double x) {
    Rectangle2D frame = getSelectedMask().getRectangleFrame();
    getSelectedMask().setRectangleFrame(new Rectangle2D.Double(Math.min(frame.getMinX(), x), frame.getMinY(),
            Math.abs(frame.getMinX() - x), frame.getHeight()));
}

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

private void changeMaskXMin(double x) {
    Rectangle2D frame = getSelectedMask().getRectangleFrame();
    getSelectedMask().setRectangleFrame(new Rectangle2D.Double(Math.min(frame.getMaxX(), x), frame.getMinY(),
            Math.abs(frame.getMaxX() - x), frame.getHeight()));
}

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

@Override
public void zoom(Rectangle2D selection) {
    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = getChartRenderingInfo().getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = getChart().getPlot();/*w  ww . j ava  2  s  . c om*/
        if (p instanceof LinkAndBrushPlot) {

            PlotOrientation orientation = null;
            if (p instanceof XYPlot) {
                XYPlot xyPlot = (XYPlot) p;
                orientation = xyPlot.getOrientation();
            }
            if (p instanceof CategoryPlot) {
                CategoryPlot categoryPlot = (CategoryPlot) p;
                orientation = categoryPlot.getOrientation();
            }

            // here we tweak the notify flag on the plot so that only
            // one notification happens even though we update multiple
            // axes...

            boolean savedNotify = p.isNotify();
            p.setNotify(false);
            LinkAndBrushPlot LABPlot = (LinkAndBrushPlot) p;

            List<Pair<Integer, Range>> zoomedDomainAxisRanges = new LinkedList<Pair<Integer, Range>>();
            List<Pair<Integer, Range>> zoomedRangeAxisRanges = new LinkedList<Pair<Integer, Range>>();

            if (orientation == PlotOrientation.HORIZONTAL) {
                zoomedDomainAxisRanges
                        .addAll(LABPlot.calculateDomainAxesZoom(vLower, vUpper, zoomOnLinkAndBrushSelection));
                zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(hLower, hUpper, plotInfo,
                        selectOrigin, zoomOnLinkAndBrushSelection));
            } else {
                zoomedDomainAxisRanges
                        .addAll(LABPlot.calculateDomainAxesZoom(hLower, hUpper, zoomOnLinkAndBrushSelection));
                zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(vLower, vUpper, plotInfo,
                        selectOrigin, zoomOnLinkAndBrushSelection));
            }
            p.setNotify(savedNotify);

            if (zoomOnLinkAndBrushSelection) {
                informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.ZOOM_IN,
                        zoomedDomainAxisRanges, zoomedRangeAxisRanges));
            } else {
                informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.SELECTION,
                        zoomedDomainAxisRanges, zoomedRangeAxisRanges));
            }

        } else {
            super.zoom(selection);
        }
    }
}

From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java

/**
 * Handles a 'mouse released' event.  On Windows, we need to check if this 
 * is a popup trigger, but only if we haven't already been tracking a zoom
 * rectangle./*from  w  ww . j a va 2  s  .c om*/
 *
 * @param e  information about the event.
 */
public void mouseReleased(MouseEvent e) {

    if (this.zoomRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            hZoom = this.rangeZoomable;
            vZoom = this.domainZoomable;
        } else {
            hZoom = this.domainZoomable;
            vZoom = this.rangeZoomable;
        }

        boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < this.zoomPoint.getX()))
                    || (vZoom && (e.getY() < this.zoomPoint.getY()))) {
                // restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = this.zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            screenDataArea.getMaxX() - this.zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = this.zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(this.zoomRectangle.getHeight(),
                            screenDataArea.getMaxY() - this.zoomPoint.getY());
                } else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            screenDataArea.getMaxX() - this.zoomPoint.getX());
                    h = Math.min(this.zoomRectangle.getHeight(),
                            screenDataArea.getMaxY() - this.zoomPoint.getY());
                }
                if (activeROI != null) {
                    Rectangle2D rectangleArea = new Rectangle2D.Double(x, y, w, h);
                    g2 = (Graphics2D) getGraphics();
                    g2.setPaint(activeROI.getColor());
                    g2.draw(rectangleArea);
                    activeROI.add(rectangleArea, getRange(rectangleArea));
                    RoiFromChartProcess process = new RoiFromChartProcess();
                    process.addParam("roi", activeROI);
                    process.addParam("raster", (FLyrRasterSE) rasterSE);
                    process.setActions(this);
                    process.start();
                    if (gestorRois != null) {
                        // Cargar la nueva ROI en el destor
                        gestorRois.clearRoiGraphics();
                    }
                }

            }
            this.zoomPoint = null;
            this.zoomRectangle = null;
            updateUI();
        } else {
            // Erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            drawRectangle(g2);
            g2.dispose();
            this.zoomPoint = null;
            this.zoomRectangle = null;
        }

    }

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

From source file:diet.gridr.g5k.util.ExtendedStackedBarRenderer.java

/**
 * Draws a stacked bar for a specific item.
 *
 * @param g2  the graphics device./*from w  ww  . j a va 2  s .  co m*/
 * @param state  the renderer state.
 * @param dataArea  the plot area.
 * @param plot  the plot.
 * @param domainAxis  the domain (category) axis.
 * @param rangeAxis  the range (value) axis.
 * @param dataset  the data.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {

    // nothing is drawn for null values...
    Number dataValue = dataset.getValue(row, column);
    if (dataValue == null) {
        return;
    }

    double value = dataValue.doubleValue();

    PlotOrientation orientation = plot.getOrientation();
    double barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge())
            - state.getBarWidth() / 2.0;

    double positiveBase = 0.0;
    double negativeBase = 0.0;

    for (int i = 0; i < row; i++) {
        Number v = dataset.getValue(i, column);
        if (v != null) {
            double d = v.doubleValue();
            if (d > 0) {
                positiveBase = positiveBase + d;
            } else {
                negativeBase = negativeBase + d;
            }
        }
    }

    double translatedBase;
    double translatedValue;
    RectangleEdge location = plot.getRangeAxisEdge();
    if (value > 0.0) {
        translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, location);
        translatedValue = rangeAxis.valueToJava2D(positiveBase + value, dataArea, location);
    } else {
        translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, location);
        translatedValue = rangeAxis.valueToJava2D(negativeBase + value, dataArea, location);
    }
    double barL0 = Math.min(translatedBase, translatedValue);
    double barLength = Math.max(Math.abs(translatedValue - translatedBase), getMinimumBarLength());

    Rectangle2D bar = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth());
    } else {
        bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength);
    }
    Paint seriesPaint = getItemPaint(row, column);
    g2.setPaint(seriesPaint);
    g2.fill(bar);
    if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        g2.setStroke(getItemStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(bar);
    }

    CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column);
    if (generator != null && isItemLabelVisible(row, column)) {
        drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0));
    }

    if (value > 0.0) {
        if (this.showPositiveTotal) {
            if (isLastPositiveItem(dataset, row, column)) {
                g2.setPaint(Color.black);
                g2.setFont(this.totalLabelFont);
                double total = calculateSumOfPositiveValuesForCategory(dataset, column);
                TextUtilities.drawRotatedString(this.totalFormatter.format(total), g2, (float) bar.getCenterX(),
                        (float) (bar.getMinY() - 4.0), TextAnchor.BOTTOM_CENTER, 0.0, TextAnchor.BOTTOM_CENTER);
            }
        }
    } else {
        if (this.showNegativeTotal) {
            if (isLastNegativeItem(dataset, row, column)) {
                g2.setPaint(Color.black);
                g2.setFont(this.totalLabelFont);
                double total = calculateSumOfNegativeValuesForCategory(dataset, column);
                TextUtilities.drawRotatedString(String.valueOf(total), g2, (float) bar.getCenterX(),
                        (float) (bar.getMaxY() + 4.0), TextAnchor.TOP_CENTER, 0.0, TextAnchor.TOP_CENTER);
            }
        }
    }

    // collect entity and tool tip information...
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            String tip = null;
            CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
            if (tipster != null) {
                tip = tipster.generateToolTip(dataset, row, column);
            }
            String url = null;
            if (getItemURLGenerator(row, column) != null) {
                url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
            }
            CategoryItemEntity entity = new CategoryItemEntity(bar, tip, url, dataset, row,
                    dataset.getColumnKey(column), column);
            entities.add(entity);
        }
    }

}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

/**
 * Draws a horizontal line used to trace the mouse position to the vertical axis.
 *
 * @param y  the y-coordinate of the trace line.
 *//* w w w . j  a v a  2  s  . c  o  m*/
private void drawVerticalAxisTrace(int y) {

    Graphics2D g2 = (Graphics2D) getGraphics();
    Rectangle2D dataArea = getScaledDataArea();

    g2.setXORMode(java.awt.Color.orange);
    if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {

        if (horizontalTraceLine != null) {
            g2.draw(horizontalTraceLine);
            horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
        } else {
            horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
        }
        g2.draw(horizontalTraceLine);
    } else {
        if (verticalTraceLine != null) {
            g2.draw(verticalTraceLine);
            verticalTraceLine = null;
        }
        if (horizontalTraceLine != null) {
            g2.draw(horizontalTraceLine);
            horizontalTraceLine = null;
        }

    }
}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

private void renderCrosshairs(Rectangle2D dataArea, Graphics2D g2) {
    int r = 5;//from  w ww.j  a v  a  2  s .  com
    Color fill = new Color(255, 255, 255, 192);
    Color outline = new Color(0, 0, 0, 128);
    double rx = this.domainAxis.valueToJava2D(this.getDomainCrosshairValue(), dataArea, RectangleEdge.BOTTOM);
    double minY = this.rangeAxis.valueToJava2D(dataArea.getMinY(), dataArea, RectangleEdge.LEFT);
    double maxY = this.rangeAxis.valueToJava2D(dataArea.getMaxY(), dataArea, RectangleEdge.RIGHT);
    double ry = this.rangeAxis.valueToJava2D(this.getRangeCrosshairValue(), dataArea, RectangleEdge.LEFT);
    double minX = this.domainAxis.valueToJava2D(dataArea.getMinX(), dataArea, RectangleEdge.BOTTOM);
    double maxX = this.domainAxis.valueToJava2D(dataArea.getMaxX(), dataArea, RectangleEdge.TOP);
    g2.setColor(fill);
    //        Rectangle2D.Double domainCrossHair = new Rectangle2D.Double(rx - 1, minY, 3, maxY - minY);
    //        Rectangle2D.Double rangeCrossHair = new Rectangle2D.Double(minX, ry - 1, maxX - minX, 3);
    //        g2.fill(domainCrossHair);
    //        g2.fill(rangeCrossHair);
    g2.setColor(outline);
    //        g2.draw(domainCrossHair);
    //        g2.draw(rangeCrossHair);
    //System.out.println("CH: " + rx + "," + ry);
    Ellipse2D.Double el2 = new Ellipse2D.Double(rx - r, ry - r, 2 * r, 2 * r);
    //            g2.drawOval(rx - r, ry - r, 2 * r, 2 * r);
    g2.fill(el2);
    g2.draw(el2);
}

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

private void moveMask(Point2D point) {
    if (maskMovePoint != null && getSelectedMask() != null) {
        Rectangle2D frame = getSelectedMask().getRectangleFrame();
        getSelectedMask().setRectangleFrame(new Rectangle2D.Double(
                frame.getMinX() + point.getX() - maskMovePoint.getX(),
                frame.getMinY() + point.getY() - maskMovePoint.getY(), frame.getWidth(), frame.getHeight()));
        maskMovePoint = point;//from www  . j  a  v  a2 s  .  c o  m
        fireMaskUpdateEvent(getSelectedMask());
    }
}

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

@Override
public void moveSelectedMask(int direction) {
    Abstract2DMask selectedMask = getSelectedMask();
    if (selectedMask == null) {
        return;//from www. j  a  va2  s.  c  o  m
    }
    double blockWidth = 0;
    double blockHeight = 0;
    try {
        XYBlockRenderer render = (XYBlockRenderer) ((XYPlot) getChart().getPlot()).getRenderer();
        blockWidth = render.getBlockWidth();
        blockHeight = render.getBlockHeight();
        if (getChart().getXYPlot().getDomainAxis().isInverted()) {
            blockWidth = -blockHeight;
        }
        if (getChart().getXYPlot().getRangeAxis().isInverted()) {
            blockHeight = -blockHeight;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    Rectangle2D frame = selectedMask.getRectangleFrame();
    switch (direction) {
    case SWT.ARROW_UP:
        selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), frame.getMinY() + blockHeight,
                frame.getWidth(), frame.getHeight()));
        break;
    case SWT.ARROW_LEFT:
        selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX() - blockWidth, frame.getMinY(),
                frame.getWidth(), frame.getHeight()));
        break;
    case SWT.ARROW_RIGHT:
        selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX() + blockWidth, frame.getMinY(),
                frame.getWidth(), frame.getHeight()));
        break;
    case SWT.ARROW_DOWN:
        selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), frame.getMinY() - blockHeight,
                frame.getWidth(), frame.getHeight()));
        break;
    default:
        break;
    }
    repaint();
    fireMaskUpdateEvent(getSelectedMask());
}