java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.monte.media.swing.ImagePanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable
Displays images on a panel.
- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPixel aspect policy: Use Anamoprh 16:9 pixel aspect (=16/9*4/5=1.4222).static final intPixel aspect policy: Preserve the exact pixel aspect.static final intPixel aspect policy: Ignore pixel aspect.static final intPixel aspect policy: Preserves only extreme pixel aspects, where one dimension is a multiple of the other dimension.static final intImage scaling policy: Scale to panel but keep the image aspect.static final intImage scaling policy: Scale as defined by #setAspectRatio and the image aspect.static final intImage scaling policy: Scale to panel size.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener who is interested in changes of this object.doubleGets the horizontal scale factor that is used to scale images shown in this image panel.doubleGets the vertical scale factor that is used to scale images shown in this image panel.getImage()Gets the image that is displayed in this image panel.intReturns the image scale policy.intReturns the pixel aspect policy.doubleGets the horizontal pixel aspect of the image according to the pixel aspect policy that is in affect.doubleGets the vertical pixel aspect of the image according to the pixel aspect policy that is in effect.Gets the preferred image size.Gets the preferred size of this image panel.Gets the rendering hints.Gets the scaled and pixel aspect corrected image size.doubleGets the scale factor.Gets the backdrop paint.booleanimageUpdate(Image img, int flags, int x, int y, int w, int h) XXX Netscape gets very slow when painting all SOMEBITS of an image.voidvoidRemoves a previously registered listener.voidsetAspectRatio(double ratioX, double ratioY) Sets the aspect ratio.protected voidsetAspectRatio0(double ratioX, double ratioY) voidSets the image and displays it in this image panel.voidsetImageScalePolicy(int policy) Sets the image scale policy.voidsetMessage(String message) voidsetPixelAspectPolicy(int policy) Sets the pixel aspect policy.voidsetRenderingHints(RenderingHints newValue) Sets the rendering hints.voidsetScaleFactor(double scaleFactor) Sets the scale factor.voidsetTexture(BufferedImage newValue) Sets the texture for the backdrop paint.Methods inherited from class javax.swing.JComponent
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, 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, updateUIMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, validateTreeMethods inherited from class java.awt.Component
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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
IGNORE_PIXEL_ASPECT
public static final int IGNORE_PIXEL_ASPECTPixel aspect policy: Ignore pixel aspect.- See Also:
-
ROUNDED_PIXEL_ASPECT
public static final int ROUNDED_PIXEL_ASPECTPixel aspect policy: Preserves only extreme pixel aspects, where one dimension is a multiple of the other dimension.- See Also:
-
EXACT_PIXEL_ASPECT
public static final int EXACT_PIXEL_ASPECTPixel aspect policy: Preserve the exact pixel aspect.- See Also:
-
ANAMORPH_PIXEL_ASPECT
public static final int ANAMORPH_PIXEL_ASPECTPixel aspect policy: Use Anamoprh 16:9 pixel aspect (=16/9*4/5=1.4222).- See Also:
-
SCALE_TO_IMAGE_SIZE
public static final int SCALE_TO_IMAGE_SIZEImage scaling policy: Scale as defined by #setAspectRatio and the image aspect.- See Also:
-
SCALE_TO_VIEW_SIZE
public static final int SCALE_TO_VIEW_SIZEImage scaling policy: Scale to panel size.- See Also:
-
SCALE_TO_IMAGE_ASPECT
public static final int SCALE_TO_IMAGE_ASPECTImage scaling policy: Scale to panel but keep the image aspect.- See Also:
-
-
Constructor Details
-
ImagePanel
public ImagePanel()
-
-
Method Details
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
setPixelAspectPolicy
public void setPixelAspectPolicy(int policy) Sets the pixel aspect policy.- Parameters:
policy- PixelAspectPolicy must be one of IGNORE_PIXEL_ASPECT, ROUNDED_PIXEL_ASPECT, EXACT_PIXEL_ASPECT.- Throws:
IllegalArgumentException- When passing invalid policy.
-
getPixelAspectPolicy
public int getPixelAspectPolicy()Returns the pixel aspect policy. -
setImageScalePolicy
public void setImageScalePolicy(int policy) Sets the image scale policy. -
getImageScalePolicy
public int getImageScalePolicy()Returns the image scale policy. -
getPixelAspectX
public double getPixelAspectX()Gets the horizontal pixel aspect of the image according to the pixel aspect policy that is in affect.- Returns:
- Horizontal pixel aspect.
-
getPixelAspectY
public double getPixelAspectY()Gets the vertical pixel aspect of the image according to the pixel aspect policy that is in effect.- Returns:
- Vertical pixel aspect.
-
getPreferredImageSize
Gets the preferred image size.- Returns:
- Image dimension after applying the pixel aspect policy.
-
getScaledImageSize
Gets the scaled and pixel aspect corrected image size.- Returns:
- Image dimension after scaling and applying the pixel aspect policy.
-
setImage
Sets the image and displays it in this image panel. -
getImage
Gets the image that is displayed in this image panel.- Returns:
- image.
-
setTexture
Sets the texture for the backdrop paint. -
getTexture
Gets the backdrop paint. -
setScaleFactor
public void setScaleFactor(double scaleFactor) Sets the scale factor. The scale factor scales images shown in this image panel.- Parameters:
scaleFactor- The scale factor.
-
getScaleFactor
public double getScaleFactor()Gets the scale factor.- Returns:
- Scale factor.
-
setRenderingHints
Sets the rendering hints.- Parameters:
newValue- The new rendering hints.
-
getRenderingHints
Gets the rendering hints.- Returns:
- Rendering Hints.
-
setAspectRatio
public void setAspectRatio(double ratioX, double ratioY) Sets the aspect ratio. The aspect ratio distorts images shown in this image panel.- Parameters:
ratioX- Horizontal scale factor.ratioY- Vertical scale factor.
-
setAspectRatio0
protected void setAspectRatio0(double ratioX, double ratioY) -
getAspectRatioX
public double getAspectRatioX()Gets the horizontal scale factor that is used to scale images shown in this image panel.- Returns:
- Horizontal scale factor.
-
getAspectRatioY
public double getAspectRatioY()Gets the vertical scale factor that is used to scale images shown in this image panel.- Returns:
- Vertical scale factor.
-
getPreferredSize
Gets the preferred size of this image panel. The preferred size depends on the image size, the scale factor and the pixel aspect policy.- Overrides:
getPreferredSizein classJComponent
-
addPropertyChangeListener
Adds a listener who is interested in changes of this object.- Overrides:
addPropertyChangeListenerin classContainer
-
removePropertyChangeListener
Removes a previously registered listener.- Overrides:
removePropertyChangeListenerin classComponent
-
setMessage
-
imageUpdate
XXX Netscape gets very slow when painting all SOMEBITS of an image.- Specified by:
imageUpdatein interfaceImageObserver- Overrides:
imageUpdatein classComponent
-