Module imp

Class ViewComponentAdapter

java.lang.Object
de.grogra.imp.awt.ViewComponentAdapter
All Implemented Interfaces:
ViewComponent, ComponentWrapper, Selectable, Disposable, Runnable
Direct Known Subclasses:
CanvasAdapter, GLDisplay, GLDisplay

public abstract class ViewComponentAdapter extends Object implements ViewComponent, Runnable, Selectable
  • Field Details

    • RENDERING

      protected static final int RENDERING
      Bit mask for renderFlags indicating that this view is currently rendering.
      See Also:
    • DISPOSING

      protected static final int DISPOSING
      Bit mask for renderFlags indicating that this view is currently disposing.
      See Also:
    • DISPOSED

      protected static final int DISPOSED
      Bit mask for renderFlags indicating that this view is disposed.
      See Also:
    • RENDERED_IMAGE

      protected static final int RENDERED_IMAGE
      See Also:
    • REPAINT_MASK

      protected static final int REPAINT_MASK
      See Also:
    • RENDER_OVERLAY

      public static final int RENDER_OVERLAY
      See Also:
    • RENDERING_OVERLAY

      public static final int RENDERING_OVERLAY
      See Also:
    • RENDER_OVERLAY_FINISHED

      public static final int RENDER_OVERLAY_FINISHED
      See Also:
  • Constructor Details

    • ViewComponentAdapter

      public ViewComponentAdapter()
  • Method Details

    • getColor

      public static Color getColor(int argb, Color old)
    • getIntColor

      public static int getIntColor(Tuple3f c)
    • getColor

      public static Color getColor(Tuple3f c, Color old)
    • initFactory

      public void initFactory(Item factory)
      Description copied from interface: ViewComponent
      Sets the factory item which created this view component.
      Specified by:
      initFactory in interface ViewComponent
      Parameters:
      factory - factory item
    • initView

      public void initView(View view, EventListener listener)
      Description copied from interface: ViewComponent
      Initializes this component. This method sets the view within which this view component is used to display the graph. It also sets an event listener. this has to be informed of mouse and keys events within the view component by implementations of this method.
      Specified by:
      initView in interface ViewComponent
      Parameters:
      view - the containing view
      listener - mouse and key events will be reported to this listener
    • installListeners

      protected void installListeners(Component canvas)
    • uninstallListeners

      protected void uninstallListeners(Component canvas)
    • getView

      public View getView()
    • getFactory

      public Item getFactory()
      Description copied from interface: ViewComponent
      Returns the factory item which has been set by ViewComponent.initFactory(Item), i.e., the item which created this component.
      Specified by:
      getFactory in interface ViewComponent
      Returns:
      factory item of this component
    • getOption

      public Object getOption(String name, Object defaultValue)
    • toSelection

      public Selection toSelection(Context ctx)
      Description copied from interface: Selectable
      Converts this object into a Selection.
      Specified by:
      toSelection in interface Selectable
      Parameters:
      ctx - the UI context
      Returns:
      a selection, or null if this is not possible
    • optionValueChanged

      protected void optionValueChanged(String name, Object object)
    • getRenderGraphState

      public GraphState getRenderGraphState()
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable
    • getFontMetrics

      public FontMetrics getFontMetrics(Font font)
    • repaint

      public void repaint(int flags)
      Description copied from interface: ViewComponent
      Initiates a repaint of those parts of the view which are indicated by the flags, interpreted as a combination of bit masks. This method may be invoked from arbitrary threads.
      Specified by:
      repaint in interface ViewComponent
      Parameters:
      flags - the parts to be repainted
    • run

      public final void run()
      Controls rendering and the global level of detail in an own thread. This method should not be invoked by user code.
      Specified by:
      run in interface Runnable
    • getGlobalLOD

      public int getGlobalLOD()
      Description copied from interface: ViewComponent
      Determines the global level-of-detail which should currently be used in this view component. The value lies between View.LOD_MIN and View.LOD_MAX inclusively.
      Specified by:
      getGlobalLOD in interface ViewComponent
      Returns:
      global level-of-detail
    • getDisplayResolution

      public int getDisplayResolution()
      Description copied from interface: ViewComponent
      Determines the level of resolution which should currently be used in this view component. The value lies between Node#MIN_RESOLUTION and Node#MAX_RESOLUTION inclusively.
      Specified by:
      getDisplayResolution in interface ViewComponent
      Returns:
      The resolution level used for the display
    • updateResolution

      public void updateResolution(int r)
      Specified by:
      updateResolution in interface ViewComponent
    • isRenderingOverlay

      public boolean isRenderingOverlay()
      Check if the overlay is being rendering
      Returns:
    • checkRepaint

      public void checkRepaint() throws InterruptedException
      Throws:
      InterruptedException
    • checkRepaintWrapException

      public void checkRepaintWrapException()
    • getInterruptedException

      public InterruptedException getInterruptedException()
    • disposeView

      public void disposeView()
    • disposeRenderer

      public void disposeRenderer(Renderer r)
      Specified by:
      disposeRenderer in interface ViewComponent
    • render

      public void render(Renderer r)
      Description copied from interface: ViewComponent
      Initiates a rendering of the graph using the specified renderer.
      Specified by:
      render in interface ViewComponent
    • render

      public void render(Renderer r, int width, int height)
      Specified by:
      render in interface ViewComponent
    • getObserverForRenderer

      protected abstract ImageObserver getObserverForRenderer()
      Returns an observer which receives the information about the rendered image from a Renderer. The returned observer has to manage the drawing of the (partially) rendered image on the view component.
      Returns:
      an observer receiving the image, or null if this is not supported by this component
    • initRender

      protected abstract void initRender(int flags)
      Performs initialization tasks in preparation for rendering. This method is invoked by run() in this ViewComponent's own thread.
      Parameters:
      flags - combination of bit masks
    • invokeRender

      protected abstract void invokeRender(int flags)
      Invoked to perform rendering. This method is invoked by run() in this ViewComponent's own thread. Its sole task is to invoke invokeRenderSync(int) in the rendering thread (which may be this ViewComponent's thread, the AWT-thread, or another thread, depending on the implementation) in a write-protected context. The invocation has to be synchronously, i.e., if it is in another thread, the current thread has to wait until invokeRenderSync(int) has completed.
      Parameters:
      flags - the flags to pass to invokeRenderSync(int)
    • invokeRenderSync

      protected void invokeRenderSync(int flags)
      Invokes render(int), ensuring that Workbench.current() returns the correct workbench. If render(int) throws an InterruptedException, a repaint is posted. The write-lock of this view's graph has to be acquired by the invoker (see Lockable).
      Parameters:
      flags - the flags to pass to render(int)
    • render

      protected abstract void render(int flags) throws InterruptedException
      Performs rendering. This method is invoked by invokeRenderSync(int) in a context where Workbench.current() returns the workbench of this view.
      Parameters:
      flags - combination of bit masks
      Throws:
      InterruptedException - if the rendering has been interrupted
    • renderUninterruptibly

      protected void renderUninterruptibly()