Package edu.wisc.ssec.mcidasv.probes
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
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class is a reimplementation ofPointProbe
that whose mouse movement is limited to the x- and y- axes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Color
private double
private double
private String
private static final Color
private FlatField
private float
Used to keep track of the last zoom "level".private final List
<ProbeListener> private static final org.slf4j.Logger
private final DisplayMaster
private static final DecimalFormat
private final ReadoutProbe.PointSelector
private float
static final String
static final String
private static final TupleType
private final TextDisplayable
Displays the value of the data at the current position. -
Constructor Summary
ConstructorsConstructorDescriptionReadoutProbe
(DisplayControlImpl control, FlatField flatField, Color color, String pattern, boolean visible) Create a "HYDRA" probe that allows for displaying things like value at current position, current color, and location. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Add this probe instance to the relevant listeners.void
addProbeListener
(ProbeListener listener) Adds aProbeListener
to the listener list so that it can be notified when the probe is changed.private static TextDisplayable
createValueDisplay
(Color color) void
Called for events happening in theDisplayImpl
associated withDisplayMaster
.protected void
fireProbeColorChanged
(Color previous, Color current) Notifies the registeredProbeListeners
that this probe's color has changed.protected void
fireProbeFormatPatternChanged
(String previous, String current) Notifies the registeredProbeListeners
that this probe's location format pattern has changed.protected void
fireProbePositionChanged
(RealTuple previous, RealTuple current) Notifies the registeredProbeListeners
that this probe's position has changed.protected void
fireProbeVisibilityChanged
(boolean previous) Notifies registeredProbeListeners
that this probe's visibility has changed.getColor()
Get the current color of thisReadoutProbe
instance.final float
Get the scaling factor for probes and such.Get the current "earth location" of the probe.Returns the number format string current being used.private static RealTuple
double
Get the current latitude of thisReadoutProbe
instance.double
Get the current longitude of thisReadoutProbe
instance.getValue()
Get the current "readout value" of thisReadoutProbe
instance.void
Called when this probe has been removed.void
boolean
hasListener
(ProbeListener listener) Determine whether or not a givenProbeListener
is listening to the current probe.static RealTuple
makeEarth2dTuple
(double lat, double lon) Returns aSpatialEarth2DTuple
for the given latitude and longitude.private static TupleType
void
projectionChanged
(MapProjection newProjection) Respond to the projection having been changed.void
Called whenever the probe fires off aPropertyChangeEvent
.void
quietlySetColor
(Color newColor) void
quietlySetFormatPattern
(String pattern) Update the location format pattern for the current probe, but do not fire off any events.void
quietlySetVisible
(boolean visibility) void
removeProbeListener
(ProbeListener listener) Removes aProbeListener
from the notification list.void
Change the color of thisReadoutProbe
instance.private void
Change the color of thisReadoutProbe
instance and control whether or not listeners should be notified.void
Sets theFlatField
associated with this probe to the givenfield
.void
setFormatPattern
(String pattern) Update the location format pattern for the current probe.private void
setFormatPattern
(String pattern, boolean quietly) Update the location format pattern for the current probe and optionally fire off an update event.void
setLatLon
(double latitude, double longitude) void
setXYPosition
(RealTuple position) toString()
Returns a brief summary of a ReadoutProbe.private Tuple
valueAtPosition
(RealTuple position, FlatField imageData) Methods inherited from class ucar.unidata.collab.SharableImpl
applySharableProperties, doShare, doShare, doShareExternal, doShareInternal, getReceiveShareTime, getSharablePropertiesComponent, getShareGroup, getSharing, getUniqueId, initSharable, receiveShareData, removeSharable, setReceiveShareTime, setShareGroup, setSharing, setUniqueId, showSharableDialog
-
Field Details
-
SHARE_PROFILE
- See Also:
-
SHARE_POSITION
- See Also:
-
DEFAULT_COLOR
-
TUPTYPE
-
logger
-
listeners
-
valueDisplay
Displays the value of the data at the current position. -
pointSelector
-
master
-
currentColor
-
currentValue
-
currentLatitude
-
currentLongitude
-
pointSize
-
field
-
numFmt
-
lastScale
Used to keep track of the last zoom "level".
-
-
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 arenull
.VisADException
- if VisAD had problems.RemoteException
- if VisAD had problems.
-
-
Method Details
-
addListeners
Add this probe instance to the relevant listeners. -
propertyChange
Called whenever the probe fires off aPropertyChangeEvent
.Only handles position changes right now, all other events are discarded.
- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
e
- Object that describes the property change.- Throws:
NullPointerException
- if passed anull
PropertyChangeEvent
.
-
displayChanged
Called for events happening in theDisplayImpl
associated withDisplayMaster
.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 interfaceDisplayListener
- Parameters:
e
- Event to handle.
-
setField
Sets theFlatField
associated with this probe to the givenfield
.- Parameters:
flatField
- NewFlatField
for this probe.- Throws:
NullPointerException
- if passed anull
field
.
-
addProbeListener
Adds aProbeListener
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
- iflistener
is null.
-
removeProbeListener
Removes aProbeListener
from the notification list.- Parameters:
listener
-ProbeListener
to remove.null
values are permitted, but since they are not allowed to be added...
-
hasListener
Determine whether or not a givenProbeListener
is listening to the current probe.- Parameters:
listener
-ProbeListener
to check.null
values are permitted.- Returns:
true
iflistener
has been added to the list ofProbeListener
objects,false
otherwise.
-
fireProbePositionChanged
Notifies the registeredProbeListeners
that this probe's position has changed.- Parameters:
previous
- Previous position. Cannot benull
.current
- Current position. Cannot benull
.
-
fireProbeColorChanged
Notifies the registeredProbeListeners
that this probe's color has changed.- Parameters:
previous
- Previous color. Cannot benull
.current
- Current color. Cannot benull
.
-
fireProbeVisibilityChanged
Notifies registeredProbeListeners
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
Notifies the registeredProbeListeners
that this probe's location format pattern has changed.- Parameters:
previous
- Previous location format pattern.current
- Current location format pattern.
-
setColor
Change the color of thisReadoutProbe
instance.- Parameters:
color
- New color. Cannot benull
.
-
getPointSelector
-
getValueDisplay
-
setColor
Change the color of thisReadoutProbe
instance and control whether or not listeners should be notified.Note that if
color
is the same ascurrentColor
, nothing will happen (the method exits early).- Parameters:
color
- New color for this probe. Cannot benull
.quietly
- Whether or not to notify the list ofProbeListeners
of a color change.
-
getColor
Get the current color of thisReadoutProbe
instance.- Returns:
Color
of thisReadoutProbe
.
-
getValue
Get the current "readout value" of thisReadoutProbe
instance.- Returns:
- The value of the data at the probe's current location.
-
getLatitude
Get the current latitude of thisReadoutProbe
instance.- Returns:
- Current latitude of the probe.
-
getLongitude
Get the current longitude of thisReadoutProbe
instance.- Returns:
- Current longitude of the probe.
-
setLatLon
-
quietlySetVisible
-
quietlySetColor
-
setFormatPattern
Update the location format pattern for the current probe.- Parameters:
pattern
- New location format pattern. Cannot benull
.
-
quietlySetFormatPattern
Update the location format pattern for the current probe, but do not fire off any events.- Parameters:
pattern
- New location format pattern. Cannot benull
.
-
setFormatPattern
Update the location format pattern for the current probe and optionally fire off an update event.- Parameters:
pattern
- New location format pattern. Cannot benull
.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
-
handleProbeRemoval
Called when this probe has been removed. -
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
-
getXYPosition
-
getEarthPosition
Get the current "earth location" of the probe.Note: this method will attempt to change the
currentLatitude
andcurrentLongitude
fields.- Returns:
- Location of
pointSelector
, ornull
if the location could not be determined.
-
projectionChanged
Respond to the projection having been changed.- Parameters:
newProjection
- New projection. Can benull
.
-
valueAtPosition
-
makeEarth2dTuple
public static RealTuple makeEarth2dTuple(double lat, double lon) throws VisADException, RemoteException Returns aSpatialEarth2DTuple
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
containinglat
andlon
.- Throws:
VisADException
- Problem creating VisAD object.RemoteException
- Java RMI error.
-
getInitialProbePosition
-
createValueDisplay
-
makeTupleType
-
toString
Returns a brief summary of a ReadoutProbe. Please note that this format is subject to change.
-