Class ReadoutProbe

java.lang.Object
ucar.unidata.collab.SharableImpl
edu.wisc.ssec.mcidasv.probes.ReadoutProbe
All Implemented Interfaces:
PropertyChangeListener, EventListener, Sharable, DisplayListener

ReadoutProbe is a probe that combines a "pickable" probe widget with an adjacent text "readout" of the data value at the probe's current location.

Primarily used with MultiSpectralControl.

  • Field Details

  • Constructor Details

    • ReadoutProbe

      public ReadoutProbe(DisplayControlImpl control, FlatField flatField, Color color, String pattern, boolean visible) throws VisADException, RemoteException
      Create a "HYDRA" probe that allows for displaying things like value at current position, current color, and location.

      Note: none of the parameters permit null values.

      Parameters:
      control - "Layer" that will be probed.
      flatField - Data to probe.
      color - Color of the probe.
      pattern - Format string to use with probe's location values.
      visible - Whether or not the probe is visible.
      Throws:
      NullPointerException - if any of the given parameters are null.
      VisADException - if VisAD had problems.
      RemoteException - if VisAD had problems.
  • Method Details

    • addListeners

      private void addListeners()
      Add this probe instance to the relevant listeners.
    • propertyChange

      Called whenever the probe fires off a PropertyChangeEvent.

      Only handles position changes right now, all other events are discarded.

      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - Object that describes the property change.
      Throws:
      NullPointerException - if passed a null PropertyChangeEvent.
    • displayChanged

      public void displayChanged(DisplayEvent e)
      Called for events happening in the DisplayImpl associated with DisplayMaster.

      The only event that is actually handled is DisplayEvent.FRAME_DONE, which allows us to snap the text value displayable to the actual "pickable" probe.

      Specified by:
      displayChanged in interface DisplayListener
      Parameters:
      e - Event to handle.
    • setField

      public void setField(FlatField flatField)
      Sets the FlatField associated with this probe to the given field.
      Parameters:
      flatField - New FlatField for this probe.
      Throws:
      NullPointerException - if passed a null field.
    • addProbeListener

      public void addProbeListener(ProbeListener listener)
      Adds a ProbeListener to the listener list so that it can be notified when the probe is changed.
      Parameters:
      listener - ProbeListener to register. null listeners are not allowed.
      Throws:
      NullPointerException - if listener is null.
    • removeProbeListener

      public void removeProbeListener(ProbeListener listener)
      Removes a ProbeListener from the notification list.
      Parameters:
      listener - ProbeListener to remove. null values are permitted, but since they are not allowed to be added...
    • hasListener

      public boolean hasListener(ProbeListener listener)
      Determine whether or not a given ProbeListener is listening to the current probe.
      Parameters:
      listener - ProbeListener to check. null values are permitted.
      Returns:
      true if listener has been added to the list of ProbeListener objects, false otherwise.
    • fireProbePositionChanged

      protected void fireProbePositionChanged(RealTuple previous, RealTuple current)
      Notifies the registered ProbeListeners that this probe's position has changed.
      Parameters:
      previous - Previous position. Cannot be null.
      current - Current position. Cannot be null.
    • fireProbeColorChanged

      protected void fireProbeColorChanged(Color previous, Color current)
      Notifies the registered ProbeListeners that this probe's color has changed.
      Parameters:
      previous - Previous color. Cannot be null.
      current - Current color. Cannot be null.
    • fireProbeVisibilityChanged

      protected void fireProbeVisibilityChanged(boolean previous)
      Notifies registered ProbeListeners that this probe's visibility has changed. Only takes a "previous" value, which is negated to form the "current" value.
      Parameters:
      previous - Visibility before change.
    • fireProbeFormatPatternChanged

      protected void fireProbeFormatPatternChanged(String previous, String current)
      Notifies the registered ProbeListeners that this probe's location format pattern has changed.
      Parameters:
      previous - Previous location format pattern.
      current - Current location format pattern.
    • setColor

      public void setColor(Color color)
      Change the color of this ReadoutProbe instance.
      Parameters:
      color - New color. Cannot be null.
    • getPointSelector

    • getValueDisplay

    • setColor

      private void setColor(Color color, boolean quietly)
      Change the color of this ReadoutProbe instance and control whether or not listeners should be notified.

      Note that if color is the same as currentColor, nothing will happen (the method exits early).

      Parameters:
      color - New color for this probe. Cannot be null.
      quietly - Whether or not to notify the list of ProbeListeners of a color change.
    • getColor

      public Color getColor()
      Get the current color of this ReadoutProbe instance.
      Returns:
      Color of this ReadoutProbe.
    • getValue

      public String getValue()
      Get the current "readout value" of this ReadoutProbe instance.
      Returns:
      The value of the data at the probe's current location.
    • getLatitude

      public double getLatitude()
      Get the current latitude of this ReadoutProbe instance.
      Returns:
      Current latitude of the probe.
    • getLongitude

      public double getLongitude()
      Get the current longitude of this ReadoutProbe instance.
      Returns:
      Current longitude of the probe.
    • setLatLon

      public void setLatLon(double latitude, double longitude)
    • quietlySetVisible

      public void quietlySetVisible(boolean visibility)
    • quietlySetColor

      public void quietlySetColor(Color newColor)
    • setFormatPattern

      public void setFormatPattern(String pattern)
      Update the location format pattern for the current probe.
      Parameters:
      pattern - New location format pattern. Cannot be null.
    • quietlySetFormatPattern

      public void quietlySetFormatPattern(String pattern)
      Update the location format pattern for the current probe, but do not fire off any events.
      Parameters:
      pattern - New location format pattern. Cannot be null.
    • setFormatPattern

      private void setFormatPattern(String pattern, boolean quietly)
      Update the location format pattern for the current probe and optionally fire off an update event.
      Parameters:
      pattern - New location format pattern. Cannot be null.
      quietly - Whether or not to fire a format pattern change update.
    • getFormatPattern

      Returns the number format string current being used.
      Returns:
      Location format pattern string.
    • handleProbeUpdate

      public void handleProbeUpdate()
    • handleProbeRemoval

      public void handleProbeRemoval()
      Called when this probe has been removed.
    • getDisplayScale

      public final 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.
    • setXYPosition

      public void setXYPosition(RealTuple position)
    • getXYPosition

    • getEarthPosition

      Get the current "earth location" of the probe.

      Note: this method will attempt to change the currentLatitude and currentLongitude fields.

      Returns:
      Location of pointSelector, or null if the location could not be determined.
    • projectionChanged

      public void projectionChanged(MapProjection newProjection)
      Respond to the projection having been changed.
      Parameters:
      newProjection - New projection. Can be null.
    • valueAtPosition

      private Tuple valueAtPosition(RealTuple position, FlatField imageData)
    • makeEarth2dTuple

      private static RealTuple makeEarth2dTuple(double lat, double lon) throws VisADException, RemoteException
      Returns a SpatialEarth2DTuple for the given latitude and longitude.

      Be aware that for whatever reason VisAD wants the longitude first, then the latitude.

      Parameters:
      lat - Latitude of the position.
      lon - Longitude of the position.
      Returns:
      SpatialEarth2DTuple containing lat and lon.
      Throws:
      VisADException - Problem creating VisAD object.
      RemoteException - Java RMI error.
    • getInitialProbePosition

    • createValueDisplay

      private static TextDisplayable createValueDisplay(Color color)
    • makeTupleType

      private static TupleType makeTupleType()
    • toString

      public String toString()
      Returns a brief summary of a ReadoutProbe. Please note that this format is subject to change.
      Overrides:
      toString in class Object
      Returns:
      String that looks like [ReadProbe@HASHCODE: color=..., latitude=..., longitude=..., value=...]