windows
Class WindowWithVideo

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byjavax.swing.JApplet
                      extended bywindows.WindowWithListeners
                          extended bywindows.WindowWithVideo
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.RootPaneContainer, java.io.Serializable, VideoListener, java.awt.event.WindowListener
Direct Known Subclasses:
PixelOperater

public class WindowWithVideo
extends WindowWithListeners
implements VideoListener

Author:
DanO This is a sample class that students can extend to create interesting web cams
See Also:
Serialized Form

Field Summary
 long elapsedTime
          This is handy for testing performance
 java.lang.String prefsFileName
           
 PixelSource ps
          This is reference to a PixelSource object from vxp.jar
 long startTime
           
 
Fields inherited from class java.awt.Component
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
WindowWithVideo(java.lang.String[] _args, int _w, int _h)
          This is the constructor
 
Method Summary
 void destroy()
          You always need to clean up
 void init()
          This is a method that you promised to have as a KeyListener.
 void initVideo()
          This cranks up the video by creating a pixelSource object.
 void keyPressed(java.awt.event.KeyEvent e)
           
static void main(java.lang.String[] args)
          The is the entry point for your program You will definitely want to override this and then get out of it as soon as possible
 void newFrame()
          This is the method that pixel source uses to tell you that a new frame is ready.
 void paint(java.awt.Graphics g)
          This gets called everytime you repaint the screen.
 void start()
          Separated this out from init video because you get a lot of null pointer exceptions when you start hearing back from the video before all your buffers are set up right You can't set up your buffers until you construct the video in case they need to be a little bigger than you expected as the case on the mac.
 void update(java.awt.Graphics g)
          This overrides the update method of JFrame which gets called on repaint.
 void useParameters(java.util.HashMap _paramNamesAndValues)
           
 
Methods inherited from class windows.WindowWithListeners
addParameterNames, applicationStuff, getParameters, getParameters, isApplication, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, put, setFullScreen, setTitle, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ps

public PixelSource ps
This is reference to a PixelSource object from vxp.jar


elapsedTime

public long elapsedTime
This is handy for testing performance


startTime

public long startTime

prefsFileName

public java.lang.String prefsFileName
Constructor Detail

WindowWithVideo

public WindowWithVideo(java.lang.String[] _args,
                       int _w,
                       int _h)
This is the constructor

Method Detail

initVideo

public void initVideo()
This cranks up the video by creating a pixelSource object. It also subscribes to the video listener, of course I would have to have previously promised to implement a VideoListener and then implement "newFrame" You might consider overriding this if you want a different kind of video object or don't want to subscribe to the notification service.


start

public void start()
Separated this out from init video because you get a lot of null pointer exceptions when you start hearing back from the video before all your buffers are set up right You can't set up your buffers until you construct the video in case they need to be a little bigger than you expected as the case on the mac.


main

public static void main(java.lang.String[] args)
The is the entry point for your program You will definitely want to override this and then get out of it as soon as possible


destroy

public void destroy()
You always need to clean up

Overrides:
destroy in class WindowWithListeners

newFrame

public void newFrame()
This is the method that pixel source uses to tell you that a new frame is ready. You have to have this if you want to implement a VideoListener

Specified by:
newFrame in interface VideoListener

update

public void update(java.awt.Graphics g)
This overrides the update method of JFrame which gets called on repaint. The reason I don't like JFrames is because it clears the screen (which I don't need) and creates flicker doing it. I redo the method with a paint but no clear


paint

public void paint(java.awt.Graphics g)
This gets called everytime you repaint the screen. You would want to override this if you want anything but side by side pictures


init

public void init()
This is a method that you promised to have as a KeyListener. For homework you might try to replace the last part with different input than a keystroke

Overrides:
init in class WindowWithListeners

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class WindowWithListeners

useParameters

public void useParameters(java.util.HashMap _paramNamesAndValues)
Overrides:
useParameters in class WindowWithListeners