public class TLcdProfileViewJPanel extends JPanel implements ILcdProfileView
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.JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static String |
MODELPOINTATMOUSELOCATION
Represents the property that is thrown when the mark point has changed.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TLcdProfileViewJPanel()
Creates a new
TLcdProfileViewJPanel . |
Modifier and Type | Method and Description |
---|---|
void |
calculateLineOfSight()
Calculates and displays the line-of-sight in the left and right direction of the last
marked point.
|
void |
calculateVisibility()
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 given
Graphics . |
double |
getAltitudeAtMouseLocation()
Returns the altitude at the current mark point.
|
int |
getEndIndex()
Returns the end index of the profile.
|
Color |
getMarkColor()
Gets the new color of the mark point.
|
int |
getMarkWidth()
Gets the new width of the mark point.
|
double |
getMaxVerticalAngle()
Get the maximum vertical angle used by the line-of-sight calculations.
|
double |
getMinVerticalAngle()
Get the minimum vertical angle used by the line-of-sight calculations.
|
ILcdPoint |
getModelPointAtMouseLocation()
Returns the model point corresponding to the current mark point.
|
ILcdPoint[] |
getProfile()
Get the array of
ILcdPoint that defines the profile. |
ILcdGeoReference |
getProfileReference()
Get the geo reference of the profile points.
|
int |
getStartIndex()
Returns the start index of the profile.
|
Color |
getUnknownColor()
Returns the color used to display unknown altitudes.
|
Color |
getValidColor()
Returns the color used to display valid altitudes.
|
ILcdFormatter |
getValueFormat()
Gets the formatter used to format elevation values.
|
Color |
getVisibilityColor()
Returns the color used to display visibility values.
|
boolean |
isChangeAltitudeOnInteraction()
If true, interactions with the mouse will change the altitude of the mark point to
match that of the mouse.
|
boolean |
isLineOfSightEnabled()
Check whether the line-of-sight action is enabled.
|
boolean |
isSimpleLineOfSightEnabled()
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 |
isVisualizeMarkPoint()
If true, visualizes the mark point as a dot and a label indicating the
height in model coordinates.
|
void |
paint(Graphics g) |
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 with
displayProfile(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 |
update(Graphics g) |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
public static final String MODELPOINTATMOUSELOCATION
public TLcdProfileViewJPanel()
TLcdProfileViewJPanel
.public void setLeftMargin(int aMargin)
aMargin
- the new left margin.public void setRightMargin(int aMargin)
aMargin
- the new right margin.public void setTopMargin(int aMargin)
aMargin
- the new top margin.public void setBottomMargin(int aMargin)
aMargin
- the new bottom margin.public ILcdPoint[] getProfile()
ILcdPoint
that defines the profile.ILcdPoint
that defines the profile.public int getStartIndex()
public int getEndIndex()
public ILcdPoint getModelPointAtMouseLocation()
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.
aProfileSegmentIndex
- The index indicating the segment where the mark point
should move to.aFraction
- The fraction from the start point of the given segment.public double getAltitudeAtMouseLocation()
public void displayProfile(ILcdPoint[] aProfile, int aStartIndex, int aEndIndex, ILcdGXYView aGXYView)
ILcdProfileView
displayProfile
in interface ILcdProfileView
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.public void update(Graphics g)
update
in class JComponent
public void setZeroInProfile(boolean aZeroInProfile)
aZeroInProfile
- true to indicate that the zero height line will always be in the profile.public void setPaintZeroLine(boolean aPaintZeroLine)
aPaintZeroLine
- a flag indicating whether the zero altitude/depth line should be painted.public void setZeroLineColor(Color aZeroLineColor)
aZeroLineColor
- the color to use to paint the zero altitude/depth line.public void paint(Graphics g)
paint
in class JComponent
public boolean isSimpleLineOfSightEnabled()
for more information.
public void setSimpleLineOfSightEnabled(boolean aSimpleLineOfSightEnabled)
setAltitudeAboveGroundForLineOfSight(double)
aSimpleLineOfSightEnabled
- whether to enable or disable the simple line-of-sight action.calculateVisibility()
public boolean isLineOfSightEnabled()
for more information.
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.
aLineOfSightEnabled
- whether to enable or disable the line-of-sight action.setProfileReference(com.luciad.reference.ILcdGeoReference)
,
calculateSightLine(com.luciad.reference.ILcdGeoReference)
public double getMinVerticalAngle()
setMinVerticalAngle(double)
public void setMinVerticalAngle(double aMinVerticalAngle)
setLineOfSightEnabled(boolean)
is set to true.aMinVerticalAngle
- The angle in degrees.public double getMaxVerticalAngle()
setMaxVerticalAngle(double)
public void setMaxVerticalAngle(double aMaxVerticalAngle)
setLineOfSightEnabled(boolean)
is set to true.aMaxVerticalAngle
- The angle in degrees.public ILcdGeoReference getProfileReference()
public void setProfileReference(ILcdGeoReference aProfileReference)
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.aProfileReference
- The geo reference to set.setLineOfSightEnabled(boolean)
,
displayProfile(com.luciad.shape.ILcdPoint[], int, int, com.luciad.view.gxy.ILcdGXYView)
public boolean isChangeAltitudeOnInteraction()
setAltitudeAboveGroundForLineOfSight(double)
method.
true
public void setChangeAltitudeOnInteraction(boolean aChangeAltitudeOnInteraction)
setAltitudeAboveGroundForLineOfSight(double)
method.
true
aChangeAltitudeOnInteraction
- if truepublic boolean isVisualizeMarkPoint()
true
public void setVisualizeMarkPoint(boolean aVisualizeMarkPoint)
true
aVisualizeMarkPoint
- true if the mark point should be visualized; false otherwisesetMarkPoint(int)
public void setValueFormat(ILcdFormatter aValueFormat)
aValueFormat
- the formatter used to format elevation values.getValueFormat()
public ILcdFormatter getValueFormat()
setValueFormat(com.luciad.util.ILcdFormatter)
public void setMarkWidth(int aMarkWidth)
aMarkWidth
- the new width of the mark point.public int getMarkWidth()
public void setMarkColor(Color aMarkColor)
aMarkColor
- the new color of the mark point.public Color getMarkColor()
public void setValidColor(Color aValidColor)
aValidColor
- the color to use to display valid altitudes.getValidColor()
public Color getValidColor()
setValidColor(java.awt.Color)
public void setUnknownColor(Color aUnknownColor)
aUnknownColor
- the color to use to display unknown altitudes.getUnknownColor()
public Color getUnknownColor()
setUnknownColor(Color)
public void setVisibilityColor(Color aVisibilityColor)
calculateVisibility()
method and setSimpleLineOfSightEnabled(boolean)
is true.aVisibilityColor
- the color to use to display visible values.getVisibilityColor()
,
calculateVisibility()
public Color getVisibilityColor()
setVisibilityColor(Color)
protected boolean isValidElevation(double aElevationValue)
false
if the elevation value is Double.NaN
,
Double.POSITIVE_INFINITY
or Double.NEGATIVE_INFINITY
.aElevationValue
- the elevation value to check.public void dispatch(EventObject event)
event
- A PropertyChangeEvent to fire.public void setAltitudeAboveGroundForLineOfSight(double aAltitudeAboveGroundForLOS)
aAltitudeAboveGroundForLOS
- the new height.setSimpleLineOfSightEnabled(boolean)
,
setLineOfSightEnabled(boolean)
,
setChangeAltitudeOnInteraction(boolean)
public void setTargetAltitudeAboveGroundForLineOfSight(double aAltitudeAboveGroundForLOS)
aAltitudeAboveGroundForLOS
- the new height.setSimpleLineOfSightEnabled(boolean)
,
setLineOfSightEnabled(boolean)
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.
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.
public void drawVisible(Graphics aGraphics)
Graphics
.aGraphics
- the graphics on which to draw the visibility.