List of usage examples for java.awt.geom Rectangle2D getMaxX
public double getMaxX()
From source file:edu.ucla.stat.SOCR.chart.gui.CircleDrawer.java
/** * Draws the circle./*from w ww. j av a 2s .c om*/ * * @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.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 a2 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.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 . j a v a2 s . com 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:com.projity.pm.graphic.xbs.XbsLayout.java
protected int updateBounds(Point2D origin, Rectangle2D ref) {//cache in current version isn't a tree double x = origin.getX() + ref.getWidth() / 2; double y = origin.getY() + ref.getHeight() / 2; GraphicNode node, previous = null;//from ww w .j av a 2 s.com int maxLevel = 0; for (ListIterator i = cache.getIterator(); i.hasNext();) { node = (GraphicNode) i.next(); if (node.getLevel() > maxLevel) maxLevel = node.getLevel(); if (previous != null && node.getLevel() <= previous.getLevel()) { setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY())); x += ref.getMaxX(); } previous = node; } if (previous != null) { setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY())); } return maxLevel; }
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 . j a v a 2 s .com } 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:com.projity.pm.graphic.pert.PertLayout.java
public void updateBounds() { dependencyGraph.updatePertLevels();//from w ww. j a v a2 s . 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.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 v a 2 s .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:com.zilbo.flamingSailor.TE.model.Component.java
public boolean onSameLine(Rectangle2D otherGeom) { Double y1 = this.geom.getMinY(); Double y3 = this.geom.getMaxY(); Double y2 = otherGeom.getMinY(); Double y4 = otherGeom.getMaxY(); // we have some kind of crossover. if (y1 <= y4 && y1 >= y2) { // AND the boxes are touching if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5 || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) { // assume it's a super/subscript letter and call it the same line. return true; }/*from w w w . j a v a2 s. c o m*/ } // we have some kind of crossover. if (y2 <= y3 && y2 >= y1) { // AND the boxes are touching // logger.info(this.geom.getMinX() - otherGeom.getMaxX()); if (Math.abs(this.geom.getMinX() - otherGeom.getMaxX()) < 0.5 || (this.geom.getMaxX() - otherGeom.getMinX()) < 0.5) { // assume it's a super/subscript letter and call it the same line. return true; } } double yAveT = (y2 + y4) / 2; // double diff = (y4-y2)/4; if ((y1 <= (yAveT)) && ((yAveT) < y3)) { return true; } yAveT = (y1 + y3) / 2; return (y2 <= yAveT) && (yAveT < y4); }
From source file:org.jfree.chart.demo.CircleDrawer.java
/** * Draws the circle./*from ww w .jav a 2 s .c o m*/ * * @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();//from www . j av a 2 s. co m 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); }