public class ImageViewer extends Component
Modifier and Type | Field and Description |
---|---|
static int |
IMAGE_FILL
Indicates the initial position of the image in the viewer to FILL the
component size.
|
static int |
IMAGE_FIT
Indicates the initial position of the image in the viewer to FIT to the
component size
|
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP
Constructor and Description |
---|
ImageViewer()
Default constructor
|
ImageViewer(Image i)
Initializes the component with an image
|
Modifier and Type | Method and Description |
---|---|
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
void |
deinitialize()
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
Image |
getImage()
Returns the currently showing image
|
ListModel<Image> |
getImageList()
Returns the list model containing the images in the we can swipe through
|
int |
getImageX()
Returns the x position of the image viewport which can be useful when it is being panned by the user
|
int |
getImageY()
Returns the y position of the image viewport which can be useful when it is being panned by the user
|
String[] |
getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this
API is designed for usage internally by the GUI builder code
|
String[] |
getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren't
identified properly, it returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
Image |
getSwipePlaceholder()
This image is shown briefly during swiping while the full size image is loaded
|
float |
getSwipeThreshold()
The swipe threshold is a number between 0 and 1 that indicates the threshold
after which the swiped image moves to the next image.
|
float |
getZoom()
Manipulate the zoom level of the application
|
void |
initComponent()
Allows subclasses to bind functionality that relies on fully initialized and
"ready for action" component state
|
boolean |
isCycleLeft()
By default the ImageViewer cycles from the beginning to the end of the list
when going to the left, setting this to false prevents this behaviour
|
boolean |
isCycleRight()
By default the ImageViewer cycles from the end to the beginning of the list
when going to the right, setting this to false prevents this behaviour
|
boolean |
isEagerLock()
Eager locking effectively locks the right/left images as well as the main image, as a result
more heap is taken
|
void |
keyReleased(int key)
If this Component is focused, the key released event
will call this method
|
protected void |
laidOut()
This is a callback method to inform the Component when it's been laidout
on the parent Container
|
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden
by subclasses to perform custom drawing or invoke the UI API's to let
the PLAF perform the rendering.
|
protected void |
paintBackground(Graphics g)
This method paints the Component background, it should be overriden
by subclasses to perform custom background drawing.
|
protected boolean |
pinch(float scale)
Invoked by subclasses interested in handling pinch to zoom events, if true is returned
other drag events will not be broadcast
|
void |
pointerDragged(int x,
int y)
If this Component is focused, the pointer dragged event
will call this method
|
void |
pointerPressed(int x,
int y)
If this Component is focused, the pointer pressed event
will call this method
|
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event
will call this method
|
protected void |
resetFocusable()
Restores the state of the focusable flag to its default state
|
void |
setCycleLeft(boolean cycleLeft)
By default the ImageViewer cycles from the beginning to the end of the list
when going to the left, setting this to false prevents this behaviour
|
void |
setCycleRight(boolean cycleRight)
By default the ImageViewer cycles from the end to the beginning of the list
when going to the right, setting this to false prevents this behaviour
|
void |
setEagerLock(boolean eagerLock)
Eager locking effectively locks the right/left images as well as the main image, as a result
more heap is taken
|
void |
setImage(Image image)
Sets the currently showing image
|
void |
setImageInitialPosition(int imageInitialPosition)
Sets the viewer initial image position to fill or to fit.
|
void |
setImageList(ListModel<Image> model)
By providing this optional list of images you can allows swiping between multiple images
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setSwipePlaceholder(Image swipePlaceholder)
This image is shown briefly during swiping while the full size image is loaded
|
void |
setSwipeThreshold(float swipeThreshold)
The swipe threshold is a number between 0 and 1 that indicates the threshold
after which the swiped image moves to the next image.
|
void |
setZoom(float zoom)
Manipulate the zoom level of the application
|
protected boolean |
shouldBlockSideSwipe()
A component that might need side swipe such as the slider
could block it from being used for some other purpose when
on top of said component.
|
addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, bindProperty, calcScrollSize, cancelRepaints, clearClientProperties, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, initLaf, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyRepeated, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, paramString, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString, unbindProperty
public static final int IMAGE_FIT
public static final int IMAGE_FILL
public ImageViewer()
public ImageViewer(Image i)
i
- image to showprotected void resetFocusable()
Component
resetFocusable
in class Component
public String[] getPropertyNames()
Component
getPropertyNames
in class Component
protected boolean shouldBlockSideSwipe()
Component
shouldBlockSideSwipe
in class Component
public Class[] getPropertyTypes()
Component
getPropertyTypes
in class Component
public String[] getPropertyTypeNames()
Component
getPropertyTypeNames
in class Component
public Object getPropertyValue(String name)
Component
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
Component
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic void initComponent()
Component
initComponent
in class Component
public int getImageX()
public int getImageY()
public void deinitialize()
Component
deinitialize
in class Component
public void keyReleased(int key)
Component
keyReleased
in class Component
key
- the key code value to indicate a physical key.public void pointerPressed(int x, int y)
Component
pointerPressed
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
Component
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerDragged(int x, int y)
Component
pointerDragged
in class Component
x
- the pointer x coordinatey
- the pointer y coordinateprotected void laidOut()
Component
protected boolean pinch(float scale)
Component
protected Dimension calcPreferredSize()
Component
calcPreferredSize
in class Component
public boolean animate()
Animation
Display
class.public void paint(Graphics g)
Component
protected void paintBackground(Graphics g)
Component
paintBackground
in class Component
g
- the component graphicspublic Image getImage()
public void setImage(Image image)
image
- the image to setpublic void setImageList(ListModel<Image> model)
list
- a list of imagespublic ListModel<Image> getImageList()
public float getZoom()
public void setZoom(float zoom)
zoom
- the zoom to setpublic Image getSwipePlaceholder()
public void setSwipePlaceholder(Image swipePlaceholder)
swipePlaceholder
- the swipePlaceholder to setpublic boolean isEagerLock()
public void setEagerLock(boolean eagerLock)
eagerLock
- the eagerLock to setpublic boolean isCycleLeft()
public void setCycleLeft(boolean cycleLeft)
cycleLeft
- the cycle left to setpublic boolean isCycleRight()
public void setCycleRight(boolean cycleRight)
cycleRight
- the cycle right to setpublic float getSwipeThreshold()
public void setSwipeThreshold(float swipeThreshold)
swipeThreshold
- the swipeThreshold to setpublic void setImageInitialPosition(int imageInitialPosition)
imageInitialPosition
- values can be IMAGE_FILL or IMAGE_FIT