Example usage for java.awt.geom Rectangle2D getMinX

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

Introduction

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

Prototype

public double getMinX() 

Source Link

Document

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

Usage

From source file:ec.ui.view.RevisionSaSeriesView.java

private void showSelectionPopup(Rectangle2D rectangle) {
    XYPlot plot = chartpanel_.getChart().getXYPlot();
    Rectangle2D dataArea = chartpanel_.getScreenDataArea();
    DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
    double minX = domainAxis.java2DToValue(rectangle.getMinX(), dataArea, plot.getDomainAxisEdge());
    double maxX = domainAxis.java2DToValue(rectangle.getMaxX(), dataArea, plot.getDomainAxisEdge());

    Date startDate = new Date((long) minX);
    Date endDate = new Date((long) maxX);
    TsPeriod start = new TsPeriod(firstPeriod.getFrequency(), startDate);
    TsPeriod end = new TsPeriod(firstPeriod.getFrequency(), endDate);

    if (end.minus(start) == 0) {
        return;/*from  w ww.j ava  2  s  .  c om*/
    }

    TsPeriodSelector sel = new TsPeriodSelector();
    sel.between(start.firstday(), end.lastday());
    List<TsData> listSeries = history_.Select(info_, startDate, endDate);
    List<TsData> revSeries = new ArrayList<>();

    for (TsData t : listSeries) {
        revSeries.add(t.select(sel));
    }

    Point pt = new Point((int) rectangle.getX(), (int) rectangle.getY());
    pt.translate(3, 3);
    SwingUtilities.convertPointToScreen(pt, chartpanel_);
    popup.setLocation(pt);
    popup.setChartTitle(info_.toUpperCase() + " First estimations");
    popup.setTsData(sRef.select(sel), revSeries);
    popup.setVisible(true);
    chartpanel_.repaint();
}

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

public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) {

    state = STATE_RUNNING;/*from  w ww . j a  v  a  2  s .co  m*/

    if (plot.isAlpha()) {
        g2.setComposite(AlphaComposite.SrcOver);
    }

    Stepper.Point2D result = stepper.getCurrentPoint2D();

    int transX, transY;

    double start = (int) dataArea.getMinX();
    double end = (int) dataArea.getMaxX();

    double[] value = new double[1];

    int prevY = 0;
    boolean flagOld = false;
    boolean flagNew = false;

    label: for (double i = start; i <= end; i += 1) {
        value[0] = this.domainAxis.java2DToValue(i, dataArea, RectangleEdge.BOTTOM);

        stepper.setInitialValue(value);
        stepper.initialize();

        for (int j = 0; j < power; j++) {
            stepper.step();
        }

        result = stepper.getCurrentPoint2D();

        transX = (int) i;
        transY = (int) rangeAxis.valueToJava2D(result.getX(), dataArea, RectangleEdge.LEFT);
        flagNew = Double.isNaN(result.getX());

        if (bigDots) {
            g2.fillRect(transX - 1, transY - 1, 3, 3);
        } else {
            g2.fillRect(transX, transY, 1, 1);
        }

        if (connectWithLines) {
            if (i > start) {
                if (!flagOld && !flagNew)
                    g2.drawLine(transX, transY, transX - 1, prevY);
            }

            prevY = transY;
            flagOld = flagNew;
        }

        if (stopped) {
            state = STATE_STOPPED;
            return;
        }

    }

    if (animate) {
        animateCowebPlot(g2, dataArea);
    }

    state = STATE_FINISHED;
}

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 {// ww w. j  av  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:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private ChartPanel createChartPanel(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();//from www.  java2 s .  c  o  m

    plot.setForegroundAlpha(0.85f);
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    ChartPanel chartPanel = new ChartPanel(chart);

    MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, chartPanel,
            "histogram_plot_area", "Mask generated from selected histogram plot area", Color.RED,
            PlotAreaSelectionTool.AreaType.X_RANGE) {

        @Override
        protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) {
            Rectangle2D bounds = shape.getBounds2D();
            return createMaskExpression(bounds.getMinX(), bounds.getMaxX());
        }

        protected String createMaskExpression(double x1, double x2) {
            String bandName = BandArithmetic.createExternalName(getRaster().getName());
            HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig();
            return String.format("%s >= %s && %s <= %s", bandName,
                    model.hasStx(currentConfig)
                            ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x1)
                            : x1,
                    bandName,
                    model.hasStx(currentConfig)
                            ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x2)
                            : x2);
        }
    };

    chartPanel.getPopupMenu().addSeparator();
    chartPanel.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem());
    chartPanel.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem());
    chartPanel.getPopupMenu().addSeparator();
    chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem());
    return chartPanel;
}

From source file:edu.ucla.stat.SOCR.chart.gui.CircleDrawer.java

/**
 * Draws the circle./*ww w . j ava2 s  .  com*/
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(), area.getMaxY());
    Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(), area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:org.n52.server.sos.generator.EESGenerator.java

@Override
public RepresentationResponse producePresentation(DesignOptions options) throws Exception {
    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 ww  w .j ava  2  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: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. ja v a2s . co 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: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 . ja v  a2  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:org.jfree.chart.demo.CircleDrawer.java

/**
 * Draws the circle.//from  w  ww .j a va 2  s  .com
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(final Graphics2D g2, final Rectangle2D area) {
    final Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    final Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(),
            area.getMaxY());
    final Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(),
            area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

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

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

    Range range = rangeAxis.getRange();/* w w  w  .j  a  v  a  2 s . com*/
    if (!range.contains(value)) {
        return;
    }

    Line2D line = null;
    double v = rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
    line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);

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

}