Module org.jpo

Class PictureController

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
OverlayedPictureController

public class PictureController extends JComponent
The job of this Component is to scale and display a picture. It notifies the registered parent about status changes so that a description object can be updated. When the image has been rendered and displayed the legend of the image is set to the parent with the ready status.

The image is centred on the component to the focusPoint in the coordinate space of the image. This translated using the ScalablePicture.setScaleFactor(double) to the coordinate space of the JComponent

Mathematics

See Also:
  • Field Details

    • focusPoint

      public final Point focusPoint
      This point of the picture will be put at the middle of the screen component. The coordinates are in x,y in the coordinate space of the picture.
  • Constructor Details

    • PictureController

      public PictureController(PictureControllerImage pictureControllerImage)
      Constructs a PicturePane components.
      Parameters:
      pictureControllerImage - image
  • Method Details

    • isCenterWhenScaled

      public boolean isCenterWhenScaled()
      returns whether the picture should be centered when scaled
      Returns:
      true if the picture should be centered when scaled
    • setCenterWhenScaled

      public void setCenterWhenScaled(boolean centerWhenScaled)
      Remembers whether the picture should be centered when scaled
      Parameters:
      centerWhenScaled - whether the picture should be centered when scaled
    • resetPicture

      public void resetPicture()
      Sets the scale of the picture to the current screen size and centres it there.
    • handleZoomRequest

      public void handleZoomRequest(PictureControllerZoomRequest request)
      Deals with a Zoom request by changing the doom factor
      Parameters:
      request - The request
    • zoomIn

      public void zoomIn()
      Multiplies the scale factor so that paint() method scales the image larger. This method calls ScalablePicture.createScaledPictureInThread(int) which in turn will tell this object by means of the status update that the image is ready and should be repainted.
    • zoomOut

      public void zoomOut()
      method that zooms out on the image leaving the centre where it is. This method calls ScalablePicture.createScaledPictureInThread(int) which in turn will tell this object by means of the status update that the image is ready and should be repainted.
    • zoomToFit

      public void zoomToFit()
      this method sets the desired scaled size of the ScalablePicture to the size of the JPanel and fires off a createScaledPictureInThread request if the ScalablePicture has been loaded or is ready.
      See Also:
    • zoomFull

      public void zoomFull()
      method that zooms the image to 100%. This method calls ScalablePicture.createScaledPictureInThread(int) which in turn will tell this object by means of the status update that the image is ready and should be repainted.
    • centerImage

      public void centerImage()
      Set image to centre of panel by putting the coordinates of the middle of the original image into the Centre to X and Centre to Y variables by invoking the setCenterLocation method. This method calls repaint() directly since no time-consuming image operations need to take place.
    • scrollUp

      public void scrollUp()
      method that moves the image up by 10% of the pixels shown on the screen. This method calls repaint() directly since no time-consuming image operations need to take place.

      Scroll Up

      See Also:
    • scrollDown

      public void scrollDown()
      method that moves the image down by 10% of the pixels shown on the screen. This method calls repaint() directly since no time-consuming image operations need to take place.

      Scroll Down

      See Also:
    • scrollLeft

      public void scrollLeft()
      method that moves the image left by 10% of the pixels shown on the screen. This method calls repaint() directly since no time-consuming image operations need to take place. works just like scrollUp().
      See Also:
    • scrollRight

      public void scrollRight()
      method that moves the image right by 10% of the pixels shown on the screen. This method calls repaint() directly since no time-consuming image operations need to take place. works just like scrollDown().
      See Also:
    • setCenterLocation

      public void setCenterLocation(int xParameter, int yParameter)
      method to set the centre of the image to the true coordinates in the picture but doesn't call repaint()
      Parameters:
      xParameter - the x coordinates
      yParameter - the y coordinates
    • paintComponent

      public void paintComponent(Graphics g)
      we are overriding the default paintComponent method, grabbing the Graphics handle and doing our own drawing here. Essentially this method draws a large background color rectangle. A drawRenderedImage is then painted doing an affine transformation on the scaled image to position it so the desired point is in the middle of the Graphics object. The picture is not scaled here because this is a slow operation and only needs to be done once, while moving the image is something the user is likely to do more often.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - Graphics