Class DisplayMaster

java.lang.Object
ucar.visad.display.DisplayMaster
Direct Known Subclasses:
AerologicalDisplay, NavigatedDisplay, WindProfileDisplay, XYDisplay

public abstract class DisplayMaster extends Object
Manages a VisAD DisplayImpl and a list of Displayables.

Instances of this class have the following bound properties:

Name Type Access Default Description
pointMode boolean set/is false Whether or not the VisAD display associated with this instance displays 1-D manifold data as points or lines.
Author:
Steven R. Emmerson
  • Field Details

    • log_

      public static LogUtil.LogCategory log_
      Use this member to log messages (through calls to LogUtil)
    • POINT_MODE

      public static String POINT_MODE
      The name of the "point mode" property.
    • behavior

      protected KeyboardBehavior behavior
      The keyboard behavior
    • defaultMouseFunctions

      public static final int[][][] defaultMouseFunctions
      The default mouse function map
  • Constructor Details

    • DisplayMaster

      public DisplayMaster()
      Parameterless ctor. Note: If you instantiate a DisplayMaster through this constructor you must also call the init method.
    • DisplayMaster

      public DisplayMaster(DisplayImpl display) throws VisADException, RemoteException
      Constructs from a Display.
      Parameters:
      display - The VisAD display.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • DisplayMaster

      public DisplayMaster(DisplayImpl display, int initialCapacity) throws VisADException, RemoteException
      Constructs from a VisAD display and an anticipated number of Displayables.
      Parameters:
      display - The VisAD display.
      initialCapacity - The anticipated number of Displayable-s.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • DisplayMaster

      public DisplayMaster(DisplayImpl display, int initialCapacity, Dimension offscreenDimension) throws VisADException, RemoteException
      Constructs from a VisAD display and an anticipated number of Displayables.
      Parameters:
      display - The VisAD display.
      initialCapacity - The anticipated number of Displayable-s.
      offscreenDimension - Use this to set the dimension of the offscreen component
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
  • Method Details

    • setWheelEventMap

      public void setWheelEventMap(int[][] map)
      Set the mapping between mouse wheel event and function
      Parameters:
      map - The mapping
    • init

      public void init(DisplayImpl display, int initialCapacity) throws VisADException, RemoteException
      Initialize this display master
      Parameters:
      display - The display
      initialCapacity - Initial capacity of the displayables list
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • setOffscreenDimension

      protected void setOffscreenDimension(Dimension dim)
      For offscreen rendering
      Parameters:
      dim - The screen dimension
    • getOffscreenDimension

      protected Dimension getOffscreenDimension()
      Get the off screen dimension
      Returns:
      off screen dimension
    • getDisplayComponent

      public Component getDisplayComponent()
      Returns the component of the display. If in offscreen mode returns the offscreenComponent
      Returns:
      Display component
    • getScreenBounds

      public Rectangle getScreenBounds()
      Helper to get the screen bounds
      Returns:
      Bounds
    • getDestroyed

      public boolean getDestroyed()
      _more_
      Returns:
      _more_
    • destroy

      public void destroy()
      Destroys this instance, releasing any resources. This method should be invoked when this instance is no longer needed. The client should not try to use this instance after invoking this method. Subclasses that override this method should invoke super.destroy().
    • getComponent

      public Component getComponent()
      Gets the associated AWT Component.
      Returns:
      The associated AWT Component.
    • reDisplayAll

      protected void reDisplayAll()
      Tells the Display to retransform all data objects.
    • reScale

      public void reScale()
      Autoscale the axes of the display that have not had a range set on them.
    • rebuildDisplay

      public void rebuildDisplay() throws VisADException, RemoteException
      Rebuilds the display if appropriate. If this instance is active and the display has been marked for a future rebuild, then the display is rebuilt.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • rebuild

      protected void rebuild() throws VisADException, RemoteException
      Rebuild the display when needed.
      Throws:
      RemoteException - Java RMI error
      VisADException - problem creating VisAD object
    • setAnimation

      public void setAnimation(Animation animation, AnimationWidget animationWidget) throws VisADException, RemoteException
      Set the Animation for this DisplayMaster
      Parameters:
      animation - Animation object
      animationWidget - the associated widget
      Throws:
      RemoteException - Java RMI error
      VisADException - problem creating VisAD object
    • getDisplay

      public final LocalDisplay getDisplay()
      Returns the associated VisAD display.
      Returns:
      The VisAD display.
    • getDisplayableCount

      public final int getDisplayableCount()
      Returns the number of Displayable-s.
      Returns:
      The number of Displayable-s.
    • addDisplayable

      public final void addDisplayable(Displayable displayable) throws RemoteException, VisADException
      Adds a Displayable to the Displayable-s managed by this instance.
      Parameters:
      displayable - The Displayable to be added.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • setDisplayables

      public final void setDisplayables(int index, Displayable displayable) throws VisADException, RemoteException
      Sets the Displayable managed by this instance at a given point in the list of Displayable-s.
      Parameters:
      index - The position in the list of Displayable-s.
      displayable - The Displayable to be in the given position.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • setDisplayables

      public final void setDisplayables(Displayable[] displayables) throws VisADException, RemoteException
      Sets the Displayables managed by this instance.
      Parameters:
      displayables - The Displayable-s to be managed by this instance.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • removeDisplayable

      public boolean removeDisplayable(Displayable displayable) throws VisADException, RemoteException
      Removes a Displayable from this instance. Invokes the Displayable's removeDataReferences() method if and only if the Displayable is in this instance's list of Displayable-s. NOTE: If the Displayable is in this instance's list of Displayable-s, then this instance must be active or be made active before the Displayable is can be successfully added to another display. The display might be rebuilt or marked for a rebuild.
      Parameters:
      displayable - The Displayable to be removed.
      Returns:
      true if and only if the Displayable was in this instance's list of Displayable-s.
      Throws:
      VisADException - if an error occurs in core VisAD
      RemoteException - if a Java RMI failure occurs.
      See Also:
    • removeDisplayables

      public void removeDisplayables() throws VisADException, RemoteException
      Removes all Displayables from this instance.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
      See Also:
    • setBackground

      public void setBackground(Color color)
      Sets the background color of this VisAD display.
      Parameters:
      color - a Java Color to become the background color.
    • getBackground

      public Color getBackground()
      Returns the background color being used
      Returns:
      color being used or null if it couldn't be determined
    • getForeground

      public Color getForeground()
      Returns the foreground color being used for the cursor and box
      Returns:
      color being used or null if it couldn't be determined
    • setForeground

      public void setForeground(Color color)
      Sets the "foreground" color of this VisAD display
      Parameters:
      color - color to use
    • getDisplayables

      public final Displayable getDisplayables(int index)
      Returns the Displayable at a given position in the list of Displayables.
      Parameters:
      index - The position in the list to get the Displayable.
      Returns:
      The Displayable at the given position.
    • getDisplayables

      public final Displayable[] getDisplayables()
      Returns the Displayables of this instance as an array.
      Returns:
      The array of Displayable-s.
    • indexOf

      public int indexOf(Displayable displayable)
      Returns the index of a particular Displayable.
      Parameters:
      displayable - The Displayable to look for.
      Returns:
      The index of the Displayable in this composite or -1 if this CompositeDisplayable does not contain this Displayable.
    • setPointMode

      public void setPointMode(boolean usePoints) throws VisADException, RemoteException
      Sets the point-mode of the VisAD display.
      Parameters:
      usePoints - True if the display should use points rather than connected line segments.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • isPointMode

      public boolean isPointMode()
      Gets the point-mode of the VisAD display.
      Returns:
      True if the display is using points rather than connected line segments.
    • saveProjection

      public void saveProjection()
      Saves the current display projection. The projection may later be restored by the method resetProjection().
      See Also:
    • setDisplayAspect

      public void setDisplayAspect(double[] newAspect) throws VisADException, RemoteException
      Sets the display aspect ratio. The argument is passed unaltered to ProjectionControl.setAspect(double[]).
      Parameters:
      newAspect - The new aspect ratio.
      Throws:
      VisADException - if a VisAD failure occurs.
      RemoteException - if a Java RMI failure occurs.
    • is3D

      protected boolean is3D()
      Are we in 3D. This is rudimentary and just checks the type of the display
      Returns:
      is the display 3D
    • getDisplayAspect

      public double[] getDisplayAspect()
      Gets the current display aspect.
      Returns:
      The current display aspect ratio.
    • getProjectionMatrix

      public double[] getProjectionMatrix()
      Gets the current display projection. The object returned from ProjectionControl.getMatrix() is returned.
      Returns:
      The current display projection.
    • getScale

      public double getScale()
      _more_
      Returns:
      _more_
    • getRotation

      public double[] getRotation()
      _more_
      Returns:
      _more_
    • setProjectionMatrix

      public void setProjectionMatrix(double[] newMatrix) throws VisADException, RemoteException
      Sets the current display projection. The argument is passed, unaltered, to ProjectionControl.setMatrix(double[]).
      Parameters:
      newMatrix - The new projection matrix.
      Throws:
      VisADException - if a VisAD failure occurs.
      RemoteException - if a Java RMI failure occurs.
    • getSavedProjectionMatrix

      public double[] getSavedProjectionMatrix()
      Returns the saved projection Matrix. The object returned from ProjectionControl.getSavedProjectionMatrix() is returned.
      Returns:
      The saved projection matrix.
    • resetProjection

      public void resetProjection() throws VisADException, RemoteException
      Restores to projection at time of last saveProjection() call -- if one was made -- or to initial projection otherwise.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
      See Also:
    • addKeyboardBehavior

      public void addKeyboardBehavior(KeyboardBehavior behavior)

      Adds a KeyboardBehavior to the display that this DisplayMaster manages.

      This implementation does nothing but check to see if this instance has been destroyed.

      Parameters:
      behavior - The keyboard behavior to be added.
    • setKeyboardBehavior

      protected void setKeyboardBehavior(KeyboardBehavior behavior)
      Set the keyboard behavior to use
      Parameters:
      behavior - the keyboard behavior
    • setKeyboardEventMap

      public void setKeyboardEventMap(int[][] map)
      Set the key to function map on the current keyboard behavior
      Parameters:
      map - the map
    • setKeyboardEventMap

      public static void setKeyboardEventMap(int[][] map, KeyboardBehavior behavior)
      Set the key to function map on the given behavior
      Parameters:
      map - the map
      behavior - behavior to set
    • setMouseFunctions

      public void setMouseFunctions(int[][][] map) throws VisADException
      Set the mouse functions for this display.
      Parameters:
      map - array of mouse functions to buttons
      Throws:
      VisADException - the VisAD exception
      See Also:
    • getMouseFunctionMap

      public int[][][] getMouseFunctionMap()
      mouse function map
      Returns:
      mouse function map
    • getMouseBehavior

      public MouseBehavior getMouseBehavior()
      Get the current mouse behavior
      Returns:
      mouse behavior
    • rotateX

      public void rotateX(double angle)
      rotate some angle
      Parameters:
      angle - rotate angle
    • rotateY

      public void rotateY(double angle)
      rotate some angle
      Parameters:
      angle - rotate angle
    • rotateZ

      public void rotateZ(double angle)
      rotate some angle
      Parameters:
      angle - rotate angle
    • handleMouseWheelMoved

      protected void handleMouseWheelMoved(MouseWheelEvent e)
      Handle when the mouse scroll wheel has been moved
      Parameters:
      e - event
    • zoom

      public void zoom(double factor)
      Zoom in on the display
      Parameters:
      factor - zoom factor ( > 1 = zoom in, 1 > zoom > 0 = zoom out). using 2.0 and .5 seems to work well.
    • zoom

      public void zoom(double xfactor, double yfactor, double zfactor)
      Zoom in on the display
      Parameters:
      xfactor - x zoom factor
      yfactor - y zoom factor
      zfactor - z zoom factor ( > 1 = zoom in, 1 > zoom > 0 = zoom out). using 2.0 and .5 seems to work well.
    • resetClipDistance

      public void resetClipDistance(double scale)
    • getDisplayScale

      public float getDisplayScale()
      Get the scaling factor for probes and such. The scaling is the parameter that gets passed to TextControl.setSize() and ShapeControl.setScale().
      Returns:
      ratio of the current matrix scale factor to the saved matrix scale factor.
    • translate

      public void translate(double xFactor, double yFactor)
      Translate (X,Y position) of the display
      Parameters:
      xFactor - X translation factor
      yFactor - Y translation factor
    • rotate

      public void rotate(double anglex, double angley, double anglez)
      rotate some angle
      Parameters:
      anglex - rotate angle
      angley - rotate angle
      anglez - rotate angle
    • resetMouseFunctions

      public void resetMouseFunctions() throws VisADException
      Reset the mouse functions to the default.
      Throws:
      VisADException - the VisAD exception
    • setDefaultMouseFunctions

      public static void setDefaultMouseFunctions(DisplayImpl display) throws VisADException
      A general utility method that sets the default mouse functions on the given display.
      Parameters:
      display - Display to set functions for
      Throws:
      VisADException - the VisAD exception
    • setWaitMessageVisible

      public void setWaitMessageVisible(boolean visible)
      Toggle the "Please wait.." string visibility.
      Parameters:
      visible - true to make it visible
    • getWaitMessageVisible

      public boolean getWaitMessageVisible()
      Get the state of the "Please wait.." string visibility.
      Returns:
      true if visible
    • setAnimationStringVisible

      public void setAnimationStringVisible(boolean visible)
      Toggle the animation string visibility.
      Parameters:
      visible - true to make it visible
    • getAnimationStringVisible

      public boolean getAnimationStringVisible()
      Return whether the animation string is visible or not
      Returns:
      true if visible
    • getStereoAvailable

      public boolean getStereoAvailable()
      Determine if this MapDisplay can do stereo. Subclasses that support this should override this method
      Returns:
      false (unless overriden)
    • setEyePosition

      public void setEyePosition(double position)
      Set the eye position of each eye for a stereo view. Subclasses that support this should override this method
      Parameters:
      position - x position of each eye (left negative, right positive).
    • addVetoableChangeListener

      public void addVetoableChangeListener(VetoableChangeListener listener)
      Adds a VetoableChangeListener.
      Parameters:
      listener - The VetoableChangeListener to add.
    • addVetoableChangeListener

      public void addVetoableChangeListener(String name, VetoableChangeListener listener)
      Adds a named VetoableChangeListener.
      Parameters:
      name - The name of the property.
      listener - The VetoableChangeListener to add.
    • removeVetoableChangeListener

      public void removeVetoableChangeListener(VetoableChangeListener listener)
      Removes a VetoableChangeListener.
      Parameters:
      listener - The VetoableChangeListener to be removed.
    • removeVetoableChangeListener

      public void removeVetoableChangeListener(String name, VetoableChangeListener listener)
      Removes a named VetoableChangeListener.
      Parameters:
      name - The name of the property.
      listener - The VetoableChangeListener to be removed.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Adds a PropertyChangeListener.
      Parameters:
      listener - The PropertyChangeListener to add.
    • addPropertyChangeListener

      public void addPropertyChangeListener(String name, PropertyChangeListener listener)
      Adds a named PropertyChangeListener.
      Parameters:
      name - The name of the property.
      listener - The PropertyChangeListener to add.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a PropertyChangeListener.
      Parameters:
      listener - The PropertyChangeListener to be removed.
    • removePropertyChangeListener

      public void removePropertyChangeListener(String name, PropertyChangeListener listener)
      Removes a named PropertyChangeListener.
      Parameters:
      name - The name of the property.
      listener - The PropertyChangeListener to be removed.
    • draw

      public void draw() throws VisADException, RemoteException
      Causes the Displayable-s managed by this instance to be rendered to the VisAD display.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • equals

      public boolean equals(Object obj)
      Indicates if this instance if semantically identical to another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The other object.
      Returns:
      true if and only if this instance is semantically identical to obj.
    • hashCode

      public int hashCode()
      Gets the hash-code of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash-code of this instance.
    • addDisplayListener

      public void addDisplayListener(DisplayListener listener)
      Adds a VisAD DisplayListener to this instance's Display.
      Parameters:
      listener - The VisAD DisplayListener to be added.
    • firePropertyChange

      protected void firePropertyChange(PropertyChangeEvent event)
      Fires a PropertyChangeEvent.
      Parameters:
      event - The PropertyChangeEvent to be fired.
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fires a PropertyChangeEvent.
      Parameters:
      propertyName - The name of the property.
      oldValue - The old value of the property.
      newValue - The new Value of the property.
    • addScalarMap

      protected void addScalarMap(ScalarMap map) throws VisADException, RemoteException

      Adds a ScalarMap to this instance. The display might be rebuilt or marked for a rebuild.

      This implementation invokes addScalarMaps(ScalarMapSet) with the given ScalarMap as the only member of the set.

      Parameters:
      map - The ScalarMap to add.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • addScalarMaps

      protected void addScalarMaps(ScalarMapSet mapSet) throws VisADException, RemoteException
      Adds ScalarMaps to this instance.
      Parameters:
      mapSet - The ScalarMap-s to add.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • removeScalarMaps

      protected void removeScalarMaps(ScalarMapSet mapSet) throws VisADException, RemoteException
      Removes given ScalarMaps from this instance. The display might be rebuilt or marked for a rebuild.
      Parameters:
      mapSet - The ScalarMap-s to remove.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • removeScalarMap

      protected boolean removeScalarMap(ScalarMap map) throws VisADException, RemoteException
      Removes a ScalarMap from this instance. The display might be rebuilt or marked for a rebuild. true is returned if and only if the ScalarMap had been added via a previous addScalarMap(ScalarMap) or addScalarMaps(ScalarMapSet).
      Parameters:
      map - The ScalarMap to remove.
      Returns:
      true if the ScalarMap existed.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • replaceScalarMap

      protected void replaceScalarMap(ScalarMap oldMap, ScalarMap newMap) throws VisADException, RemoteException
      Replaces a ScalarMap in this instance. The display might be rebuilt or marked for a rebuild.
      Parameters:
      oldMap - The ScalarMap to remove.
      newMap - The ScalarMap to add.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • setRebuildNecessary

      public void setRebuildNecessary()
      Sets the "rebuild necessary" property. deprecated
    • isActive

      public boolean isActive()
      Indicates if this instance is active (i.e will immediately rebuild the display when appropriate).
      Returns:
      true if and only if the display master is active.
    • printMe

      public void printMe()
      Print out a message
    • setDisplayInactive

      public void setDisplayInactive()
      Sets this instance inactive (ie: that it will not automatically rebuild the display when appropriate).

      This implementation invokes setActive(boolean).

    • setDisplayActive

      public void setDisplayActive() throws RemoteException, VisADException
      Activate the display if there is one or fewer pending inactive calls
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • setActive

      public void setActive(boolean newActiveValue) throws RemoteException, VisADException
      Determines whether or not this instance will automatically rebuild the display when appropriate. If the argument is true and the display has been marked for a rebuild, then the display will be rebuilt. This method is idempotent.
      Parameters:
      newActiveValue - true will cause an immediate rebuld if appropriate and ensure future, automatic rebuilds.
      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure. deprecated This will become private in the future. You should use setDisplayInactive() and setDisplayActive()
    • ensureInactive

      public boolean ensureInactive()
      Ensures that this instance is inactive (ie: that it will not automatically rebuild the display when appropriate).

      This implementation invokes setActive(boolean).

      Returns:
      The previous value of the "active" property. deprecated This will become private in the future. You should use setDisplayInactive() and setDisplayActive()
    • saveCurrentDisplay

      public void saveCurrentDisplay(File toFile)

      Capture the display's current image and save it to a file as an image (e.g., JPEG, png). No blocking occurs and the currently rendered display is captured.

      This implementation simply calls saveCurrentDisplay(File, boolean, boolean) with doSync=false.

      Parameters:
      toFile - The file to which to save the current image.
    • getAnimationSetFromDisplayables

      protected Set getAnimationSetFromDisplayables() throws VisADException, RemoteException
      Collect the animation set that is the union of all data
      Returns:
      Set of animation samplings
      Throws:
      RemoteException - problem computing set from remote data objects
      VisADException - problem computing set from local Data objects
    • buildAnimationSet

      protected Set buildAnimationSet() throws VisADException, RemoteException
      Build the animation set
      Returns:
      the animation set
      Throws:
      RemoteException - problem computing set from remote data objects
      VisADException - problem computing set from local Data objects
    • dataChange

      protected void dataChange() throws VisADException, RemoteException

      Handles a change to the data in the displayables.

      Throws:
      VisADException - VisAD failure.
      RemoteException - Java RMI failure.
    • saveCurrentDisplay

      public void saveCurrentDisplay(File toFile, boolean doSync, boolean block)
      Capture the display's current image and save it to a file as an image (eg, JPEG, png). If doSync is true, then the calling thread will block until rendering is complete.
      Parameters:
      toFile - The file to which to save the current image.
      doSync - Whether or not to wait until the display is stable.
      block - Whether or not to wait until the image is saved.
    • saveCurrentDisplay

      public void saveCurrentDisplay(File toFile, boolean doSync, boolean block, float quality)
      Capture the display's current image and save it to a file as an image (eg, JPEG, png). If doSync is true, then the calling thread will block until rendering is complete.
      Parameters:
      toFile - The file to which to save the current image.
      doSync - Whether or not to wait until the display is stable.
      block - Whether or not to wait until the image is saved.
      quality - JPEG quality
    • getImage

      public BufferedImage getImage(boolean doSync) throws Exception
      Get a buffered image of the Display
      Parameters:
      doSync - true to wait until display is done
      Returns:
      BufferedImage
      Throws:
      Exception - problem getting the image
    • printMatrix

      public void printMatrix(String name, double[] matrix)
      Print out the matrix.
      Parameters:
      name - the name of the matrix
      matrix - the matrix to print