public class WebcamPanel extends javax.swing.JPanel implements WebcamListener, java.beans.PropertyChangeListener
Modifier and Type | Class and Description |
---|---|
class |
WebcamPanel.DefaultPainter
Default painter used to draw image in panel.
|
static class |
WebcamPanel.DrawMode
This enum is to control of how image will be drawn in the panel bounds.
|
static interface |
WebcamPanel.ImageSupplier
This interface can be used to supply
BufferedImage to WebcamPanel . |
static interface |
WebcamPanel.Painter
Interface of the painter used to draw image in panel.
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> |
DEFAULT_IMAGE_RENDERING_HINTS |
static double |
MIN_FREQUENCY
Minimum FPS frequency.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
WebcamPanel(Webcam webcam)
Creates webcam panel and automatically start webcam.
|
WebcamPanel(Webcam webcam,
boolean start)
Creates new webcam panel which display image from camera in you your Swing application.
|
WebcamPanel(Webcam webcam,
java.awt.Dimension size,
boolean start)
Creates new webcam panel which display image from camera in you your Swing application.
|
WebcamPanel(Webcam webcam,
java.awt.Dimension size,
boolean start,
WebcamPanel.ImageSupplier supplier) |
Modifier and Type | Method and Description |
---|---|
WebcamPanel.Painter |
getDefaultPainter()
Get default painter used to draw panel.
|
WebcamPanel.DrawMode |
getDrawMode()
This method returns the current draw mode, mainly used by custom painters
|
double |
getFPSLimit()
Get rendering frequency in FPS (equivalent to Hz).
|
java.awt.image.BufferedImage |
getImage() |
java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> |
getImageRenderingHints()
Deprecated.
use
getDrawMode() instead. |
WebcamPanel.Painter |
getPainter()
Get painter used to draw image in webcam panel.
|
Webcam |
getWebcam()
Return
Webcam used by this panel. |
boolean |
isAntialiasingEnabled() |
boolean |
isDisplayDebugInfo()
Is displaying of some debug information enabled.
|
boolean |
isErrored()
Indicates whether the panel is in an error state
|
boolean |
isFillArea()
Deprecated.
use
getDrawMode() instead. |
boolean |
isFitArea()
Deprecated.
|
boolean |
isFPSDisplayed()
This method return true in case if camera FPS is set to be displayed on panel surface.
|
boolean |
isFPSLimited()
Is frequency limit enabled?
|
boolean |
isImageSizeDisplayed()
This method will return true in case when panel is configured to display image size.
|
boolean |
isMirrored()
This method returns true if image mirroring is enabled.
|
boolean |
isStarted()
Is webcam panel repainting started.
|
boolean |
isStarting()
Is webcam panel repainting starting.
|
protected void |
paintComponent(java.awt.Graphics g) |
void |
pause()
Pause rendering.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
resume()
Resume rendering.
|
void |
setAntialiasingEnabled(boolean antialiasing)
Turn on/off antialiasing.
|
void |
setDisplayDebugInfo(boolean displayDebugInfo)
Display some debug information on image surface.
|
void |
setDrawMode(WebcamPanel.DrawMode drawMode)
This method sets the drawmode
|
void |
setFillArea(boolean fillArea)
Deprecated.
use
setDrawMode(DrawMode drawMode) instead. |
void |
setFitArea(boolean fitArea)
Deprecated.
use
setDrawMode(DrawMode drawMode) instead. |
void |
setFPSDisplayed(boolean displayed)
This method is to control if camera FPS should be displayed on the webcam panel surface.
|
void |
setFPSLimit(double fps)
Set rendering frequency (in Hz or FPS).
|
void |
setFPSLimited(boolean frequencyLimit)
Enable or disable frequency limit.
|
void |
setImageSizeDisplayed(boolean imageSizeDisplayed)
Configure panel to display camera image size to be displayed.
|
void |
setMirrored(boolean mirrored)
Decide whether or not the image from webcam painted on panel surface will be mirrored.
|
void |
setPainter(WebcamPanel.Painter painter)
Set new painter.
|
void |
start()
Open webcam and start rendering.
|
void |
stop()
Stop rendering and close webcam.
|
void |
webcamClosed(WebcamEvent we)
Webcam has been closed
|
void |
webcamDisposed(WebcamEvent we)
Webcam has been disposed
|
void |
webcamImageObtained(WebcamEvent we)
Webcam image has been obtained.
|
void |
webcamOpen(WebcamEvent we)
Webcam has been open.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, 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
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
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, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final double MIN_FREQUENCY
public static final java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> DEFAULT_IMAGE_RENDERING_HINTS
public WebcamPanel(Webcam webcam)
webcam
- the webcam to be used to fetch imagespublic WebcamPanel(Webcam webcam, boolean start)
webcam
- the webcam to be used to fetch imagesstart
- true if webcam shall be automatically startedpublic WebcamPanel(Webcam webcam, java.awt.Dimension size, boolean start)
setFillArea(boolean)
method to configure this.webcam
- the webcam to be used to fetch imagessize
- the size of panelstart
- true if webcam shall be automatically startedsetFillArea(boolean)
public WebcamPanel(Webcam webcam, java.awt.Dimension size, boolean start, WebcamPanel.ImageSupplier supplier)
public void setPainter(WebcamPanel.Painter painter)
painter
- the painter object to be setpublic WebcamPanel.Painter getPainter()
protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void start()
public void stop()
public void pause()
public void resume()
public boolean isFPSLimited()
public void setFPSLimited(boolean frequencyLimit)
frequencyLimit
- true if limiting the frequency of image requestspublic double getFPSLimit()
public void setFPSLimit(double fps)
fps
- the frequencypublic boolean isDisplayDebugInfo()
public void setDisplayDebugInfo(boolean displayDebugInfo)
displayDebugInfo
- the value to control debug informationpublic boolean isFPSDisplayed()
setFPSDisplayed(boolean)
public void setFPSDisplayed(boolean displayed)
displayed
- the value to control if camera FPS should be displayedpublic boolean isImageSizeDisplayed()
public void setImageSizeDisplayed(boolean imageSizeDisplayed)
imageSizeDisplayed
- if true the pixel dimensions are displayed over the image.public void setAntialiasingEnabled(boolean antialiasing)
antialiasing
- the true to enable, false to disable antialiasingpublic boolean isAntialiasingEnabled()
public boolean isStarting()
public boolean isStarted()
public WebcamPanel.DrawMode getDrawMode()
WebcamPanel.DrawMode
public void setDrawMode(WebcamPanel.DrawMode drawMode)
drawMode
- the desired WebcamPanel.DrawMode
public boolean isErrored()
@Deprecated public java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getImageRenderingHints()
getDrawMode()
instead.@Deprecated public boolean isFitArea()
@Deprecated public void setFitArea(boolean fitArea)
setDrawMode(DrawMode drawMode)
instead.WebcamPanel.DrawMode.NONE
so image will be drawn as it is.fitArea
- the fit area mode enabled or disabled@Deprecated public void setFillArea(boolean fillArea)
setDrawMode(DrawMode drawMode)
instead.fillArea
- shall image be resided to fill panel area@Deprecated public boolean isFillArea()
getDrawMode()
instead.public WebcamPanel.Painter getDefaultPainter()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public void webcamOpen(WebcamEvent we)
WebcamListener
webcamOpen
in interface WebcamListener
we
- a webcam eventpublic void webcamClosed(WebcamEvent we)
WebcamListener
webcamClosed
in interface WebcamListener
we
- a webcam eventpublic void webcamDisposed(WebcamEvent we)
WebcamListener
webcamDisposed
in interface WebcamListener
we
- a webcam eventpublic void webcamImageObtained(WebcamEvent we)
WebcamListener
webcamImageObtained
in interface WebcamListener
we
- a webcam eventpublic boolean isMirrored()
public void setMirrored(boolean mirrored)
mirrored
- the parameter to control if image should be mirroredpublic java.awt.image.BufferedImage getImage()
BufferedImage
displayed on WebcamPanel
Copyright © 2012-2018 Bartosz Firyn (SarXos). All Rights Reserved.