List of usage examples for java.awt.geom Rectangle2D.Double createIntersection
public abstract Rectangle2D createIntersection(Rectangle2D r);
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws a representation of the data within the dataArea region. The * <code>info</code> and <code>crosshairState</code> arguments may be * <code>null</code>./*from www . j av a2 s . com*/ * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension information. * @param crosshairState collects crosshair information (<code>null</code> * permitted). */ public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState) { // long start = System.currentTimeMillis(); // System.out.println("Start: " + start); //System.out.println("Data area: " + dataArea); // g2.setPaint(this.paint); // if the axes use a linear scale, you can uncomment the code below and // switch to the alternative transX/transY calculation inside the loop // that follows - it is a little bit faster then. // // int xx = (int) dataArea.getMinX(); // int ww = (int) dataArea.getWidth(); // int yy = (int) dataArea.getMaxY(); // int hh = (int) dataArea.getHeight(); // double domainMin = this.domainAxis.getLowerBound(); // double domainLength = this.domainAxis.getUpperBound() - domainMin; // double rangeMin = this.rangeAxis.getLowerBound(); // double rangeLength = this.rangeAxis.getUpperBound() - rangeMin; if (this.dataImage != null) { Logger.getLogger(getClass().getName()).info("Drawing data image"); //DATA SPACE // System.out.println("Domain axis lower bound: "+this.domainAxis.getLowerBound()); // define ROI in data coordinates double xlb = this.domainAxis.getLowerBound(); double ylb = this.rangeAxis.getLowerBound(); double xub = this.domainAxis.getUpperBound(); double yub = this.rangeAxis.getUpperBound(); //construct region of interest for data in view Rectangle2D.Double roi = new Rectangle2D.Double(xlb, ylb, xub - xlb, yub - ylb); Logger.getLogger(getClass().getName()).log(Level.INFO, "ROI: {0}", roi); //construct bounding rectangle of data Rectangle2D.Double imgSpace = new Rectangle2D.Double(0, 0, this.dataImage.getWidth(), this.dataImage.getHeight()); Logger.getLogger(getClass().getName()).log(Level.INFO, "IMG Space: {0}", imgSpace); //construct intersection of both, this is the area of the data, we need to render Rectangle2D sourceCoordinates = imgSpace.createIntersection(roi); Logger.getLogger(getClass().getName()).log(Level.INFO, "Projecting from: {0}", sourceCoordinates); //VIEW SPACE // define mapping coordinates from data domain to view domain double xlow = this.domainAxis.valueToJava2D(this.domainAxis.getLowerBound(), dataArea, RectangleEdge.BOTTOM); double ylow = this.rangeAxis.valueToJava2D(this.rangeAxis.getLowerBound(), dataArea, RectangleEdge.LEFT); double xhigh = this.domainAxis.valueToJava2D(this.domainAxis.getUpperBound(), dataArea, RectangleEdge.TOP); double yhigh = this.rangeAxis.valueToJava2D(this.rangeAxis.getUpperBound(), dataArea, RectangleEdge.RIGHT); drawFromOffscreenBuffer(g2, this.dataImage, sourceCoordinates.getBounds(), dataArea.getBounds()); renderCrosshairs(dataArea, g2); } else { createImage(g2, dataArea, info, crosshairState); render(g2, dataArea, info, crosshairState); } }