java.lang.Object
de.grogra.imp.awt.ViewComponentAdapter
- All Implemented Interfaces:
ViewComponent,ComponentWrapper,Selectable,Disposable,Runnable
- Direct Known Subclasses:
CanvasAdapter,GLDisplay,GLDisplay,SocketViewAdapter
public abstract class ViewComponentAdapter
extends Object
implements ViewComponent, Runnable, Selectable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intBit mask forrenderFlagsindicating that this view is disposed.protected static final intBit mask forrenderFlagsindicating that this view is currently disposing.static final intstatic final intprotected static final intprotected static final intBit mask forrenderFlagsindicating that this view is currently rendering.static final intprotected static final intFields inherited from interface de.grogra.imp.ViewComponent
ALL, CHANGED, MIN_USER_FLAG, SCENE, SELECTION, TOOLS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoiddispose()voidvoidstatic Colorstatic ColorintDetermines 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) intDetermines the global level-of-detail which should currently be used in this view component.static intprotected abstract ImageObserverReturns an observer which receives the information about the rendered image from aRenderer.getView()voidinitFactory(Item factory) Sets the factory item which created this view component.protected abstract voidinitRender(int flags) Performs initialization tasks in preparation for rendering.voidinitView(View view, EventListener listener) Initializes this component.protected voidinstallListeners(Component canvas) protected abstract voidinvokeRender(int flags) Invoked to perform rendering.protected voidinvokeRenderSync(int flags) Invokesrender(int), ensuring thatWorkbench.current()returns the correct workbench.booleanCheck if the overlay is being renderingprotected voidoptionValueChanged(String name, Object object) protected abstract voidrender(int flags) Performs rendering.voidInitiates a rendering of the graph using the specified renderer.voidprotected voidvoidrepaint(int flags) Initiates a repaint of those parts of the view which are indicated by theflags, interpreted as a combination of bit masks.final voidrun()Controls rendering and the global level of detail in an own thread.toSelection(Context ctx) Converts this object into aSelection.protected voiduninstallListeners(Component canvas) voidupdateResolution(int r) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.grogra.pf.ui.ComponentWrapper
getComponentMethods inherited from interface de.grogra.imp.ViewComponent
makeSnapshot
-
Field Details
-
RENDERING
protected static final int RENDERINGBit mask forrenderFlagsindicating that this view is currently rendering.- See Also:
-
DISPOSING
protected static final int DISPOSINGBit mask forrenderFlagsindicating that this view is currently disposing.- See Also:
-
DISPOSED
protected static final int DISPOSEDBit mask forrenderFlagsindicating 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:ViewComponentSets the factory item which created this view component.- Specified by:
initFactoryin interfaceViewComponent- Parameters:
factory- factory item
-
initView
Description copied from interface:ViewComponentInitializes this component. This method sets theviewwithin 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:
initViewin interfaceViewComponent- Parameters:
view- the containing viewlistener- mouse and key events will be reported to this listener
-
installListeners
-
uninstallListeners
-
getView
-
getFactory
Description copied from interface:ViewComponentReturns the factory item which has been set byViewComponent.initFactory(Item), i.e., the item which created this component.- Specified by:
getFactoryin interfaceViewComponent- Returns:
- factory item of this component
-
getOption
-
toSelection
Description copied from interface:SelectableConverts this object into aSelection.- Specified by:
toSelectionin interfaceSelectable- Parameters:
ctx- the UI context- Returns:
- a selection, or
nullif this is not possible
-
optionValueChanged
-
getRenderGraphState
-
dispose
public void dispose()- Specified by:
disposein interfaceDisposable
-
getFontMetrics
-
repaint
public void repaint(int flags) Description copied from interface:ViewComponentInitiates 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:
repaintin 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:ViewComponentDetermines the global level-of-detail which should currently be used in this view component. The value lies betweenView.LOD_MINandView.LOD_MAXinclusively.- Specified by:
getGlobalLODin interfaceViewComponent- Returns:
- global level-of-detail
-
getDisplayResolution
public int getDisplayResolution()Description copied from interface:ViewComponentDetermines the level of resolution which should currently be used in this view component. The value lies betweenandinvalid reference
Node#MIN_RESOLUTIONinclusively.invalid reference
Node#MAX_RESOLUTION- Specified by:
getDisplayResolutionin interfaceViewComponent- Returns:
- The resolution level used for the display
-
updateResolution
public void updateResolution(int r) - Specified by:
updateResolutionin 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:
disposeRendererin interfaceViewComponent
-
render
Description copied from interface:ViewComponentInitiates a rendering of the graph using the specified renderer.- Specified by:
renderin interfaceViewComponent- Parameters:
r-
-
render
- Specified by:
renderin 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
nullif 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()
-