public class TLspSwingView extends ALspAWTView
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.ILspView.ViewType
Constructor and Description |
---|
TLspSwingView()
Creates a new Swing view with a default configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
beginPrinting()
Prepares the view to be printed.
|
protected TLcdGLDrawableHolder |
createGLDrawable(ILcdGLCapabilities aCapabilities,
GraphicsDevice aGraphicsDevice,
ILcdGLDrawable aShareWith)
Creates an ILcdGLDrawable for this view panel.
|
void |
endPrinting()
Returns the view to its normal state after a prior call to
ALspAWTView.beginPrinting().
|
JComponent |
getHostComponent()
Returns the Swing component that represents this
ILspView . |
JComponent |
getOverlayComponent()
Returns a component that can contain GUI element which are to be overlaid
on top of this
TLspSwingView . |
void |
invalidate(boolean aRepaint,
Object aSource,
String aMessage)
Invalidate the content of this
ILcdView . |
void |
print(Graphics2D aGraphics,
TLspViewPrintSettings aPrintSettings)
Prints the contents of the view to the given graphics.
|
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, setXYZWorldReference
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDPIScale, getLayers
addLayeredListener, removeLayeredListener
public TLspSwingView() throws UnsatisfiedLinkError
TLspViewBuilder
provides a convenient way of configuring views if
you wish to deviate from the default settings for any reason.UnsatisfiedLinkError
protected TLcdGLDrawableHolder createGLDrawable(ILcdGLCapabilities aCapabilities, GraphicsDevice aGraphicsDevice, ILcdGLDrawable aShareWith) throws UnsatisfiedLinkError
aCapabilities
- an ILcdGLCapabilitiesaGraphicsDevice
- a GraphicsDeviceaShareWith
- an ILcdGLDrawableUnsatisfiedLinkError
- when the OpenGL binding native libraries could
not be loadedILcdGLDrawableFactory
public void invalidate(boolean aRepaint, Object aSource, String aMessage)
ILcdView
ILcdView
.invalidate
in interface ILcdView
invalidate
in class ALspAWTView
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.public JComponent getHostComponent()
ILspView
. 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).public JComponent getOverlayComponent()
TLspSwingView
. The overlay component has a
TLcdOverlayLayout
by default.public void beginPrinting()
ALspAWTView
read lock
on all models in the view.beginPrinting
in class ALspAWTView
public void endPrinting()
ALspAWTView
endPrinting
in class ALspAWTView
public void print(Graphics2D aGraphics, TLspViewPrintSettings aPrintSettings)
ALspAWTView
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 a read lock
on all models in the view.print
in class ALspAWTView
aGraphics
- the graphics to print the view toaPrintSettings
- configuration settings for the printing operation