Package net.sourceforge.jiu.gui.awt
Class ImageCanvas
java.lang.Object
java.awt.Component
java.awt.Canvas
net.sourceforge.jiu.gui.awt.ImageCanvas
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
An AWT canvas that displays an
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).- Author:
- Marco Schmidt
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvas
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private Image
private ScrollPane
private int
private int
private int
private double
private double
private boolean
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
double
double
int
int
void
Draws image to upper left corner.void
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
Sets both zoom factors to1.0
.void
setZoomFactor
(double newZoomFactor) void
setZoomFactors
(double newZoomFactorX, double newZoomFactorY) void
setZoomToFit
(boolean newValue) void
Simply callspaint(Graphics)
with the argument.Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
Methods inherited from class java.awt.Component
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
-
Field Details
-
image
-
width
private int width -
height
private int height -
scaledWidth
private int scaledWidth -
scaledHeight
private int scaledHeight -
zoomFactorX
private double zoomFactorX -
zoomFactorY
private double zoomFactorY -
zoomToFit
private boolean zoomToFit -
myScrollPane
-
-
Constructor Details
-
ImageCanvas
-
-
Method Details
-
computeZoomToFitSize
public void computeZoomToFitSize() -
getZoomPercentageX
public int getZoomPercentageX() -
getZoomPercentageY
public int getZoomPercentageY() -
getPreferredSize
- Overrides:
getPreferredSize
in classComponent
-
paint
Draws image to upper left corner. -
setImage
Specifies a new Image object to be displayed in this canvas.- Parameters:
newImage
- the new Image object, potentially null
-
setOriginalSize
public void setOriginalSize()Sets both zoom factors to1.0
. -
getZoomFactorX
public double getZoomFactorX() -
getZoomFactorY
public double getZoomFactorY() -
setInterpolation
public 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. -
setZoomFactor
public void setZoomFactor(double newZoomFactor) -
setZoomFactors
public void setZoomFactors(double newZoomFactorX, double newZoomFactorY) -
setZoomToFit
public void setZoomToFit(boolean newValue) -
update
Simply callspaint(Graphics)
with the argument.
-