public class ImagePanel
extends javax.swing.JPanel
Modifier and Type | Class and Description |
---|---|
static class |
ImagePanel.LineInfo
Information about a drawn line in the image.
|
static interface |
ImagePanel.LineListener
Listener which gets informed about a currently drawn line in the image.
|
static class |
ImagePanel.PixelInfo
Information about a pixel in the image.
|
static interface |
ImagePanel.PixelListener
Listener which gets informed about the currently hovered pixel in the image.
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
DEFAULT_BACKGROUND
Default background color of the image panel.
|
static java.awt.Color |
DEFAULT_DRAW_LINE_COLOR
Default color of lines in image to measure distances.
|
static java.awt.Color |
DEFAULT_FOREGROUND
Default foreground (text) color of the image panel.
|
protected YouScopeFrame |
frame |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ImagePanel(YouScopeClient client)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addControl(java.lang.String title,
java.awt.Component component)
Adds a component with the given title to the end of the menu containing all controls.
|
void |
addControl(java.lang.String title,
java.awt.Component component,
boolean resizable)
Adds a component with the given title to the end of the menu containing all controls.
|
void |
addLineListener(ImagePanel.LineListener listener)
Adds a listener which gets informed over lines drawn in the image.
|
void |
addPixelListener(ImagePanel.PixelListener listener)
Adds a listener which gets informed over which pixels the user hovers with the mouse.
|
void |
clearControls()
Removes all added controls.
|
YouScopeFrameListener |
getFrameListener()
Returns a frame listener which can be added to the frame to which this panel is added, taking care of all default behavior.
|
int |
getNumControls()
Returns the number of controls in the menu containing all controls.
|
void |
insertControl(java.lang.String title,
java.awt.Component component,
int index)
Adds a component with the given title to the menu containing all controls at the given index.
|
void |
insertControl(java.lang.String title,
java.awt.Component component,
int index,
boolean resizable)
Adds a component with the given title to the menu containing all controls at the given index.
|
boolean |
isAutoAdjustContrast()
Returns if the contrast should be automatically adjusted whenever a new image is set.
|
void |
paintComponent(java.awt.Graphics grp) |
void |
removeControl(java.awt.Component component)
Removes a previously added control.
|
void |
removeControl(int index)
Removes the control at the given index.
|
void |
removeLineListener(ImagePanel.LineListener listener)
Removes a previously added line listener.
|
void |
removePixelListener(ImagePanel.PixelListener listener)
Removes a previously added pixel listener.
|
void |
setAutoAdjustContrast(boolean autoAdjustContrast)
Sets if the contrast should be automatically adjusted whenever a new image is set.
|
void |
setImage(java.awt.image.BufferedImage bufferedImage)
Sets the image which should be displayed.
|
void |
setImage(ImageEvent<?> imageEvent)
Sets the image which should be displayed.
|
void |
setNoImageText(java.lang.String noImageText)
Sets the text which should be displayed if no image is available, yet.
|
void |
setTitle(java.lang.String title)
Sets the title of the frame, which is opened by
toFrame() . |
void |
setUserChoosesAutoAdjustContrast(boolean userChoosesAutoAdjustContrast)
Set to true to display a checkbox with which the user can choose on him/herself if the contrast should be automatically adjusted when a new
image arrives.
|
YouScopeFrame |
toFrame()
Convenient method to show this panel in a frame.
|
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 java.awt.Color DEFAULT_BACKGROUND
public static final java.awt.Color DEFAULT_FOREGROUND
public static final java.awt.Color DEFAULT_DRAW_LINE_COLOR
protected YouScopeFrame frame
public ImagePanel(YouScopeClient client)
client
- YouScope client.public void addPixelListener(ImagePanel.PixelListener listener)
listener
- Pixel listener to add.public void removePixelListener(ImagePanel.PixelListener listener)
listener
- Pixel listener to remove.public void addLineListener(ImagePanel.LineListener listener)
listener
- Line listener to add.public void removeLineListener(ImagePanel.LineListener listener)
listener
- Line listener to remove.public void setAutoAdjustContrast(boolean autoAdjustContrast)
autoAdjustContrast
- True if automatic adjustment should be activated.public boolean isAutoAdjustContrast()
public void setUserChoosesAutoAdjustContrast(boolean userChoosesAutoAdjustContrast)
userChoosesAutoAdjustContrast
- True to display checkbox.public void addControl(java.lang.String title, java.awt.Component component)
title
- Title of the control.component
- The control element.public void addControl(java.lang.String title, java.awt.Component component, boolean resizable)
title
- Title of the control.component
- The control element.resizable
- True if the control can take up excess vertical space.public void insertControl(java.lang.String title, java.awt.Component component, int index) throws java.lang.IndexOutOfBoundsException
title
- Title of the control.component
- The control element.index
- index where to add control. Must be greater or equal to 0, and smaller or equal to getNumControls()
.java.lang.IndexOutOfBoundsException
- Thrown if index is invalid.public void insertControl(java.lang.String title, java.awt.Component component, int index, boolean resizable) throws java.lang.IndexOutOfBoundsException
title
- Title of the control.component
- The control element.index
- index where to add control. Must be greater or equal to 0, and smaller or equal to getNumControls()
.resizable
- True if the control can take up excess vertical space.java.lang.IndexOutOfBoundsException
- Thrown if index is invalid.public int getNumControls()
public void removeControl(int index) throws java.lang.IndexOutOfBoundsException
index
- index of the control. Must be greater or equal to 0, and smaller than getNumControls()
.java.lang.IndexOutOfBoundsException
- Thrown if index is invalid.public void removeControl(java.awt.Component component)
component
- The control to remove.public void clearControls()
public void paintComponent(java.awt.Graphics grp)
paintComponent
in class javax.swing.JComponent
public YouScopeFrameListener getFrameListener()
toFrame()
is used.public void setNoImageText(java.lang.String noImageText)
noImageText
- Text to display if no images are available.public YouScopeFrame toFrame()
public void setImage(java.awt.image.BufferedImage bufferedImage)
bufferedImage
- Image which should be displayed.public void setImage(ImageEvent<?> imageEvent)
imageEvent
- Image which should be displayed.public void setTitle(java.lang.String title)
toFrame()
. Has no effect when using this panel directly.title
- Title of the frame.