List of usage examples for java.awt.geom Rectangle2D contains
public boolean contains(double x, double y, double w, double h)
From source file:net.sf.maltcms.chromaui.charts.renderer.XYNoBlockRenderer.java
/** * Draws the block representing the specified item. * * @param g2 the graphics device.// ww w .j a v a 2 s.c o m * @param state the state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ @Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // return; double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = 0.0; if (dataset instanceof XYZDataset) { z = ((XYZDataset) dataset).getZValue(series, item); if (entityThreshold != Double.NaN && z < entityThreshold) { return; } } //} Paint p = getPaintScale().getPaint(z); // if(p.equals(getPaintScale().getPaint(getPaintScale().getLowerBound()))) { // return; // } // double xx0 = domainAxis.valueToJava2D(x + xOffset, dataArea, // plot.getDomainAxisEdge()); // double yy0 = rangeAxis.valueToJava2D(y + yOffset, dataArea, // plot.getRangeAxisEdge()); // double xx1 = domainAxis.valueToJava2D(x + blockWidth // + xOffset, dataArea, plot.getDomainAxisEdge()); // double yy1 = rangeAxis.valueToJava2D(y + blockHeight // + yOffset, dataArea, plot.getRangeAxisEdge()); double xx0 = domainAxis.valueToJava2D(x - getBlockWidth() / 2, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y - getBlockHeight() / 2, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + getBlockWidth() / 2, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + getBlockHeight() / 2, dataArea, plot.getRangeAxisEdge()); Rectangle2D block; PlotOrientation orientation = plot.getOrientation(); if (orientation.equals(PlotOrientation.HORIZONTAL)) { if (dataArea.contains(Math.min(yy0, yy1), Math.min(xx0, xx1), Math.abs(yy1 - yy0), Math.abs(xx0 - xx1))) { block = new Rectangle2D.Double(Math.min(yy0, yy1), Math.min(xx0, xx1), Math.abs(yy1 - yy0), Math.abs(xx0 - xx1)); } else { return; } } else { if (dataArea.contains(Math.min(xx0, xx1), Math.min(yy0, yy1), Math.abs(xx1 - xx0), Math.abs(yy0 - yy1))) { block = new Rectangle2D.Double(Math.min(xx0, xx1), Math.min(yy0, yy1), Math.abs(xx1 - xx0), Math.abs(yy0 - yy1)); } else { return; } } g2.setPaint(p); g2.fill(block); g2.setStroke(new BasicStroke(1.0f)); g2.draw(block); EntityCollection entities = state.getEntityCollection(); // System.out.println("Entity collection is of type: "+entities.getClass()); if (entities != null) { //System.out.println("Adding entity"); addEntity(entities, block, dataset, series, item, block.getCenterX(), block.getCenterY()); } }