|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.zfqjava.swing.JImageViewer
public class JImageViewer
JImageViewer provides a panel to display images, adding
support to zoom and rotate the image.
| Nested Class Summary | |
|---|---|
protected class |
JImageViewer.AccessibleJImageViewer
This class implements accessibility support for the JImageViewer class. |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected AccessibleContext |
accessibleContext
|
static int |
AUTO_SIZE_MODE
The JImageViewer is sized equal to the size of the
image that it contains. |
static int |
CENTER_IMAGE_SIZE_MODE
The image is displayed in the center if the JImageViewer is
larger than the image. |
static int |
HORIZONTAL
Indicates the horizontal filp orientation. |
static int |
NORMAL_SIZE_MODE
The image is placed in the upper-left corner of the JImageViewer. |
static int |
ROTATE_180
Identifies the rotate mode is rotate 180 degree in clockwise. |
static int |
ROTATE_270
Identifies the rotate mode is rotate 270 degree in clockwise. |
static int |
ROTATE_90
Identifies the rotate mode is rotate 90 degree in clockwise. |
static int |
ROTATE_NONE
Identifies the rotate mode is none. |
static int |
STRETCH_IMAGE_SIZE_MODE
The image within the JImageViewer is stretched or shrunk to
fit the size of the JImageViewer. |
static int |
VERTICAL
Indicates the vertical filp orientation. |
| Fields inherited from class javax.swing.JComponent |
|---|
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.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 | |
|---|---|
JImageViewer()
Constructs a JImageViewer. |
|
JImageViewer(Image image)
Constructs a JImageViewer. |
|
| Method Summary | |
|---|---|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JImageViewer. |
Image |
getImage()
Returns the display image. |
ImageIcon |
getImageIcon()
Returns the display image icon. |
Dimension |
getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for a view component. |
Dimension |
getPreferredSize()
|
int |
getRotateMode()
Returns the rotate mode. |
int |
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation. |
boolean |
getScrollableTracksViewportHeight()
Return true if a viewport should always force the height of this Scrollable to match the height of the viewport. |
boolean |
getScrollableTracksViewportWidth()
Return true if a viewport should always force the width of this Scrollable to match the width of the viewport. |
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. |
int |
getSizeMode()
Returns the JImageViewer size mode in use. |
double |
getZoomFactor()
Returns the current zoom factor. |
boolean |
isHorizontalFlipEnabled()
Determines the horizontal flip property. |
boolean |
isVerticalFlipEnabled()
Determines the vertical flip property. |
protected void |
paintComponent(Graphics g)
|
protected String |
paramString()
Returns a string representation of this JImageViewer. |
void |
reset()
Resets the image to the original state, no zooming and no rotate and no filp. |
void |
rotate(boolean clockwise)
Rotates the image use the specify clockwise flag. |
void |
setHorizontalFlipEnabled(boolean enabled)
Sets the horizontal flip property. |
void |
setImage(Image image)
Sets the image to display. |
void |
setImageIcon(ImageIcon imageIcon)
Sets the image icon to display. |
void |
setRotateMode(int rotateMode)
Sets the rotate mode. |
void |
setSizeMode(int sizeMode)
Sets the JImageViewer size mode. |
void |
setVerticalFlipEnabled(boolean enabled)
Sets the vertical flip property. |
void |
setZoomFactor(double factor)
Sets the current zoom factor. |
void |
zoom(double factor)
Zooms the image use the specify zoom factor based the current zoom factor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int AUTO_SIZE_MODE
JImageViewer is sized equal to the size of the
image that it contains.
public static final int CENTER_IMAGE_SIZE_MODE
JImageViewer is
larger than the image. If the image is larger than
the JImageViewer, the picture is placed in the center of
the JImageViewer and the outside edges are clipped.
public static final int NORMAL_SIZE_MODE
JImageViewer.
The image is clipped if it is larger than the JImageViewer
it is contained in.
public static final int STRETCH_IMAGE_SIZE_MODE
JImageViewer is stretched or shrunk to
fit the size of the JImageViewer.
public static final int HORIZONTAL
public static final int VERTICAL
public static final int ROTATE_NONE
public static final int ROTATE_90
public static final int ROTATE_180
public static final int ROTATE_270
protected AccessibleContext accessibleContext
| Constructor Detail |
|---|
public JImageViewer()
JImageViewer.
JImageViewer(java.awt.Image)public JImageViewer(Image image)
JImageViewer.
image - the image to displayJImageViewer(java.awt.Image)| Method Detail |
|---|
public void setSizeMode(int sizeMode)
JImageViewer size mode.
The size mode of the JImageViewer:
sizeMode - the size mode of the JImageViewer
IllegalArgumentException - if the size mode is illegalgetSizeMode()public int getSizeMode()
JImageViewer size mode in use.
The size mode of the JImageViewer:
JImageViewersetSizeMode(int)public void setImage(Image image)
image - the image to display#setImage(File)public Image getImage()
public void setImageIcon(ImageIcon imageIcon)
image - the image icon to display#setImageIcon(File)public ImageIcon getImageIcon()
setImageIcon(javax.swing.ImageIcon)public void setZoomFactor(double factor)
factor - the current zoom factorgetZoomFactor()public double getZoomFactor()
setZoomFactor(double)public void setRotateMode(int rotateMode)
One of 4 legal values:
int - the rotate modegetRotateMode()public int getRotateMode()
One of 4 legal values:
setRotateModepublic void setHorizontalFlipEnabled(boolean enabled)
enabled - the horizontal flip propertyisHorizontalFlipEnabled()public boolean isHorizontalFlipEnabled()
setHorizontalFlipEnabled(boolean)public void setVerticalFlipEnabled(boolean enabled)
enabled - the vertical flip propertyisVerticalFlipEnabled()public boolean isVerticalFlipEnabled()
setVerticalFlipEnabled(boolean)public void zoom(double factor)
factor - the zoom factorsetZoomFactor(double)public void rotate(boolean clockwise)
clockwise - the rotate directionsetRotateMode(int),
getRotateMode()public void reset()
public Dimension getPreferredSize()
getPreferredSize in class JComponentprotected void paintComponent(Graphics g)
paintComponent in class JComponentpublic Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize in interface ScrollableJComponent.getPreferredSize()
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Scrolling containers, like JScrollPane, will use this method each time the user requests a unit scroll.
getScrollableUnitIncrement in interface ScrollablevisibleRect - The view area visible within the viewportorientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.direction - Less than zero to scroll up/left, greater than zero for down/right.
JScrollBar.setUnitIncrement(int)
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
Scrolling containers, like JScrollPane, will use this method each time the user requests a block scroll.
getScrollableBlockIncrement in interface ScrollablevisibleRect - The view area visible within the viewportorientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.direction - Less than zero to scroll up/left, greater than zero for down/right.
JScrollBar.setBlockIncrement(int)public boolean getScrollableTracksViewportWidth()
Scrollable to match the width of the viewport.
For example a normal
text view that supported line wrapping would return true here, since it
would be undesirable for wrapped lines to disappear beyond the right
edge of the viewport. Note that returning true for a Scrollable
whose ancestor is a JScrollPane effectively disables horizontal
scrolling.
Scrolling containers, like JViewport, will use this method each time they are validated.
getScrollableTracksViewportWidth in interface Scrollablepublic boolean getScrollableTracksViewportHeight()
Scrolling containers, like JViewport, will use this method each time they are validated.
getScrollableTracksViewportHeight in interface Scrollableprotected String paramString()
JImageViewer.
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null.
paramString in class JComponentJImageViewerpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponent
|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||