public class ImagePane extends JComponent
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static String |
ELLIPSE_SELECTION
Constant for ellipse shaped selections.
|
static String |
LASSO_SELECTION
Constant for lasso type selections.
|
static String |
RECTANGLE_SELECTION
Constant for rectangle shaped selections.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
ImagePane(BufferedImage image)
Constructs a new image pane for displaying the given image.
|
Modifier and Type | Method and Description |
---|---|
void |
clearSelection()
Remove any selection.
|
Icon |
getBackgroundTile()
Returns the icon used background image tile,
null for none. |
int |
getImageHeight()
Returns the vertical size of the unscaled image to be shown..
|
int |
getImageWidth()
Returns the horizontal size of the unscaled image to be shown..
|
int |
getInnerXMargin()
Returns horizontal image offset from centering if image is snmaller
than component, zero otherwise.
|
int |
getInnerYMargin()
Returns vertical image offset from centering if image is snmaller
than component, zero otherwise.
|
Area |
getSelectionArea()
Returns the area of selection or
null for no current selection. |
double |
getZoomScale()
Returns given zoom as a scaling factor.
|
boolean |
hasUnsavedChanges()
Returns wether changes to image were made after last save.
|
void |
paintComponent(Graphics graphics)
Draws the component.
|
void |
resetPane()
Reset image to original copy, clearing any selection.
|
boolean |
selectTo(int x,
int y)
Selects to given point coordinates.
|
void |
setBackgroundTile(Icon tileIcon)
Sets an icon as background image tile,
null for none. |
protected void |
setLeftIcon(Icon leftIcon)
Sets icon be drawn left to image, if horizontal inner offset allows
it to be placed completely within this component.
|
protected void |
setTopIcon(Icon topIcon)
Sets icon be drawn above image, if vertical inner offset allows
it to be placed completely within this component.
|
void |
setZoom(int factor,
boolean zoomIn)
Sets the display zoom to the given factor, adjusting
this components size as a side effect.
|
void |
startSelection(int x,
int y,
String selectionMode)
Start selection mode with first point at given coordinates.
|
void |
storeCurrentImage(File outputFile)
Stores current image as PNG to given file.
|
int |
unzoomX(int x)
Converts a zoomed horizontal position back to image space.
|
int |
unzoomY(int y)
Converts a zoomed vertical position back to image space.
|
void |
updateImage(int[] imgData,
float[] cm)
Sets image to given values.
|
int |
zoomX(int x)
Applies the current zoom to a horizontal image space position.
|
int |
zoomY(int y)
Applies the current zoom to a vertical image space position.
|
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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
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, getAccessibleContext, 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 String RECTANGLE_SELECTION
public static final String ELLIPSE_SELECTION
public static final String LASSO_SELECTION
public ImagePane(BufferedImage image)
public int getInnerXMargin()
public int getInnerYMargin()
protected void setTopIcon(Icon topIcon)
protected void setLeftIcon(Icon leftIcon)
public void paintComponent(Graphics graphics)
paintComponent
in class JComponent
public boolean selectTo(int x, int y)
If current selection is a rectangle or an ellipse, the point defines the new corner opposite to the starting point. For lasso selection the point is added to the enclosing path. No effect if there is there is no current selection.
public void startSelection(int x, int y, String selectionMode)
x
- horizontal start coordinate for selection.y
- vertical start coordinate for selection.selectionMode
- type of selection started, one of
RECTANGLE_SELECTION
, ELLIPSE_SELECTION
,
and LASSO_SELECTION
.IllegalArgumentException
- if the selectionMode is none on the
predefined selection modes.RECTANGLE_SELECTION
,
ELLIPSE_SELECTION
,
LASSO_SELECTION
public void clearSelection()
public Area getSelectionArea()
null
for no current selection.public void setBackgroundTile(Icon tileIcon)
null
for none.public void setZoom(int factor, boolean zoomIn)
factor
- the strictly positive zoom factor.zoomIn
- determies if the image should be shown zoomed in
(magnified) or zoomed out (scaled down).public Icon getBackgroundTile()
null
for none.public double getZoomScale()
public int getImageWidth()
public int getImageHeight()
public int zoomX(int x)
public int zoomY(int y)
public int unzoomX(int x)
public int unzoomY(int y)
public void resetPane()
public boolean hasUnsavedChanges()
public void updateImage(int[] imgData, float[] cm)
imgData
- RGB values for new image.cm
- Alpha-channel of new image given as confidence matrix.public void storeCurrentImage(File outputFile) throws IOException
IOException
Copyright © 2015–2021 Fiji. All rights reserved.