Class TLcdProfileViewJPanel
- All Implemented Interfaces:
ILcdProfileView
,ImageObserver
,MenuContainer
,Serializable
,Accessible
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Represents the property that is thrown when the mark point has changed.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calculates and displays the line-of-sight in the left and right direction of the last marked point.void
Computes the line-of-sight from the current mark point.void
dispatch
(EventObject event) Deprecated.This method should never be used.void
displayProfile
(ILcdPoint[] aProfile, int aStartIndex, int aEndIndex, ILcdGXYView aGXYView) Display a profile on the view.void
drawVisible
(Graphics aGraphics) Draw the visibility lines using the givenGraphics
.double
Returns the altitude at the current mark point.int
Returns the end index of the profile.Gets the new color of the mark point.int
Gets the new width of the mark point.double
Get the maximum vertical angle used by the line-of-sight calculations.double
Get the minimum vertical angle used by the line-of-sight calculations.Returns the model point corresponding to the current mark point.Get the array ofILcdPoint
that defines the profile.Get the geo reference of the profile points.int
Returns the start index of the profile.Returns the color used to display unknown altitudes.Returns the color used to display valid altitudes.Gets the formatter used to format elevation values.Returns the color used to display visibility values.boolean
If true, interactions with the mouse will change the altitude of the mark point to match that of the mouse.boolean
Check whether the line-of-sight action is enabled.boolean
Check whether the simple line-of-sight action is enabled.protected boolean
isValidElevation
(double aElevationValue) Checks whether the given elevation value is a known value as returned by the terrain elevation provider.boolean
If true, visualizes the mark point as a dot and a label indicating the height in model coordinates.void
void
setAltitudeAboveGroundForLineOfSight
(double aAltitudeAboveGroundForLOS) Sets the height of the observer, above ground.void
setBottomMargin
(int aMargin) Sets the bottom margin.void
setChangeAltitudeOnInteraction
(boolean aChangeAltitudeOnInteraction) Sets whether or not the altitude should change as result of an interaction with the mouse.void
setLeftMargin
(int aMargin) Sets the left margin in which the left labels are placed.void
setLineOfSightEnabled
(boolean aLineOfSightEnabled) Enable or disable the line-of-sight action.void
setMarkColor
(Color aMarkColor) Sets the new color of the mark point.void
setMarkPoint
(int aProfileSegmentIndex, double aFraction) Sets the mark point to the point located at the specified fraction of the specified profile segment.void
setMarkWidth
(int aMarkWidth) Sets the new width of the mark point.void
setMaxVerticalAngle
(double aMaxVerticalAngle) Set the maximum vertical angle used by the line-of-sight calculations.void
setMinVerticalAngle
(double aMinVerticalAngle) Set the minimum vertical angle used by the line-of-sight calculations.void
setPaintZeroLine
(boolean aPaintZeroLine) Sets whether the zero altitude/depth line should be painted if its visible in the profile.void
setProfileReference
(ILcdGeoReference aProfileReference) Set the geo reference of the profile points that were set withdisplayProfile(com.luciad.shape.ILcdPoint[], int, int, com.luciad.view.gxy.ILcdGXYView)
.void
setRightMargin
(int aMargin) Sets the right margin in which the right labels are placed.void
setSimpleLineOfSightEnabled
(boolean aSimpleLineOfSightEnabled) Enable or disable the simple line-of-sight action.void
setTargetAltitudeAboveGroundForLineOfSight
(double aAltitudeAboveGroundForLOS) Sets the height of the target (the point the observer is looking to), above ground.void
setTopMargin
(int aMargin) Sets the top margin.void
setUnknownColor
(Color aUnknownColor) Sets the color to use to display unknown altitudes.void
setValidColor
(Color aValidColor) Sets the color to use to display valid altitudes.void
setValueFormat
(ILcdFormatter aValueFormat) Sets the formatter used to format elevation values.void
setVisibilityColor
(Color aVisibilityColor) Sets the color to use to display visible altitudes.void
setVisualizeMarkPoint
(boolean aVisualizeMarkPoint) If true, visualizes the mark point as a dot and a label indicating the height in model coordinates.void
setZeroInProfile
(boolean aZeroInProfile) Sets whether the line indicating zero height/altitude should always be in the profile.void
setZeroLineColor
(Color aZeroLineColor) Sets the color to use to paint the zero altitude/depth line.void
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.luciad.tea.ILcdProfileView
addPropertyChangeListener, removePropertyChangeListener
-
Field Details
-
MODELPOINTATMOUSELOCATION
Represents the property that is thrown when the mark point has changed.- See Also:
-
-
Constructor Details
-
TLcdProfileViewJPanel
public TLcdProfileViewJPanel()Creates a newTLcdProfileViewJPanel
.
-
-
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
Get the array ofILcdPoint
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
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
and1.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 interfaceILcdProfileView
- Parameters:
aProfile
- An array ofILcdPoint
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 originalILcdGXYView
that the profile is based on.
-
update
- Overrides:
update
in classJComponent
-
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
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
- Overrides:
paint
in classJComponent
-
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 withsetAltitudeAboveGroundForLineOfSight(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)
andsetMaxVerticalAngle(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 whensetLineOfSightEnabled(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 whensetLineOfSightEnabled(boolean)
is set to true.- Parameters:
aMaxVerticalAngle
- The angle in degrees.
-
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
Set the geo reference of the profile points that were set withdisplayProfile(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 thesetAltitudeAboveGroundForLineOfSight(double)
method.
The default istrue
- 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 thesetAltitudeAboveGroundForLineOfSight(double)
method.
The default istrue
- 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 istrue
- 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 istrue
- Parameters:
aVisualizeMarkPoint
- true if the mark point should be visualized; false otherwise- See Also:
-
setValueFormat
Sets the formatter used to format elevation values.- Parameters:
aValueFormat
- the formatter used to format elevation values.- See Also:
-
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
Sets the new color of the mark point. Currently not used.- Parameters:
aMarkColor
- the new color of the mark point.
-
getMarkColor
Gets the new color of the mark point. Currently not used.- Returns:
- the new color of the mark point.
-
setValidColor
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
Returns the color used to display valid altitudes.- Returns:
- the color used to display valid altitudes.
- See Also:
-
setUnknownColor
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
Returns the color used to display unknown altitudes. The default value is orange.- Returns:
- the color used to display unknown altitudes.
- See Also:
-
setVisibilityColor
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 thecalculateVisibility()
method andsetSimpleLineOfSightEnabled(boolean)
is true.- Parameters:
aVisibilityColor
- the color to use to display visible values.- See Also:
-
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 returnsfalse
if the elevation value isDouble.NaN
,Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
.- Parameters:
aElevationValue
- the elevation value to check.- Returns:
- true for known values, false for the unknown values.
-
dispatch
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
Draw the visibility lines using the givenGraphics
.- Parameters:
aGraphics
- the graphics on which to draw the visibility.
-