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 JimiCanvasLW

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

public class JimiCanvasLW
extends java.awt.Component

An `java.awt.Canvas` for easily displaying any image in a J.I.M.I. 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
- 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.
- Specify a null image to display

Since:
  Jimi1.0
See Also:
  Serialized Form

Field Summary
`static int` | `AREA_AVERAGING` One of two possible scaling mode policies.
`static int` | `BEST_FIT` One of three possible resizing policies.
`static int` | `CENTER` One of nine possilbe justification policies.
`static int` | `CROP_AS_NECESSARY` One of three possible resizing policies.
`static int` | `EAST` One of nine possible justification policies.
`static int` | `FIT_TO_WIDTH`
`protected int` | `justificationPolicy` One of eight possible imageJustifications.
`protected java.awt.Image` | `myImage` The `java.awt.Image` that this `JimiCanvas` represents.
`protected java.net.URL` | `myImageLocation` Tells J.I.M.I. where to load `myImage` from.
`static int` | `NORTH` One of nine possible justification policies.
`static int` | `NORTHEAST` One of nine possible justification policies.
`static int` | `NORTHWEST` One of nine possible justification policies.
`static int` | `REPLICATE` One of two possible scaling mode policies.
`protected int` | `resizePolicy` One of three possible resize policies.
`static int` | `SCALE` One of three possible resizing policies.
`protected int` | `scalingPolicy` One of two possible scaling policies.
`static int` | `SCROLL`
`static int` | `SOUTH` One of nine possible justification policies.
`static int` | `SOUTHEAST` One of nine possible justification policies.
`static int` | `SOUTHWEST` One of nine possible justification policies.
`static int` | `WEST` One of nine possible justification policies.
`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
`JimiCanvasLW()` No argument constructor for use in beanboxes.
`JimiCanvasLW(java.awt.Image anImage)` Create me
`JimiCanvasLW(java.net.URL aLocation)` Create me

Method Summary
`protected java.awt.Image` | `getCacheImage()`
`java.awt.Image` | `getImage()` The image that this canvas is currently displaying.
`java.net.URL` | `getImageLocation()` Where J.I.M.I. should look to find the image.
`int` | `getJustificationPolicy()` Which of the nine justification policies we use to place the image on the canvas return One of nine justification policies
`java.awt.Dimension` | `getPreferredSize()` If 'willSizeToFit', ask for the size of the image.
`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.
`protected void` | `LoadImage()` We've been given an imageLocation, and we want to pull the image from that location by using J.I.M.I. to do it.
`void` | `paint(java.awt.Graphics g)`
`void` | `setFitWidth(int width)` Set the width to be used for FIT_TO_WIDTH.
`void` | `setImage(java.awt.Image anImage)` We can explicitly set an Image instead of relying upon J.I.M.I. to load it.
`void` | `setImageLocation(java.net.URL newLocation)` Where should J.I.M.I. look to find the image? This value need not be set, and is mutually exclusive with `setImage`.
`void` | `setJustificationPolicy(int newPolicy)` Which of the nine justification policies we use to place the image on the canvas
`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 canvas.
`void` | `update(java.awt.Graphics g)`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate`

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

Field Detail

### EAST

    public static final int EAST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### NORTH

    public static final int NORTH

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### NORTHEAST

    public static final int NORTHEAST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### NORTHWEST

    public static final int NORTHWEST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### SOUTH

    public static final int SOUTH

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### SOUTHEAST

    public static final int SOUTHEAST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### SOUTHWEST

    public static final int SOUTHWEST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### WEST

    public static final int WEST

  One of nine possible justification policies.
  See Also:
    `setJustificationPolicy`

### CENTER

    public static final int CENTER

  One of nine possilbe justification policies.
  See Also:
    `setJustificationPolicy`

### BEST_FIT

    public static final int BEST_FIT

  One of three possible resizing policies. Will scale the image so that one of the axis totally fills the available space, and the other maintains aspect ratio.
  See Also:
    `setResizePolicy`, `CROP_AS_NECESSARY`, `SCALE`

### CROP_AS_NECESSARY

    public static final int CROP_AS_NECESSARY

  One of three possible resizing policies. No scaling is done. instead, if the image will not fit within the available space, it is cropped.
  See Also:
    `setResizePolicy`, `BEST_FIT`, `SCALE`

### SCALE

    public static final int SCALE

  One of three possible resizing policies. Both axis are independently scaled to totally fill the available space. This may cause distortion.
  See Also:
    `setResizePolicy`, `BEST_FIT`, `CROP_AS_NECESSARY`

### SCROLL

    public static final int SCROLL

### FIT_TO_WIDTH

    public static final int FIT_TO_WIDTH

### AREA_AVERAGING

    public static final int AREA_AVERAGING

  One of two possible scaling mode policies. This policy will cause the JimiCanvas to use java.awt.image.AreaAveragingScaleFilter for rendering the scaled version of the target image. This yields the best looking results, but can be very time consuming.
  See Also:
    `setScalingPolicy`, `REPLICATE`

### REPLICATE

    public static final int REPLICATE

  One of two possible scaling mode policies. This policy will cause the JimiCanvas to use java.awt.image.ReplicatingScaleFilter for rendering the scaled version of the target image. This filter is very fast, but does not gurantee good-looking results.
  See Also:
    `setScalingPolicy`, `AREA_AVERAGING`

### myImage

    protected transient java.awt.Image myImage

  The `java.awt.Image` that this `JimiCanvas` represents.
  See Also:
    `setImage`, `loadImage`, `getImage`

### myImageLocation

    protected java.net.URL myImageLocation

  Tells J.I.M.I. where to load `myImage` from. This value may be null if you wish to explicitly set `myImage`.
  See Also:
    `setImage`, `setImageLocation`, `getImageLocation`, `loadImage`

### willSizeToFit

    protected boolean willSizeToFit

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

### justificationPolicy

    protected int justificationPolicy

  One of eight possible imageJustifications. If image does not fill the entire canvas, it will be drawn according to this justification policy.
  See Also:
    `getImageJustification`, `setJustificationPolicy`

### resizePolicy

    protected int resizePolicy

  One of three possible resize policies. If an image needs to be modified to fill a canvas, or to fit within it, then this policy will be used to determine how to do this.
  See Also:
    `getResizePolicy`, `setResizePolicy`

### scalingPolicy

    protected int scalingPolicy

  One of two possible scaling policies. If an image needs to be scaled, then this policy will be used to determine how to do this.
  See Also:
    `getScalingPolicy`, `setScalingPolicy`

Constructor Detail

### JimiCanvasLW

    public JimiCanvasLW()

  No argument constructor for use in beanboxes.

### JimiCanvasLW

    public JimiCanvasLW(java.awt.Image anImage)

  Create me
  Parameters:
    `anImage` - The image to display
  See Also:
    `setImage`

### JimiCanvasLW

    public JimiCanvasLW(java.net.URL aLocation)

  Create me
  Parameters:
    `aLocation` - Where to load the image using J.I.M.I. from
  See Also:
    `setImageLocation`

Method Detail

### LoadImage

    protected void LoadImage()

  We've been given an imageLocation, and we want to pull the image from that location by using J.I.M.I. to do it.
  See Also:
    `setImageLocation`, `setImage`

### setFitWidth

    public void setFitWidth(int width)

  Set the width to be used for FIT_TO_WIDTH.

### 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

    public int getJustificationPolicy()

  Which of the nine justification policies we use to place the image on the canvas return One of nine justification policies
  See Also:
    `CENTER`, `NORTH`, `NORTHEAST`, `EAST`, `SOUTHEAST`, `SOUTH`, `SOUTHWEST`, `WEST`, `NORTHWEST`

### 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 three policies which specify how to fit the image into the canvas
  See Also:
    `CROP_AS_NECESSARY`, `SCALE`, `BEST_FIT`

### getResizePolicy

    public int getResizePolicy()

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

### 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 canvas.
  Parameters:
    `newPolicy` - If true, will resize the canvas to fit the new image
  See Also:
    `setImage`, `setImageLocation`

### 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

### setImageLocation

    public void setImageLocation(java.net.URL newLocation)

  Where should J.I.M.I. look to find the image?
  This value need not be set, and is mutually exclusive with `setImage`. setImagetakes precedence.
  Parameters:
    `newLocation` - Where J.I.M.I. should go to find the image
  See Also:
    `getImageLocation`, `setImage`, `getImage`

### getImageLocation

    public java.net.URL getImageLocation()

  Where J.I.M.I. 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`, `setImage`, `getImage`

### setImage

    public void setImage(java.awt.Image anImage)

  We can explicitly set an Image instead of relying upon J.I.M.I. to load it. The two ways of specifying the image location are mutually exclusive. `setImage` takes precedence over `setImageLocation`
  Parameters:
    `anImage` - The `java.awt.Image` that we wish to display
  See Also:
    `setImageLocation`, `getImageLocation`, `getImage`

### 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`, `setImageLocation`, `getImageLocation`

### getPreferredSize

    public java.awt.Dimension getPreferredSize()

  If 'willSizeToFit', ask for the size of the image.
  Overrides:
    getPreferredSize in class java.awt.Component

### update

    public void update(java.awt.Graphics g)

  Overrides:
    update in class java.awt.Component

### getCacheImage

    protected java.awt.Image getCacheImage()

### paint

    public void paint(java.awt.Graphics g)

  Overrides:
    paint in class java.awt.Component

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