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
public class ImageCanvas extends Canvas
An AWT canvas that displays anImageobject. 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:
- Serialized Form
-
-
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
Fields Modifier and Type Field Description private intheightprivate Imageimageprivate ScrollPanemyScrollPaneprivate intscaledHeightprivate intscaledWidthprivate intwidthprivate doublezoomFactorXprivate doublezoomFactorYprivate booleanzoomToFit-
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 Constructor Description ImageCanvas(ScrollPane scrollPane)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomputeZoomToFitSize()DimensiongetPreferredSize()doublegetZoomFactorX()doublegetZoomFactorY()intgetZoomPercentageX()intgetZoomPercentageY()voidpaint(Graphics g)Draws image to upper left corner.voidsetImage(Image newImage)Specifies a new Image object to be displayed in this canvas.voidsetInterpolation(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.voidsetOriginalSize()Sets both zoom factors to1.0.voidsetZoomFactor(double newZoomFactor)voidsetZoomFactors(double newZoomFactorX, double newZoomFactorY)voidsetZoomToFit(boolean newValue)voidupdate(Graphics g)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 Detail
-
image
private Image 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
private ScrollPane myScrollPane
-
-
Constructor Detail
-
ImageCanvas
public ImageCanvas(ScrollPane scrollPane)
-
-
Method Detail
-
computeZoomToFitSize
public void computeZoomToFitSize()
-
getZoomPercentageX
public int getZoomPercentageX()
-
getZoomPercentageY
public int getZoomPercentageY()
-
getPreferredSize
public Dimension getPreferredSize()
- Overrides:
getPreferredSizein classComponent
-
paint
public void paint(Graphics g)
Draws image to upper left corner.
-
setImage
public void setImage(Image newImage)
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
public void update(Graphics g)
Simply callspaint(Graphics)with the argument.
-
-