You may attach an instance of this adapter to an AWT Component. When an event happens,
it is converted to a NEWT event and the given NEWT listener is being called.
This adapter fullfills three use cases. First as a plain utility to write code AWT agnostic,
ie write an com. and some appropriate NEWT com..
Attach the com. to a NEWT com., e.g. com.,
or to an AWT com., e.g. com..
Attach the NEWT com. to a NEWT component, e.g. com.,
or to an AWT component, e.g. java..
Common:
// your demo/render code
com.jogamp.opengl.GLEvenListener demo1 = new com.jogamp.opengl.GLEvenListener() { ... } ;
// your AWT agnostic NEWT mouse listener code
com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Default NEWT use case, without using the AWTAdapter:
// the NEWT GLAutoDrawable and Window GLWindow glWindow = GLWindow.create(); // attach the renderer demo1 glWindow.addGLEventListener(demo1); // attach the NEWT mouse event listener to glWindow glWindow.addMouseListener(mouseListener);
AWT use case, AWTAdapter used as an AWT event translator and forwarder to your NEWT listener:
// the AWT GLAutoDrawable and Canvas GLCanvas glCanvas = new GLCanvas(); // attach the renderer demo1 glCanvas.addGLEventListener(demo1); // attach the AWTMouseAdapter to glCanvas, which translates and forwards events to the NEWT mouseListener new AWTMouseAdapter(mouseListener).addTo(glCanvas);
Previous code in detail:
AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener); glCanvas.addMouseListener(mouseAdapter); glCanvas.addMouseMotionListener(mouseAdapter);
Second use case is just a litte variation of the previous use case, where we pass a NEWT Window
to be used as the source of the event.
com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component
new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);
Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.
com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component
glWindow.addMouseListener(mouseListener); // add the custom EventListener to the NEWT component
new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
attachTo
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | AWTAdapter.
Return value for |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| public static final boolean | |
| protected boolean | |
| pack-priv NEWTEventListener | |
| pack-priv Window | |
| pack-priv NativeSurfaceHolder |
| Access | Constructor and Description |
|---|---|
| protected | AWTAdapter(final NEWTEventListener newtListener, final NativeSurfaceHolder nsProxy)
Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given |
| protected | AWTAdapter(final NEWTEventListener newtListener, final Window newtProxy)
Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given |
| protected | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract AWTAdapter | addTo(Component awtComponent)
Due to the fact that some NEWT |
| public synchronized AWTAdapter | |
| public final synchronized NativeSurfaceHolder | getNativeSurfaceHolder()
Returns the |
| public final synchronized NEWTEventListener | getNewtEventListener()
Returns the |
| public final synchronized Window | |
| pack-priv AWTAdapter. | Returns: One of theEventProcRes values, see above.In case the event will be wait, final NEWTEvent ENQUEUED,
passing true will block until the event has been processed, otherwise method returns immediately.The event)event to enqueue.Process the event. |
| public abstract AWTAdapter | |
| public final synchronized void | |
| public synchronized AWTAdapter |
| consumeAWTEvent | back to summary |
|---|---|
| pack-priv boolean consumeAWTEvent | |
| DEBUG_IMPLEMENTATION | back to summary |
|---|---|
| public static final boolean DEBUG_IMPLEMENTATION | |
| isSetup | back to summary |
|---|---|
| protected boolean isSetup | |
| newtListener | back to summary |
|---|---|
| pack-priv NEWTEventListener newtListener | |
| newtWindow | back to summary |
|---|---|
| pack-priv Window newtWindow | |
| nsHolder | back to summary |
|---|---|
| pack-priv NativeSurfaceHolder nsHolder | |
| AWTAdapter | back to summary |
|---|---|
| protected AWTAdapter(final NEWTEventListener newtListener, final NativeSurfaceHolder nsProxy) Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener, | |
| AWTAdapter | back to summary |
|---|---|
| protected AWTAdapter(final NEWTEventListener newtListener, final Window newtProxy) Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener, | |
| AWTAdapter | back to summary |
|---|---|
| protected AWTAdapter(final Window downstream) throws IllegalStateException Create a pipeline adapter, AWT EventListener.
| |
| AWTAdapter | back to summary |
|---|---|
| public AWTAdapter() | |
| addTo | back to summary |
|---|---|
| public abstract AWTAdapter addTo(Component awtComponent) Due to the fact that some NEWT | |
| clear | back to summary |
|---|---|
| public synchronized AWTAdapter clear() Removes all references, downstream and NEWT-EventListener.
Also sets the internal | |
| getNativeSurfaceHolder | back to summary |
|---|---|
| public final synchronized NativeSurfaceHolder getNativeSurfaceHolder() Returns the Returned value is never null. | |
| getNewtEventListener | back to summary |
|---|---|
| public final synchronized NEWTEventListener getNewtEventListener() Returns the | |
| getNewtWindow | back to summary |
|---|---|
| public final synchronized Window getNewtWindow() Returns the
Returned value maybe null if instance is used to be a
| |
| processEvent | back to summary |
|---|---|
| pack-priv AWTAdapter. Process the event.
If
If
If none of the above matches,
| |
| removeFrom | back to summary |
|---|---|
public abstract AWTAdapter removeFrom(Component awtComponent)
| |
| setConsumeAWTEvent | back to summary |
|---|---|
| public final synchronized void setConsumeAWTEvent(final boolean v) | |
| setDownstream | back to summary |
|---|---|
| public synchronized AWTAdapter setDownstream(final Window downstream) throws IllegalStateException Setup a pipeline adapter, AWT EventListener.
| |
event processing.
| Modifier and Type | Field and Description |
|---|---|
| public static final AWTAdapter. | DISPATCH
Event shall be dispatched appropriately |
| public static final AWTAdapter. | ENQUEUED
Event has been enqueued |
| public static final AWTAdapter. | NOP
No known processing method applies |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static AWTAdapter. | |
| public static AWTAdapter. |
| DISPATCH | back to summary |
|---|---|
| public static final AWTAdapter. Event shall be dispatched appropriately | |
| ENQUEUED | back to summary |
|---|---|
| public static final AWTAdapter. Event has been enqueued | |
| NOP | back to summary |
|---|---|
| public static final AWTAdapter. No known processing method applies | |
| EventProcRes | back to summary |
|---|---|
| private EventProcRes() | |
| valueOf | back to summary |
|---|---|
| public static AWTAdapter. | |
| values | back to summary |
|---|---|
| public static AWTAdapter. | |