List of usage examples for java.awt.geom Rectangle2D getY
public abstract double getY();
From source file:org.kalypsodeegree_impl.model.geometry.GM_Envelope_Impl.java
/** * returns a new GM_Envelope object representing the intersection of this GM_Envelope with the specified GM_Envelope. * * Note: If there is no intersection at all GM_Envelope will be null. * /* www. j a v a 2s . c o m*/ * @param bb * the GM_Envelope to be intersected with this GM_Envelope * @return the largest GM_Envelope contained in both the specified GM_Envelope and in this GM_Envelope. */ @Override public GM_Envelope createIntersection(final GM_Envelope bb) { Rectangle2D rect = new Rectangle2D.Double(bb.getMin().getX(), bb.getMin().getY(), bb.getWidth(), bb.getHeight()); final Rectangle2D rect2 = new Rectangle2D.Double(getMin().getX(), getMin().getY(), getWidth(), getHeight()); if (rect2.intersects(bb.getMin().getX(), bb.getMin().getY(), bb.getWidth(), bb.getHeight())) { rect = rect.createIntersection(rect2); } else { rect = null; } if (rect == null) { return null; } final double xmin = rect.getX(); final double ymin = rect.getY(); final double xmax = rect.getX() + rect.getWidth(); final double ymax = rect.getY() + rect.getHeight(); // TODO Check coordinate systems, if equal. return new GM_Envelope_Impl(xmin, ymin, xmax, ymax, m_coordinateSystem); }
From source file:ucar.unidata.idv.control.chart.WayPoint.java
/** * Draws the annotation./*from www. j a v a2s .c o m*/ * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info an optional info object that will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { super.setGraphicsState(g2); if (!getPlotWrapper().okToDraw(this)) { return; } g2.setStroke(new BasicStroke()); if (false && getSelected()) { g2.setColor(COLOR_SELECTED); } else { g2.setColor(getColor()); } x = getXFromValue(dataArea, domainAxis); int width2 = (int) (ANNOTATION_WIDTH / 2); int bottom = (int) (dataArea.getY() + dataArea.getHeight()); y = bottom; int[] xs = { x - width2, x + width2, x, x - width2 }; int[] ys = { bottom - ANNOTATION_WIDTH, bottom - ANNOTATION_WIDTH, bottom, bottom - ANNOTATION_WIDTH }; g2.fillPolygon(xs, ys, xs.length); if ((getName() != null) && !isForAnimation) { FontMetrics fm = g2.getFontMetrics(); int width = fm.stringWidth(getName()); int textLeft = x - width / 2; g2.drawString(getName(), textLeft, bottom - ANNOTATION_WIDTH - 2); } if (getSelected()) { g2.setColor(COLOR_SELECTED); g2.drawPolygon(xs, ys, xs.length); } if (getPropertyListeners().hasListeners(PROP_WAYPOINTVALUE) || isForAnimation) { g2.setColor(Color.gray); g2.drawLine(x, y - ANNOTATION_WIDTH, x, (int) dataArea.getY()); } boolean playSound = canPlaySound(); if (isForAnimation) { if (clockImage == null) { clockImage = GuiUtils.getImage("/auxdata/ui/icons/clock.gif"); } if (playSound) { g2.drawImage(clockImage, x - 8, (int) dataArea.getY() + 1, null); } else { g2.drawImage(clockImage, x - 8, (int) dataArea.getY() + 1, null); } } if (canPlaySound()) { if (noteImage == null) { noteImage = GuiUtils.getImage("/auxdata/ui/icons/note.gif"); } if (isForAnimation) { g2.drawImage(noteImage, x + 8, (int) dataArea.getY() + 1, null); } else { g2.drawImage(noteImage, x, (int) dataArea.getY() + 1, null); } } if (minutesSpan > 0.0) { int left = (int) domainAxis.valueToJava2D(domainValue - (minutesSpan * 60000) / 2, dataArea, RectangleEdge.BOTTOM); int right = (int) domainAxis.valueToJava2D(domainValue + (minutesSpan * 60000) / 2, dataArea, RectangleEdge.BOTTOM); g2.setPaint(Color.black); g2.setStroke(new BasicStroke(2.0f)); g2.drawLine(left, y, right, y); } }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Converts a Java2D coordinate to an axis value, assuming that the * axis covers the specified <code>edge</code> of the <code>area</code>. * /* w ww .j a va 2s .c o m*/ * @param java2DValue the Java2D coordinate. * @param area the area. * @param edge the edge that the axis belongs to. * * @return A value along the axis scale. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } double log = 0.0; if (isInverted()) { log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); } else { log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } return calculateValue(log); }
From source file:org.apache.pdfbox.contentstream.PDFStreamEngine.java
/** * Process the given tiling pattern. Allows the pattern matrix to be overridden for custom * rendering.//from w w w. ja v a 2 s. c o m * * @param tilingPattern the tiling pattern * @param color color to use, if this is an uncoloured pattern, otherwise null. * @param colorSpace color space to use, if this is an uncoloured pattern, otherwise null. * @param patternMatrix the pattern matrix, may be overridden for custom rendering. */ protected final void processTilingPattern(PDTilingPattern tilingPattern, PDColor color, PDColorSpace colorSpace, Matrix patternMatrix) throws IOException { PDResources parent = pushResources(tilingPattern); Matrix parentMatrix = initialMatrix; initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix); // save the original graphics state Stack<PDGraphicsState> savedStack = saveGraphicsStack(); // save a clean state (new clipping path, line path, etc.) Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D(); PDRectangle rect = new PDRectangle((float) bbox.getX(), (float) bbox.getY(), (float) bbox.getWidth(), (float) bbox.getHeight()); graphicsStack.push(new PDGraphicsState(rect)); // non-colored patterns have to be given a color if (colorSpace != null) { color = new PDColor(color.getComponents(), colorSpace); getGraphicsState().setNonStrokingColorSpace(colorSpace); getGraphicsState().setNonStrokingColor(color); getGraphicsState().setStrokingColorSpace(colorSpace); getGraphicsState().setStrokingColor(color); } // transform the CTM using the stream's matrix getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix); // clip to bounding box clipToRect(tilingPattern.getBBox()); processStreamOperators(tilingPattern); initialMatrix = parentMatrix; restoreGraphicsStack(savedStack); popResources(parent); }
From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or * a printer).//from w ww . j av a 2 s .c o m * * @param g2 the graphics device. * @param plotArea the area within which the plot (including axis labels) should be drawn. * @param info collects chart drawing information (<code>null</code> permitted). */ public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info) { // if (data == null) // return; // set up info collection... if (info != null) { info.setPlotArea(plotArea); } // adjust the drawing area for plot insets (if any)... Insets insets = getInsets(); if (insets != null) { plotArea.setRect(plotArea.getX() + insets.left, plotArea.getY() + insets.top, plotArea.getWidth() - insets.left - insets.right, plotArea.getHeight() - insets.top - insets.bottom); } AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(plotArea, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); /* if automatic bounds... */ if (!isNoData()) { if (this instanceof DmcRenderablePlot) { DmcPlotRenderer renderer; renderer = ((DmcRenderablePlot) this).getPlotRenderer(); if (renderer != null) { renderer.initialize(); if (renderer.getState() == DmcPlotRenderer.STATE_STOPPED) { return; } } } } AxisState domainAxisState = null, rangeAxisState = null; if (this.domainAxis != null) { double cursor; cursor = dataArea.getMaxY(); domainAxisState = this.domainAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, info); // cursor = info.getCursor(); } if (this.rangeAxis != null) { double cursor; cursor = dataArea.getMinX(); rangeAxisState = this.rangeAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, info); } if (drawGridlines == true && domainAxisState != null && rangeAxisState != null) { drawGridlines(g2, dataArea, domainAxisState.getTicks(), rangeAxisState.getTicks()); } Shape originalClip = g2.getClip(); g2.clip(dataArea); // Composite originalComposite = g2.getComposite(); // g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, // getForegroundAlpha())); // g2.setStroke(new BasicStroke(12.0F)); if (isNoData()) { drawNoDataMessage(g2, plotArea); } else { drawPlot(g2, dataArea, info); } g2.setClip(originalClip); drawOutline(g2, dataArea); }
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 w w .j a v a 2s .c o m 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.tsho.dmc2.core.chart.LyapunovRenderer.java
public boolean renderArea(Graphics2D g2, Rectangle2D dataArea) { g2.setPaint(plot.paint);//w w w . j a v a 2s .c o m if (pass == 1) { if (image != null) { double x = dataArea.getX(); double y = dataArea.getY(); //there is a problem when using Graphics2D with affine transform //and BufferedImage; using subclass of Image returned below. //rescaling needed because adding legend causes dataArea to change. Image scaledImage = image.getScaledInstance((int) dataArea.getWidth() - 1, (int) dataArea.getHeight() - 1, Image.SCALE_DEFAULT); g2.drawImage(scaledImage, (int) x + 1, (int) y + 1, (int) dataArea.getWidth() - 1, (int) dataArea.getHeight() - 1, this); //g2.translate(-1,-1); //g2.drawRect((int) x, (int) y, (int) dataArea.getWidth(),(int) dataArea.getHeight()); //g2.translate(1,1); } return true; } final double parHStep, parVStep; double parHLower = plot.getDomainAxis().getRange().getLowerBound(); double parHUpper = plot.getDomainAxis().getRange().getUpperBound(); double parVLower = plot.getRangeAxis().getRange().getLowerBound(); double parVUpper = plot.getRangeAxis().getRange().getUpperBound(); parHStep = Math.abs(parHUpper - parHLower) / dataArea.getWidth(); parVStep = Math.abs(parVUpper - parVLower) / dataArea.getHeight(); image = new BufferedImage((int) dataArea.getWidth(), (int) dataArea.getHeight(), BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer(); int[] data = dataBuffer.getData(); final double parHStart = parHLower + parHStep / 2; final double parVStart = parVUpper - parVStep / 2; if (model instanceof ODE) { double step = stepSize; // stepSize and timeStep probably mean the same thing, one for discrete another for ODE double[] result = new double[model.getNVar()]; for (int i = 0; i < (int) dataArea.getWidth(); i++) { for (int j = 0; j < (int) dataArea.getHeight(); j++) { parameters.put(firstParLabel, parHStart + i * parHStep); parameters.put(secondParLabel, parVStart - j * parVStep); int color; result = Lua.evaluateLyapunovExponentsODE(model, parameters, initialPoint, timePeriod, stepSize); if (result == null) { System.out.println("i: " + i + " j: " + j); System.out.println("par1: " + parHStart + i * parHStep); System.out.println("par2: " + parVStart + j * parVStep); g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); return false; } int zer = 0; int pos = 0; int neg = 0; int nan = 0; for (int ii = 0; ii < result.length; ii++) { if (Math.abs(result[ii]) == (1.0 / 0.0)) nan++; else if (Math.abs(result[ii]) <= epsilon) zer++; else if (result[ii] > epsilon) pos++; else if (result[ii] < (-epsilon)) neg++; else nan++; } color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB(); ExpsSigns es = new ExpsSigns(zer, pos, neg, nan); if (!signsSet.contains(es)) signsSet.add(es); data[i + j * (int) dataArea.getWidth()] = color; if (stopped == true) return false; if (j == (int) dataArea.getHeight() - 1) { g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); } } //end for } //end for } //end if ODE else { for (int i = 0; i < (int) dataArea.getWidth(); i++) { for (int j = 0; j < (int) dataArea.getHeight(); j++) { parameters.put(firstParLabel, parHStart + i * parHStep); parameters.put(secondParLabel, parVStart - j * parVStep); double[] result; int color; result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations); if (result == null) { System.out.println("i: " + i + " j: " + j); System.out.println("par1: " + parHStart + i * parHStep); System.out.println("par2: " + parVStart + j * parVStep); g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); return false; } int zer = 0; int pos = 0; int neg = 0; int nan = 0; for (int ii = 0; ii < result.length; ii++) { if (Math.abs(result[ii]) == (1.0 / 0.0)) nan++; else if (Math.abs(result[ii]) <= epsilon) zer++; else if (result[ii] > epsilon) pos++; else if (result[ii] < (-epsilon)) neg++; else nan++; } color = (lyapunovColors.getColor(zer, pos, neg, nan)).getRGB(); ExpsSigns es = new ExpsSigns(zer, pos, neg, nan); if (!signsSet.contains(es)) signsSet.add(es); data[i + j * (int) dataArea.getWidth()] = color; if (stopped == true) return false; if (j == (int) dataArea.getHeight() - 1) g2.drawImage(image, null, (int) dataArea.getX() + 1, (int) dataArea.getY() + 1); } //end for } //end for } //end else return true; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.ColoredBlockContainer.java
/** * Disclaimer: this is a "works for me" implementation, and probably only works as long as the * items are arranged horizontally in exactly one line, since it brutally enforces the items to * be aligned vertically centered.//w ww. ja v a 2s .co m */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = drawFill(g2, area); // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); } } Rectangle2D contentArea = (Rectangle2D) area.clone(); contentArea = trimMargin(contentArea); drawBorder(g2, contentArea); contentArea = trimBorder(contentArea); contentArea = trimPadding(contentArea); Iterator iterator = getBlocks().iterator(); while (iterator.hasNext()) { Block block = (Block) iterator.next(); Rectangle2D bounds = block.getBounds(); // enforce vertically centered alignment double y = area.getY() + (area.getHeight() - bounds.getHeight()) / 2.0; Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + area.getX(), y, bounds.getWidth(), bounds.getHeight()); Object r = block.draw(g2, drawArea, params); if (sec != null) { if (r instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) r; EntityCollection ec = ebr.getEntityCollection(); sec.addAll(ec); } } } BlockResult result = null; if (sec != null) { result = new BlockResult(); result.setEntityCollection(sec); } return result; }
From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java
protected void drawRadar(Graphics2D g2, Rectangle2D plotArea, PlotRenderingInfo info, int pieIndex, PieDataset data) {//from w w w . j av a2s. c o m // adjust the plot area by the interior spacing value double gapHorizontal = plotArea.getWidth() * this.interiorGap; double gapVertical = plotArea.getHeight() * this.interiorGap; double radarX = plotArea.getX() + gapHorizontal / 2; double radarY = plotArea.getY() + gapVertical / 2; double radarW = plotArea.getWidth() - gapHorizontal; double radarH = plotArea.getHeight() - gapVertical; // make the radar area a square if the radar chart is to be circular... // NOTE that non-circular radar charts are not currently supported. if (true) { //circular) { double min = Math.min(radarW, radarH) / 2; radarX = (radarX + radarX + radarW) / 2 - min; radarY = (radarY + radarY + radarH) / 2 - min; radarW = 2 * min; radarH = 2 * min; } double radius = radarW / 2; double centerX = radarX + radarW / 2; double centerY = radarY + radarH / 2; Rectangle2D radarArea = new Rectangle2D.Double(radarX, radarY, radarW, radarH); // plot the data (unless the dataset is null)... if ((data != null) && (data.getKeys().size() > 0)) { // get a list of categories... List keys = data.getKeys(); int numAxes = keys.size(); // draw each of the axes on the radar chart, and register // the shape of the radar line. double multiplier = 1.0; GeneralPath lineShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1); GeneralPath gridShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1); int axisNumber = -1; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable currentKey = (Comparable) iterator.next(); axisNumber++; Number dataValue = data.getValue(currentKey); double value = (dataValue != null ? dataValue.doubleValue() : 0); if (value > 1 || Double.isNaN(value) || Double.isInfinite(value)) value = 1.0; if (value < 0) value = 0.0; multiplier *= value; double angle = 2 * Math.PI * axisNumber / numAxes; double deltaX = Math.sin(angle) * radius; double deltaY = -Math.cos(angle) * radius; // draw the spoke g2.setPaint(axisPaint); g2.setStroke(axisStroke); Line2D line = new Line2D.Double(centerX, centerY, centerX + deltaX, centerY + deltaY); g2.draw(line); // register the grid line and the shape line if (axisNumber == 0) { gridShape.moveTo((float) deltaX, (float) deltaY); lineShape.moveTo((float) (deltaX * value), (float) (deltaY * value)); } else { gridShape.lineTo((float) deltaX, (float) deltaY); lineShape.lineTo((float) (deltaX * value), (float) (deltaY * value)); } if (showAxisLabels) { // draw the label double labelX = centerX + deltaX * (1 + axisLabelGap); double labelY = centerY + deltaY * (1 + axisLabelGap); String label = currentKey.toString(); drawLabel(g2, radarArea, label, axisNumber, labelX, labelY); } } gridShape.closePath(); lineShape.closePath(); // draw five gray concentric gridlines g2.translate(centerX, centerY); g2.setPaint(gridLinePaint); g2.setStroke(gridLineStroke); for (int i = 5; i > 0; i--) { Shape scaledGrid = gridShape .createTransformedShape(AffineTransform.getScaleInstance(i / 5.0, i / 5.0)); g2.draw(scaledGrid); } // get the color for the plot shape. Paint dataPaint = plotLinePaint; if (dataPaint == ADAPTIVE_COLORING) { //multiplier = Math.exp(Math.log(multiplier) * 2 / numAxes); dataPaint = getMultiplierColor((float) multiplier); } // compute a slightly transparent version of the plot color for // the fill. Paint dataFill = null; if (dataPaint instanceof Color && getForegroundAlpha() != 1.0) dataFill = new Color(((Color) dataPaint).getRed() / 255f, ((Color) dataPaint).getGreen() / 255f, ((Color) dataPaint).getBlue() / 255f, getForegroundAlpha()); else dataFill = dataPaint; // draw the plot shape. First fill with a parially // transparent color, then stroke with the opaque color. g2.setPaint(dataFill); g2.fill(lineShape); g2.setPaint(dataPaint); g2.setStroke(plotLineStroke); g2.draw(lineShape); // cleanup the graphics context. g2.translate(-centerX, -centerY); } }
From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java
public void calcGrids() { Rectangle2D rect = getBounds2D(); double w = rect.getWidth(); double h = rect.getHeight(); if (h > 150 || w > 150) { Logger.getLogger("at.tuwien.ifs.somtoolbox").fine("Error: " + this); return;//from w w w. j a v a 2 s . c om } int x = (int) rect.getX(); int y = (int) rect.getY(); int xSteps = (int) (w / (int) Grid.SIZE); int ySteps = (int) (h / (int) Grid.SIZE); for (int i = 0; i < xSteps; i++) { for (int j = 0; j < ySteps; j++) { Polygon p = new Polygon(); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); if (this.contains(p.getBounds().x + Grid.SIZE / 2, p.getBounds().y + Grid.SIZE / 2)) { Pnt topLeft = new Pnt(x + i * Grid.SIZE, y + j * Grid.SIZE); Pnt bottomRight = new Pnt(x + i * Grid.SIZE + Grid.SIZE, y + Grid.SIZE + j * Grid.SIZE); Grid grid = new Grid(topLeft, bottomRight); grids.add(grid); } } } }