de.grogra.imp.awt
Class CanvasAdapter
java.lang.Object
de.grogra.imp.awt.ViewComponentAdapter
de.grogra.imp.awt.CanvasAdapter
- All Implemented Interfaces:
- ViewComponent, ComponentWrapper, Selectable, Disposable, java.awt.image.ImageObserver, java.lang.Runnable
- Direct Known Subclasses:
- WireframeCanvas
public abstract class CanvasAdapter
- extends ViewComponentAdapter
- implements java.awt.image.ImageObserver
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Method Summary |
protected void |
checkBuffers()
|
java.lang.Object |
getComponent()
|
java.awt.Graphics2D |
getGraphics()
|
protected java.awt.image.ImageObserver |
getObserverForRenderer()
Returns an observer which receives the information about the
rendered image from a Renderer . |
boolean |
imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
|
void |
initCanvas(java.awt.Component canvas)
|
protected abstract void |
initPaint(int flags,
int width,
int height)
|
protected void |
initRender(int flags)
Performs initialization tasks in preparation for rendering. |
void |
initView(View view,
EventListener listener)
Initializes this component. |
protected void |
invokeRender(int flags)
Invoked to perform rendering. |
void |
makeSnapshot(ObjectConsumer<? super java.awt.image.RenderedImage> callback)
Instructs the view component to create a snapshot. |
protected void |
optionValueChanged(java.lang.String name,
java.lang.Object object)
|
protected abstract void |
paintHighlight(int flags,
java.awt.Graphics2D g)
|
protected abstract void |
paintScene(int flags,
java.awt.Graphics2D g)
|
protected void |
render(int flags)
Performs rendering. |
void |
resetGraphicsTransform()
|
abstract void |
setColor(java.awt.Color color)
|
void |
setColor(java.awt.Color color,
int state,
boolean showSel)
|
void |
setColor(int color)
|
void |
setColor(int color,
int state,
boolean showSel)
|
void |
setColor(Tuple3f color)
|
void |
setColor(Tuple3f color,
int state,
boolean showSel)
|
static void |
writeEPS(Item item,
java.lang.Object info,
Context ctx)
|
Methods inherited from class de.grogra.imp.awt.ViewComponentAdapter |
checkRepaint, checkRepaintWrapException, dispose, disposeRenderer, getColor, getColor, getFactory, getFontMetrics, getGlobalLOD, getIntColor, getInterruptedException, getOption, getRenderGraphState, getView, initFactory, installListeners, invokeRenderSync, render, render, renderUninterruptibly, repaint, run, toSelection, uninstallListeners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
antialiasing
protected boolean antialiasing
IDENTITY
protected static final java.awt.geom.AffineTransform IDENTITY
sceneBuffer
protected ImageAndGraphics sceneBuffer
CanvasAdapter
public CanvasAdapter()
checkBuffers
protected void checkBuffers()
getComponent
public java.lang.Object getComponent()
- Specified by:
getComponent
in interface ComponentWrapper
getGraphics
public final java.awt.Graphics2D getGraphics()
getObserverForRenderer
protected java.awt.image.ImageObserver getObserverForRenderer()
- Description copied from class:
ViewComponentAdapter
- 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.
- Specified by:
getObserverForRenderer
in class ViewComponentAdapter
- Returns:
- an observer receiving the image, or
null
if
this is not supported by this component
imageUpdate
public boolean imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
- Specified by:
imageUpdate
in interface java.awt.image.ImageObserver
initCanvas
public void initCanvas(java.awt.Component canvas)
initPaint
protected abstract void initPaint(int flags,
int width,
int height)
initRender
protected void initRender(int flags)
- Description copied from class:
ViewComponentAdapter
- Performs initialization tasks in preparation for rendering.
This method is invoked by
ViewComponentAdapter.run()
in this
ViewComponent
's own thread.
- Specified by:
initRender
in class ViewComponentAdapter
- 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
- Overrides:
initView
in class ViewComponentAdapter
- Parameters:
view
- the containing viewlistener
- mouse and key events will be reported to this listener
invokeRender
protected void invokeRender(int flags)
- Description copied from class:
ViewComponentAdapter
- Invoked to perform rendering. This method is invoked
by
ViewComponentAdapter.run()
in this ViewComponent
's own thread.
Its sole task is to invoke ViewComponentAdapter.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 ViewComponentAdapter.invokeRenderSync(int)
has completed.
- Specified by:
invokeRender
in class ViewComponentAdapter
- Parameters:
flags
- the flags to pass to ViewComponentAdapter.invokeRenderSync(int)
makeSnapshot
public void makeSnapshot(ObjectConsumer<? super java.awt.image.RenderedImage> callback)
- Description copied from interface:
ViewComponent
- Instructs the view component to create a snapshot. The created snapshot
has to be delivered to the provided
callback
as an
instance of RenderedImage
. This may happen asynchronously,
i.e., in an arbitrary thread.
- Specified by:
makeSnapshot
in interface ViewComponent
- Parameters:
callback
- callback which asynchronously receives the snapshot
optionValueChanged
protected void optionValueChanged(java.lang.String name,
java.lang.Object object)
- Overrides:
optionValueChanged
in class ViewComponentAdapter
paintHighlight
protected abstract void paintHighlight(int flags,
java.awt.Graphics2D g)
paintScene
protected abstract void paintScene(int flags,
java.awt.Graphics2D g)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
render
protected void render(int flags)
throws java.lang.InterruptedException
- Description copied from class:
ViewComponentAdapter
- Performs rendering. This method is invoked by
ViewComponentAdapter.invokeRenderSync(int)
in a context where
Workbench.current()
returns the workbench of this
view.
- Specified by:
render
in class ViewComponentAdapter
- Parameters:
flags
- combination of bit masks
- Throws:
java.lang.InterruptedException
- if the rendering has been interrupted
resetGraphicsTransform
public void resetGraphicsTransform()
setColor
public abstract void setColor(java.awt.Color color)
setColor
public void setColor(java.awt.Color color,
int state,
boolean showSel)
setColor
public void setColor(int color)
setColor
public void setColor(int color,
int state,
boolean showSel)
setColor
public void setColor(Tuple3f color)
setColor
public void setColor(Tuple3f color,
int state,
boolean showSel)
writeEPS
public static void writeEPS(Item item,
java.lang.Object info,
Context ctx)