Class PixelMarkerOverlay

java.lang.Object
org.loboevolution.img.Overlay
org.loboevolution.img.PixelMarkerOverlay

public final class PixelMarkerOverlay extends Overlay
An overlay for marking pixels of the image. A circle will be drawn around the selected pixels; the size of the circle is set independently of the current zoom, but it may be enlarged in order to contain the pixel entirely.

The default size is 5 pixels and the default color is red.

This object stores the list of pixels; this list can be edited with the setPoint(Point), setPoints(Iterable), addPoint(Point), and clear() functions. All of these mutator functions cause the overlay to be repainted. Author Kazo Csaba

  • Constructor Details

    • PixelMarkerOverlay

      public PixelMarkerOverlay()
  • Method Details

    • setSize

      public void setSize(int newSize)
      Sets the size of the circle. The actual width and height of the circle will be 2*newSize+1.
      Parameters:
      newSize - the new size of the marker circles
      Throws:
      IllegalArgumentException - if newSize is negative
    • setColor

      public void setColor(Color color)
      Sets the color of the marker circles.
      Parameters:
      color - the new color
      Throws:
      NullPointerException - in case of error if color is null
    • addPoint

      public void addPoint(Point p)
      Adds a point to the list of pixels marked by this overlay.
      Parameters:
      p - a new point
      Throws:
      NullPointerException - in case of error if p is null
    • setPoint

      public void setPoint(Point p)
      Sets the argument as the only point marked by this overlay.
      Parameters:
      p - the point to mark; if null, then no points will be selected
    • setPoints

      public void setPoints(Iterable<Point> points)
      Sets the marked pixels.
      Parameters:
      points - an iterable of all the pixels that should be selected
      Throws:
      NullPointerException - in case of error if points or any individual point is null
    • clear

      public void clear()
      Removes all pixels from the overlay, clearing the selection.
    • paint

      public void paint(Graphics2D g, BufferedImage image, AffineTransform transform)
      Called to paint the contents of this overlay. The graphics context to paint on is a copy for this overlay and can be freely modified.

      The method receives the currently displayed image. The image is never null - if there is currently no image being displayed in the image viewer, then the paint method is not called.

      This method also receives the transformation that is applied to the image before it is displayed. This transformation is most commonly the concatenation of a uniform scale and a translation. The original image bounds (0, 0) - (image.getWidth(), image.getHeight()) are mapped using this transformation to get the final display bounds. The overlay should not rely on whether painting outside these final bounds will be visible or not.

      Specified by:
      paint in class Overlay
      Parameters:
      g - the graphics context to draw onto
      image - the current image
      transform - the transformation applied to the image before displaying