de.grogra.imp.awt
Class ViewComponentAdapter

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

public abstract class ViewComponentAdapter
extends java.lang.Object
implements ViewComponent, java.lang.Runnable, Selectable


Field Summary
protected static int DISPOSED
          Bit mask for renderFlags indicating that this view is disposed.
protected static int DISPOSING
          Bit mask for renderFlags indicating that this view is currently disposing.
protected static int RENDERED_IMAGE
           
protected static int RENDERING
          Bit mask for renderFlags indicating that this view is currently rendering.
protected static int REPAINT_MASK
           
 
Fields inherited from interface de.grogra.imp.ViewComponent
ALL, CHANGED, MIN_USER_FLAG, SCENE, SELECTION, TOOLS
 
Constructor Summary
ViewComponentAdapter()
           
 
Method Summary
 void checkRepaint()
           
 void checkRepaintWrapException()
           
 void dispose()
           
 void disposeRenderer(Renderer r)
           
static java.awt.Color getColor(int argb, java.awt.Color old)
           
static java.awt.Color getColor(Tuple3f c, java.awt.Color old)
           
 Item getFactory()
          Returns the factory item which has been set by ViewComponent.initFactory(Item), i.e., the item which created this component.
 java.awt.FontMetrics getFontMetrics(java.awt.Font font)
           
 int getGlobalLOD()
          Determines the global level-of-detail which should currently be used in this view component.
static int getIntColor(Tuple3f c)
           
 java.lang.InterruptedException getInterruptedException()
           
protected abstract  java.awt.image.ImageObserver getObserverForRenderer()
          Returns an observer which receives the information about the rendered image from a Renderer.
 java.lang.Object getOption(java.lang.String name, java.lang.Object defaultValue)
           
 GraphState getRenderGraphState()
           
 View getView()
           
 void initFactory(Item factory)
          Sets the factory item which created this view component.
protected abstract  void initRender(int flags)
          Performs initialization tasks in preparation for rendering.
 void initView(View view, EventListener listener)
          Initializes this component.
protected  void installListeners(java.awt.Component canvas)
           
protected abstract  void invokeRender(int flags)
          Invoked to perform rendering.
protected  void invokeRenderSync(int flags)
          Invokes render(int), ensuring that Workbench.current() returns the correct workbench.
protected  void optionValueChanged(java.lang.String name, java.lang.Object object)
           
protected abstract  void render(int flags)
          Performs rendering.
 void render(Renderer r)
          Initiates a rendering of the graph using the specified renderer.
 void render(Renderer r, int width, int height)
           
protected  void renderUninterruptibly()
           
 void repaint(int flags)
          Initiates a repaint of those parts of the view which are indicated by the flags, interpreted as a combination of bit masks.
 void run()
          Controls rendering and the global level of detail in an own thread.
 Selection toSelection(Context ctx)
          Converts this object into a Selection.
protected  void uninstallListeners(java.awt.Component canvas)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.grogra.imp.ViewComponent
makeSnapshot
 
Methods inherited from interface de.grogra.pf.ui.ComponentWrapper
getComponent
 

Field Detail

DISPOSED

protected static final int DISPOSED
Bit mask for renderFlags indicating that this view is disposed.

See Also:
Constant Field Values

DISPOSING

protected static final int DISPOSING
Bit mask for renderFlags indicating that this view is currently disposing.

See Also:
Constant Field Values

RENDERED_IMAGE

protected static final int RENDERED_IMAGE
See Also:
Constant Field Values

RENDERING

protected static final int RENDERING
Bit mask for renderFlags indicating that this view is currently rendering.

See Also:
Constant Field Values

REPAINT_MASK

protected static final int REPAINT_MASK
See Also:
Constant Field Values
Constructor Detail

ViewComponentAdapter

public ViewComponentAdapter()
Method Detail

checkRepaint

public void checkRepaint()
                  throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

checkRepaintWrapException

public void checkRepaintWrapException()

dispose

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

disposeRenderer

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

getColor

public static java.awt.Color getColor(int argb,
                                      java.awt.Color old)

getColor

public static java.awt.Color getColor(Tuple3f c,
                                      java.awt.Color old)

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

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font font)

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

getIntColor

public static int getIntColor(Tuple3f c)

getInterruptedException

public java.lang.InterruptedException getInterruptedException()

getObserverForRenderer

protected abstract java.awt.image.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

getOption

public java.lang.Object getOption(java.lang.String name,
                                  java.lang.Object defaultValue)

getRenderGraphState

public GraphState getRenderGraphState()

getView

public View getView()

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

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

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(java.awt.Component canvas)

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)

optionValueChanged

protected void optionValueChanged(java.lang.String name,
                                  java.lang.Object object)

render

protected abstract void render(int flags)
                        throws java.lang.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:
java.lang.InterruptedException - if the rendering has been interrupted

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

renderUninterruptibly

protected void renderUninterruptibly()

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 java.lang.Runnable

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

uninstallListeners

protected void uninstallListeners(java.awt.Component canvas)