List of usage examples for java.awt Rectangle intersects
public boolean intersects(double x, double y, double w, double h)
From source file:SWTGraphics2D.java
/** * Sets the clipping to the intersection of the current clip region and * the specified rectangle./*from w ww.j av a 2 s . com*/ * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width. * @param height the height. */ public void clipRect(int x, int y, int width, int height) { org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping(); clip.intersects(x, y, width, height); this.gc.setClipping(clip); }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
private void drawSquares(Graphics squares, Point start, Rectangle bounds, Dataset dataset, boolean clusterColumns) { // ColorFactory colors = ColorFactoryList.getInstance().getActiveColorFactory(dataset); colors = colorFactory.getActiveColorFactory(dataset); Rectangle view = getSquaresBounds(dataset); squares.translate(start.x, start.y); int rows = this.countgenes(this.rowNode); int counter = 0; double[] gengenscalevals = null; int[] upperArrangement = null; if (clusterColumns) { upperArrangement = upperTree.arrangement; } else {//from w w w. j a v a 2s . co m upperArrangement = new int[dataset.getColumnIds().length]; for (int x = 0; x < dataset.getColumnIds().length; x++) upperArrangement[x] = x; } double[][] dat = null; dat = dataset.getData(); if (sideTree == null) { return; } for (int i = 0; i < sideTree.arrangement.length; i++) { double v = 0; Rectangle sqr = new Rectangle(0, 0, squareW, squareL); for (int j = 0; j < upperArrangement.length; j++) { if (bounds == null || bounds.intersects((j * squareW), (i * squareL), squareW, squareL)) { if (upperTree != null) { sqr.setLocation((j * squareW), (i * squareL)); if (!view.intersects(sqr)) { continue; } if (sideTree.arrangement[i] != -1 && upperArrangement[j] != -1) { if (dataset.isMissing(sideTree.arrangement[i], upperArrangement[j])) { squares.setColor(colors.getMissing()); } else { if (!gengenscale) { v = dat[sideTree.arrangement[i]][upperArrangement[j]]; squares.setColor(colors.getColor(v)); } else { v = gengenscalevals[upperArrangement[j]]; squares.setColor(colors.getColor(v)); } } squares.fillRect((j * squareW), (i * squareL), squareW, squareL); } } else { sqr.setLocation((j * squareW), (i * squareL)); if (!view.intersects(sqr)) { continue; } v = dat[sideTree.arrangement[i]][upperArrangement[j]]; if (dataset.isMissing(sideTree.arrangement[i], upperArrangement[j])) { squares.setColor(colors.getMissing()); } else { squares.setColor(colors.getColor(v)); } squares.fillRect((j * squareW), (i * squareL), squareW, squareL); } } } counter++; if (counter == rows) { break; } } counter = 0; if (true) { squares.setColor(GridCol); for (int i = 0; i < sideTree.arrangement.length + 1; i++) { if (bounds == null || bounds.intersects(0, i * squareL, upperArrangement.length * squareW, i * squareL)) { squares.drawLine(0, i * squareL, (upperArrangement.length * squareW) + 0, i * squareL); } counter++; if (counter > rows) { break; } } for (int j = 0; j < upperArrangement.length; j++) { if (bounds == null || bounds.intersects(j * squareW, 0, j * squareW, rows * squareL)) { squares.drawLine(j * squareW, 0, j * squareW, rows * squareL); } } if (bounds == null || bounds.intersects(upperArrangement.length * squareW, 0, upperArrangement.length * squareW, rows * squareL)) { squares.drawLine(upperArrangement.length * squareW, 0, upperArrangement.length * squareW, rows * squareL); } } squares.translate(-start.x, -start.y); }