Package hec.gfx2d

Class G2dLine

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, ActionListener, Serializable, Cloneable, Comparable, EventListener, Observer, Modifiable
Direct Known Subclasses:
G2dLogarithmicLine, G2dTimeSeriesLine, G2dVerifyLine

public class G2dLine extends NamedType implements AsciiSerializable, Serializable, ActionListener
Description of the Class
See Also:
  • Field Details

    • _properties

      protected G2dLineProperties _properties
    • _popupMenu

      protected JPopupMenu _popupMenu
    • _nameMenuItem

      protected RmaJMenuLabel _nameMenuItem
    • _clipToBounds

      protected boolean _clipToBounds
  • Constructor Details

    • G2dLine

      public G2dLine()
      Constructor for the G2dLine object
    • G2dLine

      public G2dLine(G2dLineProperties prop)
      Constructor for the G2dLine object
      Parameters:
      prop - Description of Parameter
    • G2dLine

      public G2dLine(G2dLineProperties prop, double[] xarray, double[] yarray, int size)
      The constructor creates a new G2dLine for the given properties and data
      Parameters:
      prop - - the specific line properties
      xarray - - the set of x data points in World Coordinates
      yarray - - the set of y data points in World Coordinates
      size - - the number of points on the line
  • Method Details

    • setStepInterval

      public void setStepInterval(double interval)
    • getStepInterval

      public double getStepInterval()
    • setLineData

      public void setLineData(double[] xarray, double[] yarray, int numPts)
      This sets the data that the line uses to draw to the screen. This deletes any previous line data
      Parameters:
      xarray - - the set of x data points in World Coordinates
      yarray - - the set of y data points in World Coordinates
      numPts - The new LineData value
    • setSelectedPoints

      public void setSelectedPoints(double[] xarray, double[] yarray, int numPts)
      This sets the points that will be selected and drawn with the "selected" properties in the G2dLineProperties.
      Parameters:
      xarray - - the set of x data points in World Coordinates
      yarray - - the set of y data points in World Coordinates
      numPts - - the number of value from the arrays to copy, we copy starting at index 0
    • copyCurveProperties

      public void copyCurveProperties(G2dLineProperties prop)
    • setProperties

      public void setProperties(G2dLineProperties prop)
      Sets the properties that this line uses to draw
      Parameters:
      prop - The new Properties value
    • setScale

      public void setScale(IScale s)
      Sets the Scale attribute of the G2dLine object
      Parameters:
      s - The new Scale value
    • getScale

      public IScale getScale()
    • setGlyph

      public void setGlyph(G2dGlyph g)
      Sets the Glyph attribute of the G2dLine object
      Parameters:
      g - The new Glyph value
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Sets the FieldObject attribute of the G2dLine object
      Specified by:
      setFieldObject in interface FieldAccessor
      Overrides:
      setFieldObject in class NamedType
      Parameters:
      fld - The new FieldObject value
      fobj - The new FieldObject value
      Returns:
      Description of the Returned Value
    • getProperties

      public G2dLineProperties getProperties()
      Gets the line properties
      Returns:
      The Properties value
    • getNumPoints

      public int getNumPoints()
      Gets the NumPoints attribute of the G2dLine object
      Returns:
      The NumPoints value
    • getLineWidth

      public float getLineWidth()
      Gets the LineWidth attribute of the G2dLine object
      Returns:
      The LineWidth value
    • getNearestDataPt

      public WorldPt getNearestDataPt(WorldPt pt, boolean interpolate)
      Gets the NearestDataPt attribute of the G2dLine object
      Parameters:
      pt - Description of Parameter
      interpolate - Description of Parameter
      Returns:
      The NearestDataPt value
    • getNearestDataPt

      public LocalPt getNearestDataPt(LocalPt pt)
      Gets the NearestDataPt attribute of the G2dLine object
      Parameters:
      pt - Description of Parameter
      Returns:
      The NearestDataPt value
    • toLocalGeometry

      protected com.vividsolutions.jts.geom.Geometry toLocalGeometry()
      Returns a geometry in local coordinates that represents this list.
      Returns:
    • toWorldGeometry

      protected com.vividsolutions.jts.geom.Geometry toWorldGeometry()
    • getNearestDataPt

      public LocalPt getNearestDataPt(LocalPt pt, boolean interpolate)
      Returns the point in local coordinates of the closest data point to the given pt if interpolate is true then the point is returned that is on a line segment that joins two data points on the G2dLine.
      Parameters:
      pt - Description of Parameter
      interpolate - Description of Parameter
      Returns:
      The NearestDataPt value
    • getNearestDataPt

      public double getNearestDataPt(LocalPt lpt, WorldPt ptnbest)
      Returns the nearest data point in world coordinates to a given local point. All test are done in local coordinates because local coordinates are in pixels and scaling does not matter. Returns RMAConst.UNDEF_DOUBLE if nothing was found.
      Parameters:
      lpt - The local point to test on.
      ptnbest - This value is filled with the best world point
      Returns:
      The distance between the input local pt in world coordinates and the best world coordinate.
    • getNearestLocation

      public double getNearestLocation(LocalPt lpt, WorldPt ptnbest)
      Computes the nearest point on the line to the given point, the nearest point is returned in "ptnbest".
      Parameters:
      lpt -
      ptnbest -
      Returns:
      the distance from lpt to ptnbest
    • getFieldObject

      public Object getFieldObject(Field fld)
      Gets the FieldObject attribute of the G2dLine object
      Specified by:
      getFieldObject in interface FieldAccessor
      Overrides:
      getFieldObject in class NamedType
      Parameters:
      fld - Description of Parameter
      Returns:
      The FieldObject value
    • clearLineData

      public void clearLineData()
      Description of the Method
    • addCallout

      public void addCallout(LocalPt p)
      Adds a feature to the Callout attribute of the G2dLine object
      Parameters:
      p - The feature to be added to the Callout attribute
    • setClipLineToBounds

      public void setClipLineToBounds(boolean b)
    • setVisible

      public void setVisible(boolean visible)
    • isVisible

      public boolean isVisible()
    • drawLine

      public void drawLine(Graphics g, Rectangle clipRect)
      This method draws a line to the specified graphics context. The line is clipped so it fits within the clipping rectangle
      Parameters:
      g - - the graphics context to clip to
      clipRect - - the rectangle that bounds the viewable region. This describes how the line is clipped. The clipping units are in world coordinates
    • isCalloutsVisible

      public boolean isCalloutsVisible()
    • setCalloutsVisible

      public void setCalloutsVisible(boolean b)
      Sets the callouts visible or not visible depending on the value of b
      Parameters:
      b - true for visible, false otherwise
    • clearCallouts

      public void clearCallouts()
      Clears the table of callouts, effectivly erasing them.
    • getLabelColor

      public Color getLabelColor()
    • getLabelColorString

      public String getLabelColorString()
    • setLabelColor

      public void setLabelColor(Color c)
    • setLabelColor

      public void setLabelColor(String c)
    • drawCallouts

      public void drawCallouts(Graphics g, Rectangle clipRect)
      Draws the callouts on the particular line if the _drawCallouts variable is true
      Parameters:
      g - the graphics context to draw to.
      clipRect - a rectangle that defines the viewable regions. Callouts will not be drawn outside the clipping rectangle.
    • addLineData

      public void addLineData(double[] xarray, double[] yarray, int numPts)
      Adds a adds line data to the last line segment in the list
      Parameters:
      xarray - The feature to be added to the LineData attribute
      yarray - The feature to be added to the LineData attribute
      numPts - The feature to be added to the LineData attribute
    • addLineSegment

      public void addLineSegment(double[] xarray, double[] yarray, int numPts)
    • getNumLineSegments

      public int getNumLineSegments()
      Returns the number of line segments added to this line since the last time the clearLineData() method has been called.
      Returns:
      int
    • getLineSegmentAt

      public double[][] getLineSegmentAt(int index)
    • clone

      public Object clone() throws CloneNotSupportedException
      Description of the Method
      Overrides:
      clone in class NamedType
      Returns:
      Description of the Returned Value
      Throws:
      CloneNotSupportedException - Description of Exception
    • finalize

      public void finalize() throws Throwable
      Description of the Method
      Overrides:
      finalize in class Object
      Throws:
      Throwable - Description of Exception
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      This method listens for action events. If an action event is generated by a component of this line it is routed to the appropriate handler
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - Description of Parameter
    • buildPropertiesPanel

      protected DefaultJPanel[] buildPropertiesPanel()
    • editLineProperties

      public G2dPropertiesDlg editLineProperties()
      Method that allows the editing of line properties. This method displays a visible dialog for line editing.
    • editLineProperties

      public G2dPropertiesDlg editLineProperties(Window w)
      An overloaded editLineProperties that allows the passing in of the Window.
      Parameters:
      w -
      See Also:
    • getOKListeners

      protected List getOKListeners()
    • showPopup

      public void showPopup(Component c, int x, int y)
      Description of the Method
      Parameters:
      c - Description of Parameter
      x - Description of Parameter
      y - Description of Parameter
    • contains

      public boolean contains(LocalPt pt)
      Description of the Method
      Parameters:
      pt - Description of Parameter
      Returns:
      Description of the Returned Value
    • toString

      public String toString()
      Description of the Method
      Overrides:
      toString in class NamedType
      Returns:
      Description of the Returned Value
    • createPopupMenu

      protected void createPopupMenu()
      Creates the default popup menu for this line
    • scale

      protected void scale(double[] worldXData, double[] worldYData, int[] scaledXData, int[] scaledYData, int startPt, int numPoints)
      Description of the Method
      Parameters:
      worldXData - Description of Parameter
      worldYData - Description of Parameter
      scaledXData - Description of Parameter
      scaledYData - Description of Parameter
      startPt -
      numPoints - Description of Parameter
    • scale

      protected void scale(double[] worldXData, double[] worldYData, double[] scaledXData, double[] scaledYData, int startPt, int numPoints)
    • getLabelAlignment

      public int getLabelAlignment()
    • getLabelAlignmentString

      public String getLabelAlignmentString()
    • setLabelAlignment

      public void setLabelAlignment(int align)
    • setLabelAlignment

      public void setLabelAlignment(String align)
    • getLabelPosition

      public int getLabelPosition()
    • getLabelPositionString

      public String getLabelPositionString()
    • setLabelPosition

      public void setLabelPosition(int position)
    • setLabelPosition

      public void setLabelPosition(String pos)
    • getLabelFont

      public Font getLabelFont()
    • getLabelFontString

      public String getLabelFontString()
    • setLabelFont

      public void setLabelFont(Font f)
    • setLabelFont

      public void setLabelFont(String fontString)
    • setLabelVisible

      public void setLabelVisible(boolean b)
    • setLineLabelVisible

      public void setLineLabelVisible(boolean b)
    • isLabelVisible

      public boolean isLabelVisible()
    • isLineLabelVisible

      public boolean isLineLabelVisible()
    • getLabel

      public String getLabel()
    • setLabel

      public void setLabel(String label)
    • getLineLabel

      public String getLineLabel()
    • setLineLabel

      public void setLineLabel(String label)
    • setFillType

      public void setFillType(String fillStyle)
      set the Fill type for this line.
      Parameters:
      fillStyle - one of the following Strings "None", "Above", "Below" or null for "None"
      See Also:
    • getFillTypeString

      public String getFillTypeString()
      get the Fill type for this line as a String
      Returns:
      the fill type String
    • getFillType

      public int getFillType()
      get the Fill type for this line
      Returns:
      the fill type
    • setFillPattern

      public void setFillPattern(String fillPattern)
      set the fill pattern for this line
      Parameters:
      fillPattern - the fill pattern
      See Also:
    • getFillPatternString

      public String getFillPatternString()
      get the fill pattern for this G2dLine as a String
      Returns:
      the fill pattern String
    • getFillPattern

      public int getFillPattern()
      get the fill pattern for this G2dLine
      Returns:
      the fill pattern
    • setFillColor

      public void setFillColor(String fillColor)
      set the fill color for this line.
      Parameters:
      fillColor - the fill color
      See Also:
    • setFillColor

      public void setFillColor(Color c)
    • getFillColorString

      public String getFillColorString()
      get the fill color for this line as a String
      Returns:
      the fill color String
    • getFillColor

      public Color getFillColor()
      get the fill Color for this line
      Returns:
      the fill Color
    • setLineColor

      public void setLineColor(String lineColor)
      set the line color for this G2dLine
      Parameters:
      lineColor - the line color
      See Also:
    • setLineColor

      public void setLineColor(Color c)
    • getLineColorString

      public String getLineColorString()
      get the line color for this line as a String
      Returns:
      the line color String
    • getLineColor

      public Color getLineColor()
      get the line Color for this line
      Returns:
      the line Color
    • setLineStyle

      public void setLineStyle(String lineStyle)
      set the line style for this G2dLine
      Parameters:
      lineStyle - the line style
      See Also:
    • getLineStyleString

      public String getLineStyleString()
      get the line style for this line as a String
      Returns:
      the line style String
    • getLineStyle

      public float[] getLineStyle()
      get the line style for this line
      Returns:
      the line style
    • setLineVisible

      public void setLineVisible(boolean state)
      set the visibility of this line
      See Also:
    • setDrawLineOn

      @Deprecated public void setDrawLineOn()
      Deprecated.
      set this line to draw
    • setDrawLineOff

      @Deprecated public void setDrawLineOff()
      Deprecated.
      set this line not to draw
    • isLineVisible

      public boolean isLineVisible()
      return whether this line draws or not
      Returns:
      whether this line draws
    • isLineDrawn

      @Deprecated public boolean isLineDrawn()
      Deprecated.
      return whether this line draws or not
    • setSymbolFillColor

      public void setSymbolFillColor(String symbolFillColor)
      set the symbol fill color for this line's symbols
      Parameters:
      symbolFillColor - the symbol fill color
      See Also:
    • getSymbolFillColorString

      public String getSymbolFillColorString()
      get the Symbol Fill Color as a String
      Returns:
      the Symbol fill color String
    • getSymbolFillColor

      public Color getSymbolFillColor()
      get the Symbol Fill Color
      Returns:
      the Symbol fill Color
    • setSymbolLineColor

      public void setSymbolLineColor(String symbolLineColor)
      set the symbol line color for this line's symbols
      Parameters:
      symbolLineColor - the symbol line color
      See Also:
    • getSymbolLineColorString

      public String getSymbolLineColorString()
      get the Symbol Line Color as a String
      Returns:
      the Symbol Line Color String
    • getSymbolLineColor

      public Color getSymbolLineColor()
      get the Symbol Line Color
      Returns:
      the Symbol Line Color
    • setSymbolsVisible

      public void setSymbolsVisible(boolean state)
      set whether symbols are visible
      See Also:
    • setDrawSymbolsOn

      @Deprecated public void setDrawSymbolsOn()
      Deprecated.
      set this line to draw it's symbols
    • setDrawSymbolsOff

      @Deprecated public void setDrawSymbolsOff()
      Deprecated.
      set this line not to draw it's symbols
    • areSymbolsVisible

      public boolean areSymbolsVisible()
      return whether the Symbols are visible
      Returns:
      whether the symbols are visible
    • areSymbolsDrawn

      @Deprecated public boolean areSymbolsDrawn()
      Deprecated.
      return whether the Symbols are drawn for this line
    • setLineStepStyle

      public void setLineStepStyle(String stepStyle)
      set the line step style for this line.
      Parameters:
      stepStyle - the step style - "normal", "step" or "cubic"
      See Also:
    • setPeriodStepStyle

      public void setPeriodStepStyle(String stepStyle)
    • getLineStepStyle

      public int getLineStepStyle()
      return the line step style
      Returns:
      the line step style
    • getLineStepStyleString

      public String getLineStepStyleString()
      return the line step style as a String
      Returns:
      the line step style as a String
    • setLineWidth

      public void setLineWidth(float width)
      set the width for this G2dLine
      Parameters:
      width - the new line width
      See Also:
    • setFirstSymbolOffset

      public void setFirstSymbolOffset(int offset)
      set the offset for the first symbol for this G2dLine
      Parameters:
      offset - the symbol offset
      See Also:
    • setSymbolOffset

      @Deprecated public void setSymbolOffset(int offset)
      Deprecated.
      set the symbol offset for this G2dLine
    • getFirstSymbolOffset

      public int getFirstSymbolOffset()
      get the offset for the first symbol of this line
      Returns:
      the symbol offset
    • getSymbolOffset

      @Deprecated public int getSymbolOffset()
      Deprecated.
      get the symbol offset of this line
    • setSymbolSkipCount

      public void setSymbolSkipCount(int skipCount)
      set the symbol skip count for this G2dLine
      Parameters:
      skipCount -
      See Also:
    • setSymbolInterval

      public void setSymbolInterval(int interval)
      set the symbol interval for this G2dLine
      Parameters:
      interval -
      See Also:
    • setSymbolsSkipInterval

      @Deprecated public void setSymbolsSkipInterval(int skipInterval)
      Deprecated.
      set the symbol skip interval for this G2dLine
    • getSymbolSkipCount

      public int getSymbolSkipCount()
      get the symbol skip count for this G2dLine
      Returns:
      the symbol skip interval
    • getSymbolInterval

      public int getSymbolInterval()
      get the symbol skip count for this G2dLine
      Returns:
      the symbol skip interval
    • getSymbolSkipInterval

      @Deprecated public int getSymbolSkipInterval()
      Deprecated.
      get the symbol skip interval for this G2dLine
    • setSymbolSize

      public void setSymbolSize(float size)
      set the symbol size for this G2dLine
      Parameters:
      size - the symbol size
      See Also:
    • getSymbolSize

      public float getSymbolSize()
      get the symbol size for this G2dLine
      Returns:
      the symbol size
    • setSymbolType

      public void setSymbolType(int type)
      set the symbol type for this G2dLine
      Parameters:
      type - the symbol type
    • setSymbolType

      public void setSymbolType(String name)
      set the symbol type for this G2dLine
      Parameters:
      name - the symbol type
    • getSymbolType

      public int getSymbolType()
      get the symbol type for this G2dLine
      Returns:
      the symbol type
    • getSymbolTypeString

      public String getSymbolTypeString()
      get the symbol type string for this G2dLine
      Returns:
      the symbol type
    • setSymbolsAutoInterval

      public void setSymbolsAutoInterval(boolean state)
      set the line symbols auto skip state
      See Also:
    • setAutoSkipSymbolsOn

      @Deprecated public void setAutoSkipSymbolsOn()
      Deprecated.
      set the line to auto skip it's symbols
    • setAutoSkipSymbolsOff

      @Deprecated public void setAutoSkipSymbolsOff()
      Deprecated.
      set the line to not auto skip it's symbols
    • areSymbolsAutoInterval

      public boolean areSymbolsAutoInterval()
      get whether the line auto skips drawing it's symbols
      Returns:
      whether the line auto skips drawing it's symbols
    • getAutoSkipSymbols

      @Deprecated public boolean getAutoSkipSymbols()
      Deprecated.
      get whether the line auto skips drawing it's symbols