wheelsunh.users
Class Image

java.lang.Object
  extended by wheelsunh.etc.AbstractGraphic
      extended by wheelsunh.users.AbstractShape
          extended by wheelsunh.users.Image
All Implemented Interfaces:
CustomGraphic, Locatable, Rotatable, Sizeable

public class Image
extends AbstractShape
implements CustomGraphic, Locatable, Sizeable

A class that can display an image on a DrawingPanel.


Field Summary
 
Fields inherited from class wheelsunh.users.AbstractShape
_rot
 
Constructor Summary
Image(DrawingPanel dp, java.lang.String file)
          Create an image from the specified filename, in the specified DrawingPanel.
Image(DrawingPanel dp, java.net.URL url)
          Create an image from a URL.
Image(java.awt.Image awtImage)
          Create a wheels image from awt Image A UNH wheels extension.
Image(int w, int h)
          Create an Image object of a give size, but no image yet.
Image(int w, int h, int iType)
          Create an Image object of a give size and type but no image yet.
Image(java.lang.String file)
          Create an image from the specified filename, in the wheelsunh.users.Frame's DrawingPanel.
Image(java.net.URL url)
          Create an image from the specified URL, in the wheelsunh.users.Frame's DrawingPanel.
 
Method Summary
 boolean contains(java.awt.Point p)
          See if this Image contains the Point
 void drag(java.awt.event.MouseEvent e)
          Override to do something useful.
 java.awt.Image getAWTImage()
          Get the AWT Image that we are using, not necessary for most users.
 java.awt.Rectangle getBounds()
          Get the rectangle that indicates the bounds of this Image
 int getHeight()
          Returns the height of this Image.
 java.awt.Point getLocation()
          Get the location of this Image
 int getRotation()
          Get the rotation for this Image
 java.awt.Dimension getSize()
          Get the dimensions of this Image
 int getWidth()
          Returns the width of the Image.
 int getXLocation()
          Get the x value of the Image's location.
 int getYLocation()
          Get the y value of the Image's location.
 void hide()
          Hide the Image so it won't paint
 void mouseClicked(java.awt.event.MouseEvent e)
          Called when the Panel detects that the mouse was clicked.
 void mouseDragged(java.awt.event.MouseEvent e)
          Called when the Panel detects that the mouse was dragged.
 void mousePressed(java.awt.event.MouseEvent e)
          Called when the Panel detects that the mouse was pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          Called when the Panel detects that the mouse was released.
 void paint(java.awt.Graphics2D g)
          Normal users need not use this!
protected  void setAWTImage(java.awt.Image newImage)
          set the internal awt version of the image; UNH extension: On MacOSX, we get image objects of type apple.awt.OSXImage.
 void setLocation(int x, int y)
          Set the location of the Image.
 void setLocation(java.awt.Point p)
          Set the location of this Image
 void setRotation(int degrees)
          Set the rotation for this Image
 void setSize(java.awt.Dimension d)
          Set the dimensions of this Image
 void setSize(int width, int height)
          Set the dimensions of this Image
protected  void setup(DrawingPanel dp)
          Normal users need not use this!
 void show()
          Show the Image so it paints
 
Methods inherited from class wheelsunh.users.AbstractShape
boundsIntersects, center, distance, getCenter, getCenterX, getCenterY, getIntersection, intersects, intersects, setCenter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Image

public Image(int w,
             int h)
Create an Image object of a give size, but no image yet. UNH extension. rdb 11/15/09


Image

public Image(int w,
             int h,
             int iType)
Create an Image object of a give size and type but no image yet. UNH extension. rdb 11/15/09


Image

public Image(java.lang.String file)
Create an image from the specified filename, in the wheelsunh.users.Frame's DrawingPanel. Note that if you are running on Windows, the location of the image must be in your classpath.

Parameters:
file - the filename to take this image form (gif or jpg).

Image

public Image(java.net.URL url)
Create an image from the specified URL, in the wheelsunh.users.Frame's DrawingPanel.

Parameters:
url - the URL to take this image form (gif or jpg)

Image

public Image(DrawingPanel dp,
             java.lang.String file)
Create an image from the specified filename, in the specified DrawingPanel. Note that if you are running on Windows, the location of the image must be in your classpath.

Parameters:
dp - the DrawingPanel for this image
file - the filename to take this image form (gif or jpg).

Image

public Image(DrawingPanel dp,
             java.net.URL url)
Create an image from a URL.

Parameters:
dp - the DrawingPanel for this image
url - the URL to take this image form (gif or jpg)

Image

public Image(java.awt.Image awtImage)
Create a wheels image from awt Image A UNH wheels extension.

Parameters:
awtImage -
Method Detail

setup

protected void setup(DrawingPanel dp)
Normal users need not use this!

Use the media tracker to load the image, then initialize everything else.


setAWTImage

protected void setAWTImage(java.awt.Image newImage)
set the internal awt version of the image; UNH extension: On MacOSX, we get image objects of type apple.awt.OSXImage. They may be more efficient, but makes it difficult to do anything with them in a system independent way. Check for that, and convert to a BufferedImage. Maybe we should call it a BufferedImage instead of just Image??


setSize

public void setSize(java.awt.Dimension d)
Set the dimensions of this Image

Specified by:
setSize in interface Sizeable
Parameters:
d - the new Dimension for this Image

setSize

public void setSize(int width,
                    int height)
Set the dimensions of this Image

Specified by:
setSize in interface Sizeable

getSize

public java.awt.Dimension getSize()
Get the dimensions of this Image

Specified by:
getSize in interface Sizeable
Returns:
the Dimension for this Image

getWidth

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

Specified by:
getWidth in interface Sizeable
Specified by:
getWidth in class AbstractShape

getHeight

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

Specified by:
getHeight in interface Sizeable
Specified by:
getHeight in class AbstractShape

setLocation

public void setLocation(java.awt.Point p)
Set the location of this Image

Specified by:
setLocation in interface Locatable
Specified by:
setLocation in class AbstractShape
Parameters:
p - the new Point for this Image

setLocation

public void setLocation(int x,
                        int y)
Set the location of the Image.

Specified by:
setLocation in interface Locatable
Overrides:
setLocation in class AbstractShape

getLocation

public java.awt.Point getLocation()
Get the location of this Image

Specified by:
getLocation in interface Locatable
Specified by:
getLocation in class AbstractShape
Returns:
the Point for this Image

getXLocation

public int getXLocation()
Get the x value of the Image's location.

Specified by:
getXLocation in interface Locatable
Specified by:
getXLocation in class AbstractShape

getYLocation

public int getYLocation()
Get the y value of the Image's location.

Specified by:
getYLocation in interface Locatable
Specified by:
getYLocation in class AbstractShape

hide

public void hide()
Hide the Image so it won't paint


show

public void show()
Show the Image so it paints


getAWTImage

public java.awt.Image getAWTImage()
Get the AWT Image that we are using, not necessary for most users.

Returns:
the real AWT image

contains

public boolean contains(java.awt.Point p)
See if this Image contains the Point

Specified by:
contains in interface CustomGraphic
Parameters:
p - the Point to test

setRotation

public void setRotation(int degrees)
Set the rotation for this Image

Specified by:
setRotation in interface Rotatable
Specified by:
setRotation in class AbstractShape
Parameters:
degrees - the degrees (clockwise) that this should rotate

getRotation

public int getRotation()
Get the rotation for this Image

Specified by:
getRotation in interface Rotatable
Specified by:
getRotation in class AbstractShape
Returns:
the degrees (clockwise) that this should rotate

paint

public void paint(java.awt.Graphics2D g)
Normal users need not use this!

Rotate the Graphics Context if necessary, the paint, then reset the rotation

Specified by:
paint in interface CustomGraphic
Parameters:
g - the Graphics2D you should use to paint your graphic

getBounds

public java.awt.Rectangle getBounds()
Get the rectangle that indicates the bounds of this Image

Specified by:
getBounds in class AbstractShape
Returns:
the java.awt.Rectangle that indicates our bounds.

drag

public void drag(java.awt.event.MouseEvent e)
Override to do something useful.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Called when the Panel detects that the mouse was clicked. If the click is within this Image. Override to do somthing useful.

Specified by:
mouseClicked in interface CustomGraphic
Overrides:
mouseClicked in class AbstractGraphic

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Called when the Panel detects that the mouse was dragged. Override to do something useful.

Specified by:
mouseDragged in interface CustomGraphic
Overrides:
mouseDragged in class AbstractGraphic

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Called when the Panel detects that the mouse was pressed. Override to do something useful.

Specified by:
mousePressed in interface CustomGraphic
Overrides:
mousePressed in class AbstractGraphic

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Called when the Panel detects that the mouse was released. Override to do something useful.

Specified by:
mouseReleased in interface CustomGraphic
Overrides:
mouseReleased in class AbstractGraphic