safehome
Class CameraView
java.lang.Object
java.awt.Component
safehome.CameraView
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Runnable
public class CameraView
- extends Component
- implements Runnable
CameraView
class is a simple java component
which has BufferedImage
from DeviceCamera
.
This java component can be attached to any JFrame
.
This class creates a DeviceCamera
instance.
The camera instance reads camera image from the file
camera.jpg and provides the image as an BufferedImage
instance.
- Author:
- cs550TA
- See Also:
- Serialized Form
Constructor Summary |
CameraView()
Constructs camera view component. |
Method Summary |
void |
paint(Graphics g)
Paints this component. |
void |
run()
When an object implementing interface Runnable is used to create a thread,
starting the thread causes the object's run method to be called in that separately executing thread. |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
camera
DeviceCamera camera
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
CameraView
public CameraView()
- Constructs camera view component. Constructor set the id of the camera instance and
start a thread to repaint the updated camera image periodically.
DeviceCamera
reads an image from the file camera.jpg in the current working director.
If the file cannot be opened, DeviceCamera
shows an error message.
Pre-condition: The main instantiates MainDemo class and MainDemo instantiates CameraTest class
and CameraTest instantiates this class in consecutively
Post-condition: jpg image file is loaded to memory and the camera instance is ready to draw.
Thread is running to update camera view periodically.
paint
public void paint(Graphics g)
- Paints this component. This method gets new image from camera device and re-draw image to the component.
Pre-condition: JPG image file is loaded to camera device's memory and ready to draw
Post-condition: A user can see the image from the camera component.
- Overrides:
paint
in class Component
- Parameters:
g
- the graphics context to use for painting- See Also:
Component.paint(java.awt.Graphics)
run
public void run()
- When an object implementing interface
Runnable
is used to create a thread,
starting the thread causes the object's run method to be called in that separately executing thread.
This thread updates view of the camera in periodic interval 100ms.
Pre-condition: JPG image file is loaded to camera device's memory and ready to draw.
Post-condition: A user can see the updated image from the camera
- Specified by:
run
in interface Runnable
- See Also:
Runnable.run()