List of usage examples for java.awt.geom Rectangle2D getMinY
public double getMinY()
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. j a va 2 s. co m*/ * @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); } }
From source file:com.newatlanta.bluedragon.CustomClusteredXYBarRenderer.java
private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar, PlotOrientation orientation) {//w w w . j av a2s . co 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:gda.plots.DataMagnifierWindow.java
/** * The SimplePlot will call this method when the Rectangle to be magnified has changed. * //from www .j a v a2 s. 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:Hexagon.java
public void align(Rectangle2D bounds, Direction direction) { // these are defined here INSTEAD of in the switch, or it won't compile Point2D newTopRight, newTopLeft, newBottomRight, newBottomLeft; Point2D oldTopRight, oldTopLeft, oldBottomRight, oldBottomLeft; switch (direction) { case NorthEast: newTopRight = new Point2D.Double(bounds.getMaxX(), bounds.getMinY()); oldTopRight = boundingCorners.get(BoundingCorner.TopRight); translate(newTopRight.getX() - oldTopRight.getX(), // deltaX newTopRight.getY() - oldTopRight.getY() // deltaY );//from ww w . j a va 2 s .c om break; case East: newTopRight = new Point2D.Double(bounds.getMaxX(), bounds.getMinY()); oldTopRight = boundingCorners.get(BoundingCorner.TopRight); translate(newTopRight.getX() - oldTopRight.getX(), // deltaX 0 // deltaY ); break; case SouthEast: newBottomRight = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY()); oldBottomRight = boundingCorners.get(BoundingCorner.BottomRight); translate(newBottomRight.getX() - oldBottomRight.getX(), // deltaX newBottomRight.getY() - oldBottomRight.getY() // deltaY ); break; case SouthWest: newBottomLeft = new Point2D.Double(bounds.getMinX(), bounds.getMaxY()); oldBottomLeft = boundingCorners.get(BoundingCorner.BottomLeft); translate(newBottomLeft.getX() - oldBottomLeft.getX(), // deltaX newBottomLeft.getY() - oldBottomLeft.getY() // deltaY ); break; case West: newTopLeft = new Point2D.Double(bounds.getMinX(), bounds.getMinY()); oldTopLeft = boundingCorners.get(BoundingCorner.TopLeft); translate(newTopLeft.getX() - oldTopLeft.getX(), // deltaX 0 // deltaY ); break; case NorthWest: newTopLeft = new Point2D.Double(bounds.getMinX(), bounds.getMinY()); oldTopLeft = boundingCorners.get(BoundingCorner.TopLeft); translate(newTopLeft.getX() - oldTopLeft.getX(), // deltaX newTopLeft.getY() - oldTopLeft.getY() // deltaY ); break; } }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
private ChartPanel createChartPanel(final JFreeChart chart) { scatterPlotDisplay = new ChartPanel(chart) { @Override/*from w ww . j av a 2s .co m*/ public void restoreAutoBounds() { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... final XYPlot plot = chart.getXYPlot(); boolean savedNotify = plot.isNotify(); plot.setNotify(false); xAxisRangeControl.adjustAxis(plot.getDomainAxis(), 3); yAxisRangeControl.adjustAxis(plot.getRangeAxis(), 3); plot.setNotify(savedNotify); } }; MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, scatterPlotDisplay, "correlative_plot_area", "Mask generated from selected correlative plot area", Color.RED, PlotAreaSelectionTool.AreaType.Y_RANGE) { @Override protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) { Rectangle2D bounds = shape.getBounds2D(); return createMaskExpression(bounds.getMinY(), bounds.getMaxY()); } protected String createMaskExpression(double x1, double x2) { String bandName = BandArithmetic.createExternalName(getRaster().getName()); return String.format("%s >= %s && %s <= %s", bandName, x1, bandName, x2); } }; scatterPlotDisplay.getPopupMenu().addSeparator(); scatterPlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem()); scatterPlotDisplay.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem()); scatterPlotDisplay.getPopupMenu().addSeparator(); scatterPlotDisplay.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return scatterPlotDisplay; }
From source file:org.gumtree.vis.awt.time.TimePlotPanel.java
@Override protected void drawToolTipFollower(Graphics2D g2, int x, int y) { Rectangle2D dataArea = getScreenDataArea(); if (((int) dataArea.getMinX() <= x) && (x <= (int) dataArea.getMaxX()) && ((int) dataArea.getMinY() <= y) && (y <= (int) dataArea.getMaxY())) { Date date = new Date((long) getChartX()); String text = ""; SimpleDateFormat format = new SimpleDateFormat("EEE d MMM HH:mm:ss"); StringBuffer buffer = new StringBuffer(); format.format(date, buffer, new FieldPosition(0)); text = buffer.toString();//from w ww . j a v a 2 s. c om text = "(" + text + String.format(", %.2f)", getChartY()); int xLoc = x + 10; int yLoc = y + 20; double width = text.length() * 5.5; double height = 15; if (xLoc + width > dataArea.getMaxX()) { xLoc = (int) (x - width); } if (yLoc + height > dataArea.getMaxY()) { yLoc = (int) (y - height); } Rectangle2D toolTipArea = new Rectangle2D.Double(xLoc, yLoc, width, height); g2.setColor(Color.white); g2.fill(toolTipArea); g2.setColor(Color.black); g2.drawString(text, xLoc + 3, yLoc + 11); } }
From source file:Polygon2D.java
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Rectangle2D./* w ww . ja va 2 s.c o m*/ * @param rec the Rectangle2D * @exception NullPointerException rec is <code>null</code>. */ public Polygon2D(Rectangle2D rec) { if (rec == null) { throw new IndexOutOfBoundsException("null Rectangle"); } npoints = 4; xpoints = new float[4]; ypoints = new float[4]; xpoints[0] = (float) rec.getMinX(); ypoints[0] = (float) rec.getMinY(); xpoints[1] = (float) rec.getMaxX(); ypoints[1] = (float) rec.getMinY(); xpoints[2] = (float) rec.getMaxX(); ypoints[2] = (float) rec.getMaxY(); xpoints[3] = (float) rec.getMinX(); ypoints[3] = (float) rec.getMaxY(); calculatePath(); }
From source file:com.lfx.web.WebChartXYPlot.java
/** * Draws the gridlines for the plot's primary range axis, if they are * visible./*w ww. j a v a 2s . co m*/ * * @param g2 the graphics device. * @param area the data area. * @param ticks the ticks. * * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { Composite oldcomp = g2.getComposite(); Paint bandPaint = getBackgroundPaint(); if (bandPaint != null && bandPaint instanceof java.awt.Color) { g2.setComposite(AlphaComposite.SrcIn); java.awt.Color bandcolor = (java.awt.Color) (bandPaint); boolean fillBand = true; ValueAxis axis = getDomainAxis(); double previous = axis.getLowerBound(); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); if (!tick.getTickType().equals(TickType.MAJOR)) continue; double current = tick.getValue(); double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge()); double y2 = axis.valueToJava2D(current, dataArea, getDomainAxisEdge()); Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth()); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); previous = current; fillBand = !fillBand; } double end = axis.getUpperBound(); double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge()); double y2 = axis.valueToJava2D(end, dataArea, getDomainAxisEdge()); Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth()); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); } else { super.drawDomainGridlines(g2, dataArea, ticks); } g2.setComposite(oldcomp); }
From source file:org.gumtree.vis.awt.CompositePanel.java
@Override public BufferedImage getImage() { BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D gc2 = image.createGraphics(); gc2.setBackground(Color.white); gc2.setPaint(Color.white);/*from ww w . ja v a 2s.com*/ gc2.fill(new Rectangle2D.Double(0, 0, getWidth(), getHeight())); for (IPlot plot : plotList) { if (plot instanceof JPanel) { JPanel panel = (JPanel) plot; Rectangle2D panelBounds = panel.getBounds(); Image panelImage = plot.getImage(); gc2.drawImage(panelImage, (int) panelBounds.getMinX(), (int) panelBounds.getMinY(), panel); } } gc2.dispose(); return image; }
From source file:it.unibo.alchemist.model.implementations.actions.SocialForceAgent.java
/** * Method used to retrieve the obstacle edge nearest to the pedestrian * /*w ww . j a v a 2 s . co m*/ * @param myx * - the current pedestrian x-coordinate position * @param myy * - the current pedestrian y-coordinate position * @param bounds * - the rectangle obstacle bounds * @return nearest - an array containing two Continuous2DEuclidean object * representing nearest edge vertices */ private Continuous2DEuclidean[] getNearestEdge(final double myx, final double myy, final Rectangle2D bounds) { Continuous2DEuclidean[] nearest = null; final double minX = bounds.getMinX(); final double maxX = bounds.getMaxX(); final double minY = bounds.getMinY(); final double maxY = bounds.getMaxY(); if (myx > minX && myx < maxX) { if (myy > maxY) { // above the obstacle nearest = new Continuous2DEuclidean[] { new Continuous2DEuclidean(bounds.getMinX(), bounds.getMaxY()), new Continuous2DEuclidean(bounds.getMaxX(), bounds.getMaxY()) }; } else if (myy < minY) { // under the obstacle nearest = new Continuous2DEuclidean[] { new Continuous2DEuclidean(bounds.getMinX(), bounds.getMinY()), new Continuous2DEuclidean(bounds.getMaxX(), bounds.getMinY()) }; } } else if (myy > minY && myy < maxY) { if (myx < minX) { // to the left the obstacle nearest = new Continuous2DEuclidean[] { new Continuous2DEuclidean(bounds.getMinX(), bounds.getMaxY()), new Continuous2DEuclidean(bounds.getMinX(), bounds.getMinY()) }; } else if (myx > maxX) { // to the right the obstacle nearest = new Continuous2DEuclidean[] { new Continuous2DEuclidean(bounds.getMaxX(), bounds.getMaxY()), new Continuous2DEuclidean(bounds.getMaxX(), bounds.getMinY()) }; } } return nearest; }