Java Code Examples for java.awt.Rectangle#isEmpty()
The following examples show how to use
java.awt.Rectangle#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MotifScrollBarUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w - 1, h - 1); g.setColor(thumbHighlightColor); drawVLine(g, 0, 0, h - 1); drawHLine(g, 1, w - 1, 0); g.setColor(thumbLightShadowColor); drawHLine(g, 1, w - 1, h - 1); drawVLine(g, w - 1, 1, h - 2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 2
Source File: MotifScrollBarUI.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w - 1, h - 1); g.setColor(thumbHighlightColor); drawVLine(g, 0, 0, h - 1); drawHLine(g, 1, w - 1, 0); g.setColor(thumbLightShadowColor); drawHLine(g, 1, w - 1, h - 1); drawVLine(g, w - 1, 1, h - 2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 3
Source File: RepaintArea.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Adds a <code>Rectangle</code> to this <code>RepaintArea</code>. * PAINT Rectangles are divided into mostly vertical and mostly horizontal. * Each group is unioned together. * UPDATE Rectangles are unioned. * * @param r the specified <code>Rectangle</code> * @param id possible values PaintEvent.UPDATE or PaintEvent.PAINT * @since 1.3 */ public synchronized void add(Rectangle r, int id) { // Make sure this new rectangle has positive dimensions if (r.isEmpty()) { return; } int addTo = UPDATE; if (id == PaintEvent.PAINT) { addTo = (r.width > r.height) ? HORIZONTAL : VERTICAL; } if (paintRects[addTo] != null) { paintRects[addTo].add(r); } else { paintRects[addTo] = new Rectangle(r); } }
Example 4
Source File: WidgetOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Rectangle getBounds() { final Rectangle bounds = super.getBounds(); final Rectangle parent = getParentBounds(client.getWidget(widgetInfo)); if (parent.isEmpty()) { return bounds; } int x = bounds.x; int y = bounds.y; x = Math.max(parent.x, x); y = Math.max(parent.y, y); x = Math.min((int)parent.getMaxX() - bounds.width, x); y = Math.min((int)parent.getMaxY() - bounds.height, y); bounds.setLocation(x, y); return bounds; }
Example 5
Source File: MotifScrollBarUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w - 1, h - 1); g.setColor(thumbHighlightColor); drawVLine(g, 0, 0, h - 1); drawHLine(g, 1, w - 1, 0); g.setColor(thumbLightShadowColor); drawHLine(g, 1, w - 1, h - 1); drawVLine(g, w - 1, 1, h - 2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 6
Source File: MotifScrollBarUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if(thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w-1, h-1); g.setColor(thumbHighlightColor); g.drawLine(0, 0, 0, h-1); g.drawLine(1, 0, w-1, 0); g.setColor(thumbLightShadowColor); g.drawLine(1, h-1, w-1, h-1); g.drawLine(w-1, 1, w-1, h-2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 7
Source File: MotifScrollBarUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w - 1, h - 1); g.setColor(thumbHighlightColor); drawVLine(g, 0, 0, h - 1); drawHLine(g, 1, w - 1, 0); g.setColor(thumbLightShadowColor); drawHLine(g, 1, w - 1, h - 1); drawVLine(g, w - 1, 1, h - 2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 8
Source File: MotifScrollBarUI.java From hottub with GNU General Public License v2.0 | 6 votes |
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) { return; } int w = thumbBounds.width; int h = thumbBounds.height; g.translate(thumbBounds.x, thumbBounds.y); g.setColor(thumbColor); g.fillRect(0, 0, w - 1, h - 1); g.setColor(thumbHighlightColor); drawVLine(g, 0, 0, h - 1); drawHLine(g, 1, w - 1, 0); g.setColor(thumbLightShadowColor); drawHLine(g, 1, w - 1, h - 1); drawVLine(g, w - 1, 1, h - 2); g.translate(-thumbBounds.x, -thumbBounds.y); }
Example 9
Source File: BufferedImage.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Sets a rectangular region of the image to the contents of the * specified <code>Raster</code> <code>r</code>, which is * assumed to be in the same coordinate space as the * <code>BufferedImage</code>. The operation is clipped to the bounds * of the <code>BufferedImage</code>. * @param r the specified <code>Raster</code> * @see #getData * @see #getData(Rectangle) */ public void setData(Raster r) { int width = r.getWidth(); int height = r.getHeight(); int startX = r.getMinX(); int startY = r.getMinY(); int[] tdata = null; // Clip to the current Raster Rectangle rclip = new Rectangle(startX, startY, width, height); Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height); Rectangle intersect = rclip.intersection(bclip); if (intersect.isEmpty()) { return; } width = intersect.width; height = intersect.height; startX = intersect.x; startY = intersect.y; // remind use get/setDataElements for speed if Rasters are // compatible for (int i = startY; i < startY+height; i++) { tdata = r.getPixels(startX,i,width,1,tdata); raster.setPixels(startX,i,width,1, tdata); } }
Example 10
Source File: BufferedImage.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Sets a rectangular region of the image to the contents of the * specified <code>Raster</code> <code>r</code>, which is * assumed to be in the same coordinate space as the * <code>BufferedImage</code>. The operation is clipped to the bounds * of the <code>BufferedImage</code>. * @param r the specified <code>Raster</code> * @see #getData * @see #getData(Rectangle) */ public void setData(Raster r) { int width = r.getWidth(); int height = r.getHeight(); int startX = r.getMinX(); int startY = r.getMinY(); int[] tdata = null; // Clip to the current Raster Rectangle rclip = new Rectangle(startX, startY, width, height); Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height); Rectangle intersect = rclip.intersection(bclip); if (intersect.isEmpty()) { return; } width = intersect.width; height = intersect.height; startX = intersect.x; startY = intersect.y; // remind use get/setDataElements for speed if Rasters are // compatible for (int i = startY; i < startY+height; i++) { tdata = r.getPixels(startX,i,width,1,tdata); raster.setPixels(startX,i,width,1, tdata); } }
Example 11
Source File: RepaintArea.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Subtracts subtr from rect. If the result is rectangle * changes rect and returns true. Otherwise false. */ static boolean subtract(Rectangle rect, Rectangle subtr) { if (rect == null || subtr == null) { return true; } Rectangle common = rect.intersection(subtr); if (common.isEmpty()) { return true; } if (rect.x == common.x && rect.y == common.y) { if (rect.width == common.width) { rect.y += common.height; rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.x += common.width; rect.width -= common.width; return true; } } else if (rect.x + rect.width == common.x + common.width && rect.y + rect.height == common.y + common.height) { if (rect.width == common.width) { rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.width -= common.width; return true; } } return false; }
Example 12
Source File: RepaintArea.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Subtracts subtr from rect. If the result is rectangle * changes rect and returns true. Otherwise false. */ static boolean subtract(Rectangle rect, Rectangle subtr) { if (rect == null || subtr == null) { return true; } Rectangle common = rect.intersection(subtr); if (common.isEmpty()) { return true; } if (rect.x == common.x && rect.y == common.y) { if (rect.width == common.width) { rect.y += common.height; rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.x += common.width; rect.width -= common.width; return true; } } else if (rect.x + rect.width == common.x + common.width && rect.y + rect.height == common.y + common.height) { if (rect.width == common.width) { rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.width -= common.width; return true; } } return false; }
Example 13
Source File: RepaintArea.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Subtracts subtr from rect. If the result is rectangle * changes rect and returns true. Otherwise false. */ static boolean subtract(Rectangle rect, Rectangle subtr) { if (rect == null || subtr == null) { return true; } Rectangle common = rect.intersection(subtr); if (common.isEmpty()) { return true; } if (rect.x == common.x && rect.y == common.y) { if (rect.width == common.width) { rect.y += common.height; rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.x += common.width; rect.width -= common.width; return true; } } else if (rect.x + rect.width == common.x + common.width && rect.y + rect.height == common.y + common.height) { if (rect.width == common.width) { rect.height -= common.height; return true; } else if (rect.height == common.height) { rect.width -= common.width; return true; } } return false; }
Example 14
Source File: BufferedImage.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Sets a rectangular region of the image to the contents of the * specified {@code Raster r}, which is * assumed to be in the same coordinate space as the * {@code BufferedImage}. The operation is clipped to the bounds * of the {@code BufferedImage}. * @param r the specified {@code Raster} * @see #getData * @see #getData(Rectangle) */ public void setData(Raster r) { int width = r.getWidth(); int height = r.getHeight(); int startX = r.getMinX(); int startY = r.getMinY(); int[] tdata = null; // Clip to the current Raster Rectangle rclip = new Rectangle(startX, startY, width, height); Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height); Rectangle intersect = rclip.intersection(bclip); if (intersect.isEmpty()) { return; } width = intersect.width; height = intersect.height; startX = intersect.x; startY = intersect.y; // remind use get/setDataElements for speed if Rasters are // compatible for (int i = startY; i < startY+height; i++) { tdata = r.getPixels(startX,i,width,1,tdata); raster.setPixels(startX,i,width,1, tdata); } }
Example 15
Source File: BufferedImage.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Sets a rectangular region of the image to the contents of the * specified <code>Raster</code> <code>r</code>, which is * assumed to be in the same coordinate space as the * <code>BufferedImage</code>. The operation is clipped to the bounds * of the <code>BufferedImage</code>. * @param r the specified <code>Raster</code> * @see #getData * @see #getData(Rectangle) */ public void setData(Raster r) { int width = r.getWidth(); int height = r.getHeight(); int startX = r.getMinX(); int startY = r.getMinY(); int[] tdata = null; // Clip to the current Raster Rectangle rclip = new Rectangle(startX, startY, width, height); Rectangle bclip = new Rectangle(0, 0, raster.width, raster.height); Rectangle intersect = rclip.intersection(bclip); if (intersect.isEmpty()) { return; } width = intersect.width; height = intersect.height; startX = intersect.x; startY = intersect.y; // remind use get/setDataElements for speed if Rasters are // compatible for (int i = startY; i < startY+height; i++) { tdata = r.getPixels(startX,i,width,1,tdata); raster.setPixels(startX,i,width,1, tdata); } }
Example 16
Source File: AbstractAreaEffect.java From Pixelitor with GNU General Public License v3.0 | 4 votes |
@Override public void apply(Graphics2D g, Shape clipShape, int width, int height) { // opacity support added by lbalazscs Composite savedComposite = g.getComposite(); if(opacity < 1.0f){ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity)); } // create a rect to hold the bounds Rectangle2D clipShapeBounds = clipShape.getBounds2D(); if(clipShapeBounds.isEmpty()) { // check added by lbalazscs return; } width = (int) (clipShapeBounds.getWidth() + clipShapeBounds.getX()); height = (int) (clipShapeBounds.getHeight() + clipShapeBounds.getY()); Rectangle effectBounds = new Rectangle(0, 0, (int) (width + getEffectWidth() * 2 + 1), (int) (height + getEffectWidth() * 2 + 1)); if (effectBounds.isEmpty()) { // check added by lbalazscs // this can be empty even if the clip shape bounds is not // when the clip shape starts at large negative coordinates return; } // Apply the border glow effect if (isShapeMasked()) { BufferedImage clipImage = getClipImage(effectBounds); Graphics2D g2 = clipImage.createGraphics(); // lbalazscs: moved here from getClipImage // in order to avoid two createGraphics calls g2.clearRect(0, 0, clipImage.getWidth(), clipImage.getHeight()); try { // clear the buffer g2.setPaint(Color.BLACK); g2.setComposite(AlphaComposite.Clear); g2.fillRect(0, 0, effectBounds.width, effectBounds.height); if (debug) { g2.setPaint(Color.WHITE); g2.setComposite(AlphaComposite.SrcOver); g2.drawRect(0, 0, effectBounds.width - 1, effectBounds.height - 1); } // turn on smoothing g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(getEffectWidth() - getOffset().getX(), getEffectWidth() - getOffset().getY()); paintBorderGlow(g2, clipShape, width, height); // clip out the parts we don't want g2.setComposite(AlphaComposite.Clear); g2.setColor(Color.WHITE); if (isRenderInsideShape()) { // clip the outside Area area = new Area(effectBounds); area.subtract(new Area(clipShape)); g2.fill(area); } else { // clip the inside g2.fill(clipShape); } } finally { // draw the final image g2.dispose(); } int drawX = (int) (-getEffectWidth() + getOffset().getX()); int drawY = (int) (-getEffectWidth() + getOffset().getY()); g.drawImage(clipImage, drawX, drawY, null); } else { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); paintBorderGlow(g, clipShape, width, height); } //g.setColor(Color.MAGENTA); //g.draw(clipShape.getBounds2D()); //g.drawRect(0,0,width,height); g.setComposite(savedComposite); }
Example 17
Source File: JLightweightFrame.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. */ public JLightweightFrame() { super(); copyBufferEnabled = "true".equals(AccessController. doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); add(rootPane, BorderLayout.CENTER); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); if (getGraphicsConfiguration().isTranslucencyCapable()) { setBackground(new Color(0, 0, 0, 0)); } layoutSizeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { Dimension d = (Dimension)e.getNewValue(); if ("preferredSize".equals(e.getPropertyName())) { content.preferredSizeChanged(d.width, d.height); } else if ("maximumSize".equals(e.getPropertyName())) { content.maximumSizeChanged(d.width, d.height); } else if ("minimumSize".equals(e.getPropertyName())) { content.minimumSizeChanged(d.width, d.height); } } }; repaintListener = (JComponent c, int x, int y, int w, int h) -> { Window jlf = SwingUtilities.getWindowAncestor(c); if (jlf != JLightweightFrame.this) { return; } Point p = SwingUtilities.convertPoint(c, x, y, jlf); Rectangle r = new Rectangle(p.x, p.y, w, h).intersection( new Rectangle(0, 0, bbImage.getWidth() / scaleFactor, bbImage.getHeight() / scaleFactor)); if (!r.isEmpty()) { notifyImageUpdated(r.x, r.y, r.width, r.height); } }; SwingAccessor.getRepaintManagerAccessor().addRepaintListener( RepaintManager.currentManager(this), repaintListener); }
Example 18
Source File: JLightweightFrame.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. */ public JLightweightFrame() { super(); copyBufferEnabled = "true".equals(AccessController. doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); add(rootPane, BorderLayout.CENTER); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); if (getGraphicsConfiguration().isTranslucencyCapable()) { setBackground(new Color(0, 0, 0, 0)); } layoutSizeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { Dimension d = (Dimension)e.getNewValue(); if ("preferredSize".equals(e.getPropertyName())) { content.preferredSizeChanged(d.width, d.height); } else if ("maximumSize".equals(e.getPropertyName())) { content.maximumSizeChanged(d.width, d.height); } else if ("minimumSize".equals(e.getPropertyName())) { content.minimumSizeChanged(d.width, d.height); } } }; repaintListener = (JComponent c, int x, int y, int w, int h) -> { Window jlf = SwingUtilities.getWindowAncestor(c); if (jlf != JLightweightFrame.this) { return; } Point p = SwingUtilities.convertPoint(c, x, y, jlf); Rectangle r = new Rectangle(p.x, p.y, w, h).intersection( new Rectangle(0, 0, bbImage.getWidth() / scaleFactor, bbImage.getHeight() / scaleFactor)); if (!r.isEmpty()) { notifyImageUpdated(r.x, r.y, r.width, r.height); } }; SwingAccessor.getRepaintManagerAccessor().addRepaintListener( RepaintManager.currentManager(this), repaintListener); }
Example 19
Source File: TIFFImageWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void prepareReplacePixels(int imageIndex, Rectangle region) throws IOException { synchronized(replacePixelsLock) { // Check state and parameters vis-a-vis ImageWriter specification. if (stream == null) { throw new IllegalStateException("Output not set!"); } if (region == null) { throw new IllegalArgumentException("region == null!"); } if (region.getWidth() < 1) { throw new IllegalArgumentException("region.getWidth() < 1!"); } if (region.getHeight() < 1) { throw new IllegalArgumentException("region.getHeight() < 1!"); } if (inReplacePixelsNest) { throw new IllegalStateException ("In nested call to prepareReplacePixels!"); } // Read the IFD for the pixel replacement index. TIFFIFD replacePixelsIFD = readIFD(imageIndex); // Ensure that compression is "none". TIFFField f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION); int compression = f.getAsInt(0); if (compression != BaselineTIFFTagSet.COMPRESSION_NONE) { throw new UnsupportedOperationException ("canReplacePixels(imageIndex) == false!"); } // Get the image dimensions. f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH); if(f == null) { throw new IIOException("Cannot read ImageWidth field."); } int w = f.getAsInt(0); f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_LENGTH); if(f == null) { throw new IIOException("Cannot read ImageHeight field."); } int h = f.getAsInt(0); // Create image bounds. Rectangle bounds = new Rectangle(0, 0, w, h); // Intersect region with bounds. region = region.intersection(bounds); // Check for empty intersection. if(region.isEmpty()) { throw new IIOException("Region does not intersect image bounds"); } // Save the region. replacePixelsRegion = region; // Get the tile offsets. f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_OFFSETS); if(f == null) { f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS); } replacePixelsTileOffsets = f.getAsLongs(); // Get the byte counts. f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS); if(f == null) { f = replacePixelsIFD.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS); } replacePixelsByteCounts = f.getAsLongs(); replacePixelsOffsetsPosition = replacePixelsIFD.getStripOrTileOffsetsPosition(); replacePixelsByteCountsPosition = replacePixelsIFD.getStripOrTileByteCountsPosition(); // Get the image metadata. replacePixelsMetadata = new TIFFImageMetadata(replacePixelsIFD); // Save the image index. replacePixelsIndex = imageIndex; // Set the pixel replacement flag. inReplacePixelsNest = true; } }
Example 20
Source File: ComputeMaskAreaAction.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private MaskAreaStatistics computeMaskAreaStatistics(ProgressMonitor pm) { final MultiLevelImage maskImage = mask.getSourceImage(); final int minTileX = maskImage.getMinTileX(); final int minTileY = maskImage.getMinTileY(); final int numXTiles = maskImage.getNumXTiles(); final int numYTiles = maskImage.getNumYTiles(); final int w = mask.getRasterWidth(); final int h = mask.getRasterHeight(); final Rectangle imageRect = new Rectangle(0, 0, w, h); final PixelPos[] pixelPoints = new PixelPos[5]; final GeoPos[] geoPoints = new GeoPos[5]; for (int i = 0; i < geoPoints.length; i++) { pixelPoints[i] = new PixelPos(); geoPoints[i] = new GeoPos(); } GeoCoding geoCoding = mask.getGeoCoding(); AreaCalculator areaCalculator = new AreaCalculator(geoCoding); MaskAreaStatistics areaStatistics = new MaskAreaStatistics(areaCalculator.getEarthRadius() / 1000.0); pm.beginTask("Computing Mask area...", numXTiles * numYTiles); try { for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) { for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) { if (pm.isCanceled()) { break; } final Rectangle tileRectangle = new Rectangle( maskImage.getTileGridXOffset() + tileX * maskImage.getTileWidth(), maskImage.getTileGridYOffset() + tileY * maskImage.getTileHeight(), maskImage.getTileWidth(), maskImage.getTileHeight()); final Rectangle r = imageRect.intersection(tileRectangle); if (!r.isEmpty()) { Raster maskTile = maskImage.getTile(tileX, tileY); for (int y = r.y; y < r.y + r.height; y++) { for (int x = r.x; x < r.x + r.width; x++) { if (maskTile.getSample(x, y, 0) != 0) { double pixelArea = areaCalculator.calculatePixelSize(x, y) / Math.pow(1000.0, 2); areaStatistics.setPixelAreaMin(Math.min(areaStatistics.getPixelAreaMin(), pixelArea)); areaStatistics.setPixelAreaMax(Math.max(areaStatistics.getPixelAreaMax(), pixelArea)); areaStatistics.setMaskArea(areaStatistics.getMaskArea() + pixelArea); areaStatistics.setNumPixels(areaStatistics.getNumPixels() + 1); } } } } pm.worked(1); } } } finally { pm.done(); } return areaStatistics; }