Package hec.gfx2d

Class G2dDialog

All Implemented Interfaces:
RefreshListener, ActionListener, ComponentListener, ImageObserver, MenuContainer, Pageable, Printable, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, Modifiable
Direct Known Subclasses:
AbstractG2dDialog, AnimatedProfileG2dDialog, G2dDialogIndividualSelect, ScalarOutputDialog

public class G2dDialog extends RmaJFrame implements ActionListener, Pageable, Printable, RefreshListener
Simple dialog that holds a G2dPanel.
See Also:
  • Field Details

  • Constructor Details

    • G2dDialog

      public G2dDialog()
      Creates a non-modal dialog with no owner.
    • G2dDialog

      public G2dDialog(Frame owner)
      Creates a non-modal dialog with specified owner.
    • G2dDialog

      public G2dDialog(Frame owner, String title)
      Creates non-modal dialog with specified title and owner.
    • G2dDialog

      public G2dDialog(Frame owner, boolean modal)
      Creates a modal or non-modal dialog with specified owner.
    • G2dDialog

      public G2dDialog(Frame owner, String title, boolean modal)
      Creates a modal or non-modal dialog with specified title and owner.
    • G2dDialog

      public G2dDialog(Frame owner, String title, boolean modal, Vector datavec, Vector colorvec)
      Creates a modal or non-modal dialog with specified title and owner and plots a vector of g2dobjects with specific colors.
    • G2dDialog

      public G2dDialog(Frame owner, String title, boolean modal, Vector containers, G2dPanelProp prop)
      Creates a modal or non-modal dialog with specified title and owner and plots a vector of containers or of g2dobjects.
    • G2dDialog

      public G2dDialog(Frame owner, String title, boolean modal, PlotLayout plotLayout)
      Creates a modal or non-modal dialog with specified title and owner and plots a vector of containers or of g2dobjects.
      Parameters:
      owner -
      title -
      modal -
      plotLayout -
    • G2dDialog

      public G2dDialog(Frame owner, String title, boolean modal, Vector containers)
      Creates a modal or non-modal dialog with specified title and owner and plots a vector of containers or of g2dobjects.
  • Method Details

    • setVisible

      public void setVisible(boolean b)
      Overrides:
      setVisible in class RmaJFrame
    • setTransferHandler

      public void setTransferHandler(TransferHandler transferHandler)
      Overrides:
      setTransferHandler in class JFrame
    • addG2dDialogWindowListener

      public static void addG2dDialogWindowListener(WindowListener wl)
    • removeG2dDialogWindowListener

      public static void removeG2dDialogWindowListener(WindowListener wl)
    • getVisibleDialogs

      public static Vector getVisibleDialogs()
      Returns a list of open G2dDialogs
    • setLocation

      public void setLocation(int x, int y)
      Sets the location of the dialog in screen coordinates
      Overrides:
      setLocation in class Window
      Parameters:
      x - The x location coordinate
      y - The y-location coordinate
    • setSize

      public void setSize(int width, int height)
      sets the size of the dialog on the screen. Makes sure the components inside the dialog are resized accordingly.
      Overrides:
      setSize in class Window
      Parameters:
      width - the new width
      height - the new height
    • initDialog

      protected void initDialog()
      Builds default gfx panel.
    • initDialog

      protected void initDialog(Vector objvec)
    • initDialog

      protected void initDialog(Vector objvec, Vector colorvec, G2dPanelProp prop)
      Builds default gfx panel.
      Parameters:
      objvec -
      colorvec - a list of G2dLineProperties to configure line styles. This will override any linestyles in the "prop" parameter. Pass in an empty list or null to use line sytles in the prop parameter.
      prop - defines a set of properties to build a plot including line styles. If no line styles are defined in "prop" or "colorvec" then default line styles will be used.
    • makeMenus

      public void makeMenus()
      Makes the menu items that are used in the dialog
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Method that handles action events generated by the menu items
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - The action event generated by a specific item
    • setUseLineStylesOn

      public void setUseLineStylesOn()
      set the plot to use line styles
    • getFileMenu

      public JMenu getFileMenu()
    • getEditMenu

      public JMenu getEditMenu()
    • getViewMenu

      public JMenu getViewMenu()
    • setUseLineStylesOff

      public void setUseLineStylesOff()
      set the plot to not use line styles
    • applyTemplate

      public void applyTemplate(G2dPanelProp properties)
    • applyTemplate

      public void applyTemplate(String templateFile)
      apply the given template to this plot
      Parameters:
      templateFile - the path to the template
    • importProperties

      public void importProperties()
    • writeLocal

      public void writeLocal(String path)
    • exportProperties

      public void exportProperties()
      Allows the user to save the properties of the plot to a disk.
    • exportProperties

      public void exportProperties(String templateName)
    • setUseLineStyles

      public static void setUseLineStyles(boolean useLineStyles)
      Set if line styles should be used by default
      Parameters:
      useLineStyles - boolean indicating if it should be selected or not
    • getUseLineStyles

      public static boolean getUseLineStyles()
      Returns if "Use Line Styles" menu item is selected
      Returns:
      boolean if selected
    • close

      public void close()
    • printPreview

      public void printPreview()
    • getPageFormat

      public PageFormat getPageFormat(int pageNum)
      Returns the page format that is used for each page. The page format is the default page format generated by the print job and is the same for all pages.
      Specified by:
      getPageFormat in interface Pageable
    • getPrintable

      public Printable getPrintable(int pageNum)
      Returns a reference to this dialog. This dialog controls which plots go on which page
      Specified by:
      getPrintable in interface Pageable
    • getNumberOfPages

      public int getNumberOfPages()
      Returns the number of pages for this document
      Specified by:
      getNumberOfPages in interface Pageable
    • printToDefault

      public void printToDefault()
      Prints using the printer defaults such as page format and printer. This method does not display the printer dialog for user interaction.
    • print

      public void print()
    • print

      public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
      print this plot This method is public as an implementation side effect. do not call.
      Specified by:
      print in interface Printable
      Throws:
      PrinterException
    • useLocalPageSettings

      public void useLocalPageSettings(boolean set)
    • getPrintProperties

      public PrintProperties getPrintProperties()
    • pageSetup

      public void pageSetup()
    • printMultiple

      public void printMultiple()
    • tabulate

      public HecDataTableFrame tabulate()
      tabulate this plot. Do not show the HecDataTableFrame
      Returns:
      the HecDataTableFrame
    • tabulate

      public HecDataTableFrame tabulate(boolean showTable)
      tabulate this plot
      Parameters:
      showTable - whether to set the HecDataTableFrame visible or not
      Returns:
      the HecDataTableFrame
    • getTabulateObjects

      protected List getTabulateObjects(List v)
    • Edit

      public void Edit()
    • Open

      public void Open()
    • saveAs

      public void saveAs()
    • saveToPng

      public void saveToPng(String fileName)
    • saveToPng

      public void saveToPng(File file)
    • saveToJpeg

      public void saveToJpeg(String fileName)
      Save this plot to a jpeg file.
      Parameters:
      fileName - The file to save this plot to.
    • saveToJpeg

      public void saveToJpeg(String fileName, int quality)
      Save this plot to a jpeg file, specifying the quality of the output.

      Quality and compression are inversely proportional.

      Parameters:
      fileName - The file to save this plot to.
      quality - The quality to use (0 - 100). If no quality is specified, the underlying mechanism seems to use a value of 75.
    • saveToJpeg

      public void saveToJpeg(File file)
      Save this plot to a jpeg file.
      Parameters:
      file - The file to save this plot to.
    • saveToJpeg

      public void saveToJpeg(File file, int quality)
      Save this plot to a jpeg file, optionally specifying the quality of the output.

      Quality and compression are inversely proportional.

      Parameters:
      file - The file to save this plot to.
      quality - The quality to use (0 - 100). If no quality is specified, the underlying mechanism seems to use a value of 75.
    • saveToPostscript

      public void saveToPostscript(String fileName)
      save this plot to a post script file
      Parameters:
      fileName - the name of the file to save this plot to
    • saveToPostscript

      public void saveToPostscript(File file)
      save this plot to a post script file
      Parameters:
      file - the file to save this plot to
    • saveToMetafile

      public void saveToMetafile(String fileName)
      Save this plot to a Meta file
      Parameters:
      fileName - the name of the file to save to
    • saveToMetafile

      public void saveToMetafile(File file)
      Save this plot to a Meta file
      Parameters:
      file - the file to save to
    • savePlotSpecification

      public void savePlotSpecification()
    • copyToClipboard

      public void copyToClipboard()
    • setXAxisColor

      public void setXAxisColor(Color x)
    • setYAxisColor

      public void setYAxisColor(Color y)
    • getXAxisColor

      public Color getXAxisColor()
    • getYAxisColor

      public Color getYAxisColor()
    • setPanel

      public void setPanel(G2dPanel panel)
    • getPlotpanel

      public G2dPanel getPlotpanel()
    • setPlotpanel

      public void setPlotpanel(G2dPanel panel)
    • setFrame

      public void setFrame(Frame owner)
    • getFrame

      public Frame getFrame()
    • getLegend

      public LegendPanel getLegend()
      Returns the LegendPanel object for this plot.
      Returns:
      The LegendPanel object
    • setLegendBackground

      public void setLegendBackground(String colorString)
      Sets the background (fill) color of the legend.
      Parameters:
      colorString - The specified color.
    • setLegendBackground

      public void setLegendBackground(Color c)
      Sets the background (fill) color of the legend.
      Parameters:
      c - The specified color.
    • setLegendLocation

      public void setLegendLocation(String location)
      Sets the location of the legend for this plot.
      Parameters:
      location - The location of the legend. Valid locations are:
      • Right
      • Bottom
    • getLegendLabel

      public G2dLabel getLegendLabel(DataContainer dc)
      Returns the G2dLabel of the legend item associated with the data container (display object).
      Parameters:
      dc - The data container (display object)
      Returns:
      The G2dLabel of the matching legend item.
    • getLegendLabel

      public G2dLabel getLegendLabel(DataContainer dc, int curveNumber)
      Returns the G2dLabel of the specified curve number of the legend item associated with the data container (display object).

      Parameters:
      dc - The data container (display object)
      curveNumber - The number of the curve to get

      Returns:
      The G2dLabel of the matching legend item.
    • setLegendItemVisible

      public void setLegendItemVisible(HecMath dataSet, boolean isVisible)
      Sets the legend item visibility for the specified dataset
      Parameters:
      dataSet - the data to set the legend item visibility for
      isVisible - the new visibility state of the legend item
    • setLegendItemVisible

      public void setLegendItemVisible(DataContainer dataContainer, boolean isVisible)
      Sets the legend item visibility for the specified data container
      Parameters:
      dataContainer - the data to set the legend item visibility for
      isVisible - the new visibility state of the legend item
    • setLegendItemVisible

      public void setLegendItemVisible(String dataName, boolean isVisible)
      Sets the legend item visibility for the specified data
      Parameters:
      dataName - the name of the data to set the legend item visibility for (e.g. DSS pathname, CWMS identifier, etc...)
      isVisible - the new visibility state of the legend item
    • setLegendLabelText

      public void setLegendLabelText(DataContainer dc, String text)
      Sets the label text for the legend item associated with the specified data container (display object)
      Parameters:
      dc - The data container (display object) for which to set the legend label text.
      text - The legend label text.
    • setLegendLabelText

      public void setLegendLabelText(DataContainer dc, int curveNumber, String text)
      Sets the label text for the specified curve number of the legend item associated with the specified data container (display object)
      Parameters:
      dc - The data container (display object) for which to set the legend label text.
      curveNumber - The number of the curve to set
      text - The legend label text.
    • setLegendLabelTextFontSize

      public void setLegendLabelTextFontSize(DataContainer dc, int size)
      Sets the label text font size for the legend item associated with the specified data container (display object)
      Parameters:
      dc - The data container (display object) for which to set the legend label text.
      size - The legend label text font size.
    • setTabulate

      public void setTabulate(boolean enable)
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • setTimeWindow

      public void setTimeWindow(String timewindow)
      Sets the time window for the plot. The time axis of the plot is bounded by the time window inserted here. Used for retrieving dss data sets. A sample time window is 11OCT2001 0200 20OCT2001 0200
    • plotTimeWindow

      public void plotTimeWindow(RunTimeWindow window, int offset, String windowName)
      Plots a time window. The minimum time bounds is bounded to the time window and a marker marks off the start time. Throws an illegal arguement exception if the parameter value is null. The offsetFromGmt marks number of hours from GMT that this windows occurs in. Allows the display to plot the timewindow in various timezones correctly.
    • plotProperties

      public void plotProperties()
    • defaultPlotProperties

      public void defaultPlotProperties()
    • configurePlotTypes

      public void configurePlotTypes()
    • configureLiveDisplay

      public void configureLiveDisplay()
    • configurePlotLayout

      public void configurePlotLayout()
    • configurePlotLayout

      public void configurePlotLayout(PlotLayout plotLayout)
    • addDataSet

      public void addDataSet(G2dObject object)
    • addDisplayObject

      @Deprecated public void addDisplayObject(DataContainer dc)
      Deprecated.
      Use addData(DataContainer) instead.
      Adds data (DataContainer) to the G2dDialog object.
      Parameters:
      dc - The DataContainer to add to the object.
    • addData

      public void addData(DataContainer dc)
      Adds data (DataContainer) to the G2dDialog object.
      Parameters:
      dc - The DataContainer to add to the object.
    • getViewport

      public Viewport getViewport(int viewportIndex)
      get the Viewport at index specified by viewportIndex
      Parameters:
      viewportIndex -
      Returns:
    • getViewports

      public Vector getViewports()
    • initPlot

      public void initPlot()
    • showPlot

      public void showPlot()
    • getPlotTitle

      public G2dTitle getPlotTitle()
      get the Title for the G2dPanel
      Returns:
      the plot title
    • setPlotTitleVisible

      public void setPlotTitleVisible(boolean visible)
      set whether the Title for the G2dPanel is visible
      Parameters:
      visible - the visibility state
    • isPlotTitleVisible

      public boolean isPlotTitleVisible()
      get whether the Title for the G2dPanel is visible
      Returns:
      the plot title is visible
    • setPlotTitleText

      public void setPlotTitleText(String text)
      set the text of the Title for the G2dPanel
      Parameters:
      text - the title text
    • getPlotTitleText

      public String getPlotTitleText()
      get the text of the Title for the G2dPanel
      Returns:
      the plot title text
    • setBackground

      public void setBackground(String colorString)
      set the background for this plot to the color represented by colorString
      Parameters:
      colorString -
    • getGlyph

      public G2dGlyph getGlyph(HecMath dataSet)
      Return the G2dGlyph specified for the dataset
      Parameters:
      dataSet - The data to return the glyph for
      Returns:
      The glyph for the specified data or null if not found
    • getGlyph

      public G2dGlyph getGlyph(DataContainer dataContainer)
      Return the G2dGlyph specified for the data container
      Parameters:
      dataContainer - The data to return the glyph for
      Returns:
      The glyph for the specified data or null if not found
    • getGlyph

      public G2dGlyph getGlyph(String dataName)
      Return the G2dGlyph specified for the data name (DSS pathname, CWMS identifier, etc...)
      Parameters:
      dataName - The identifier of the data to return the glyph for
      Returns:
      The glyph for the specified data or null if not found
    • getCurve

      public G2dLine getCurve(HecMath dataSet)
      return the G2dLine for the path specified in dataSet
      Parameters:
      dataSet - the HecMath object of the curve to return
      Returns:
      the G2dLine or null if not found
    • getCurve

      public G2dLine getCurve(HecMath dataSet, int curveNumber)
      return the G2dLine for the path specified in dataSet for the specified curve number
      Parameters:
      dataSet - the HecMath object of the curve to return
      curveNumber - the index of the curve to retrieve
      Returns:
      the G2dLine or null if not found
    • getCurve

      public G2dLine getCurve(DataContainer dataContainer)
      return the G2dLine for the path specified in dataSet
      Parameters:
      dataContainer - the DataContainer object of the curve to return
      Returns:
      the G2dLine or null if not found
    • getCurve

      public G2dLine getCurve(DataContainer dataContainer, int curveNumber)
      return the G2dLine for the path specified in dataSet for the specified curve number
      Parameters:
      dataContainer - the DataContainer object of the curve to return
      curveNumber - the index of the curve to retrieve
      Returns:
      the G2dLine or null if not found
    • getCurve

      public G2dLine getCurve(String dssPath)
      return the G2dLine for the path specified in dssPath
      Parameters:
      dssPath - the DSS path name of the curve to return
      Returns:
      the G2dLine or null if not found
    • getCurve

      public G2dLine getCurve(String dssPath, int curveNumber)
      return the G2dLine for the path specified in dssPath for the specified curve number
      Parameters:
      dssPath - the DSS path name of the curve to return
      curveNumber - the index of the curve to retrieve
      Returns:
      the G2dLine or null if not found
    • getViewport

      public Viewport getViewport(String dataSetPath)
      return the Viewport that contains the curve specified by dataSetPath
      Parameters:
      dataSetPath - the path for a curve
      Returns:
      the enclosing Viewport
    • getViewport

      public Viewport getViewport(DataContainer dc)
      return the Viewport that contains the curve specified by dc
      Parameters:
      dc - the DataContainer for a curve
      Returns:
      the enclosing Viewport
    • getViewport

      public Viewport getViewport(HecMath dataSet)
      return the Viewport that contains the curve specified by dataSet
      Parameters:
      dataSet - the HecMath object for a curve
      Returns:
      the enclosing Viewport
    • maximize

      public void maximize()
      Maximizes the frame.
    • minimize

      public void minimize()
      Minimizes (iconifies) the frame.
    • iconify

      public void iconify()
      Minimizes (iconifies) the frame.
    • restore

      public void restore()
      Restores the frame to normal size.
    • getTabulateObject

      public Object getTabulateObject(Object obj, Class firstObjClass)
      Parameters:
      obj -
      firstObjClass -
      Returns:
    • refresh

      public void refresh(RefreshEvent event)
      Specified by:
      refresh in interface RefreshListener
    • createDefaultG2dPanel

      protected G2dPanel createDefaultG2dPanel()
      Returns the default G2dPanel object. A subclass can override this method to return a different G2dPanel object.
      Returns:
      the default G2dPanel object
      See Also: