Class DrawingControl

All Implemented Interfaces:
ActionListener, ItemListener, PropertyChangeListener, EventListener, HyperlinkListener, Sharable, DataChangeListener, DisplayControl, Prototypable, ControlListener, DisplayListener
Direct Known Subclasses:
FrontDrawingControl, GridTrajectoryControl, GridTrajectoryControlNew, PointCloudControl, RadarEditor, TransectDrawingControl

public class DrawingControl extends DisplayControlImpl
A MetApps Display Control for drawing lines on a navigated display.
Author:
MetApps development team
  • Field Details

    • ATTR_USETIMESINANIMATION

      public static final String ATTR_USETIMESINANIMATION
      xgrf xml attribute
      See Also:
    • ATTR_FRONTDISPLAY

      public static final String ATTR_FRONTDISPLAY
      xgrf attribute
      See Also:
    • TAG_EDITOR

      public static final String TAG_EDITOR
      Xml tag for the editor settings in the import/export format
      See Also:
    • ATTR_EDITABLE

      public static final String ATTR_EDITABLE
      Xml attribute for the editable property
      See Also:
    • ATTR_TITLE

      public static final String ATTR_TITLE
      Xml attribute for the title property
      See Also:
    • FILTER_XGRF

      public static final PatternFileFilter FILTER_XGRF
      File filter used for the xgrf files
    • SUFFIX_XGRF

      public static final String SUFFIX_XGRF
      File suffix used for the xgrfg files
      See Also:
    • SHARE_LINES

      public static final String SHARE_LINES
      property for sharing lines
      See Also:
    • FLAG_FILLED

      public static final int FLAG_FILLED
      Filled capable flag for the command object
      See Also:
    • FLAG_FULLLATLON

      public static final int FLAG_FULLLATLON
      Full lat/lon capable flag for the command object
      See Also:
    • FLAG_STRAIGHT

      public static final int FLAG_STRAIGHT
      flag for straight
      See Also:
    • CMD_SELECT

      public static final DrawingCommand CMD_SELECT
      Select command
    • CMD_MOVE

      public static final DrawingCommand CMD_MOVE
      command
    • CMD_STRETCH

      public static final DrawingCommand CMD_STRETCH
      command
    • enabledCbx

      protected JCheckBox enabledCbx
      Controls the disabled state
    • straightCbx

      protected JCheckBox straightCbx
      Filled mode
    • glyphs

      protected List glyphs
      List of all glyphs
    • selectedGlyphs

      protected List selectedGlyphs
      List of selected glyphs
    • currentCmd

      protected DrawingCommand currentCmd
      Current command
    • datachoice

      protected DataChoice datachoice
    • isProbsevere

      public boolean isProbsevere
    • dataChoiceProperties

      protected HashMap dataChoiceProperties
      The label to show the readout in the side legend
    • legendNoteTextArea

      protected JTextArea legendNoteTextArea
      Keep around for the legend
    • legendNoteWrapper

      protected JComponent legendNoteWrapper
      Keep around for the legend
  • Constructor Details

    • DrawingControl

      public DrawingControl()
      Create a new Drawing Control; set attributes.
  • Method Details

    • getControlChangeSleepTime

      protected long getControlChangeSleepTime()
      How long do we sleep until we act on the control changed event
      Overrides:
      getControlChangeSleepTime in class DisplayControlImpl
      Returns:
      sleep time
    • formatDistance

      public String formatDistance(Real distance) throws VisADException, RemoteException
      Utility
      Parameters:
      distance - The distance
      Returns:
      Formatted string
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getDistanceUnit

      public Unit getDistanceUnit()
      Get the distance unit
      Returns:
      the distance unit
    • init

      public boolean init(DataChoice dataChoice) throws VisADException, RemoteException
      Call to help make this kind of Display Control; also calls code to made the Displayable (empty of data thus far). This method is called from inside DisplayControlImpl.init(several args).
      Overrides:
      init in class DisplayControlImpl
      Parameters:
      dataChoice - the DataChoice of the moment.
      Returns:
      true if everything is okay
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • initDisplayUnit

      protected void initDisplayUnit()
      Initialize the display unit
    • shouldAddDisplayListener

      protected boolean shouldAddDisplayListener()
      Signal base class to add this as a display listener
      Overrides:
      shouldAddDisplayListener in class DisplayControlImpl
      Returns:
      Add as display listener
    • handleWindowClosing

      protected void handleWindowClosing()
      Handle the window closing.
      Overrides:
      handleWindowClosing in class DisplayControlImpl
    • close

      public void close()
      Clear the selection when we minisze the window
      Overrides:
      close in class DisplayControlImpl
    • shouldAddControlListener

      protected boolean shouldAddControlListener()
      Signal base class to add this as a control listener
      Overrides:
      shouldAddControlListener in class DisplayControlImpl
      Returns:
      Add as control listener
    • timeChanged

      protected void timeChanged(Real time)
      Respond to a timeChange event
      Overrides:
      timeChanged in class DisplayControlImpl
      Parameters:
      time - new time
    • processData

      protected void processData(Data data) throws VisADException, RemoteException
      Process the visad data object. For now this is a text object that holds the glyph xml
      Parameters:
      data - The data object
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • processProperties

      protected void processProperties(DataChoice dataChoice)
      Process the visad data object. For now this is a text object that holds the glyph xml
      Parameters:
      dataChoice - The data object
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • resetData

      protected void resetData() throws VisADException, RemoteException
      respond to the reload data call
      Overrides:
      resetData in class DisplayControlImpl
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • toggleVisibilityForVectorGraphicsRendering

      public void toggleVisibilityForVectorGraphicsRendering(int rasterMode) throws Exception
      Toggle the visibility for vector graphics rendering
      Specified by:
      toggleVisibilityForVectorGraphicsRendering in interface DisplayControl
      Overrides:
      toggleVisibilityForVectorGraphicsRendering in class DisplayControlImpl
      Parameters:
      rasterMode - the toggle mode
      Throws:
      Exception - problem toggling
    • shouldBeVisible

      public boolean shouldBeVisible(DrawingGlyph tg)
      Should this glyph be visible
      Parameters:
      tg - glyph
      Returns:
      should be visible
    • setDisplayVisibility

      public void setDisplayVisibility(boolean on)
      TUrn on the visibility of this display
      Specified by:
      setDisplayVisibility in interface DisplayControl
      Overrides:
      setDisplayVisibility in class DisplayControlImpl
      Parameters:
      on - Visible?
    • addGlyph

      protected boolean addGlyph(DrawingGlyph glyph)
      Add the glyph into the list of glyphs
      Parameters:
      glyph - The glyph to add
      Returns:
      Was this successful
    • glyphChanged

      public void glyphChanged(DrawingGlyph glyph)
      The given glyph has changed somehow. Update the JTable
      Parameters:
      glyph - The glyph that changed
    • doRemove

      public void doRemove() throws VisADException, RemoteException
      Remove this DisplayControl from the system. Nulls out any objects for garbage collection
      Specified by:
      doRemove in interface DisplayControl
      Overrides:
      doRemove in class DisplayControlImpl
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • getLegendLabels

      protected void getLegendLabels(List labels, int legendType)
      Overwrite the legend labels method to use the editor title if there is one.
      Overrides:
      getLegendLabels in class DisplayControlImpl
      Parameters:
      labels - List of labels
      legendType - Side or bottom
    • createGlyph

      protected DrawingGlyph createGlyph(DisplayEvent event, boolean mousePress) throws VisADException, RemoteException
      Create a glyph
      Parameters:
      event - The event
      mousePress - Is mouse pressed or released
      Returns:
      The glyph or null
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • viewpointChanged

      public void viewpointChanged()
      Respond to control changed events from the view manager
      Overrides:
      viewpointChanged in class DisplayControlImpl
    • projectionChanged

      public void projectionChanged()
      Respond to the projection changing event
      Specified by:
      projectionChanged in interface DisplayControl
      Overrides:
      projectionChanged in class DisplayControlImpl
    • canHandleEvents

      protected boolean canHandleEvents()
      Should we handle display events
      Returns:
      Ok to handle events
    • doFlythrough

      public void doFlythrough() throws VisADException, RemoteException
      Do the flythrough
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD problem
    • handleDisplayChanged

      public void handleDisplayChanged(DisplayEvent event)
      Listen for DisplayEvents
      Overrides:
      handleDisplayChanged in class DisplayControlImpl
      Parameters:
      event - The event
    • doneMovingGlyph

      protected void doneMovingGlyph(DrawingGlyph glyph)
      Done moving glyph
      Parameters:
      glyph - the glyph
    • closestGlyph

      public DrawingGlyph closestGlyph(DisplayEvent event)
      Find the glyph that is closest to the x/y point of the given event
      Parameters:
      event - The event
      Returns:
      The closest glyph (or null if none close).
    • closestGlyph

      public DrawingGlyph closestGlyph(DisplayEvent event, boolean forMove)
      Find the glyph that is closest to the x/y point of the given event
      Parameters:
      event - The event
      forMove - Are we looking for a glyph to move
      Returns:
      The closest glyph (or null if none close).
    • removeGlyph

      public void removeGlyph(DrawingGlyph glyph)
      Remove the glyph from the drawing
      Parameters:
      glyph - The glyph to remove
    • selectionChanged

      protected void selectionChanged()
      The selection set changed. Update the JTable
    • setSelection

      public void setSelection(DrawingGlyph glyph) throws VisADException, RemoteException
      Clear the selection and add the given glyph to the selection
      Parameters:
      glyph - Glyph to add to the selection set
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • setSelection

      public void setSelection(List newSelection, boolean addTo) throws VisADException, RemoteException
      Set the selection. Clear the old selection set if addTo is false.
      Parameters:
      newSelection - New set of glyphs
      addTo - If true then don't clear the selection
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • isSelected

      public boolean isSelected(DrawingGlyph glyph)
      Is the given glyph selected
      Parameters:
      glyph - The glyph
      Returns:
      Is selected
    • doCut

      protected void doCut() throws VisADException, RemoteException
      Remove the glyphs in the selection set
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • doProperties

      public void doProperties(List glyphs) throws VisADException, RemoteException
      Show the properties dialog for the glyphs in the list
      Parameters:
      glyphs - Glyphs to set properties on
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • receiveShareData

      public void receiveShareData(Sharable from, Object dataId, Object[] data)
      Method called by other classes that share the the state.
      Specified by:
      receiveShareData in interface Sharable
      Overrides:
      receiveShareData in class DisplayControlImpl
      Parameters:
      from - other class.
      dataId - type of sharing
      data - Array of data being shared. In this case, the first (and only?) object in the array is the level
    • setCurrentCommand

      protected void setCurrentCommand(DrawingCommand command)
      Set the current active command
      Parameters:
      command - The command
    • makeButtonPanel

      protected JPanel makeButtonPanel(List commands, ButtonGroup bg)
      Utility to make a panel holding the icon buttons.
      Parameters:
      commands - Command to make buttons for.
      bg - Button group to add buttons to
      Returns:
      The button panel
    • getShapeCommands

      protected List getShapeCommands()
      Get the lsit of shape commands the user can draw with. Derived classes can override this to control what can be drawn
      Returns:
      Shape commands
    • doMakeShapesPanel

      protected JComponent doMakeShapesPanel()
      Make the shapes panel
      Returns:
      the shapes panel
    • doMakeContents

      protected Container doMakeContents() throws VisADException, RemoteException
      Make the gui
      Overrides:
      doMakeContents in class DisplayControlImpl
      Returns:
      The gui
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • zSliderChanged

      public void zSliderChanged(double value)
      Handle the z position slider changed
      Overrides:
      zSliderChanged in class DisplayControlImpl
      Parameters:
      value - the new z slider value
    • doMakeControlsPanel

      protected JComponent doMakeControlsPanel()
      Make the main tabbed pane
      Returns:
      Controls panel
    • addControlWidgets

      protected void addControlWidgets(List widgets)
      Add the widgets into the controls panel
      Parameters:
      widgets - List to add to. Add in pairs (label, widget)
    • getInitialZPosition

      protected double getInitialZPosition()
      Get default z position to use
      Overrides:
      getInitialZPosition in class DisplayControlImpl
      Returns:
      Default z position
    • makeModePanel

      protected void makeModePanel(List widgets)
      Makes the model panel. Can be overwritten.
      Parameters:
      widgets - List ot add label/widget pairs
    • doMakeTablePanel

      protected JComponent doMakeTablePanel()
      Make the jtable panel
      Returns:
      jtable panel
    • doMakeStylePanel

      protected JComponent doMakeStylePanel()
      Make the style panel
      Returns:
      Style panel
    • checkZSliderEnabled

      protected void checkZSliderEnabled()
      Enable/disable the z slider
    • showFilledCbx

      protected boolean showFilledCbx()
      Should we show the filled cbx
      Returns:
      Show the filled cbx
    • showTimeWidgets

      protected boolean showTimeWidgets()
      Should we show the time widgets
      Returns:
      show the tiem widgets
    • showLocationWidgets

      protected boolean showLocationWidgets()
      Should we show the locatio widgets
      Returns:
      show the locatio widgets
    • getRGBColorTable

      public ColorTable getRGBColorTable()
      Get the color table to use for the image glyphs
      Returns:
      The rgb color table
    • doMakeLineWidthBox

      public static JComboBox doMakeLineWidthBox(int lineWidth)
      Make a component to change the width of the lines.
      Parameters:
      lineWidth - The selected width
      Returns:
      the component.
    • getCoordType

      public int getCoordType()
      Get the coord type (e.g., LATLON, XYZ)
      Returns:
      The coord type
    • setCoordType

      protected void setCoordType(int c)
      Get the coord type (e.g., LATLON, XYZ)
      Parameters:
      c - The coord type to use
    • getEditMenuItems

      protected void getEditMenuItems(List items, boolean forMenuBar)
      Add the relevant edit menu items into the list
      Overrides:
      getEditMenuItems in class DisplayControlImpl
      Parameters:
      items - List of menu items
      forMenuBar - Is this for the menu in the window's menu bar or for a popup menu in the legend
    • getFileMenuItems

      protected void getFileMenuItems(List items, boolean forMenuBar)
      Add to the file menu.
      Overrides:
      getFileMenuItems in class DisplayControlImpl
      Parameters:
      items - Holds the menu items
      forMenuBar - Is it for the main window
    • addFileMenuItems

      protected void addFileMenuItems(List items, boolean forMenuBar)
      Add to the file menu
      Parameters:
      items - List to add to
      forMenuBar - for the menu bar
    • applyColorToAll

      public void applyColorToAll()
      Apply the current color to all glyphs
    • applyZPosition

      public void applyZPosition(List glyphs) throws VisADException, RemoteException
      Apply the current z position to all glyphs
      Parameters:
      glyphs - the list of glyphs
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • removeAllGlyphs

      public void removeAllGlyphs()
      Remove em all.
    • setLineWidth

      public void setLineWidth(int width)
      Set the width of the lines.
      Overrides:
      setLineWidth in class DisplayControlImpl
      Parameters:
      width - width of lines.
    • getLineWidth

      public int getLineWidth()
      Get the line width
      Overrides:
      getLineWidth in class DisplayControlImpl
      Returns:
      The line width
    • getAllTimes

      public DateTime[] getAllTimes() throws VisADException, RemoteException
      Get an array of all the current times in the display
      Returns:
      All the animation times
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • getCurrentTime

      public Real getCurrentTime() throws VisADException, RemoteException
      Get the current time in the animation
      Returns:
      The current time
      Throws:
      RemoteException - On Badness
      VisADException - On Badness
    • getAnimationSet

      public Set getAnimationSet() throws VisADException, RemoteException
      Get the animation set
      Returns:
      animation set
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getTimeForGlyph

      public Real getTimeForGlyph() throws VisADException, RemoteException
      If we are not drawing in the current time then return null. Else return the current time.
      Returns:
      The time to use for a glyph
      Throws:
      RemoteException - On Badness
      VisADException - On Badness
    • getJustification

      public String getJustification()
      Get the text justification value
      Returns:
      h justification
    • getVerticalJustification

      public String getVerticalJustification()
      Get the vert text justification value
      Returns:
      The vert justification_
    • getFont

      public Font getFont()
      Get the font from the ui widget
      Returns:
      The font to use for new text glyphs
    • setLines

      public void setLines(UnionSet lines)
      Set the line data. deprecated
      Parameters:
      lines - set of lines to use
    • setActive

      public void setActive(boolean b)
      Enable/disable the drawing deprecated
      Parameters:
      b - true to enable
    • setGlyphs

      public void setGlyphs(List value)
      Set the DrawingGlyphs property.
      Parameters:
      value - The new value for DrawingGlyphs
    • getGlyphs

      public List getGlyphs()
      Get the Glyphs property.
      Returns:
      The Glyphs
    • setIgnoreTime

      public void setIgnoreTime(boolean value)
      Set the IgnoreTime property.
      Parameters:
      value - The new value for IgnoreTime
    • getIgnoreTime

      public boolean getIgnoreTime()
      Get the IgnoreTime property.
      Returns:
      The IgnoreTime
    • setUseTime

      public void setUseTime(boolean value)
      Set the UseTime property.
      Parameters:
      value - The new value for UseTime
    • getUseTime

      public boolean getUseTime()
      Get the UseTime property.
      Returns:
      The UseTime
    • 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
    • setEnabled

      public void setEnabled(boolean value)
      Set the Enabled property.
      Parameters:
      value - The new value for Enabled
    • getEnabled

      public boolean getEnabled()
      Get the Enabled property.
      Returns:
      The Enabled
    • setEditorTitle

      public void setEditorTitle(String value)
      Set the editorTitle property.
      Parameters:
      value - The new value for editorTitle
    • getEditorTitle

      public String getEditorTitle()
      Get the Editor Title property.
      Returns:
      The Title
    • 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
    • setStraight

      public void setStraight(boolean value)
      Set the Straight property.
      Parameters:
      value - The new value for Straight
    • getStraight

      public boolean getStraight()
      Get the Straight property.
      Returns:
      The Straight
    • 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
    • evaluateGlyphJython

      public void evaluateGlyphJython(DrawingGlyph glyph, String jython)
      Evalue the given jython for the glyph
      Parameters:
      glyph - The glyph
      jython - The jython
    • setGlyphJython

      public void setGlyphJython(String value)
      Set the GlyphJython property.
      Parameters:
      value - The new value for GlyphJython
    • getGlyphJython

      public String getGlyphJython()
      Get the GlyphJython property.
      Returns:
      The GlyphJython
    • getGlyphNameDefault

      protected String getGlyphNameDefault(DrawingGlyph glyph)
      Get the default name to use
      Parameters:
      glyph - the glyph
      Returns:
      The name
    • setShowFronts

      public void setShowFronts(boolean value)
      Set the ShowFronts property.
      Parameters:
      value - The new value for ShowFronts
    • getShowFronts

      public boolean getShowFronts()
      Get the ShowFronts property.
      Returns:
      The ShowFronts
    • setFrontScale

      public void setFrontScale(double value)
      Set the FrontScale property.
      Parameters:
      value - The new value for FrontScale
    • getFrontScale

      public double getFrontScale()
      Get the FrontScale property.
      Returns:
      The FrontScale
    • setFrontDisplay

      public void setFrontDisplay(boolean value)
      Set the FrontDisplay property.
      Parameters:
      value - The new value for FrontDisplay
    • getFrontDisplay

      public boolean getFrontDisplay()
      Get the FrontDisplay property.
      Returns:
      The FrontDisplay
    • addLabelMacros

      protected void addLabelMacros(String template, List patterns, List values)
      Add any macro name/value pairs.
      Overrides:
      addLabelMacros in class DisplayControlImpl
      Parameters:
      template - The template to use
      patterns - The macro names
      values - The macro values
    • getDefaultDisplayListTemplate

      protected String getDefaultDisplayListTemplate()
      Get the default display list template for this control. Subclasses can override
      Overrides:
      getDefaultDisplayListTemplate in class DisplayControlImpl
      Returns:
      the default template
    • updateLegendLabel

      protected void updateLegendLabel()
      This method is called to update the legend labels when some state has changed in this control that is reflected in the labels.
      Overrides:
      updateLegendLabel in class DisplayControlImpl
    • getExtraLegendComponent

      protected JComponent getExtraLegendComponent(int legendType)
      Assume that any display controls that have a color table widget will want the color table to show up in the legend.
      Overrides:
      getExtraLegendComponent in class DisplayControlImpl
      Parameters:
      legendType - type of legend
      Returns:
      The extra JComponent to use in legend
    • getViewMenuItems

      protected void getViewMenuItems(List items, boolean forMenuBar)
      Set the show html item
      Overrides:
      getViewMenuItems in class DisplayControlImpl
      Parameters:
      items - The items of view menu
      forMenuBar - Is this for the menu in the window's menu bar or for a popup menu in the legend
    • setShowNoteInLegend

      public void setShowNoteInLegend(boolean value)
      Set the ShowNoteInLegend property.
      Parameters:
      value - The new value for ShowTable
    • getShowNoteInLegend

      public boolean getShowNoteInLegend()
      Get the ShowNoteInLegend property.
    • setNoteText

      public void setNoteText(String n)
      Set the value of the note text area.
      Overrides:
      setNoteText in class DisplayControlImpl
      Parameters:
      n - The note text
    • getInitialColorTable

      protected ColorTable getInitialColorTable()
      The specific color table here is for the ProbSevere display
      Overrides:
      getInitialColorTable in class DisplayControlImpl
      Returns:
      The color table to use
    • getInitialRange

      protected Range getInitialRange() throws RemoteException, VisADException
      Hook method to allow derived classes to return a different initial Range
      Overrides:
      getInitialRange in class DisplayControlImpl
      Returns:
      The initial range to use
      Throws:
      RemoteException - Java RMI problem
      VisADException - VisAD problem
    • getDisplayUnit

      public Unit getDisplayUnit()
      Return the display unit
      Overrides:
      getDisplayUnit in class DisplayControlImpl
      Returns:
      The display unit
    • initAfterUnPersistence

      public void initAfterUnPersistence(ControlContext vc, Hashtable properties)
      Description copied from class: DisplayControlImpl
      Called by the IntegratedDataViewer to initialize after this control has been unpersisted
      Specified by:
      initAfterUnPersistence in interface DisplayControl
      Overrides:
      initAfterUnPersistence in class DisplayControlImpl
      Parameters:
      vc - The context in which this control exists
      properties - Properties that may hold things