ucar.unidata.idv.control.drawing
Class DrawingGlyph

java.lang.Object
  extended by ucar.unidata.idv.control.drawing.DrawingGlyph
Direct Known Subclasses:
ArrowGlyph, FrontGlyph, HighLowGlyph, ImageGlyph, LineGlyph, MovieGlyph, SymbolGlyph, TextGlyph

public abstract class DrawingGlyph
extends Object

Class Glyph. Base class for all drawing things

Version:
$Revision: 1.92 $
Author:
IDV Development Team

Field Summary
protected  List actualPoints
          actual points being displayed
static String ATTR_COLOR
          xml attribute name
static String ATTR_COORDTYPE
          xml attribute name
static String ATTR_FILLED
          xml attribute name
static String ATTR_FULLLATLON
          xml attribute name
static String ATTR_LINEWIDTH
          xml attribute name
static String ATTR_NAME
          xml attribute name
static String ATTR_PICKABLE
          xml attribute name
static String ATTR_POINTS
          xml attribute name
static String ATTR_TEXT
          xml attr names
static String ATTR_TIMES
          xml attribute name
static String ATTR_ZPOSITION
          xml attribute name
protected  DrawingControl control
          My control
static String[] COORD_LABELS
          labels for coordinate syste type.
static int COORD_LATLON
          Represents LAT/LON vertical coordinate
static int COORD_LATLONALT
          Represents LAT/LON/ALT vertical coordinate
static int COORD_NONE
          Represents no vertical coordinate
static String[] COORD_TYPENAMES
          Drawing coordinate names
static int[] COORD_TYPES
          Drawing coordinate types
static int COORD_XY
          Represents XY vertical coordinate
static int COORD_XYZ
          Represents XYZ vertical coordinate
protected  int coordType
          What drawing coord system are we on
protected  EarthLocation firstMoveEarthLocation
          Where did we start moving
protected  double[] firstMoveLocation
          Where did we start moving
static int IDX_ALT
          Indices into arrays
static int IDX_LAT
          Indices into arrays
static int IDX_LON
          Indices into arrays
static int IDX_X
          Indices into arrays
static int IDX_Y
          Indices into arrays
static int IDX_Z
          Indices into arrays
protected  CompositeDisplayable parentDisplayable
          Top level displayable
protected  List points
          List of points.
protected  JDialog propDialog
          The properties dialog
protected  boolean propertiesUp
          Is properties dialog shown
static int PT_X
          Indices into arrays
static int PT_Y
          Indices into arrays
static int PT_Z
          Indices into arrays
protected  CompositeDisplayable selectionDisplayable
          Shows selected highlight
protected  int stretchIndex
          What point are we stretching
protected  JTabbedPane tabbedPane
          For props
static String TAG_ARROW
          Xml tag name
static String TAG_FRONT
          Xml tag name
static String TAG_HIGH
          Xml tag name
static String TAG_IMAGE
          Xml tag name
static String TAG_LOW
          Xml tag name
static String TAG_MOVIE
          Xml tag name
static String TAG_POLYGON
          Xml tag name
static String TAG_SHAPE
          Xml tag name
static String TAG_SYMBOL
          Xml tag name
static String TAG_TEXT
          Xml tag name
protected static int uniqueCnt
          For unique ids
protected  float zPosition
          Fixed z position
 
Constructor Summary
DrawingGlyph()
          Ctor
DrawingGlyph(DrawingControl control, DisplayEvent event)
          Ctor
DrawingGlyph(DrawingControl control, DisplayEvent event, boolean filled)
          Ctor
 
Method Summary
protected  void addAttributes(Element e)
          Populate the xml node with attrs
protected  void addDisplayable(Displayable displayable)
          Add the displayable to the main parent displayable
 void addTime(Real time)
          Add the time to the list of times
protected  boolean applyProperties(Hashtable compMap)
          Handle the property apply.
 boolean canShowArea()
          Can this glyph type calculate area
 boolean canShowDistance()
          Can this glyph type calculate distance
 void checkTimeVisibility()
          Is this glyph visible in the current time step
 void checkVisibility()
          Make sure the displayable is not visible if this glyph is not visible
 int closestPoint(double[] location, List points)
          Find index of closest point
protected  boolean constrainedTo2D()
          Is glyph constrained to 2d
 double distance(double[] location, double[] direction)
          Calculate distance
static double distanceBetween(double[] origin, double[] loc2)
          Get distance between
 double distanceBetween(double[] loc1, EarthLocation el)
          Get distance
protected  void doInterpolatedStretch(DisplayEvent event)
          This stretches the current point and also stretches the rest of the points by a linear delta from the initial point.
 void doMove(DisplayEvent event)
          Move this glyph
 void doneBeingCreated()
          all done
 void doStretch(DisplayEvent event)
          Stretch this glyph
 void evaluateJython()
          Evaluate the jython from the properties dialog
 double getArea()
          Get the area in square feet.
 boolean getBeenRemoved()
          Get the BeenRemoved property.
 boolean getBeingCreated()
          currently being created
protected  List getBoundingBox(List points)
          Find bounding box of points
protected  double[] getBoxPoint(int i)
          Get xyz of point at given index
protected  double[] getBoxPoint(int i, List l)
          Get xyz of point at given index
protected  double[] getBoxPoint(Object point)
          Convert point (either latlonalt or xyz) to xyz
 Color getColor()
          Get the Color property.
 int getCoordType()
          Get the CoordType property.
 boolean getCreatedByUser()
          Get the CreatedByUser property.
protected  float getDefaultZPosition()
          Get the default Z position for the glyph.
 String getDescription()
          Get the description
 Displayable getDisplayable()
          Get the main displayable.
 Real getDistance()
          Calculate the distance along the line
 boolean getEditable()
          Get the Editable property.
 Element getElement(Document doc)
          Create an xml element that represents this glyph
 String getExtraDescription()
          Get extra description to show in the JTable
 boolean getFilled()
          Get the Filled property.
protected  double getFixedAltitude()
          Get altitude of zposition
 boolean getFullLatLon()
          Get the FullLatLon property.
protected  float[][] getLatLons(List points)
          Convert points list of array of xyz or lat/lon/alt
 String getName()
          Get the Name property.
protected  CompositeDisplayable getParent()
          Get the main displayable.
 boolean getPickable()
          Get the Pickable property.
protected  Object getPoint(DisplayEvent event)
          Get point to use from the event.
 List getPoints()
          Get the Points property.
protected  float[][] getPointValues()
          Convert points list of array of xyz or lat/lon/alt
protected  float[][] getPointValues(boolean convertToXY)
          Convert points list of array of xyz or lat/lon/alt
protected  double[][] getPointValuesDouble()
          Convert points list of array of xyz or lat/lon/alt
protected  double[][] getPointValuesDouble(boolean convertToXY)
          Convert points list of array of xyz or lat/lon/alt
protected  void getPropertiesComponents(List comps, Hashtable compMap)
          Make the properties widgets
protected  List getSelectionPoints()
          Get points used to select this glyph.
abstract  String getTagName()
          Get xml tag name to use
protected  Data getTimeField(Data data)
          Make the time field if we have time values If not, just return the data
protected  void getTimePropertiesComponents(List comps, Hashtable compMap)
          Add to the comps array the time list for selecting times
 List getTimeValues()
          Get the TimeValue property.
abstract  String getTypeName()
          Get the name of this glyph type
 boolean getVisibleFlag()
          Get the VisibleFlag property.
 float getZPosition()
          Get the ZPosition property.
 DrawingGlyph handleCreation(DisplayEvent event)
          Handle the creation event.
 DrawingGlyph handleKeyPressed(DisplayEvent event)
          Handle event.
 DrawingGlyph handleMouseDragged(DisplayEvent event)
          Handle event.
 DrawingGlyph handleMouseMoved(DisplayEvent event)
          Handle the event.
 DrawingGlyph handleMousePressed(DisplayEvent event)
          Handle the event.
 DrawingGlyph handleMouseReleased(DisplayEvent event)
          Handle event.
 void hide()
          Hide glyph
 boolean initFinal()
          Do final initialization
protected  boolean initFinalInner()
          This is called to do final initialization
 void initFromBundle(DrawingControl control)
          Initialize when recreated from a bundle
 boolean initFromUser(DrawingControl control, DisplayEvent event)
          Initialize from a user event.
 void initFromXml(DrawingControl control, Element node)
          Initialize from xml
 void initMove(DisplayEvent event)
          Started moving
 void initStretch(DisplayEvent event)
          Start streth
 boolean isInFlatSpace()
          Are we drawing in xy or lat/lon space
 boolean isInLatLonSpace()
          In lat/lon or lat/lon/alt space
 boolean isInXYSpace()
          Are we drawing in xy or xyz space
 boolean isSelectable()
          Is this glyph selectable
 boolean isValid()
          Is this glyph valid.
 boolean isVisible()
          Is this glyph visible
protected  EarthLocation makePoint(double lat, double lon, double alt)
          Utility to make a point
 boolean mousePressed(DisplayEvent event)
          handle event
protected  void moveTo(DisplayEvent event)
          Move this glyph to the location of the event
 void processPointStrings(List pointStrings)
          Parse the List of point strings.
 void projectionChanged()
          Handle event
protected  void removeDisplayable(Displayable displayable)
          Remove the displayable from the main displayable
protected  void setActualPoints(float[][] pts)
          Set the points list
 void setBeenRemoved(boolean value)
          Set the BeenRemoved property.
 void setColor(Color value)
          Set the Color property.
protected  void setColor(Displayable displayable, Color c)
          Set color on displayable
 void setCoordType(int value)
          Set the CoordType property.
 void setCreatedByUser(boolean value)
          Set the CreatedByUser property.
 void setEditable(boolean value)
          Set the Editable property.
 void setFilled(boolean value)
          Set the Filled property.
 void setFullLatLon(boolean value)
          Set the Fulllatlon property.
 void setName(String value)
          Set the Name property.
 void setPickable(boolean value)
          Set the Pickable property.
 void setPoints(List value)
          Set the Points property.
 void setProperties()
          Set the properties from the dialog
 void setSelected(boolean selected)
          Set this glyph selected
 void setTimeValues(List value)
          Set the TimeValue property.
 void setVisible(boolean visible)
          Toggle visiblity of the displayable
 void setVisibleFlag(boolean value)
          Set the VisibleFlag property.
 void setZPosition(float value)
          Set the Zposition property.
protected  boolean shouldShowColorSelector()
          Should show color selector in properties
 void show()
          Show glyph
static double[][] smoothCurve(double[][] curve, int window)
          Smooth the curve
static double squared(double v1)
          Square value
protected  void swap(double[] a1, double[] a2, int index)
          Swap array values at index
protected  void swap(float[] a1, float[] a2, int index)
          Swap array values at index
protected  float[] toLatLonAlt(EarthLocation el)
          Convert to float array
 String toString()
          to string
protected  Data tryToFill(float[][] pts, Data dflt)
          Try to fill the pts array
 void updateLocation()
          Glyph moved.
 void viewpointChanged()
          viewpoint changed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uniqueCnt

protected static int uniqueCnt
For unique ids


TAG_POLYGON

public static final String TAG_POLYGON
Xml tag name

See Also:
Constant Field Values

TAG_ARROW

public static final String TAG_ARROW
Xml tag name

See Also:
Constant Field Values

TAG_FRONT

public static final String TAG_FRONT
Xml tag name

See Also:
Constant Field Values

TAG_TEXT

public static final String TAG_TEXT
Xml tag name

See Also:
Constant Field Values

TAG_HIGH

public static final String TAG_HIGH
Xml tag name

See Also:
Constant Field Values

TAG_LOW

public static final String TAG_LOW
Xml tag name

See Also:
Constant Field Values

TAG_SHAPE

public static final String TAG_SHAPE
Xml tag name

See Also:
Constant Field Values

TAG_SYMBOL

public static final String TAG_SYMBOL
Xml tag name

See Also:
Constant Field Values

TAG_IMAGE

public static final String TAG_IMAGE
Xml tag name

See Also:
Constant Field Values

TAG_MOVIE

public static final String TAG_MOVIE
Xml tag name

See Also:
Constant Field Values

ATTR_COLOR

public static final String ATTR_COLOR
xml attribute name

See Also:
Constant Field Values

ATTR_FILLED

public static final String ATTR_FILLED
xml attribute name

See Also:
Constant Field Values

ATTR_PICKABLE

public static final String ATTR_PICKABLE
xml attribute name

See Also:
Constant Field Values

ATTR_FULLLATLON

public static final String ATTR_FULLLATLON
xml attribute name

See Also:
Constant Field Values

ATTR_TIMES

public static final String ATTR_TIMES
xml attribute name

See Also:
Constant Field Values

ATTR_ZPOSITION

public static final String ATTR_ZPOSITION
xml attribute name

See Also:
Constant Field Values

ATTR_COORDTYPE

public static final String ATTR_COORDTYPE
xml attribute name

See Also:
Constant Field Values

ATTR_POINTS

public static final String ATTR_POINTS
xml attribute name

See Also:
Constant Field Values

ATTR_LINEWIDTH

public static final String ATTR_LINEWIDTH
xml attribute name

See Also:
Constant Field Values

ATTR_TEXT

public static final String ATTR_TEXT
xml attr names

See Also:
Constant Field Values

ATTR_NAME

public static final String ATTR_NAME
xml attribute name

See Also:
Constant Field Values

COORD_NONE

public static final int COORD_NONE
Represents no vertical coordinate

See Also:
Constant Field Values

COORD_XYZ

public static final int COORD_XYZ
Represents XYZ vertical coordinate

See Also:
Constant Field Values

COORD_XY

public static final int COORD_XY
Represents XY vertical coordinate

See Also:
Constant Field Values

COORD_LATLONALT

public static final int COORD_LATLONALT
Represents LAT/LON/ALT vertical coordinate

See Also:
Constant Field Values

COORD_LATLON

public static final int COORD_LATLON
Represents LAT/LON vertical coordinate

See Also:
Constant Field Values

COORD_TYPES

public static final int[] COORD_TYPES
Drawing coordinate types


COORD_TYPENAMES

public static final String[] COORD_TYPENAMES
Drawing coordinate names


COORD_LABELS

public static final String[] COORD_LABELS
labels for coordinate syste type.


propertiesUp

protected boolean propertiesUp
Is properties dialog shown


propDialog

protected JDialog propDialog
The properties dialog


tabbedPane

protected JTabbedPane tabbedPane
For props


points

protected List points
List of points. May be lat/lon/alt or x/y/z


stretchIndex

protected int stretchIndex
What point are we stretching


firstMoveLocation

protected double[] firstMoveLocation
Where did we start moving


actualPoints

protected List actualPoints
actual points being displayed


firstMoveEarthLocation

protected EarthLocation firstMoveEarthLocation
Where did we start moving


PT_X

public static final int PT_X
Indices into arrays

See Also:
Constant Field Values

PT_Y

public static final int PT_Y
Indices into arrays

See Also:
Constant Field Values

PT_Z

public static final int PT_Z
Indices into arrays

See Also:
Constant Field Values

IDX_X

public static final int IDX_X
Indices into arrays

See Also:
Constant Field Values

IDX_Y

public static final int IDX_Y
Indices into arrays

See Also:
Constant Field Values

IDX_Z

public static final int IDX_Z
Indices into arrays

See Also:
Constant Field Values

IDX_LAT

public static final int IDX_LAT
Indices into arrays

See Also:
Constant Field Values

IDX_LON

public static final int IDX_LON
Indices into arrays

See Also:
Constant Field Values

IDX_ALT

public static final int IDX_ALT
Indices into arrays

See Also:
Constant Field Values

coordType

protected int coordType
What drawing coord system are we on


zPosition

protected float zPosition
Fixed z position


parentDisplayable

protected CompositeDisplayable parentDisplayable
Top level displayable


selectionDisplayable

protected CompositeDisplayable selectionDisplayable
Shows selected highlight


control

protected DrawingControl control
My control

Constructor Detail

DrawingGlyph

public DrawingGlyph()
Ctor


DrawingGlyph

public DrawingGlyph(DrawingControl control,
                    DisplayEvent event)
Ctor

Parameters:
control - The control I'm in
event - The display event.

DrawingGlyph

public DrawingGlyph(DrawingControl control,
                    DisplayEvent event,
                    boolean filled)
Ctor

Parameters:
control - The control I'm in
event - The display event.
filled - Is this glyph filled
Method Detail

initFinal

public final boolean initFinal()
                        throws VisADException,
                               RemoteException
Do final initialization

Returns:
Success
Throws:
RemoteException - On badness
VisADException - On badness

initFinalInner

protected boolean initFinalInner()
                          throws VisADException,
                                 RemoteException
This is called to do final initialization

Returns:
Successful
Throws:
RemoteException - On badness
VisADException - On badness

initFromUser

public boolean initFromUser(DrawingControl control,
                            DisplayEvent event)
                     throws VisADException,
                            RemoteException
Initialize from a user event.

Parameters:
control - The control I'm in
event - The display event.
Returns:
OK
Throws:
RemoteException - When bad things happen
VisADException - When bad things happen

initFromBundle

public void initFromBundle(DrawingControl control)
                    throws VisADException,
                           RemoteException
Initialize when recreated from a bundle

Parameters:
control - The control I'm in
Throws:
RemoteException - When bad things happen
VisADException - When bad things happen

initFromXml

public void initFromXml(DrawingControl control,
                        Element node)
                 throws VisADException,
                        RemoteException
Initialize from xml

Parameters:
control - The control I'm in
node - The xml node
Throws:
RemoteException - When bad things happen
VisADException - When bad things happen

isSelectable

public boolean isSelectable()
Is this glyph selectable

Returns:
By default return true

getDefaultZPosition

protected float getDefaultZPosition()
Get the default Z position for the glyph.

Returns:
_more_

isValid

public boolean isValid()
Is this glyph valid. Some glyph classes get created but are not fully valid.

Returns:
By default return true

processPointStrings

public void processPointStrings(List pointStrings)
                         throws VisADException,
                                RemoteException
Parse the List of point strings. The format depends on the coordinate system type (e.g., XY, XYZ, etc.)

Parameters:
pointStrings - List of Strings that represent double location values
Throws:
RemoteException - On badness
VisADException - On badness

mousePressed

public boolean mousePressed(DisplayEvent event)
                     throws VisADException,
                            RemoteException
handle event

Parameters:
event - event
Returns:
continue processing
Throws:
RemoteException - On badness
VisADException - On badness

setSelected

public void setSelected(boolean selected)
                 throws VisADException,
                        RemoteException
Set this glyph selected

Parameters:
selected - Is selected
Throws:
RemoteException - On badness
VisADException - On badness

getSelectionPoints

protected List getSelectionPoints()
Get points used to select this glyph.

Returns:
Selection points

getElement

public final Element getElement(Document doc)
Create an xml element that represents this glyph

Parameters:
doc - The doc to create with
Returns:
The element

getTimeField

protected Data getTimeField(Data data)
                     throws VisADException,
                            RemoteException
Make the time field if we have time values If not, just return the data

Parameters:
data - the data to make the range of the time field with
Returns:
The time field or the data argument if there are no times
Throws:
RemoteException - On badness
VisADException - On badness

addAttributes

protected void addAttributes(Element e)
Populate the xml node with attrs

Parameters:
e - Xml node

getTagName

public abstract String getTagName()
Get xml tag name to use

Returns:
Xml tag name

getTypeName

public abstract String getTypeName()
Get the name of this glyph type

Returns:
The name

getDescription

public String getDescription()
Get the description

Returns:
the description

getExtraDescription

public String getExtraDescription()
Get extra description to show in the JTable

Returns:
extra description

getDisplayable

public Displayable getDisplayable()
                           throws VisADException,
                                  RemoteException
Get the main displayable.

Returns:
The displayable
Throws:
RemoteException - On badness
VisADException - On badness

getParent

protected CompositeDisplayable getParent()
                                  throws VisADException,
                                         RemoteException
Get the main displayable.

Returns:
The displayable
Throws:
RemoteException - On badness
VisADException - On badness

addDisplayable

protected void addDisplayable(Displayable displayable)
                       throws VisADException,
                              RemoteException
Add the displayable to the main parent displayable

Parameters:
displayable - The displayable to add
Throws:
RemoteException - On badness
VisADException - On badness

removeDisplayable

protected void removeDisplayable(Displayable displayable)
                          throws VisADException,
                                 RemoteException
Remove the displayable from the main displayable

Parameters:
displayable - The displayable to remove
Throws:
RemoteException - On badness
VisADException - On badness

addTime

public void addTime(Real time)
Add the time to the list of times

Parameters:
time - The time

setTimeValues

public void setTimeValues(List value)
Set the TimeValue property.

Parameters:
value - The new value for TimeValue

getTimeValues

public List getTimeValues()
Get the TimeValue property.

Returns:
The TimeValue

checkTimeVisibility

public void checkTimeVisibility()
                         throws VisADException,
                                RemoteException
Is this glyph visible in the current time step

Throws:
RemoteException - When bad things happen
VisADException - When bad things happen

setVisible

public void setVisible(boolean visible)
                throws VisADException,
                       RemoteException
Toggle visiblity of the displayable

Parameters:
visible - Is visible
Throws:
RemoteException - When bad things happen
VisADException - When bad things happen

isVisible

public boolean isVisible()
Is this glyph visible

Returns:
is visible

checkVisibility

public void checkVisibility()
Make sure the displayable is not visible if this glyph is not visible


constrainedTo2D

protected boolean constrainedTo2D()
Is glyph constrained to 2d

Returns:
Constrained to 2d

setCoordType

public void setCoordType(int value)
Set the CoordType property.

Parameters:
value - The new value for CoordType

getCoordType

public int getCoordType()
Get the CoordType property.

Returns:
The CoordType

isInXYSpace

public boolean isInXYSpace()
Are we drawing in xy or xyz space

Returns:
Is in xy space

isInFlatSpace

public boolean isInFlatSpace()
Are we drawing in xy or lat/lon space

Returns:
Is in 2d space

isInLatLonSpace

public boolean isInLatLonSpace()
In lat/lon or lat/lon/alt space

Returns:
Is in latlon space

getPoint

protected Object getPoint(DisplayEvent event)
                   throws VisADException,
                          RemoteException
Get point to use from the event. This may be an earthlocation if in latlon space or a double array if in x space.

Parameters:
event - The display event.
Returns: