ch.dieseite.glemulator

## Class GLAdapter

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - ch.dieseite.glemulator.PEmulator
          - - ch.dieseite.glemulator.GLAdapter

- All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

      public class GLAdapter
      extends PEmulator

  This class is an OpenGL Adapter in case the OpenGL mode (P2D/P3D) doesn't work in Processing. It overrides Processing environment using direct access to JOGL libraries and emulates a new Processing like 3D API

  As a subclass of PEmulator it merges its callbacks and callbacks from PApplet into a proper runtime order.

  An usage example is the following:

  Sketch header

      GLAdapter adapter;

  settings() section

      size(sizeX, sizeY); //leave Processing in 2D

  setup() section

      adapter = new GLAdapter(sizeX, sizeY);

  draw() section

       adapter.line(srcX, srcY, srcZ, dstX, dstX, dstZ); //an example

       //repaint() IS A VERY IMPORTANT INVOKE AT
       //THE END OF DRAW SECTION
       //OTHERWISE YOU RISK QUEUE OVERFLOW
       adapter.repaint();  //flush jobs

  This source underlies the GNU General Public License; You can redistribute it or modify by nameing the originally author

  Version:
    3.1
  Author:
    Markus Zimmermann http://www.die-seite.ch
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.JPanel

      `javax.swing.JPanel.AccessibleJPanel`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `javax.swing.JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `drawing`
    `private java.util.concurrent.BlockingQueue<java.lang.Runnable>` | `jobqueue`
    `static int` | `TRIANGLE`

    - ### Fields inherited from class javax.swing.JComponent

      `listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

    - ### Fields inherited from class java.awt.Component

      `accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GLAdapter(int width, int height)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `background(float c)` see Processing API
    `void` | `beginShape(int mode)` see Processing API
    `int` | `color(int r, int g, int b, int a)` see Processing API
    `void` | `endShape()` see Processing API
    `(package private) void` | `execQueue()` callback, invoked by superclass on GLEventListener.display() event
    `void` | `fill(float c)` see Processing API
    `void` | `fill(float r, float g, float b, float t)` see Processing API
    `void` | `lights()` see Processing API
    `void` | `line(float xa, float ya, float za, float xb, float yb, float zb)` see Processing API
    `private void` | `putQueue(java.lang.Runnable r)` caches all processing draw commands until repaint is invoked
    `void` | `repaint()` must be the last invoke inside the draw() block from PApplet sketch
    `void` | `rotateX(float angle)` see Processing API
    `void` | `rotateY(float angle)` see Processing API
    `void` | `rotateZ(float angle)` see Processing API
    `void` | `scale(float v)` see Processing API
    `void` | `stroke(float r, float g, float b)` see Processing API
    `void` | `strokeWeight(float w)` see Processing API
    `void` | `texture(PImage img)` see Processing API
    `void` | `translate(float x, float y, float z)` see Processing API
    `void` | `vertex(float x, float y, float z)` see Processing API
    `void` | `vertex(float x, float y, float z, float tx, float ty)` see Processing API

    - ### Methods inherited from class ch.dieseite.glemulator.PEmulator

      `_background, _beginShape, _color, _endShape, _fill, _fill, _lights, _line, _rotateX, _rotateY, _rotateZ, _scale, _stroke, _strokeWeight, _texture, _translate, _vertex, _vertex, display, dispose, GLConfig, init, reshape`

    - ### Methods inherited from class javax.swing.JPanel

      `getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

    - ### Methods inherited from class javax.swing.JComponent

      `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

    - ### Methods inherited from class java.awt.Container

      `add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TRIANGLE

          public static final int TRIANGLE

    - #### jobqueue

          private java.util.concurrent.BlockingQueue<java.lang.Runnable> jobqueue

    - #### drawing

          private boolean drawing

  - ### Constructor Detail

    - #### GLAdapter

          public GLAdapter(int width,
                           int height)

  - ### Method Detail

    - #### execQueue

          void execQueue()

      callback, invoked by superclass on GLEventListener.display() event
      Specified by:
        `execQueue` in class `PEmulator`

    - #### putQueue

          private void putQueue(java.lang.Runnable r)

      caches all processing draw commands until repaint is invoked
      Parameters:
        `r` -

    - #### repaint

          public void repaint()

      must be the last invoke inside the draw() block from PApplet sketch
      Overrides:
        `repaint` in class `PEmulator`

    - #### lights

          public void lights()

      see Processing API

    - #### strokeWeight

          public void strokeWeight(float w)

      see Processing API

    - #### stroke

          public void stroke(float r,
                             float g,
                             float b)

      see Processing API

    - #### line

          public void line(float xa,
                           float ya,
                           float za,
                           float xb,
                           float yb,
                           float zb)

      see Processing API

    - #### translate

          public void translate(float x,
                                float y,
                                float z)

      see Processing API

    - #### rotateY

          public void rotateY(float angle)

      see Processing API

    - #### rotateX

          public void rotateX(float angle)

      see Processing API

    - #### rotateZ

          public void rotateZ(float angle)

      see Processing API

    - #### scale

          public void scale(float v)

      see Processing API

    - #### beginShape

          public void beginShape(int mode)

      see Processing API

    - #### endShape

          public void endShape()

      see Processing API

    - #### fill

          public void fill(float r,
                           float g,
                           float b,
                           float t)

      see Processing API

    - #### fill

          public void fill(float c)

      see Processing API

    - #### vertex

          public void vertex(float x,
                             float y,
                             float z)

      see Processing API

    - #### vertex

          public void vertex(float x,
                             float y,
                             float z,
                             float tx,
                             float ty)

      see Processing API

    - #### texture

          public void texture(PImage img)

      see Processing API

    - #### background

          public void background(float c)

      see Processing API

    - #### color

          public int color(int r,
                           int g,
                           int b,
                           int a)

      see Processing API