com.sun.media.jai.widget
Class DisplayJAI

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.sun.media.jai.widget.DisplayJAI
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class DisplayJAI
extends JPanel
implements MouseListener, MouseMotionListener

A JavaTM Foundation Classes JPanel which is able to contain an image. The image and its container may have different sizes. The image may also be positioned within the container.

This class extends JPanel in order to support layout management. Image tiling is supported as of version 1.3 of the JavaTM 2 Platform via Graphics2D.drawRenderedImage(RenderedImage,AffineTransform).

This class is not a committed part of the JavaTM Advanced Imaging API per se. It might therefore not be supported by JAI implementations other than that of Sun Microsystems, Inc.

See Also:
Graphics2D, RenderedImage, JPanel, JComponent, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int originX
          Abscissa of image origin relative to panel origin.
protected  int originY
          Ordinate of image origin relative to panel origin.
protected  RenderedImage source
          The image to display.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
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
DisplayJAI()
          Constructs a DisplayJAI and sets its the layout to null.
DisplayJAI(RenderedImage image)
          Constructs a DisplayJAI, sets its layout to null, and sets its displayed image.
 
Method Summary
 Point getOrigin()
          Retrieves the image origin.
 RenderedImage getSource()
          Returns the image to be displayed by this panel.
 void mouseClicked(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse clicks.
 void mouseDragged(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse dragging.
 void mouseEntered(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse entrances.
 void mouseExited(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse exits.
 void mouseMoved(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse movement.
 void mousePressed(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse presses.
 void mouseReleased(MouseEvent e)
          An empty method which should be overridden by subclasses which respond to mouse releases.
 void paintComponent(Graphics g)
          Draws the image or fills the panel with a background color.
 void set(RenderedImage im)
          Sets a new image to display.
 void set(RenderedImage im, int x, int y)
          Sets a new image to display and its coordinates within the container.
 void setOrigin(int x, int y)
          Moves the image within it's container.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected RenderedImage source
The image to display.


originX

protected int originX
Abscissa of image origin relative to panel origin.


originY

protected int originY
Ordinate of image origin relative to panel origin.

Constructor Detail

DisplayJAI

public DisplayJAI()
Constructs a DisplayJAI and sets its the layout to null.


DisplayJAI

public DisplayJAI(RenderedImage image)
Constructs a DisplayJAI, sets its layout to null, and sets its displayed image.

The preferred size is set such that its width is the image width plus the left and right insets and its height is the image height plus the top and bottom insets.

Parameters:
image - The image to display.
Throws:
IllegalArgumentException - if image is null.
Method Detail

setOrigin

public void setOrigin(int x,
                      int y)
Moves the image within it's container. The instance variables originX and originY are set to the parameter valus x and y, respectively. Component.repaint() is invoked after the origin values are changed.

Parameters:
x - image origin abscissa.
y - image origin ordinate.

getOrigin

public Point getOrigin()
Retrieves the image origin.


set

public void set(RenderedImage im)
Sets a new image to display.

The preferred size is set such that its width is the image width plus the left and right insets and its height is the image height plus the top and bottom insets. JComponent.revalidate() and Component.repaint() are invoked after all other changes.

Parameters:
im - The image to display.
Throws:
IllegalArgumentException - if im is null.

set

public void set(RenderedImage im,
                int x,
                int y)
Sets a new image to display and its coordinates within the container.

The preferred size is set such that its width is the image width plus the left and right insets and its height is the image height plus the top and bottom insets. JComponent.revalidate() and Component.repaint() are invoked after all other changes.

Parameters:
im - The image to display.
x - image origin abscissa.
y - image origin ordinate.
Throws:
IllegalArgumentException - if im is null.

getSource

public RenderedImage getSource()
Returns the image to be displayed by this panel.

Returns:
The value of the source instance variable.

paintComponent

public void paintComponent(Graphics g)
Draws the image or fills the panel with a background color.

If the current image is null, the rectangle new Rectangle(0,0,JComponent.getWidth(),JComponent.getHeight()) is filled with the background color returned by Component.getBackground().

If the current image is non-null, the rectangle returned by Graphics.getClipBounds() is filled with the background color and the image is drawn using Graphics2D.drawRenderedImage(RenderedImage,AffineTransform) at the location (JComponent.getInsets().left+originX, JComponent.getInsets().right+originY).

Parameters:
g - Graphics context in which to paint.

mousePressed

public void mousePressed(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse presses.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse releases.

Specified by:
mouseReleased in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse movement.

Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse dragging.

Specified by:
mouseDragged in interface MouseMotionListener

mouseEntered

public void mouseEntered(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse entrances.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse exits.

Specified by:
mouseExited in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
An empty method which should be overridden by subclasses which respond to mouse clicks.

Specified by:
mouseClicked in interface MouseListener