Class TLcdProfileViewJPanel

All Implemented Interfaces:
ILcdProfileView, ImageObserver, MenuContainer, Serializable, Accessible

public class TLcdProfileViewJPanel extends JPanel implements ILcdProfileView
Implementation of ILcdProfileView which displays the profile in a JPanel. This can be used in combination with the TLcdTerrainProfileController to display the profile for a line drawn on the map. The profile is displayed as a 2D side view using the heights of the sample points. A scale is displayed as well. The panel supports mouse interaction to display extra information, such as the height of the last clicked point and the visibility from a given point.
See Also:
  • Field Details

    • MODELPOINTATMOUSELOCATION

      public static final String MODELPOINTATMOUSELOCATION
      Represents the property that is thrown when the mark point has changed.
      See Also:
  • Constructor Details

    • TLcdProfileViewJPanel

      public TLcdProfileViewJPanel()
      Creates a new TLcdProfileViewJPanel.
  • Method Details

    • setLeftMargin

      public void setLeftMargin(int aMargin)
      Sets the left margin in which the left labels are placed.
      Parameters:
      aMargin - the new left margin.
    • setRightMargin

      public void setRightMargin(int aMargin)
      Sets the right margin in which the right labels are placed.
      Parameters:
      aMargin - the new right margin.
    • setTopMargin

      public void setTopMargin(int aMargin)
      Sets the top margin.
      Parameters:
      aMargin - the new top margin.
    • setBottomMargin

      public void setBottomMargin(int aMargin)
      Sets the bottom margin.
      Parameters:
      aMargin - the new bottom margin.
    • getProfile

      public ILcdPoint[] getProfile()
      Get the array of ILcdPoint that defines the profile.
      Returns:
      the array of ILcdPoint that defines the profile.
    • getStartIndex

      public int getStartIndex()
      Returns the start index of the profile. This is the first index of which the profile is drawn.
      Returns:
      the start index of the profile.
    • getEndIndex

      public int getEndIndex()
      Returns the end index of the profile. This is the last index of which the profile is drawn.
      Returns:
      the end index of the profile.
    • getModelPointAtMouseLocation

      public ILcdPoint getModelPointAtMouseLocation()
      Returns the model point corresponding to the current mark point.
      Returns:
      the model point corresponding to the current mark point.
    • setMarkPoint

      public void setMarkPoint(int aProfileSegmentIndex, double aFraction)

      Sets the mark point to the point located at the specified fraction of the specified profile segment. The fraction should lie within the interval between 0.0 and 1.0.

      Note that, if the profile is empty, the mark point cannot be updated.

      Parameters:
      aProfileSegmentIndex - The index indicating the segment where the mark point should move to.
      aFraction - The fraction from the start point of the given segment.
    • getAltitudeAtMouseLocation

      public double getAltitudeAtMouseLocation()
      Returns the altitude at the current mark point.
      Returns:
      the altitude at the current mark point.
    • displayProfile

      public void displayProfile(ILcdPoint[] aProfile, int aStartIndex, int aEndIndex, ILcdGXYView aGXYView)
      Description copied from interface: ILcdProfileView
      Display a profile on the view.
      Specified by:
      displayProfile in interface ILcdProfileView
      Parameters:
      aProfile - An array of ILcdPoint that defines the profile.
      aStartIndex - The first index of the points in aProfile that should be taken into account.
      aEndIndex - The last index of the points in aProfile that should be taken into account.
      aGXYView - The original ILcdGXYView that the profile is based on.
    • update

      public void update(Graphics g)
      Overrides:
      update in class JComponent
    • setZeroInProfile

      public void setZeroInProfile(boolean aZeroInProfile)
      Sets whether the line indicating zero height/altitude should always be in the profile. Default value is true.
      Parameters:
      aZeroInProfile - true to indicate that the zero height line will always be in the profile.
    • setPaintZeroLine

      public void setPaintZeroLine(boolean aPaintZeroLine)
      Sets whether the zero altitude/depth line should be painted if its visible in the profile. Default value is false.
      Parameters:
      aPaintZeroLine - a flag indicating whether the zero altitude/depth line should be painted.
    • setZeroLineColor

      public void setZeroLineColor(Color aZeroLineColor)
      Sets the color to use to paint the zero altitude/depth line. Default value is red.
      Parameters:
      aZeroLineColor - the color to use to paint the zero altitude/depth line.
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • isSimpleLineOfSightEnabled

      public boolean isSimpleLineOfSightEnabled()
      Check whether the simple line-of-sight action is enabled.
      Returns:
      true if it's enabled, false otherwise.
      See Also:
    • setSimpleLineOfSightEnabled

      public void setSimpleLineOfSightEnabled(boolean aSimpleLineOfSightEnabled)
      Enable or disable the simple line-of-sight action. If enabled, when clicking on the profile view with the right mouse button, points that are visible from the terrain at the position of the mark line, are drawn in red. This visibility result does not take the effects of the spherical shape of the Earth into account in its calculation. The height above the terrain of the eye point is fixed and can be set with setAltitudeAboveGroundForLineOfSight(double)
      Parameters:
      aSimpleLineOfSightEnabled - whether to enable or disable the simple line-of-sight action.
      See Also:
    • isLineOfSightEnabled

      public boolean isLineOfSightEnabled()
      Check whether the line-of-sight action is enabled.
      Returns:
      true if it's enabled, false otherwise.
      See Also:
    • setLineOfSightEnabled

      public void setLineOfSightEnabled(boolean aLineOfSightEnabled)

      Enable or disable the line-of-sight action. If enabled, when clicking on the profile view with the left mouse button, the line-of-sight in the left and right direction is calculated and graphically displayed. If this action is enabled, then the geo reference of the profile points has to be set with setProfileReference(com.luciad.reference.ILcdGeoReference).

      This is different from the simple line-of-sight action. The line-of-sight is drawn using lines and a shaded area showing the visible parts. This is drawn in the sky while the simple line-of-sight action colors the terrain. The spherical shape of the Earth is taken into account. The minimum and maximum vertical angle can be customized with setMinVerticalAngle(double) and setMaxVerticalAngle(double). The height of the point where the mouse clicked will be used as the height of the center point of the LOS calculation.

      Parameters:
      aLineOfSightEnabled - whether to enable or disable the line-of-sight action.
      See Also:
    • getMinVerticalAngle

      public double getMinVerticalAngle()
      Get the minimum vertical angle used by the line-of-sight calculations.
      Returns:
      The angle in degrees.
      See Also:
    • setMinVerticalAngle

      public void setMinVerticalAngle(double aMinVerticalAngle)
      Set the minimum vertical angle used by the line-of-sight calculations. An angle of 0 degrees represents looking straight forward to the horizon. This angle is only used when setLineOfSightEnabled(boolean) is set to true.
      Parameters:
      aMinVerticalAngle - The angle in degrees.
    • getMaxVerticalAngle

      public double getMaxVerticalAngle()
      Get the maximum vertical angle used by the line-of-sight calculations.
      Returns:
      The angle in degrees.
      See Also:
    • setMaxVerticalAngle

      public void setMaxVerticalAngle(double aMaxVerticalAngle)
      Set the maximum vertical angle used by the line-of-sight calculations. An angle of 0 degrees represents looking straight forward to the horizon. This angle is only used when setLineOfSightEnabled(boolean) is set to true.
      Parameters:
      aMaxVerticalAngle - The angle in degrees.
    • getProfileReference

      public ILcdGeoReference getProfileReference()
      Get the geo reference of the profile points. This geo reference is used by the line-of-sight action. It returns null if the geo reference wasn't set.
      Returns:
      The geo reference of the profile points.
    • setProfileReference

      public void setProfileReference(ILcdGeoReference aProfileReference)
      Set the geo reference of the profile points that were set with displayProfile(com.luciad.shape.ILcdPoint[], int, int, com.luciad.view.gxy.ILcdGXYView). If the line-of-sight action is used, then it's required to set the reference.
      Parameters:
      aProfileReference - The geo reference to set.
      See Also:
    • isChangeAltitudeOnInteraction

      public boolean isChangeAltitudeOnInteraction()
      If true, interactions with the mouse will change the altitude of the mark point to match that of the mouse. If false, the altitude will be determined by the setAltitudeAboveGroundForLineOfSight(double) method.

      The default is true
      Returns:
      true if altitude is changed through mouse interaction; false otherwise.
    • setChangeAltitudeOnInteraction

      public void setChangeAltitudeOnInteraction(boolean aChangeAltitudeOnInteraction)
      Sets whether or not the altitude should change as result of an interaction with the mouse. If true, the altitude will be set to the position of the mouse. If false the altitude will be determined by the setAltitudeAboveGroundForLineOfSight(double) method.

      The default is true
      Parameters:
      aChangeAltitudeOnInteraction - if true
    • isVisualizeMarkPoint

      public boolean isVisualizeMarkPoint()
      If true, visualizes the mark point as a dot and a label indicating the height in model coordinates.

      The default is true
      Returns:
      true if the mark point is visualized; false otherwise.
    • setVisualizeMarkPoint

      public void setVisualizeMarkPoint(boolean aVisualizeMarkPoint)
      If true, visualizes the mark point as a dot and a label indicating the height in model coordinates.

      The default is true
      Parameters:
      aVisualizeMarkPoint - true if the mark point should be visualized; false otherwise
      See Also:
      • setMarkPoint(int)
    • setValueFormat

      public void setValueFormat(ILcdFormatter aValueFormat)
      Sets the formatter used to format elevation values.
      Parameters:
      aValueFormat - the formatter used to format elevation values.
      See Also:
    • getValueFormat

      public ILcdFormatter getValueFormat()
      Gets the formatter used to format elevation values.
      Returns:
      the formatter used to format elevation values.
      See Also:
    • setMarkWidth

      public void setMarkWidth(int aMarkWidth)
      Sets the new width of the mark point. Currently not used.
      Parameters:
      aMarkWidth - the new width of the mark point.
    • getMarkWidth

      public int getMarkWidth()
      Gets the new width of the mark point. Currently not used.
      Returns:
      the new width of the mark point.
    • setMarkColor

      public void setMarkColor(Color aMarkColor)
      Sets the new color of the mark point. Currently not used.
      Parameters:
      aMarkColor - the new color of the mark point.
    • getMarkColor

      public Color getMarkColor()
      Gets the new color of the mark point. Currently not used.
      Returns:
      the new color of the mark point.
    • setValidColor

      public void setValidColor(Color aValidColor)
      Sets the color to use to display valid altitudes. The default value is green.
      Parameters:
      aValidColor - the color to use to display valid altitudes.
      See Also:
    • getValidColor

      public Color getValidColor()
      Returns the color used to display valid altitudes.
      Returns:
      the color used to display valid altitudes.
      See Also:
    • setUnknownColor

      public void setUnknownColor(Color aUnknownColor)
      Sets the color to use to display unknown altitudes. The default value is orange.
      Parameters:
      aUnknownColor - the color to use to display unknown altitudes.
      See Also:
    • getUnknownColor

      public Color getUnknownColor()
      Returns the color used to display unknown altitudes. The default value is orange.
      Returns:
      the color used to display unknown altitudes.
      See Also:
    • setVisibilityColor

      public void setVisibilityColor(Color aVisibilityColor)
      Sets the color to use to display visible altitudes. The default value is red. Note that this color is only displayed when visibility is calculated using the calculateVisibility() method and setSimpleLineOfSightEnabled(boolean) is true.
      Parameters:
      aVisibilityColor - the color to use to display visible values.
      See Also:
    • getVisibilityColor

      public Color getVisibilityColor()
      Returns the color used to display visibility values. The default value is red.
      Returns:
      the color used to display visibility values.
      See Also:
    • isValidElevation

      protected boolean isValidElevation(double aElevationValue)
      Checks whether the given elevation value is a known value as returned by the terrain elevation provider. This method returns false if the elevation value is Double.NaN, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY.
      Parameters:
      aElevationValue - the elevation value to check.
      Returns:
      true for known values, false for the unknown values.
    • dispatch

      public void dispatch(EventObject event)
      Deprecated.
      This method should never be used.
      Fire an event.
      Parameters:
      event - A PropertyChangeEvent to fire.
    • setAltitudeAboveGroundForLineOfSight

      public void setAltitudeAboveGroundForLineOfSight(double aAltitudeAboveGroundForLOS)
      Sets the height of the observer, above ground.
      Parameters:
      aAltitudeAboveGroundForLOS - the new height.
      See Also:
    • setTargetAltitudeAboveGroundForLineOfSight

      public void setTargetAltitudeAboveGroundForLineOfSight(double aAltitudeAboveGroundForLOS)
      Sets the height of the target (the point the observer is looking to), above ground. Only points for which the sum of the terrain height plus the target height is smaller than the minimal visible height at that point, looking from the observer's point, are considered visible.
      Parameters:
      aAltitudeAboveGroundForLOS - the new height.
      See Also:
    • calculateLineOfSight

      public void calculateLineOfSight()

      Calculates and displays the line-of-sight in the left and right direction of the last marked point. The geo reference of the profile points has to be set with setProfileReference(com.luciad.reference.ILcdGeoReference).

      The height of the point will be determined by the setAltitudeAboveGround(double) method.

      See Also:
    • calculateVisibility

      public void calculateVisibility()

      Computes the line-of-sight from the current mark point. The geo reference of the profile points has to be set with setProfileReference(com.luciad.reference.ILcdGeoReference).

      The height of the point will be determined by the setAltitudeAboveGround(double) method.

      See Also:
    • drawVisible

      public void drawVisible(Graphics aGraphics)
      Draw the visibility lines using the given Graphics.
      Parameters:
      aGraphics - the graphics on which to draw the visibility.