|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.lucidviews.util.gui.swing.FloatingImage
public class FloatingImage
An image that can be positioned at any given co-ordinate.
Once created you will need to explicitly call paint
, usually
from within the paint
method of the parent component.
e.g.
public class MyPanel extends JPanel { ... protected static final Image THE_IMAGE = Toolkit.getDefaultToolkit().createImage( "some/file/path.gif" ); ... public MyPanel() { ... _floatingImage = new FloatingImage( THE_IMAGE, this ); ... } ... public void paint( Graphics g ) { super.paint( g ); // paint the floating image, which is a non-standard component _floatingImage.paint( g ); } }
Field Summary | |
---|---|
protected boolean |
_displayed
A flag indicating if this image is to be rendered. |
protected Image |
_image
The image to be displayed. |
protected Collection |
_mouseListeners
A collection of MouseListener s listening for events from
this object. |
protected Component |
_parentComponent
The UI component that this image component is contained within. |
protected int |
_xPos
The x position of the left edge of the image, relative to the Graphics context passed to the paint method. |
protected int |
_yPos
The y position of the top edge of the image, relative to the Graphics context passed to the paint method. |
protected static int |
DEFAULT_X_POS
The initial _xPos value. |
protected static int |
DEFAULT_Y_POS
The initial _yPos value. |
Constructor Summary | |
---|---|
FloatingImage(Image image,
Component parentComponent)
Create a floating image to be displayed at the top-left corner of the specified parent component. |
|
FloatingImage(Image image,
int xPos,
int yPos,
Component parentComponent)
Create a floating image to be displayed at a given position, relative to the specified parent component. |
|
FloatingImage(Image image,
Point location,
Component parentComponent)
Create a floating image to be displayed at a given position, relative to the specified parent component. |
Method Summary | |
---|---|
void |
addMouseListener(MouseListener listener)
Register a listener that wants to be notified of mouse events on the floating image. |
int |
getHeight()
|
Point |
getPosition()
|
int |
getWidth()
|
int |
getXPosition()
|
int |
getYPosition()
|
boolean |
isAtLocation(Point location)
Determines if the image sits over a particular point. |
void |
mouseClicked(MouseEvent e)
|
void |
mouseEntered(MouseEvent e)
|
void |
mouseExited(MouseEvent e)
|
void |
mousePressed(MouseEvent e)
|
void |
mouseReleased(MouseEvent e)
|
void |
paint(Graphics g)
Render the image. |
void |
removeMouseListener(MouseListener listener)
Un-register a listener that does not want to be notified of mouse events on the floating image. |
void |
setDisplayed(boolean display)
Set the display status of the image. |
void |
setPosition(int xPos,
int yPos)
Move the image to a given location. |
void |
setPosition(Point position)
|
void |
setXPosition(int xPos)
|
void |
setYPosition(int yPos)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_X_POS
_xPos
value.
protected static final int DEFAULT_Y_POS
_yPos
value.
protected Image _image
protected int _xPos
Graphics
context passed to the paint
method.
protected int _yPos
Graphics
context passed to the paint
method.
protected Component _parentComponent
protected boolean _displayed
protected Collection _mouseListeners
MouseListener
s listening for events from
this object.
Constructor Detail |
---|
public FloatingImage(Image image, int xPos, int yPos, Component parentComponent)
image
- the image to be renderedxPos
- the x co-ordinate of the left edge of the image, relative to
the left edge of the parent componentyPos
- the y co-ordinate of the top edge of the image, relative to
the top edge of the parent componentparentComponent
- the parent componentpublic FloatingImage(Image image, Point location, Component parentComponent)
image
- the image to be renderedlocation
- the co-ordinates of the top-left corner of the image,
relative to the top-left corner of the parent componentparentComponent
- the parent componentpublic FloatingImage(Image image, Component parentComponent)
image
- the image to be renderedparentComponent
- the parent componentMethod Detail |
---|
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void addMouseListener(MouseListener listener)
listener
- object that is to receive notificationspublic void removeMouseListener(MouseListener listener)
listener
- object that is no longer to receive notificationspublic void setPosition(Point position)
public void setXPosition(int xPos)
public void setYPosition(int yPos)
public Point getPosition()
public int getXPosition()
public int getYPosition()
public int getWidth()
public int getHeight()
public boolean isAtLocation(Point location)
location
- a Point
on the parent component
public void setPosition(int xPos, int yPos)
xPos
- the x co-ordinate of the left edge of the image, relative to
the left edge of the parent componentyPos
- the y co-ordinate of the top edge of the image, relative to
the top edge of the parent componentpublic void setDisplayed(boolean display)
display
- indicates if the image is to be displayedpublic void paint(Graphics g)
g
- the graphics context onto which the image is to be drawn
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |