public void setScale(double scale) { if (scale <= 0) { throw new IllegalArgumentException("Scale must be a positive number"); } this.scale = scale; refreshComponent(); }
public void setTileGridVisible(boolean visible) { this.tileGridVisible = visible; repaint(); } }
private void refreshComponent() { int w = (int) Math.ceil(image.getWidth() * scale); int h = (int) Math.ceil(image.getHeight() * scale); int minX = (int) Math.ceil(image.getMinX() * scale); int minY = (int) Math.ceil(image.getMinY() * scale); Insets insets = getInsets(); Dimension dim = new Dimension(w + insets.left + insets.right + minX, h + insets.top + insets.bottom + minY); setPreferredSize(dim); revalidate(); repaint(); }
display = new ZoomableImageDisplay(); tileGrid.setSelected(display.isTileGridVisible()); display.addMouseMotionListener(new MouseMotionAdapter()
public void setImage(RenderedImage image) { this.image = image; if(image == null) { display.setVisible(false); pixelIter = null; } else { display.setImage(image); display.setVisible(true); pixelIter = RandomIterFactory.create(image, null); ipixel = new int[image.getSampleModel().getNumBands()]; dpixel = new double[image.getSampleModel().getNumBands()]; } }
/** * Constructs a <code>DisplayJAI</code>, sets its layout to * <code>null</code>, and sets its displayed image. * * <p> * The preferred size is set such that its width is the image width plus the * left and right insets and its height is the image height plus the top and * bottom insets. * </p> * * @param image * The image to display. * @throws IllegalArgumentException * if <code>image</code> is <code>null</code>. */ public ZoomableImageDisplay(RenderedImage image) { this(); setImage(image); }
g2d.setColor(getBackground()); g2d.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
private void refreshComponent() { int w = (int) Math.ceil(image.getWidth() * scale); int h = (int) Math.ceil(image.getHeight() * scale); int minX = (int) Math.ceil(image.getMinX() * scale); int minY = (int) Math.ceil(image.getMinY() * scale); Insets insets = getInsets(); Dimension dim = new Dimension(w + insets.left + insets.right + minX, h + insets.top + insets.bottom + minY); setPreferredSize(dim); revalidate(); repaint(); }
display = new ZoomableImageDisplay(); tileGrid.setSelected(display.isTileGridVisible()); display.addMouseMotionListener(new MouseMotionAdapter()
public void setImage(RenderedImage image) { this.image = image; if(image == null) { display.setVisible(false); pixelIter = null; } else { display.setImage(image); display.setVisible(true); pixelIter = RandomIterFactory.create(image, null); ipixel = new int[image.getSampleModel().getNumBands()]; dpixel = new double[image.getSampleModel().getNumBands()]; } }
/** * Constructs a <code>DisplayJAI</code>, sets its layout to * <code>null</code>, and sets its displayed image. * * <p> * The preferred size is set such that its width is the image width plus the * left and right insets and its height is the image height plus the top and * bottom insets. * </p> * * @param image * The image to display. * @throws IllegalArgumentException * if <code>image</code> is <code>null</code>. */ public ZoomableImageDisplay(RenderedImage image) { this(); setImage(image); }
g2d.setColor(getBackground()); g2d.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
public void setScale(double scale) { if (scale <= 0) { throw new IllegalArgumentException("Scale must be a positive number"); } this.scale = scale; refreshComponent(); }
public void setTileGridVisible(boolean visible) { this.tileGridVisible = visible; repaint(); } }
/** * Sets a new image to display. * * @param image * The image to display. * @throws IllegalArgumentException * if <code>im</code> is <code>null</code>. */ public void setImage(RenderedImage image) { if (image == null) { throw new IllegalArgumentException("Image displayed cannot be null"); } this.image = image; refreshComponent(); }