Package com.luciad.view.lightspeed
Class TLspSwingView
java.lang.Object
com.luciad.view.lightspeed.ALspAWTView
com.luciad.view.lightspeed.TLspSwingView
- All Implemented Interfaces:
ILcdPropertyChangeSource,ILcdLayered,ILcdTreeLayered,ILcdView,ILspAWTView,ILspView,Serializable
An
ILspAWTView which is represented by a Swing component. The component
can be accessed via the getHostComponent() method. This
implementation uses a lightweight component for drawing into. Like
TLspAWTView, this view contains a separate
overlay component
to hold GUI elements that are overlaid on top of the view. The overlay
component has a TLcdOverlayLayout by default.
Using TLspSwingView incurs a performance penalty
compared to TLspAWTView. This is because, in order to be composited
properly with other lightweight components, the view needs to render to
an offscreen buffer and then copy the resulting image back onto the screen. This
copy operation adds a fixed overhead to every repaint of the view, the cost of
which is proportional to the dimensions of the view.- Since:
- 2013.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.lightspeed.ILspView
ILspView.ViewType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPrepares the view to be printed.protected TLcdGLDrawableHoldercreateGLDrawable(ILcdGLCapabilities aCapabilities, GraphicsDevice aGraphicsDevice, ILcdGLDrawable aShareWith) Creates an ILcdGLDrawable for this view panel.voidReturns the view to its normal state after a prior call to ALspAWTView.beginPrinting().Returns the Swing component that represents thisILspView.Returns a component that can contain GUI element which are to be overlaid on top of thisTLspSwingView.voidinvalidate(boolean aRepaint, Object aSource, String aMessage) Invalidate the content of thisILcdView.voidprint(Graphics2D aGraphics, TLspViewPrintSettings aPrintSettings) Prints the contents of the view to the given graphics.Methods inherited from class com.luciad.view.lightspeed.ALspAWTView
addLayer, addLayeredListener, addLayerModelListener, addLayerSelectionListener, addLayersFor, addModel, addPropertyChangeListener, addViewInvalidationListener, addViewListener, containsLayer, destroy, getAltitudeExaggerationFactor, getBackground, getController, getGLDrawable, getHeight, getImage, getLabelPlacer, getLayer, getLayerFactory, getPaintExceptionHandler, getPaintingHints, getPaintingOrder, getRequiredOpenGLProfile, getRootNode, getServices, getViewType, getViewXYZWorldTransformation, getWidth, getXYZWorldReference, indexOf, invokeLater, isAutoUpdate, layerCount, layerOf, layers, layersBackwards, moveLayerAt, removeAllLayers, removeLayer, removeLayeredListener, removeLayerModelListener, removeLayerSelectionListener, removeModel, removePropertyChangeListener, removeViewInvalidationListener, removeViewListener, setAltitudeExaggerationFactor, setAutoUpdate, setBackground, setController, setLabelPlacer, setLayerFactory, setPaintingOrder, setViewXYZWorldTransformation, setXYZWorldReferenceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.ILcdLayered
addLayeredListener, removeLayeredListenerMethods inherited from interface com.luciad.view.lightspeed.ILspView
getDPIScale, getLayers
-
Constructor Details
-
TLspSwingView
Creates a new Swing view with a default configuration. Note thatTLspViewBuilderprovides a convenient way of configuring views if you wish to deviate from the default settings for any reason.- Throws:
UnsatisfiedLinkError
-
-
Method Details
-
createGLDrawable
protected TLcdGLDrawableHolder createGLDrawable(ILcdGLCapabilities aCapabilities, GraphicsDevice aGraphicsDevice, ILcdGLDrawable aShareWith) throws UnsatisfiedLinkError Creates an ILcdGLDrawable for this view panel. This method is called during construction of the TLspSwingView. The arguments of this method are also those passed in via the constructors.- Parameters:
aCapabilities- an ILcdGLCapabilitiesaGraphicsDevice- a GraphicsDeviceaShareWith- an ILcdGLDrawable- Returns:
- a TLcdGLDrawableHolder
- Throws:
UnsatisfiedLinkError- when the OpenGL binding native libraries could not be loaded- See Also:
-
invalidate
Description copied from interface:ILcdViewInvalidate the content of thisILcdView.- Specified by:
invalidatein interfaceILcdView- Overrides:
invalidatein classALspAWTView- Parameters:
aRepaint- if true, this ILcdView shall be repainted immediately.aSource- the class instance that calls this method. Used for tracing.aMessage- a message associated with this call. Used for tracing.
-
getHostComponent
Returns the Swing component that represents thisILspView. This component can be used as the view's on-screen representation. The host component can also be used to print the contents of the view (e.g. using TLcdPrintComponentAction).- Returns:
- a Swing component
-
getOverlayComponent
Returns a component that can contain GUI element which are to be overlaid on top of thisTLspSwingView. The overlay component has aTLcdOverlayLayoutby default.- Returns:
- a Swing component
-
beginPrinting
public void beginPrinting()Description copied from class:ALspAWTViewPrepares the view to be printed. Among other things, this method stops asynchronous tasks and animations, making sure that the state of the view cannot change unexpectedly while printing is in progress. When doing multi-page prints, this method should be called before the first page, and ALspAWTView.endPrinting() should be called after the last. Not doing so will allow animations and asynchronous tasks to briefly resume in between pages, leading to possible inconsistencies from one page to the next. For single-page prints, it is not technically necessary to call this method, although there is no harm in doing so. The view must not be changed while printing. This includes all layers in the view and their models. A typical case is a model that is updated asynchronously (for example updates received from a remote server or a updates from a simulation). These asynchronous updates should be paused before starting the print. You can for example do this by taking aread lockon all models in the view.- Overrides:
beginPrintingin classALspAWTView
-
endPrinting
public void endPrinting()Description copied from class:ALspAWTViewReturns the view to its normal state after a prior call to ALspAWTView.beginPrinting().- Overrides:
endPrintingin classALspAWTView
-
print
Description copied from class:ALspAWTViewPrints the contents of the view to the given graphics. The TLspViewPrintSettings object provides additional configuration options for the print, such as the aspect ratio. When doing multi-page prints, it is strongly recommended to call ALspAWTView.beginPrinting() before the first page and ALspAWTView.endPrinting() after the last. This avoids redundant state changes in between pages, thus reducing the time needed to complete the print. It also avoids potential inconsistencies between pages due to animations or other changes. If these methods are not called,print()will call them itself. For single-page prints, this is sufficient. The view must not be changed while printing. This includes all layers in the view and their models. A typical case is a model that is updated asynchronously (for example updates received from a remote server or a updates from a simulation). These asynchronous updates should be paused before starting the print. You can for example do this by taking aread lockon all models in the view.- Overrides:
printin classALspAWTView- Parameters:
aGraphics- the graphics to print the view toaPrintSettings- configuration settings for the printing operation
-