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

public class TLspSwingView extends ALspAWTView
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:
  • Constructor Details Link icon

    • TLspSwingView Link icon

      public TLspSwingView() throws UnsatisfiedLinkError
      Creates a new Swing view with a default configuration. Note that TLspViewBuilder provides a convenient way of configuring views if you wish to deviate from the default settings for any reason.
      Throws:
      UnsatisfiedLinkError
  • Method Details Link icon

    • createGLDrawable Link icon

      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 ILcdGLCapabilities
      aGraphicsDevice - a GraphicsDevice
      aShareWith - an ILcdGLDrawable
      Returns:
      a TLcdGLDrawableHolder
      Throws:
      UnsatisfiedLinkError - when the OpenGL binding native libraries could not be loaded
      See Also:
    • invalidate Link icon

      public void invalidate(boolean aRepaint, Object aSource, String aMessage)
      Description copied from interface: ILcdView
      Invalidate the content of this ILcdView.
      Specified by:
      invalidate in interface ILcdView
      Overrides:
      invalidate in class ALspAWTView
      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 Link icon

      public JComponent getHostComponent()
      Returns the Swing component that represents this 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).

      Returns:
      a Swing component
    • getOverlayComponent Link icon

      public JComponent getOverlayComponent()
      Returns a component that can contain GUI element which are to be overlaid on top of this TLspSwingView. The overlay component has a TLcdOverlayLayout by default.
      Returns:
      a Swing component
    • beginPrinting Link icon

      public void beginPrinting()
      Description copied from class: ALspAWTView
      Prepares 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 a read lock on all models in the view.

      Overrides:
      beginPrinting in class ALspAWTView
    • endPrinting Link icon

      public void endPrinting()
      Description copied from class: ALspAWTView
      Returns the view to its normal state after a prior call to ALspAWTView.beginPrinting().
      Overrides:
      endPrinting in class ALspAWTView
    • print Link icon

      public void print(Graphics2D aGraphics, TLspViewPrintSettings aPrintSettings)
      Description copied from class: ALspAWTView
      Prints 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 a read lock on all models in the view.

      Overrides:
      print in class ALspAWTView
      Parameters:
      aGraphics - the graphics to print the view to
      aPrintSettings - configuration settings for the printing operation