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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Bit mask forrenderFlags
indicating that this view is disposed.protected static final int
Bit mask forrenderFlags
indicating that this view is currently disposing.static final int
static final int
protected static final int
protected static final int
Bit mask forrenderFlags
indicating that this view is currently rendering.static final int
protected static final int
Fields inherited from interface de.grogra.imp.ViewComponent
ALL, CHANGED, MIN_USER_FLAG, SCENE, SELECTION, TOOLS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
dispose()
void
void
static Color
static Color
int
Determines the level of resolution which should currently be used in this view component.Returns the factory item which has been set byViewComponent.initFactory(Item)
, i.e., the item which created this component.getFontMetrics
(Font font) int
Determines the global level-of-detail which should currently be used in this view component.static int
protected abstract ImageObserver
Returns an observer which receives the information about the rendered image from aRenderer
.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
(Component canvas) protected abstract void
invokeRender
(int flags) Invoked to perform rendering.protected void
invokeRenderSync
(int flags) Invokesrender(int)
, ensuring thatWorkbench.current()
returns the correct workbench.boolean
Check if the overlay is being renderingprotected void
optionValueChanged
(String name, Object object) protected abstract void
render
(int flags) Performs rendering.void
Initiates a rendering of the graph using the specified renderer.void
protected void
void
repaint
(int flags) Initiates a repaint of those parts of the view which are indicated by theflags
, interpreted as a combination of bit masks.final void
run()
Controls rendering and the global level of detail in an own thread.toSelection
(Context ctx) Converts this object into aSelection
.protected void
uninstallListeners
(Component canvas) void
updateResolution
(int r) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.grogra.pf.ui.ComponentWrapper
getComponent
Methods inherited from interface de.grogra.imp.ViewComponent
makeSnapshot
-
Field Details
-
RENDERING
protected static final int RENDERINGBit mask forrenderFlags
indicating that this view is currently rendering.- See Also:
-
DISPOSING
protected static final int DISPOSINGBit mask forrenderFlags
indicating that this view is currently disposing.- See Also:
-
DISPOSED
protected static final int DISPOSEDBit mask forrenderFlags
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
-
getIntColor
-
getColor
-
initFactory
Description copied from interface:ViewComponent
Sets the factory item which created this view component.- Specified by:
initFactory
in interfaceViewComponent
- Parameters:
factory
- factory item
-
initView
Description copied from interface:ViewComponent
Initializes this component. This method sets theview
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 interfaceViewComponent
- Parameters:
view
- the containing viewlistener
- mouse and key events will be reported to this listener
-
installListeners
-
uninstallListeners
-
getView
-
getFactory
Description copied from interface:ViewComponent
Returns the factory item which has been set byViewComponent.initFactory(Item)
, i.e., the item which created this component.- Specified by:
getFactory
in interfaceViewComponent
- Returns:
- factory item of this component
-
getOption
-
toSelection
Description copied from interface:Selectable
Converts this object into aSelection
.- Specified by:
toSelection
in interfaceSelectable
- Parameters:
ctx
- the UI context- Returns:
- a selection, or
null
if this is not possible
-
optionValueChanged
-
getRenderGraphState
-
dispose
public void dispose()- Specified by:
dispose
in interfaceDisposable
-
getFontMetrics
-
repaint
public void repaint(int flags) Description copied from interface:ViewComponent
Initiates a repaint of those parts of the view which are indicated by theflags
, interpreted as a combination of bit masks. This method may be invoked from arbitrary threads.- Specified by:
repaint
in interfaceViewComponent
- 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. -
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 betweenView.LOD_MIN
andView.LOD_MAX
inclusively.- Specified by:
getGlobalLOD
in interfaceViewComponent
- 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 betweenNode#MIN_RESOLUTION
andNode#MAX_RESOLUTION
inclusively.- Specified by:
getDisplayResolution
in interfaceViewComponent
- Returns:
- The resolution level used for the display
-
updateResolution
public void updateResolution(int r) - Specified by:
updateResolution
in interfaceViewComponent
-
isRenderingOverlay
public boolean isRenderingOverlay()Check if the overlay is being rendering- Returns:
-
checkRepaint
- Throws:
InterruptedException
-
checkRepaintWrapException
public void checkRepaintWrapException() -
getInterruptedException
-
disposeView
public void disposeView() -
disposeRenderer
- Specified by:
disposeRenderer
in interfaceViewComponent
-
render
Description copied from interface:ViewComponent
Initiates a rendering of the graph using the specified renderer.- Specified by:
render
in interfaceViewComponent
-
render
- Specified by:
render
in interfaceViewComponent
-
getObserverForRenderer
Returns an observer which receives the information about the rendered image from aRenderer
. 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 byrun()
in thisViewComponent
's own thread.- Parameters:
flags
- combination of bit masks
-
invokeRender
protected abstract void invokeRender(int flags) Invoked to perform rendering. This method is invoked byrun()
in thisViewComponent
's own thread. Its sole task is to invokeinvokeRenderSync(int)
in the rendering thread (which may be thisViewComponent
'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 untilinvokeRenderSync(int)
has completed.- Parameters:
flags
- the flags to pass toinvokeRenderSync(int)
-
invokeRenderSync
protected void invokeRenderSync(int flags) Invokesrender(int)
, ensuring thatWorkbench.current()
returns the correct workbench. Ifrender(int)
throws anInterruptedException
, a repaint is posted. The write-lock of this view's graph has to be acquired by the invoker (seeLockable
).- Parameters:
flags
- the flags to pass torender(int)
-
render
Performs rendering. This method is invoked byinvokeRenderSync(int)
in a context whereWorkbench.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()
-