|
JIGL v1.6 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Canvas
|
+--jigl.gui.ImageCanvas
ImageCanvas is a class made to facilitate the displaying of a JIGL image. ImageCanvas also easily supports a highlight box when active and a mouse drawn selection box. These options can be turned on or off with the showSelectionBox() and showActiveBox() methods. The options are meant to be used with the MouseListener and MouseMotionListener methods,and can be used as in the example code (demonstrating the selecton box):
Supports JIGL images, Java images (.gif, .jpg, .jpeg),and PPM images (.ppm, .pgm, .pbm).
//MouseListener method
public void mousePressed(MouseEvent e)
{
if (e.getComponent() instanceof jigl.gui.ImageCanvas)
{
jigl.gui.ImageCanvas canvas = (jigl.gui.ImageCanvas)e.getComponent();
canvas.clearSelectionBox();
canvas.setSelectionBoxAnchor(e.getX(),e.getY());
}
}
//MouseMotionListener method
public void mouseDragged(MouseEvent e)
{
if (e.getComponent() instanceof jigl.gui.ImageCanvas)
{
jigl.gui.ImageCanvas canvas = (jigl.gui.ImageCanvas)e.getComponent();
canvas.setSelectionBoxExtent(e.getX(),e.getY());
}
}
| Nested Class Summary |
| Nested classes inherited from class java.awt.Canvas |
Canvas.AccessibleAWTCanvas |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
protected Image |
image
Java image |
protected Image |
jimage
JIGL image |
private Color |
m_activeColor
|
private boolean |
m_bIsActive
|
private int |
m_boxlx
|
private int |
m_boxly
|
private int |
m_boxux
|
private int |
m_boxuy
|
private boolean |
m_bShowActive
|
private boolean |
m_bShowSelectionBox
|
| Fields inherited from class java.awt.Canvas |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
ImageCanvas()
Creates an empty ImageCanvas |
|
ImageCanvas(ColorImage image)
Creates an ImageCanvas from a ColorImage |
|
ImageCanvas(ComplexImage image)
Creates an ImageCanvas from a ComplexImage |
|
ImageCanvas(GrayImage image)
Creates an ImageCanvas from a GrayImage |
|
ImageCanvas(Image image)
Creates an ImageCanvas from a JIGL Image |
|
ImageCanvas(RealColorImage image)
Creates an ImageCanvas from a RealColorImage |
|
ImageCanvas(RealGrayImage image)
Creates an ImageCanvas from a RealGrayImage |
|
| Method Summary | |
void |
clearSelectionBox()
Clears the selection box. |
private void |
drawActiveBox(Graphics g)
Draw the active box. |
private void |
drawBox(Graphics g,
int ux,
int uy,
int lx,
int ly)
Draw a rectangle. |
Image |
getImage()
Returns the JIGL image |
Image |
getJavaImage()
Returns the Java image |
Image |
getJavaImage(Image img)
Takes a jigl image as input, converts it to a java image, and returns the java image. |
Rectangle |
getSelectionBox()
Returns the selection box in a Rectangle object. |
int |
getSelectionBoxAnchorX()
Returns the upper x (anchor) coordinate of the selection box. |
int |
getSelectionBoxAnchorY()
Returns the upper y (anchor) coordinate of the selection box. |
int |
getSelectionBoxExtentX()
Rturns the lower x (extent) coordinate of the selection box. |
int |
getSelectionBoxExtentY()
Returns the lower y (extent) coordinate of the selection box. |
int |
imHeight()
Returns the image height |
int |
imWidth()
Returns the image width |
void |
paint(Graphics g)
Overrides the paint method for smoother redraw |
void |
setActive(boolean active)
Sets whether or not the image is active. |
void |
setActiveColor(Color color)
Sets the color used to highlight the image when active (default is blue). |
void |
setImage(Image image)
Sets the Java image to image and JIGL Image to null |
void |
setImage(Image image)
Sets the JIGL Image and Java Image to image |
Graphics |
setOffScreen()
Returns an instance of Graphics that, when modified, modifies the Java image |
Graphics |
setOffScreen(double xfactor,
double yfactor)
Returns an instance of Graphics that, when modified, modifies the Java image |
void |
setSelectionBoxAnchor(int ux,
int uy)
Sets the upper corner of the selection box (ux and uy). |
void |
setSelectionBoxExtent(int lx,
int ly)
Sets the lower corner of the selection box (lx and ly). |
void |
setVisible(boolean b)
Overrides Component.setVisible(boolean) |
void |
showActiveBox(boolean b)
Sets whether or not the image is highlighted with a border when activated. |
void |
showSelectionBox(boolean b)
Sets whether or not selection box is displayed. |
void |
update(Graphics g)
Repaints the ImageCanvas. |
| Methods inherited from class java.awt.Canvas |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Image image
protected Image jimage
private boolean m_bShowSelectionBox
private boolean m_bShowActive
private boolean m_bIsActive
private Color m_activeColor
private int m_boxlx
private int m_boxly
private int m_boxux
private int m_boxuy
| Constructor Detail |
public ImageCanvas()
public ImageCanvas(GrayImage image)
throws BadImageException
image - GrayImage
BadImageException
public ImageCanvas(ColorImage image)
throws BadImageException
image - ColorImage
BadImageException
public ImageCanvas(RealGrayImage image)
throws BadImageException
image - RealGrayImage
BadImageException
public ImageCanvas(RealColorImage image)
throws BadImageException
image - RealColorImage
BadImageException
public ImageCanvas(ComplexImage image)
throws BadImageException
image - ComplexImage
BadImageException
public ImageCanvas(Image image)
throws BadImageException
image - JIGL Image
BadImageException| Method Detail |
public void setImage(Image image)
image and JIGL Image to null
image - java.awt.ImageImage
public void setImage(Image image)
throws BadImageException
image
image - JIGL Image
BadImageExceptionpublic Image getImage()
public Image getJavaImage()
Imagepublic Graphics setOffScreen()
Image
public Graphics setOffScreen(double xfactor,
double yfactor)
xfactor - Zoom of x axisyfactor - Zoom of y axis
Imagepublic void setVisible(boolean b)
setVisible in class Componentb - flag. true == visible.public int imHeight()
public int imWidth()
public Image getJavaImage(Image img)
throws BadImageException
img - The JIGL image.
BadImageExceptionImagepublic void update(Graphics g)
update in class Canvasg - Graphicsprivate void drawActiveBox(Graphics g)
private void drawBox(Graphics g,
int ux,
int uy,
int lx,
int ly)
public void paint(Graphics g)
paint in class Canvasg - Graphics object
public void setSelectionBoxAnchor(int ux,
int uy)
ux - Upper x coordinate of boxuy - Upper y coordinate of box
public void setSelectionBoxExtent(int lx,
int ly)
lx - Lower x coordinate of boxly - Lower y coordinate of boxpublic void showSelectionBox(boolean b)
b - true = box is displayed, false = box is not displayed.public void clearSelectionBox()
public Rectangle getSelectionBox()
null if no selection box is set.
public int getSelectionBoxAnchorX()
public int getSelectionBoxAnchorY()
public int getSelectionBoxExtentX()
public int getSelectionBoxExtentY()
public void setActive(boolean active)
active - true = the image is active, false = the image is not active.public void showActiveBox(boolean b)
b - true = show border when active, false = don't show borderpublic void setActiveColor(Color color)
color - Color object.
|
JIGL v1.6 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||