org.selman.java3d.book.myjava3d
Class Surface

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.selman.java3d.book.myjava3d.Surface
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable
Direct Known Subclasses:
AnimatingSurface

public abstract class Surface
extends javax.swing.JPanel
implements java.awt.print.Printable

The Surface class implements a 2D rendering surface using a Swing JPanel. The Surface can contain an AlphaComposite and a background Texture as well as foreground rendered output.

The Surface can have anti-aliasing enabled and be optimized for speed or quality.

This class is based on that found in the Java 2D examples.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 org.selman.java3d.book.myjava3d.AnimatingSurface animating
           
 java.lang.Object AntiAlias
           
 java.awt.image.BufferedImage bimg
           
 boolean clearSurface
           
 java.awt.AlphaComposite composite
           
 int imageType
           
 java.lang.String name
           
 java.lang.String perfStr
           
 java.lang.Object Rendering
           
protected  long sleepAmount
           
 java.awt.Paint texture
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Surface()
           
 
Method Summary
 java.awt.image.BufferedImage createBufferedImage(int w, int h, int imgType)
           
 java.awt.Graphics2D createGraphics2D(int width, int height, java.awt.image.BufferedImage bi, java.awt.Graphics g)
           
 int getImageType()
           
 long getSleepAmount()
           
 void paint(java.awt.Graphics g)
           
 void paintImmediately(int x, int y, int w, int h)
          It's possible to turn off double-buffering for just the repaint calls invoked directly on the non double buffered component.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pi)
           
abstract  void render(int w, int h, java.awt.Graphics2D g2)
           
 void setAntiAlias(boolean aa)
           
 void setComposite(boolean cp)
           
 void setImageType(int imgType)
           
 void setRendering(boolean rd)
           
 void setSleepAmount(long amount)
           
 void setTexture(java.lang.Object obj)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AntiAlias

public java.lang.Object AntiAlias

Rendering

public java.lang.Object Rendering

composite

public java.awt.AlphaComposite composite

texture

public java.awt.Paint texture

perfStr

public java.lang.String perfStr

bimg

public java.awt.image.BufferedImage bimg

imageType

public int imageType

name

public java.lang.String name

clearSurface

public boolean clearSurface

animating

public org.selman.java3d.book.myjava3d.AnimatingSurface animating

sleepAmount

protected long sleepAmount
Constructor Detail

Surface

public Surface()
Method Detail

getImageType

public int getImageType()

setImageType

public void setImageType(int imgType)

setAntiAlias

public void setAntiAlias(boolean aa)

setRendering

public void setRendering(boolean rd)

setTexture

public void setTexture(java.lang.Object obj)

setComposite

public void setComposite(boolean cp)

setSleepAmount

public void setSleepAmount(long amount)

getSleepAmount

public long getSleepAmount()

createBufferedImage

public java.awt.image.BufferedImage createBufferedImage(int w,
                                                        int h,
                                                        int imgType)

createGraphics2D

public java.awt.Graphics2D createGraphics2D(int width,
                                            int height,
                                            java.awt.image.BufferedImage bi,
                                            java.awt.Graphics g)

render

public abstract void render(int w,
                            int h,
                            java.awt.Graphics2D g2)

paintImmediately

public void paintImmediately(int x,
                             int y,
                             int w,
                             int h)
It's possible to turn off double-buffering for just the repaint calls invoked directly on the non double buffered component. This can be done by overriding paintImmediately() (which is called as a result of repaint) and getting the current RepaintManager and turning off double buffering in the RepaintManager before calling super.paintImmediately(g).

Overrides:
paintImmediately in class javax.swing.JComponent

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pi)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
java.awt.print.PrinterException