Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jimi.core.component
Class JimiCanvas

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--com.sun.jimi.core.component.JimiCanvas

public class JimiCanvas
extends java.awt.Container

An `java.awt.Canvas` for easily displaying any image in a JIMI. supported image format, or any `java.awt.Image`. Subclasses will support using this as a Bean.

The following features exist :

- Specify the image to show based upon a `java.net.URL` or a `java.awt.Image`
- Resizable with the following policies :
  1. Crop if necessary
  2. Scale the image
  3. Best fit the image
  4. Fit to Width
  5. Scrolling modes.
- Specify a justification for the image based upon the cardinal directions of a compass.
- Explicitly set a canvas size.
- Automatically resize the canvas to fit a new image
- Specify a background color for areas of the canvas unpainted by the image.
- "Paged" scrolling, where only the visible portion of the image is buffered in an Image object. This preserves memory significantly, and when used in conjunction with VMM can be used to view images of any size.

Since:
  Jimi1.0
See Also:
  Serialized Form

Field Summary
`static int` | `AREA`
`static int` | `AREA_AVERAGING`
`protected boolean` | `aspectAdjust`
`static int` | `BEST_FIT`
`static int` | `CENTER`
`static int` | `CROP`
`static int` | `CROP_AS_NECESSARY`
`static int` | `EAST`
`static int` | `FIT_TO_WIDTH`
`static int` | `FIT_WIDTH`
`protected int` | `fitWidth`
`protected ImageCache` | `imageCache`
`protected int` | `justificationPolicy` initialized policy to a default value.
`protected int` | `loadingFlags`
`static int` | `MULTIPAGE`
`protected java.awt.Image` | `myImage`
`protected java.net.URL` | `myImageLocation`
`protected java.awt.image.ImageProducer` | `myImageProducer`
`static int` | `NORTH`
`static int` | `NORTHEAST`
`static int` | `NORTHWEST`
`static int` | `PAGED`
`protected ProgressListener` | `progressListener`
`protected JimiImageRenderer` | `renderer`
`static int` | `REPLICATE`
`protected int` | `resizePolicy`
`static int` | `SCALE`
`protected int` | `scalingPolicy`
`static int` | `SCROLL`
`static int` | `SOUTH`
`static int` | `SOUTHEAST`
`static int` | `SOUTHWEST`
`static int` | `WEST`
`protected boolean` | `willSizeToFit` This `JimiCanvas` will automatically resize to fit the `Image` if true.

Fields inherited from class java.awt.Component
`BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Constructor Summary
`JimiCanvas()` No argument constructor for use in beanboxes.
`JimiCanvas(java.awt.Image myImage)` Creates a JimiCanvas displaying the image passed.
`JimiCanvas(int resizePolicy)` Creates a canvas with a specified initial resize policy.
`JimiCanvas(java.lang.String path)` Creates a JimiCanvas and loads the Image form the path specified.
`JimiCanvas(java.net.URL myImageLocation)` Creates a JimiCanvas and loads the Image from the URL specified.

Method Summary
`void` | `firstImage()` For multi-image files, regress to the first image.
`int` | `getFitWidth()`
`java.awt.Image` | `getImage()` The image that this canvas is currently displaying.
`java.net.URL` | `getImageLocation()` Where JIMI should look to find the image.
`int` | `getJustificationPolicy()`
`JimiImageRenderer` | `getRenderer()`
`protected JimiImageRenderer` | `getRenderer(int resizePolicy)` Creates and returns a new renderer based on resize policy
`int` | `getResizePolicy()` Do we crop the image, scale it, or scale it so that it fits best?
`int` | `getScalingPolicy()` Retrieve the scaling mode currently in effect.
`boolean` | `getWillSizeToFit()` If true, the canvas will resize itself so that it exactly fits the canvas.
`boolean` | `hasNextImage()` For multi-image files, check if there is a next image to move to.
`boolean` | `hasPreviousImage()` For multi-image files, check if there is a previous image to mvoe to.
`void` | `lastImage()` For multi-image files, progress to the last image.
`protected java.awt.image.ImageProducer` | `loadImageProducer(JimiReader reader)` Load an image.
`protected java.awt.image.ImageProducer` | `loadImageProducer(java.lang.String filename)`
`protected java.awt.image.ImageProducer` | `loadImageProducer(java.net.URL location)`
`void` | `nextImage()` For multi-image files, progress to the next image.
`void` | `previousImage()` For multi-image files, regress to the previous image.
`void` | `setAspectAdjust(boolean flag)` Set whether the canvas should adjust aspect ratio for image formats which provide aspect information.
`void` | `setFitWidth(int width)` Set the width to be used for FIT_WIDTH
`void` | `setImage(java.awt.Image myImage)` We can explicitly set an Image instead of relying upon JIMI to load it.
`void` | `setImageLocation(java.net.URL newLocation)` Where should JIMI look to find the image? This method loads the image from the URL then calls setImage.
`void` | `setImagePath(java.lang.String path)` Loads an image from the path specified and calls setImage(Image) with the returned Image object.
`void` | `setImageProducer(java.awt.image.ImageProducer producer)` displays an image created from the given ImageProducer
`void` | `setJustificationPolicy(int newPolicy)` Which of the nine justification policies we use to place the image on the canvas
`void` | `setLoadingFlags(int flags)` Set the flags to use for image loading.
`void` | `setProgressListener(ProgressListener listener)` Set a ProgressListener to be informed of image loading status.
`void` | `setRasterImage(JimiRasterImage raster)` display an image created from the given JimiRasterImage
`void` | `setRenderer(JimiImageRenderer renderer)` set the renderer to be used
`void` | `setResizePolicy(int newPolicy)` Do we crop the image, scale it, or scale it so that it fits best?
`void` | `setScalingPolicy(int newPolicy)` Set the scaling mode for this canvas.
`void` | `setWillSizeToFit(boolean newPolicy)` If true, the canvas will resize itself so that it exactly fits the the image.
`protected void` | `showError(java.lang.String message)`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### NORTH

    public static final int NORTH

### SOUTH

    public static final int SOUTH

### EAST

    public static final int EAST

### WEST

    public static final int WEST

### NORTHEAST

    public static final int NORTHEAST

### NORTHWEST

    public static final int NORTHWEST

### SOUTHEAST

    public static final int SOUTHEAST

### SOUTHWEST

    public static final int SOUTHWEST

### CENTER

    public static final int CENTER

### BEST_FIT

    public static final int BEST_FIT

### CROP

    public static final int CROP

### SCALE

    public static final int SCALE

### SCROLL

    public static final int SCROLL

### FIT_WIDTH

    public static final int FIT_WIDTH

### AREA

    public static final int AREA

### MULTIPAGE

    public static final int MULTIPAGE

### PAGED

    public static final int PAGED

### CROP_AS_NECESSARY

    public static final int CROP_AS_NECESSARY

### FIT_TO_WIDTH

    public static final int FIT_TO_WIDTH

### AREA_AVERAGING

    public static final int AREA_AVERAGING

### REPLICATE

    public static final int REPLICATE

### myImage

    protected transient java.awt.Image myImage

### myImageProducer

    protected transient java.awt.image.ImageProducer myImageProducer

### myImageLocation

    protected transient java.net.URL myImageLocation

### willSizeToFit

    protected boolean willSizeToFit

  This `JimiCanvas` will automatically resize to fit the `Image` if true.
  See Also:
    `JimiCanvas#getWillResize`, `JimiCanvas#setWillResize`

### fitWidth

    protected int fitWidth

### renderer

    protected JimiImageRenderer renderer

### justificationPolicy

    protected int justificationPolicy

  initialized policy to a default value.

### resizePolicy

    protected int resizePolicy

### scalingPolicy

    protected int scalingPolicy

### progressListener

    protected ProgressListener progressListener

### loadingFlags

    protected int loadingFlags

### aspectAdjust

    protected boolean aspectAdjust

### imageCache

    protected ImageCache imageCache

Constructor Detail

### JimiCanvas

    public JimiCanvas()

  No argument constructor for use in beanboxes.

### JimiCanvas

    public JimiCanvas(java.awt.Image myImage)

  Creates a JimiCanvas displaying the image passed.
  Parameters:
    `anImage` - The image to display
  See Also:
    `setImage(java.awt.Image)`

### JimiCanvas

    public JimiCanvas(java.net.URL myImageLocation)

  Creates a JimiCanvas and loads the Image from the URL specified.
  Parameters:
    `aLocation` - Where to load the image using J.I.M.I. from
  See Also:
    `setImageLocation(java.net.URL)`

### JimiCanvas

    public JimiCanvas(java.lang.String path)

  Creates a JimiCanvas and loads the Image form the path specified.
  Parameters:
    `path` - to the image
  See Also:
    `setImage(java.awt.Image)`

### JimiCanvas

    public JimiCanvas(int resizePolicy)

  Creates a canvas with a specified initial resize policy.
  Parameters:
    `resizePolicy` - the resize policy

Method Detail

### setRenderer

    public void setRenderer(JimiImageRenderer renderer)

  set the renderer to be used

### getRenderer

    public JimiImageRenderer getRenderer()

  Returns:
    current renderer

### getRenderer

    protected JimiImageRenderer getRenderer(int resizePolicy)

  Creates and returns a new renderer based on resize policy
  See Also:
    `setResizePolicy(int)`, `getResizePolicy()`

### setProgressListener

    public void setProgressListener(ProgressListener listener)

  Set a ProgressListener to be informed of image loading status.

### setLoadingFlags

    public void setLoadingFlags(int flags)

  Set the flags to use for image loading. These are the same flags as used in Jimi.getImage( .. , flags )

### loadImageProducer

    protected java.awt.image.ImageProducer loadImageProducer(JimiReader reader)

  Load an image.

### loadImageProducer

    protected java.awt.image.ImageProducer loadImageProducer(java.net.URL location)

### loadImageProducer

    protected java.awt.image.ImageProducer loadImageProducer(java.lang.String filename)

### showError

    protected void showError(java.lang.String message)

### setFitWidth

    public void setFitWidth(int width)

  Set the width to be used for FIT_WIDTH

### getFitWidth

    public int getFitWidth()

  Returns:
    current fitWidth

### setJustificationPolicy

    public void setJustificationPolicy(int newPolicy)

  Which of the nine justification policies we use to place the image on the canvas
  Parameters:
    `newPolicy` - The new justification policy
  See Also:
    `CENTER`, `NORTH`, `NORTHEAST`, `EAST`, `SOUTHEAST`, `SOUTH`, `SOUTHWEST`, `WEST`, `NORTHWEST`, `getJustificationPolicy()`

### getJustificationPolicy

    public int getJustificationPolicy()

  Returns:
    current justification policy

### setResizePolicy

    public void setResizePolicy(int newPolicy)

  Do we crop the image, scale it, or scale it so that it fits best?
  Parameters:
    `newPolicy` - One of policies which specify how to fit the image into the canvas
  See Also:
    `CROP`, `SCALE`, `BEST_FIT`, `FIT_WIDTH`, `SCROLL`

### getResizePolicy

    public int getResizePolicy()

  Do we crop the image, scale it, or scale it so that it fits best?
  See Also:
    `CROP`, `SCALE`, `BEST_FIT`, `FIT_WIDTH`, `SCROLL`

### setScalingPolicy

    public void setScalingPolicy(int newPolicy)

  Set the scaling mode for this canvas. There are currently two possibilities: AreaAveraging and Replicate. Each derived from a corresponding standard ImageFilter. The AreaAveraging mode will yield the best looking results, but it takes significantly longer to execute than the Replicate mode.
  Parameters:
    `newPolicy` - One of two policies which specify how to scale the image into the canvas
  See Also:
    `AREA_AVERAGING`, `REPLICATE`

### getScalingPolicy

    public int getScalingPolicy()

  Retrieve the scaling mode currently in effect. There are currently two possibilities: AreaAveraging and Replicate. Each derived from a corresponding standard ImageFilter. The AreaAveraging mode will yield the best looking results, but it takes significantly longer to execute than the Replicate mode does.
  See Also:
    `AREA_AVERAGING`, `REPLICATE`

### setWillSizeToFit

    public void setWillSizeToFit(boolean newPolicy)

  If true, the canvas will resize itself so that it exactly fits the the image.
  Parameters:
    `newPolicy` - If true, will resize the canvas to fit the new image
  See Also:
    `getWillSizeToFit()`

### getWillSizeToFit

    public boolean getWillSizeToFit()

  If true, the canvas will resize itself so that it exactly fits the canvas.
  Returns:
    true if the canvas will be automatically sized to fit the image
  See Also:
    `setWillSizeToFit(boolean)`

### setImageLocation

    public void setImageLocation(java.net.URL newLocation)

  Where should JIMI look to find the image?
  This method loads the image from the URL then calls setImage.
  Parameters:
    `newLocation` - Where JIMI should go to find the image
  See Also:
    `getImageLocation()`, `getImage()`, `setImage(java.awt.Image)`

### getImageLocation

    public java.net.URL getImageLocation()

  Where JIMI should look to find the image.
  If the image was set with `setImage` this value may be `null`
  Returns:
    The URL location of the image
  See Also:
    `setImageLocation(java.net.URL)`

### setImage

    public void setImage(java.awt.Image myImage)

  We can explicitly set an Image instead of relying upon JIMI to load it.
  Parameters:
    `myImage` - The `java.awt.Image` that we wish to display
  See Also:
    `getImage()`, `setImageLocation(java.net.URL)`, `getImageLocation()`

### setImagePath

    public void setImagePath(java.lang.String path)

  Loads an image from the path specified and calls setImage(Image) with the returned Image object.
  Parameters:
    `path` - The path to the image
  See Also:
    `setImage(java.awt.Image)`

### getImage

    public java.awt.Image getImage()

  The image that this canvas is currently displaying. This is not the cropped nor resized image, but the base image that is being used to create the cropped or scaled image.
  Returns:
    Image The base image that we're displaying currently
  See Also:
    `setImage(java.awt.Image)`, `setImageLocation(java.net.URL)`, `getImageLocation()`

### setImageProducer

    public void setImageProducer(java.awt.image.ImageProducer producer)

  displays an image created from the given ImageProducer

### setRasterImage

    public void setRasterImage(JimiRasterImage raster)

  display an image created from the given JimiRasterImage
  Parameters:
    `raster` - the JimiRasterImage you want to display

### nextImage

    public void nextImage()

  For multi-image files, progress to the next image.

### previousImage

    public void previousImage()

  For multi-image files, regress to the previous image.

### firstImage

    public void firstImage()

  For multi-image files, regress to the first image.

### lastImage

    public void lastImage()

  For multi-image files, progress to the last image.

### hasNextImage

    public boolean hasNextImage()

  For multi-image files, check if there is a next image to move to.

### hasPreviousImage

    public boolean hasPreviousImage()

  For multi-image files, check if there is a previous image to mvoe to.

### setAspectAdjust

    public void setAspectAdjust(boolean flag)

  Set whether the canvas should adjust aspect ratio for image formats which provide aspect information.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD