|
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.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--jigl.gui.JImageCanvas
JImageCanvas is a SWING compatible class made to facilitate the displaying of a JIGL image. JImageCanvas 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.JImageCanvas)
{
jigl.gui.JImageCanvas canvas = (jigl.gui.JImageCanvas)e.getComponent();
canvas.clearSelectionBox();
canvas.setSelectionBoxAnchor(e.getX(),e.getY());
}
}
//MouseMotionListener method
public void mouseDragged(MouseEvent e)
{
if (e.getComponent() instanceof jigl.gui.JImageCanvas)
{
jigl.gui.JImageCanvas canvas = (jigl.gui.JImageCanvas)e.getComponent();
canvas.setSelectionBoxExtent(e.getX(),e.getY());
}
}
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| 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 javax.swing.JPanel |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| 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 | |
JImageCanvas()
Creates an empty JImageCanvas. |
|
JImageCanvas(BinaryImage image)
Creates a JImageCanvas from a GrayImage. |
|
JImageCanvas(ColorImage image)
Creates a JImageCanvas from a ColorImage. |
|
JImageCanvas(ComplexImage image)
Creates a JImageCanvas from a ComplexImage. |
|
JImageCanvas(GrayImage image)
Creates a JImageCanvas from a GrayImage. |
|
JImageCanvas(Image image)
Creates a JImageCanvas from a JIGL Image. |
|
JImageCanvas(RealColorImage image)
Creates a JImageCanvas from a RealColorImage. |
|
JImageCanvas(RealGrayImage image)
Creates a JImageCanvas from a RealGrayImage. |
|
| Method Summary | |
void |
clearSelectionBox()
Clears the selection box. |
private void |
drawActiveBox(Graphics g)
|
private void |
drawBox(Graphics g,
int ux,
int uy,
int lx,
int ly)
|
int |
getHeight()
Overridden to reflect image size. |
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. |
Dimension |
getPreferredSize()
Overridden to reflect image size. |
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()
Returns the lower x (extent) coordinate of the selection box. |
int |
getSelectionBoxExtentY()
Returns the lower y (extent) coordinate of the selection box. |
Dimension |
getSize()
Overridden to reflect image size. |
Dimension |
getSize(Dimension rv)
Overridden to reflect image size. |
int |
getWidth()
Overridden to reflect image size. |
int |
imHeight()
Returns the image height. |
int |
imWidth()
Returns the image width. |
void |
paint(Graphics g)
Overrides the paint method for smoother redraw. |
void |
paintComponent(Graphics g)
Overrides the paintComponent 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 JImageCanvas. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| 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 JImageCanvas()
public JImageCanvas(BinaryImage image)
throws ImageNotSupportedException
image - GrayImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(GrayImage image)
throws ImageNotSupportedException
image - GrayImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(ColorImage image)
throws ImageNotSupportedException
image - ColorImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(RealGrayImage image)
throws ImageNotSupportedException
image - RealGrayImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(RealColorImage image)
throws ImageNotSupportedException
image - RealColorImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(ComplexImage image)
throws ImageNotSupportedException
image - ComplexImage
ImageNotSupportedException - if the image type is not supported
public JImageCanvas(Image image)
throws ImageNotSupportedException
image - jigl.image.Image
ImageNotSupportedException - if the image type is not supported| Method Detail |
public void setImage(Image image)
image and JIGL Image to null.
image - java.awt.ImageImage
public void setImage(Image image)
throws ImageNotSupportedException
image.
image - jigl.image.Image
ImageNotSupportedException - if the image type is not supportedpublic Image getImage()
public Image getJavaImage()
public Graphics setOffScreen()
Graphics
public Graphics setOffScreen(double xfactor,
double yfactor)
xfactor - Zoom of x axis.yfactor - Zoom of y axis.
public void setVisible(boolean b)
setVisible in class JComponentb - flag: true == visiblepublic int imHeight()
public int imWidth()
public Dimension getSize()
getSize in class Componentpublic Dimension getSize(Dimension rv)
getSize in class JComponentrv - Dimension object
public int getWidth()
getWidth in class JComponentpublic int getHeight()
getHeight in class JComponentpublic Dimension getPreferredSize()
getPreferredSize in class JComponent
public Image getJavaImage(Image img)
throws ImageNotSupportedException
img - The JIGL image.
ImageNotSupportedException - if the image type is not supportedImagepublic void update(Graphics g)
update in class JComponentg - Graphicspublic void paint(Graphics g)
paint in class JComponentg - Graphics objectpublic void paintComponent(Graphics g)
paintComponent in class JComponentg - Graphics objectprivate void drawActiveBox(Graphics g)
private void drawBox(Graphics g,
int ux,
int uy,
int lx,
int ly)
public void setSelectionBoxAnchor(int ux,
int uy)
ux - Upper x coordinate of box.uy - Upper y coordinate of box.
public void setSelectionBoxExtent(int lx,
int ly)
lx - Lower x coordinate of box.ly - Lower y coordinate of box.public void showSelectionBox(boolean b)
b - true = box is displayed, false = box is not displayedpublic void clearSelectionBox()
public Rectangle getSelectionBox()
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 activepublic 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 | ||||||||||