Class EarthDataViewPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, DelayedRenderingComponent, TransformableImageComponent

public class EarthDataViewPanel extends JPanel implements DelayedRenderingComponent, TransformableImageComponent

The EarthDataViewPanel class displays an onscreen version of an EarthDataView object. The panel has enhanced functionality over the RenderablePanel class with resizing behaviour and mouse events. The panel also supplies a tracking bar that may be used to display the mouse cursor position within the panel.

Changes to the view should be performed using panel methods wherever possible rather than the corresponding view methods, since a rendering loop may be active in the panel. When the view must be modified directly, users should call the panel stopRendering() method before making the change.

The panel signals a change in rendering status by firing a RENDERING_PROPERTY change event with value true when rendering is in progress or false if not. This can help with progress monitors.

Since:
3.1.2
Author:
Peter Hollemans
See Also:
  • Field Details

    • RENDERING_PROPERTY

      public static final String RENDERING_PROPERTY
      The rendering status property for property change events.
      See Also:
  • Constructor Details

    • EarthDataViewPanel

      public EarthDataViewPanel(EarthDataView view)
      Creates a new earth data view panel using the specified view.
      Parameters:
      view - the earth data view to display.
  • Method Details

    • isRendering

      public boolean isRendering()
      Returns true if the view panel is being rendered, or false if not.
      Specified by:
      isRendering in interface DelayedRenderingComponent
      Returns:
      true if the component is in a rendering state, or false if not.
    • stopRendering

      public void stopRendering()
      Stops the current rendering thread if it is active. If there is no active rendering taking place, no operation is performed.
      Specified by:
      stopRendering in interface DelayedRenderingComponent
    • getView

      public EarthDataView getView()
      Gets the earth data view.
      Returns:
      the data view.
    • setView

      public void setView(EarthDataView view)
      Sets the earth data view.
      Parameters:
      view - the new data view.
    • unityMagnify

      public void unityMagnify()
      Sets the magnification of the view around the current center location so that the data:screen pixel magnification is 1:1. This method should be used rather than manipulating the EarthDataView() object directly.
      See Also:
    • magnify

      public void magnify(double factor)
      Magnifies the view around the current center location. This method should be used for magnification of the view rather than calling the EarthDataView.magnify() method directly on the view itself.
      Parameters:
      factor - the factor by which to magnify. Factors greater than 1 increase the magnification and factors less than 1 decrease the magnification.
      See Also:
    • magnify

      public void magnify(Rectangle rect)
      Magnifies the specified rectangle to occupy the entire view. The center data location is changed to match the center of the specified rectangle. The scaling factor is changed so that the maximum dimension of the rectangle fits within the view dimensions. This method should be used for magnification of the view rather than calling the EarthDataView.magnify() method directly on the view itself.
      Parameters:
      rect - the magnification rectangle in panel-relative coordinates.
      See Also:
    • setCenter

      public void setCenter(Point2D center)
      Sets the view center to a new data location. The image dimensions and image scaling factor are unaffected. This method should be used for recentering of the view rather than calling the EarthDataView.setCenter() method directly on the view itself.
      Parameters:
      center - the new center data location in panel-relative coordinates.
      See Also:
    • setStaticView

      public void setStaticView(boolean flag)
      Sets the static view mode flag. In this mode, any resizing of the panel window or calls to magnify, recenter, or reset the view panel keep the view image size the same. When off, these operations dyamically change the view size based on the size of the panel window. The "on" mode is more appropriate when the view panel is being used to display exactly the same width and height in pixels of data area every time the view panel is modified. The "off" mode is better for maximizing the use of the view panel window to show as much data as possible. By default, static view mode is off.
      Parameters:
      flag - the static view flag, true for static view mode.
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • getDefaultCursor

      public Cursor getDefaultCursor()
      Gets the default cursor.
      Returns:
      the default cursor.
    • setDefaultCursor

      public void setDefaultCursor(Cursor cursor)
      Sets the default cursor.
      Parameters:
      cursor - the new default cursor to use.
    • setBounds

      public void setBounds(Rectangle r)
      Overrides:
      setBounds in class Component
    • fitReset

      public void fitReset()
      Resets the view panel so that one dimension of the data grid fits, centered within the panel. This method should be used to maximize the use of the view area so that no data edges are visible.
      Throws:
      UnsupportedOperationException - if the static view mode flag is on.
      See Also:
    • reset

      public void reset()
      Resets the view panel so that the entire data grid fits, centered within the panel. This method should be used for resetting the view rather than calling the EarthDataView.reset() method directly on the view itself.
    • getImageAffine

      public AffineTransform getImageAffine()
      Gets the image affine transform in the view.
      Specified by:
      getImageAffine in interface TransformableImageComponent
      Returns:
      the image affine transform or null for no transform.
      See Also:
    • setImageAffine

      public void setImageAffine(AffineTransform affine)
      Sets the image affine transform in the view. This method should be used for modifying the view rather than calling the EarthDataView.setImageAffine() method directly on the view itself.
      Specified by:
      setImageAffine in interface TransformableImageComponent
      Parameters:
      affine - the image affine transform, or null for no transform.
      See Also:
    • translate

      public Point2D translate(Point2D point)
      Translates the specified panel-relative point to a view-relative point. Depending on the view dimensions, the view may be offset from (0,0) inside the panel.
      Parameters:
      point - the point for translation.
      Returns:
      the translated point.
    • getAffine

      public AffineTransform getAffine()
      Gets the affine transform that translates view panel coordinates to data location coordinates.
      Returns:
      the affine transform.