List of usage examples for java.awt.geom Rectangle2D getMaxY
public double getMaxY()
From source file:ro.cs.products.landsat.LandsatSearch.java
@Override public void setAreaOfInterest(Polygon2D polygon) { super.setAreaOfInterest(polygon); final Rectangle2D bounds2D = polygon.getBounds2D(); this.keyValues.add(new BasicNameValuePair("upperLeftCornerLatitude", String.valueOf(bounds2D.getMaxY()))); this.keyValues.add(new BasicNameValuePair("lowerRightCornerLatitude", String.valueOf(bounds2D.getMinY()))); this.keyValues.add(new BasicNameValuePair("lowerLeftCornerLongitude", String.valueOf(bounds2D.getMinX()))); this.keyValues.add(new BasicNameValuePair("upperRightCornerLongitude", String.valueOf(bounds2D.getMaxX()))); }
From source file:com.projity.pm.graphic.xbs.XbsLayout.java
protected void updateBounds(int level, Point2D origin, Rectangle2D ref) {//cache in current version isn't a tree double y = origin.getY() + ref.getHeight() / 2 + ref.getMaxY() * (level - 1); Point2D childCenter, center;/*from ww w .j a v a 2 s .c om*/ double x0, x1; GraphicNode node, child; boolean hasChild; for (ListIterator i = cache.getIterator(); i.hasNext();) { node = (GraphicNode) i.next(); if (node.getLevel() == level) { x0 = -1; x1 = -1; hasChild = false; while (i.hasNext()) { child = (GraphicNode) i.next(); if (child.getLevel() <= level) { i.previous(); break; } else if (child.getLevel() == level + 1) { hasChild = true; childCenter = child.getXbsCenter(); if (x0 == -1 || childCenter.getX() < x0) x0 = childCenter.getX(); if (x1 == -1 || childCenter.getX() > x1) x1 = childCenter.getX(); dependencies.add(new GraphicDependency(node, child, null)); } } if (hasChild) setShape(node, ref, (x0 + x1) / 2, y); } } }
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 w w w . j a v a 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:ca.sqlpower.wabit.report.ChartRenderer.java
public boolean renderReportContent(Graphics2D g, double width, double height, double scaleFactor, int pageIndex, boolean printing, SPVariableResolver variablesContext) { if (printing) { // If we're printing a streaming query, we have to // print whatever's displayed. if (this.chartCache == null || (this.chartCache != null && !this.chartCache.getQuery().isStreaming())) { refresh(false);/*from w w w .j av a 2s. co m*/ } } else if (needsRefresh || this.chartCache == null) { // No chart loaded. Doing a refresh will trigger a new // redraw later on. refresh(); return false; } JFreeChart jFreeChart = null; try { jFreeChart = ChartSwingUtil.createChartFromQuery(chartCache); if (jFreeChart == null) { g.drawString("Loading...", 0, g.getFontMetrics().getHeight()); return false; } Rectangle2D area = new Rectangle2D.Double(0, 0, width, height); // first pass establishes rendering info but draws nothing ChartRenderingInfo info = new ChartRenderingInfo(); Graphics2D dummyGraphics = (Graphics2D) g.create(0, 0, 0, 0); jFreeChart.draw(dummyGraphics, area, info); dummyGraphics.dispose(); // now for real Rectangle2D plotArea = info.getPlotInfo().getDataArea(); ChartGradientPainter.paintChartGradient(g, area, (int) plotArea.getMaxY()); jFreeChart.draw(g, area); } catch (Exception e) { logger.error("Error while rendering chart", e); g.drawString("Could not render chart: " + e.getMessage(), 0, g.getFontMetrics().getHeight()); } return false; }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java
/** * Returns a point based on (x, y) but constrained to be within the bounds * of the given rectangle. This method could be moved to JCommon. * * @param x the x-coordinate./* www .java2 s .c om*/ * @param y the y-coordinate. * @param area the rectangle (<code>null</code> not permitted). * * @return A point within the rectangle. */ protected Point getPointInRectangle(int x, int y, Rectangle2D area) { x = (int) Math.max(Math.ceil(area.getMinX()), Math.min(x, Math.floor(area.getMaxX()))); y = (int) Math.max(Math.ceil(area.getMinY()), Math.min(y, Math.floor(area.getMaxY()))); return new Point(x, y); }
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()); }//w w w . jav a 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:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.CustomLegendGraphic.java
@Override public void draw(Graphics2D g2, Rectangle2D area) { area = trimMargin(area);/*from ww w .ja v a 2s.c o m*/ drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); if (isLineVisible()) { Point2D location = RectangleAnchor.coordinates(area, getShapeLocation()); Shape aLine = ShapeUtilities.createTranslatedShape(getLine(), getShapeAnchor(), location.getX(), location.getY()); g2.setPaint(getLinePaint()); g2.setStroke(getLineStroke()); g2.draw(aLine); } if (isShapeVisible()) { Point2D location = RectangleAnchor.coordinates(area, getShapeLocation()); Shape s = ShapeUtilities.createTranslatedShape(getShape(), getShapeAnchor(), location.getX(), location.getY()); if (isShapeFilled()) { Paint p = getFillPaint(); if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) getFillPaint(); p = getFillPaintTransformer().transform(gp, s); } else if (p instanceof LinearGradientPaint) { LinearGradientPaint gradient = (LinearGradientPaint) p; Rectangle2D bounds = s.getBounds2D(); p = getTranslatedLinearGradientPaint(gradient, new Point2D.Double(bounds.getMinX(), bounds.getMinY()), new Point2D.Double(bounds.getMaxX(), bounds.getMaxY()), false); } g2.setPaint(p); g2.fill(s); } if (isShapeOutlineVisible()) { g2.setPaint(getOutlinePaint()); g2.setStroke(getOutlineStroke()); g2.draw(s); } } }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java
/** * Draw a box to the left of the selected region, and one to the right, that together * encompass everything but the selection * * * @param selectedRegion//from w w w.j a v a 2 s . c om * @param stroke * @param color */ protected void drawAllButSelectedRegionHoriz(Rectangle2D selectedRegion, Stroke stroke, Color color, boolean xorMode, Graphics2D g2) { Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea(); Rectangle2D firstBox = new Rectangle((int) scaledDataArea.getMinX(), (int) scaledDataArea.getMinY(), (int) (selectedRegion.getMinX() - scaledDataArea.getMinX()), (int) scaledDataArea.getMaxY()); Rectangle2D secondBox = new Rectangle((int) selectedRegion.getMaxX(), (int) scaledDataArea.getMinY(), (int) (scaledDataArea.getMaxX() - selectedRegion.getMaxX()), (int) scaledDataArea.getMaxY()); drawSelectedRegion(firstBox, stroke, color, xorMode, g2); drawSelectedRegion(secondBox, stroke, color, xorMode, g2); }
From source file:net.sourceforge.processdash.ui.lib.chart.DiscLegendAxis.java
/** * Converts a coordinate in Java2D space on the legend axis to the corresponding * disc area./*from ww w.ja v a2 s.co m*/ */ @Override public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { if (discItemDistributor == null) { // This should not happen since prior to using a legend axis, a DiscPlot // should set a DiscItemDistributor. return 0.0; } double scaledDiameter = area.getMaxY() - java2DValue; double discDiameter = scaledDiameter / discItemDistributor.getScale(); double discRadius = discDiameter / 2; double value = Math.PI * discRadius * discRadius; return value; }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ZoomHandlerFX.java
@Override public void handleMouseReleased(ChartCanvas canvas, MouseEvent e) { Plot p = canvas.getChart().getPlot(); if (!(p instanceof Zoomable)) { return;/* w w w . j a va2 s. c om*/ } boolean hZoom, vZoom; Zoomable z = (Zoomable) p; if (z.getOrientation().isHorizontal()) { hZoom = z.isRangeZoomable(); vZoom = z.isDomainZoomable(); } else { hZoom = z.isDomainZoomable(); vZoom = z.isRangeZoomable(); } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.startPoint.getX()) >= 10; boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.startPoint.getY()) >= 10; if (zoomTrigger1 || zoomTrigger2) { Point2D endPoint = new Point2D.Double(e.getX(), e.getY()); PlotRenderingInfo pri = canvas.getRenderingInfo().getPlotInfo(); if ((hZoom && (e.getX() < this.startPoint.getX())) || (vZoom && (e.getY() < this.startPoint.getY()))) { boolean saved = p.isNotify(); p.setNotify(false); z.zoomDomainAxes(0, pri, endPoint); z.zoomRangeAxes(0, pri, endPoint); p.setNotify(saved); } else { double x = this.startPoint.getX(); double y = this.startPoint.getY(); double w = e.getX() - x; double h = e.getY() - y; Rectangle2D dataArea = canvas.findDataArea(this.startPoint); double maxX = dataArea.getMaxX(); double maxY = dataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { y = dataArea.getMinY(); w = Math.min(w, maxX - this.startPoint.getX()); h = dataArea.getHeight(); } else if (!hZoom) { x = dataArea.getMinX(); w = dataArea.getWidth(); h = Math.min(h, maxY - this.startPoint.getY()); } else { w = Math.min(w, maxX - this.startPoint.getX()); h = Math.min(h, maxY - this.startPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); boolean saved = p.isNotify(); p.setNotify(false); double pw0 = percentW(x, dataArea); double pw1 = percentW(x + w, dataArea); double ph0 = percentH(y, dataArea); double ph1 = percentH(y + h, dataArea); PlotRenderingInfo info = this.viewer.getRenderingInfo().getPlotInfo(); if (z.getOrientation().isVertical()) { z.zoomDomainAxes(pw0, pw1, info, endPoint); z.zoomRangeAxes(1 - ph1, 1 - ph0, info, endPoint); } else { z.zoomRangeAxes(pw0, pw1, info, endPoint); z.zoomDomainAxes(1 - ph1, 1 - ph0, info, endPoint); } p.setNotify(saved); } } viewer.hideZoomRectangle(); this.startPoint = null; canvas.clearLiveHandler(); }