jcontrol.graphics
Class ResourceImage

java.lang.Object
  extended by jcontrol.graphics.ResourceImage
All Implemented Interfaces:
Image, Drawable

public class ResourceImage
extends Object
implements Image

Image that gets its data from a Resource. The graphics formats supported depend on the XGraphics used for drawing.

See Also:
Resource, jcontrol.ui.XGraphics

Constructor Summary
ResourceImage(Resource r)
          Creates a new ResourceImage with the given Resource as data source.
ResourceImage(String name)
          Creates a new ResourceImage.
 
Method Summary
 void draw(Graphics g, int x, int y)
          draws current image inside overgiven graphics at coordinates x, y
 void draw(Graphics g, int x, int y, int w, int h, int xo, int yo)
          draws current image inside overgiven graphics at coordinates x, y with special width, height and x-, y-offset-translation
 void draw(XGraphics g, int x, int y, int anchor)
          draws current image inside overgiven graphics at coordinates x, y with anchor alignment
 Resource getData()
          Returns the Resource containing the image data.
 int getHeight()
          Returns the height of the Image.
 int getWidth()
          Returns the width of the Image.
 boolean isValid()
          see parent-method for description
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Constructor Detail

ResourceImage

public ResourceImage(Resource r)
Creates a new ResourceImage with the given Resource as data source.

Parameters:
r - data source

ResourceImage

public ResourceImage(String name)
Creates a new ResourceImage. The given String contains the name of the Resource. If the Resource cannot be opened, the Image will still be created, but without any stored data.

Parameters:
name - Resource name
Method Detail

getData

public Resource getData()
Returns the Resource containing the image data.

Returns:
image data

getWidth

public int getWidth()
Returns the width of the Image.

Specified by:
getWidth in interface Image
Returns:
image width (0, if image is not valid)

getHeight

public int getHeight()
Returns the height of the Image.

Specified by:
getHeight in interface Image
Returns:
image height (0, if image is not valid)

isValid

public boolean isValid()
see parent-method for description

Specified by:
isValid in interface Image
Returns:

draw

public void draw(Graphics g,
                 int x,
                 int y)
draws current image inside overgiven graphics at coordinates x, y

Specified by:
draw in interface Drawable
Parameters:
g -
x -
y -

draw

public void draw(Graphics g,
                 int x,
                 int y,
                 int w,
                 int h,
                 int xo,
                 int yo)
draws current image inside overgiven graphics at coordinates x, y with special width, height and x-, y-offset-translation

Specified by:
draw in interface Drawable
Parameters:
g -
x -
y -
w -
h -
xo -
yo -

draw

public void draw(XGraphics g,
                 int x,
                 int y,
                 int anchor)
draws current image inside overgiven graphics at coordinates x, y with anchor alignment

Specified by:
draw in interface Image
Parameters:
g -
x -
y -
anchor -
See Also:
XGraphics