ImageObserver
, MenuContainer
, Serializable
, Accessible
public class ImageCanvas extends Canvas
Image
object.
Capable to display at arbitrary zooming levels.
Does not use rendering hints because they require Java 1.2 or higher
(although bilinear and bicubic interpolation usually improve display quality
when zooming at the cost of slowing down image drawing).Canvas.AccessibleAWTCanvas
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field | Description |
---|---|---|
private int |
height |
|
private Image |
image |
|
private ScrollPane |
myScrollPane |
|
private int |
scaledHeight |
|
private int |
scaledWidth |
|
private int |
width |
|
private double |
zoomFactorX |
|
private double |
zoomFactorY |
|
private boolean |
zoomToFit |
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor | Description |
---|---|
ImageCanvas(ScrollPane scrollPane) |
Modifier and Type | Method | Description |
---|---|---|
void |
computeZoomToFitSize() |
|
Dimension |
getPreferredSize() |
|
double |
getZoomFactorX() |
|
double |
getZoomFactorY() |
|
int |
getZoomPercentageX() |
|
int |
getZoomPercentageY() |
|
void |
paint(Graphics g) |
Draws image to upper left corner.
|
void |
setImage(Image newImage) |
Specifies a new Image object to be displayed in this canvas.
|
void |
setInterpolation(int newType) |
Sets the interpolation type used for drawing to the argument
(must be one of the
INTERPOLATION_xyz constants of EditorState), but does not
do a redraw.
|
void |
setOriginalSize() |
Sets both zoom factors to
1.0 . |
void |
setZoomFactor(double newZoomFactor) |
|
void |
setZoomFactors(double newZoomFactorX,
double newZoomFactorY) |
|
void |
setZoomToFit(boolean newValue) |
|
void |
update(Graphics g) |
Simply calls
paint(Graphics) with the argument. |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
private Image image
private int width
private int height
private int scaledWidth
private int scaledHeight
private double zoomFactorX
private double zoomFactorY
private boolean zoomToFit
private ScrollPane myScrollPane
public ImageCanvas(ScrollPane scrollPane)
public void computeZoomToFitSize()
public int getZoomPercentageX()
public int getZoomPercentageY()
public Dimension getPreferredSize()
getPreferredSize
in class Component
public void paint(Graphics g)
public void setImage(Image newImage)
newImage
- the new Image object, potentially nullpublic void setOriginalSize()
1.0
.public double getZoomFactorX()
public double getZoomFactorY()
public void setInterpolation(int newType)
public void setZoomFactor(double newZoomFactor)
public void setZoomFactors(double newZoomFactorX, double newZoomFactorY)
public void setZoomToFit(boolean newValue)
public void update(Graphics g)
paint(Graphics)
with the argument.