Class DrawingGlyph

java.lang.Object
ucar.unidata.idv.control.drawing.DrawingGlyph
Direct Known Subclasses:
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 Details

  • Constructor Details

    • 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 Details

    • 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
    • isFrontDisplay

      protected boolean isFrontDisplay()
      Is the control a front display
      Returns:
      is a front display
    • getDefaultZPosition

      protected float getDefaultZPosition()
      Get the default Z position for the glyph.
      Returns:
      default Z position for the glyph.
    • 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
    • processPointStrings

      public void processPointStrings(List pointStrings, boolean normalize360) 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
    • getAreaString

      public String getAreaString() throws Exception
      get string representation of the area for showing the user
      Returns:
      area label
      Throws:
      Exception - on badness
    • 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:
      The point
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • setProperties

      public final void setProperties()
      Set the properties from the dialog
    • writePoints

      public void writePoints()
      write out the points as a csv file
    • evaluateJython

      public void evaluateJython()
      Evaluate the jython from the properties dialog
    • applyProperties

      protected boolean applyProperties(Hashtable compMap) throws VisADException, RemoteException
      Handle the property apply.
      Parameters:
      compMap - Holds property widgets
      Returns:
      Success
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • hide

      public void hide() throws VisADException, RemoteException
      Hide glyph
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • show

      public void show() throws VisADException, RemoteException
      Show glyph
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • shouldShowColorSelector

      protected boolean shouldShowColorSelector()
      Should show color selector in properties
      Returns:
      show color selector
    • shouldShowBgColorSelector

      protected boolean shouldShowBgColorSelector()
    • getPropertiesComponents

      protected void getPropertiesComponents(List comps, Hashtable compMap)
      Make the properties widgets
      Parameters:
      comps - List of components
      compMap - Map to hold name to widget
    • getTimePropertiesComponents

      protected void getTimePropertiesComponents(List comps, Hashtable compMap)
      Add to the comps array the time list for selecting times
      Parameters:
      comps - comps
      compMap - map
    • getDistance

      public Real getDistance() throws Exception
      Calculate the distance along the line
      Returns:
      Distance or null if this glyph type cannot calculate it
      Throws:
      Exception - On badness
    • getArea

      public double getArea() throws Exception
      Get the area in square feet.
      Returns:
      area of this shape in square feet
      Throws:
      Exception - On badness
    • canShowDistance

      public boolean canShowDistance()
      Can this glyph type calculate distance
      Returns:
      can do distance
    • canShowArea

      public boolean canShowArea()
      Can this glyph type calculate area
      Returns:
      can do area
    • getBeingCreated

      public boolean getBeingCreated()
      currently being created
      Returns:
      being created
    • doneBeingCreated

      public void doneBeingCreated()
      all done
    • handleCreation

      public DrawingGlyph handleCreation(DisplayEvent event) throws VisADException, RemoteException
      Handle the creation event. If it returns this then the DrawingControl keeps routing events to me. If returns null then no more events get routed to me.
      Parameters:
      event - The display event.
      Returns:
      This or null
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • handleMousePressed

      public DrawingGlyph handleMousePressed(DisplayEvent event) throws VisADException, RemoteException
      Handle the event. If it returns this then the DrawingControl keeps routing events to me. If returns null then no more events get routed to me.
      Parameters:
      event - The display event.
      Returns:
      This or null.
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • handleMouseMoved

      public DrawingGlyph handleMouseMoved(DisplayEvent event) throws VisADException, RemoteException
      Handle the event. If it returns this then the DrawingControl keeps routing events to me. If returns null then no more events get routed to me.
      Parameters:
      event - The display event.
      Returns:
      This or null
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • initStretch

      public void initStretch(DisplayEvent event) throws VisADException, RemoteException
      Start streth
      Parameters:
      event - The display event.
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • doStretch

      public void doStretch(DisplayEvent event) throws VisADException, RemoteException
      Stretch this glyph
      Parameters:
      event - The display event.
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • doDeletePoint

      public void doDeletePoint(DisplayEvent event) throws VisADException, RemoteException
      delete the point nearest the event
      Parameters:
      event - the event
      Throws:
      RemoteException - on badness
      VisADException - on badness
    • doMove

      public void doMove(DisplayEvent event) throws VisADException, RemoteException
      Move this glyph
      Parameters:
      event - The display event.
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • moveTo

      protected void moveTo(DisplayEvent event) throws VisADException, RemoteException
      Move this glyph to the location of the event
      Parameters:
      event - The display event.
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getPointValues

      protected float[][] getPointValues() throws VisADException, RemoteException
      Convert points list of array of xyz or lat/lon/alt
      Returns:
      Location
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getPointValues

      protected float[][] getPointValues(boolean convertToXY) throws VisADException, RemoteException
      Convert points list of array of xyz or lat/lon/alt
      Parameters:
      convertToXY - If true, force result to be xyz
      Returns:
      Location
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getLatLons

      public float[][] getLatLons() throws Exception
      get the points as an array of lat/lons
      Returns:
      latlons
      Throws:
      Exception - on badness
    • getLatLons

      protected float[][] getLatLons(List points) throws VisADException, RemoteException
      Convert points list of array of xyz or lat/lon/alt
      Parameters:
      points - List of points. Either double array or EarthLocation
      Returns:
      lat/lons
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getPointValuesDouble

      protected double[][] getPointValuesDouble() throws VisADException, RemoteException
      Convert points list of array of xyz or lat/lon/alt
      Returns:
      Location
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getPointValuesDouble

      protected double[][] getPointValuesDouble(boolean convertToXY) throws VisADException, RemoteException
      Convert points list of array of xyz or lat/lon/alt
      Parameters:
      convertToXY - If true, force result to be xyz
      Returns:
      Location
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • tryToFill

      protected Data tryToFill(float[][] pts, Data dflt) throws VisADException, RemoteException
      Try to fill the pts array
      Parameters:
      pts - The points to fill
      dflt - The default to return if cannot fill
      Returns:
      The filled data or the default if fill is not possible
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • toLatLonAlt

      protected float[] toLatLonAlt(EarthLocation el) throws VisADException, RemoteException
      Convert to float array
      Parameters:
      el - Location
      Returns:
      Converted location
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getFixedAltitude

      protected double getFixedAltitude() throws VisADException, RemoteException
      Get altitude of zposition
      Returns:
      Altitude
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • projectionChanged

      public void projectionChanged() throws VisADException, RemoteException
      Handle event
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • viewpointChanged

      public void viewpointChanged() throws VisADException, RemoteException
      viewpoint changed
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • updateLocation

      public void updateLocation() throws VisADException, RemoteException
      Glyph moved. Update the Displayable location.
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • initMove

      public void initMove(DisplayEvent event) throws VisADException, RemoteException
      Started moving
      Parameters:
      event - The display event.
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • handleKeyPressed

      public DrawingGlyph handleKeyPressed(DisplayEvent event) throws VisADException, RemoteException
      Handle event.
      Parameters:
      event - The display event.
      Returns:
      This or null
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • handleMouseDragged

      public DrawingGlyph handleMouseDragged(DisplayEvent event) throws VisADException, RemoteException
      Handle event.
      Parameters:
      event - The display event.
      Returns:
      This or null
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • handleMouseReleased

      public DrawingGlyph handleMouseReleased(DisplayEvent event) throws VisADException, RemoteException
      Handle event.
      Parameters:
      event - The display event.
      Returns:
      This or null
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • setColor

      public void setColor(Color value)
      Set the Color property.
      Parameters:
      value - The new value for Color
    • setColor

      protected void setColor(Displayable displayable, Color c) throws VisADException, RemoteException
      Set color on displayable
      Parameters:
      displayable - displayable_
      c - color
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getColor

      public Color getColor()
      Get the Color property.
      Returns:
      The Color
    • setBgcolor

      public void setBgcolor(Color value)
      Set the Bgcolor property.
      Parameters:
      value - The new value for Bgcolor
    • getBgcolor

      public Color getBgcolor()
      Get the Bgcolor property.
      Returns:
      The Bgcolor
    • setActualPoints

      protected void setActualPoints(float[][] pts) throws VisADException, RemoteException
      Set the points list
      Parameters:
      pts - Points
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • makePoint

      protected EarthLocation makePoint(double lat, double lon, double alt) throws VisADException, RemoteException
      Utility to make a point
      Parameters:
      lat - lat
      lon - lon
      alt - alt
      Returns:
      point
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • distance

      public double distance(double[] location, double[] direction) throws VisADException, RemoteException
      Calculate distance
      Parameters:
      location - from
      direction - direction
      Returns:
      distance
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • distanceBetween

      public static double distanceBetween(double[] origin, double[] loc2)
      Get distance between
      Parameters:
      origin - From
      loc2 - To
      Returns:
      Distance
    • distanceBetween

      public double distanceBetween(double[] loc1, EarthLocation el) throws VisADException, RemoteException
      Get distance
      Parameters:
      loc1 - point 1
      el - point 2
      Returns:
      distance
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • doInterpolatedStretch

      protected void doInterpolatedStretch(DisplayEvent event) throws VisADException, RemoteException
      This stretches the current point and also stretches the rest of the points by a linear delta from the initial point.
      Parameters:
      event - The mouse move event
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • squared

      public static double squared(double v1)
      Square value
      Parameters:
      v1 - Value
      Returns:
      Squared
    • closestPoint

      public int closestPoint(double[] location, List points) throws VisADException, RemoteException
      Find index of closest point
      Parameters:
      location - From
      points - Points
      Returns:
      Index
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • smoothCurve

      public static double[][] smoothCurve(double[][] curve, int window)
      Smooth the curve
      Parameters:
      curve - The curve
      window - Smooth window
      Returns:
      Smoothed curve
    • setZPosition

      public void setZPosition(float value)
      Set the Zposition property.
      Parameters:
      value - The new value for Zposition
    • getZPosition

      public float getZPosition()
      Get the ZPosition property.
      Returns:
      The ZPosition
    • setPoints

      public void setPoints(List value)
      Set the Points property.
      Parameters:
      value - The new value for Points
    • getPoints

      public List getPoints()
      Get the Points property.
      Returns:
      The Points
    • getBoxPoint

      protected double[] getBoxPoint(int i) throws VisADException, RemoteException
      Get xyz of point at given index
      Parameters:
      i - Index
      Returns:
      xyz
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getBoxPoint

      protected double[] getBoxPoint(int i, List l) throws VisADException, RemoteException
      Get xyz of point at given index
      Parameters:
      i - Index
      l - Points
      Returns:
      xyz
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getBoxPoint

      protected double[] getBoxPoint(Object point) throws VisADException, RemoteException
      Convert point (either latlonalt or xyz) to xyz
      Parameters:
      point - Point
      Returns:
      xyz
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • swap

      protected void swap(double[] a1, double[] a2, int index)
      Swap array values at index
      Parameters:
      a1 - Array 1
      a2 - Array 2
      index - Index
    • swap

      protected void swap(float[] a1, float[] a2, int index)
      Swap array values at index
      Parameters:
      a1 - Array 1
      a2 - Array 2
      index - Index
    • getBoundingBox

      protected List getBoundingBox(List points) throws VisADException, RemoteException
      Find bounding box of points
      Parameters:
      points - Points
      Returns:
      bbox
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • setFilled

      public void setFilled(boolean value)
      Set the Filled property.
      Parameters:
      value - The new value for Filled
    • getFilled

      public boolean getFilled()
      Get the Filled property.
      Returns:
      The Filled
    • setPickable

      public void setPickable(boolean value)
      Set the Pickable property.
      Parameters:
      value - The new value for Pickable
    • getPickable

      public boolean getPickable()
      Get the Pickable property.
      Returns:
      The Pickable
    • setFullLatLon

      public void setFullLatLon(boolean value)
      Set the Fulllatlon property.
      Parameters:
      value - The new value for Fulllatlon
    • getFullLatLon

      public boolean getFullLatLon()
      Get the FullLatLon property.
      Returns:
      The FullLatLon
    • setBeenRemoved

      public void setBeenRemoved(boolean value)
      Set the BeenRemoved property.
      Parameters:
      value - The new value for BeenRemoved
    • getBeenRemoved

      public boolean getBeenRemoved()
      Get the BeenRemoved property.
      Returns:
      The BeenRemoved
    • setName

      public void setName(String value)
      Set the Name property.
      Parameters:
      value - The new value for Name
    • getName

      public String getName()
      Get the Name property.
      Returns:
      The Name
    • toString

      public String toString()
      to string
      Overrides:
      toString in class Object
      Returns:
      tostring
    • setEditable

      public void setEditable(boolean value)
      Set the Editable property.
      Parameters:
      value - The new value for Editable
    • getEditable

      public boolean getEditable()
      Get the Editable property.
      Returns:
      The Editable
    • setVisibleFlag

      public void setVisibleFlag(boolean value) throws VisADException, RemoteException
      Set the VisibleFlag property.
      Parameters:
      value - The new value for VisibleFlag
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getVisibleFlag

      public boolean getVisibleFlag()
      Get the VisibleFlag property.
      Returns:
      The VisibleFlag
    • getIsRaster

      public boolean getIsRaster()
      is this glyph a raster thing
      Returns:
      is raster
    • setCreatedByUser

      public void setCreatedByUser(boolean value)
      Set the CreatedByUser property.
      Parameters:
      value - The new value for CreatedByUser
    • getCreatedByUser

      public boolean getCreatedByUser()
      Get the CreatedByUser property.
      Returns:
      The CreatedByUser