Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ImageViewer
ImplementsAnimation, Editable, StyleListener
ImageViewer allows zooming/panning an image and potentially flicking between multiple images within a list of images.
E.g. the trivial usage works like this:
Form hi = new Form("ImageViewer", new BorderLayout());
Image duke = FontImage.createMaterial(FontImage.MATERIAL_INFO, "Label", 3.0f);
ImageViewer iv = new ImageViewer(duke);
hi.add(BorderLayout.CENTER, iv);
hi.show();You can simulate pinch to zoom on the simulator by dragging the right button away from the top left corner to zoom in and towards the top left corner to zoom out. On Mac touchpads you can drag two fingers to achieve that.
A more elaborate usage includes flicking between multiple images e.g.:
Form hi = new Form("ImageViewer", new BorderLayout());
Image red = Image.createImage(100, 100, 0xffff0000);
Image green = Image.createImage(100, 100, 0xff00ff00);
Image blue = Image.createImage(100, 100, 0xff0000ff);
Image gray = Image.createImage(100, 100, 0xffcccccc);
ImageViewer iv = new ImageViewer(red);
iv.setImageList(new DefaultListModel<>(red, green, blue, gray));
hi.add(BorderLayout.CENTER, iv);Optional navigation affordances can be enabled when using an image list:
iv.setNavigationArrowsVisible(true);
iv.setThumbnailsVisible(true);
iv.setThumbnailBarHeight(6f);These options can also be configured globally using theme constants:
imageviewerNavigationArrowsBoolimageviewerThumbnailsBoolimageviewerThumbnailBarHeightMM
You can even download image URL’s dynamically into the ImageViewer thanks to the usage of the
com.codename1.ui.list.ListModel. E.g. in this model book cover images are downloaded dynamically:
Form hi = new Form("ImageViewer", new BorderLayout());
final EncodedImage placeholder = EncodedImage.createFromImage(
FontImage.createMaterial(FontImage.MATERIAL_SYNC, s).
scaled(300, 300), false);
class ImageList implements ListModel {
private int selection;
private String[] imageURLs = {
"http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/300px-AGameOfThrones.jpg",
"http://awoiaf.westeros.org/images/thumb/3/39/AClashOfKings.jpg/300px-AClashOfKings.jpg",
"http://awoiaf.westeros.org/images/thumb/2/24/AStormOfSwords.jpg/300px-AStormOfSwords.jpg",
"http://awoiaf.westeros.org/images/thumb/a/a3/AFeastForCrows.jpg/300px-AFeastForCrows.jpg",
"http://awoiaf.westeros.org/images/7/79/ADanceWithDragons.jpg"
};
private Image[] images;
private EventDispatcher listeners = new EventDispatcher();
public ImageList() {
this.images = new EncodedImage[imageURLs.length];
}
public Image getItemAt(final int index) {
if(images[index] == null) {
images[index] = placeholder;
Util.downloadUrlToStorageInBackground(imageURLs[index], "list" + index, (e) -> {
try {
images[index] = EncodedImage.create(Storage.getInstance().createInputStream("list" + index));
listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
} catch(IOException err) {
err.printStackTrace();
}
});
}
return images[index];
}
public int getSize() {
return imageURLs.length;
}
public int getSelectedIndex() {
return selection;
}
public void setSelectedIndex(int index) {
selection = index;
}
public void addDataChangedListener(DataChangedListener l) {
listeners.addListener(l);
}
public void removeDataChangedListener(DataChangedListener l) {
listeners.removeListener(l);
}
public void addSelectionListener(SelectionListener l) {
}
public void removeSelectionListener(SelectionListener l) {
}
public void addItem(Image item) {
}
public void removeItem(int index) {
}
};
ImageList imodel = new ImageList();
ImageViewer iv = new ImageViewer(imodel.getItemAt(0));
iv.setImageList(imodel);
hi.add(BorderLayout.CENTER, iv);Fields
public static final int IMAGE_FIT = 0 | Indicates the initial position of the image in the viewer to FIT to the component size |
public static final int IMAGE_FILL = 1 | Indicates the initial position of the image in the viewer to FILL the component size. |
Constructors
public ImageViewer() | Default constructor |
public ImageViewer(Image i) | Initializes the component with an image |
Methods
protected void resetFocusable() | Restores the state of the focusable flag to its default state |
public 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 |
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. |
public Class[] getPropertyTypes() | Matches the property names method (see that method for further details). |
public 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[],I… |
public Object getPropertyValue(String name) | Returns the current value of the property name, this method is used by the GUI builder |
public String setPropertyValue(String name, Object value) | Sets a new value to the given property, returns an error message if failed and null if successful. |
public void initComponent() | Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state |
public int getImageX() | Returns the x position of the image viewport which can be useful when it is being panned by the user |
public int getImageY() | Returns the y position of the image viewport which can be useful when it is being panned by the user |
public void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
public void keyReleased(int key) | If this Component is focused, the key released event will call this method |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
protected void dragFinished(int x, int y) | Callback indicating that the drag has finished either via drop or by releasing the component |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
protected void pinchReleased(int x, int y) | To be implemented by subclasses interested in being notified when a pinch zoom has ended (i.e the user has removed one of their fingers, but is still dragging). |
protected boolean mouseWheel(WheelEvent ev) | Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy. |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged 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 |
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 |
public void setCropMode(boolean cropMode) | Turns the crop mode on or off. |
public boolean isCropMode() | Whether the crop mode is on. |
public void setCropAspectRatio(float aspectRatio) | Sets the width-to-height ratio the crop rectangle keeps; 0 (the default) lets it take any shape. |
public float getCropAspectRatio() | The width-to-height ratio of the crop rectangle, 0 for free. |
public void setCropCircle(boolean circle) | Draws a round outline in the crop rectangle; #getCroppedImage() then makes the corners outside the circle transparent. |
public boolean isCropCircle() | Whether the crop is round. |
public Rectangle getCropBounds() | The crop rectangle in image pixels. |
public void setCropBounds(int x, int y, int w, int h) | Places the crop rectangle, in image pixels. |
public float getCropImageScale() | The scale the image is drawn at in crop mode, display pixels per image pixel. |
public void setCropImageScale(float scale) | Zooms the image in crop mode about the centre of the crop rectangle, limited so the image keeps covering the rectangle. |
public Image getCroppedImage() | The part of the image inside the crop rectangle, at the image’s own resolution; round with transparent corners when #isCropCircle(). |
public void setWidth(int width) | Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public void setHeight(int height) | Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
protected boolean isStickyDrag() | Returns true if the component is interested in receiving drag/pointer release events even after the gesture exceeded its boundaries. |
public String getAccessibilityText() | Returns the text that describes this component to assistive technologies. |
public Image getCroppedImage(int backgroundColor) | Gets the current image cropped using the current pan and zoom state. |
public Image getCroppedImage(int width, int height, int backgroundColor) | Gets the current image cropped using the current pan and zoom state. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
public boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
public boolean isAllowScaleDown() | Allows the image to scale down when image initial position is set to fit this is off by default since the UX isn’t great |
public void setAllowScaleDown(boolean allowScaleDown) | Allows the image to scale down when image initial position is set to fit this is off by default since the UX isn’t great |
public 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. |
public Image getImage() | Returns the currently showing image |
public final void setImage(Image image) | Sets the currently showing image |
public void setImageNoReposition(Image image) | Sets the current image without any changes to the panning/scaling |
public ListModel<Image> getImageList() | Returns the list model containing the images in the we can swipe through |
public void setImageList(ListModel<Image> model) | By providing this optional list of images you can allows swiping between multiple images |
public void setAnimateZoom(boolean animateZoom) | Indicates if the zoom should bee animated. |
public boolean isAnimatedZoom() | Indicates if the zoom should bee animated. |
public boolean isNavigationArrowsVisible() | Indicates if side navigation arrows should be painted for moving between images. |
public void setNavigationArrowsVisible(boolean navigationArrowsVisible) | Enables side navigation arrows (material font icons) for moving between images. |
public boolean isThumbnailsVisible() | Indicates if thumbnails should be painted in a strip at the bottom for direct image selection. |
public void setThumbnailsVisible(boolean thumbnailsVisible) | Enables a bottom thumbnail strip for direct image selection. |
public float getThumbnailBarHeight() | Gets the thumbnail strip height in millimeters. |
public void setThumbnailBarHeight(float thumbnailBarHeight) | Sets the thumbnail strip height in millimeters. |
public float getZoom() | Manipulate the zoom level of the application |
public void setZoom(float zoom) | Manipulate the zoom level of the application |
public void setZoom(float zoom, float panPositionX, float panPositionY) | Manipulate the zoom level of the application |
public Image getSwipePlaceholder() | This image is shown briefly during swiping while the full size image is loaded |
public void setSwipePlaceholder(Image swipePlaceholder) | This image is shown briefly during swiping while the full size image is loaded |
public boolean isEagerLock() | Eager locking effectively locks the right/left images as well as the main image, as a result more heap is taken |
public 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 |
public 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 |
public 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 |
public 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 |
public 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 |
public 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. |
public 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. |
public void setImageInitialPosition(int imageInitialPosition) | Sets the viewer initial image position to fill or to fit. |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, initLaf, getUIManager, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, clearClientProperties, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, getOuterWidth, getInnerWidth, getHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, fireClicked, isSelectableInteraction, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, isScrollable, isScrollableX, isScrollableY, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, getBottomGap, getSideGap, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyPressed, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, dragInitiated, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, paramString, refreshTheme, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, cancelRepaints, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Field details
IMAGE_FIT
public static final int IMAGE_FIT = 0IMAGE_FILL
public static final int IMAGE_FILL = 1Constructor details
ImageViewer
public ImageViewer()ImageViewer
public ImageViewer(Image i)Parameters
iImage- image to show
Method details
resetFocusable
protected void resetFocusable()getPropertyNames
public String[] getPropertyNames()Returns
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyTypeNames
public String[] getPropertyTypeNames()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property
Returns
initComponent
public void initComponent()getImageX
public int getImageX()Returns
getImageY
public int getImageY()Returns
deinitialize
public void deinitialize()keyReleased
public void keyReleased(int key)Parameters
keyint- the key code value to indicate a physical key.
pointerPressed
public void pointerPressed(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
dragFinished
protected void dragFinished(int x, int y)Parameters
xint- the x location
yint- the y location
pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pinchReleased
protected void pinchReleased(int x, int y)Parameters
xint- The x-coordinate of the remaining finger in the drag. (Absolute)
yint- The y-coordinate of the remaining finger in the drag. (Absolute)
mouseWheel
protected boolean mouseWheel(WheelEvent ev)Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy.
A component that moves its own content – an editor that scrolls itself, a viewer that pans – implements this. Everything else leaves it alone and the wheel scrolls the nearest scrollable ancestor, which is what a wheel means.
This exists because a wheel used to arrive as a synthetic press, drag and release played into the component tree: a component that wanted the wheel got it by handling pointer events, and so did every component that did not want it. The events are gone and this is what replaces them, for the few components that have something of their own to move.
A wheel pans a zoomed image, which is what a wheel over a picture means on a
desktop, and leaves an unzoomed one alone so the page it sits on scrolls instead.
Zoom is the wheel with a modifier, which the ports already deliver as a magnify
gesture – see #pinch(float).
Parameters
evWheelEvent- the wheel event, carrying the scroll deltas in display pixels
Returns
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
laidOut
protected void laidOut()pinch
protected boolean pinch(float scale)Parameters
scalefloat- the scaling of the pinch operation a number larger than 1 means scaling up and smaller than 1 means scaling down. It is recommended that code would threshold the number (so a change between 1.0 and 1.02 shouldn’t necessarily trigger zoom). Notice that this number is relevant to current zoom levels and unaware of them so you should also enforce limits of maximum/minimum zoom levels.
Returns
setCropMode
public void setCropMode(boolean cropMode)Turns the crop mode on or off. In crop mode the viewer shows its image
under a crop rectangle the user can move and resize, and
#getCroppedImage() returns the part inside it: the profile picture and
attachment cropping step.
ImageViewer cropper = new ImageViewer(Image.createImage(600, 400, 0xff336699));
cropper.setCropMode(true);
cropper.setCropAspectRatio(1f);
cropper.setCropCircle(true);
Image avatar = cropper.getCroppedImage();Drag inside the rectangle to move it and drag a corner to resize it.
Drag outside it to pan the image, and pinch to zoom the image. With an
aspect ratio set, a resize keeps the rectangle’s proportions. With the
circle overlay on, a round outline is drawn and #getCroppedImage()
makes the corners transparent. Swiping between the images of an image
list is off while cropping.
Parameters
cropModeboolean- true to crop
isCropMode
public boolean isCropMode()Returns
setCropAspectRatio
public void setCropAspectRatio(float aspectRatio)Parameters
aspectRatiofloat- the ratio, for example 1 for a square
getCropAspectRatio
public float getCropAspectRatio()Returns
setCropCircle
public void setCropCircle(boolean circle)#getCroppedImage() then
makes the corners outside the circle transparent.Parameters
circleboolean- true for a round crop
isCropCircle
public boolean isCropCircle()Returns
getCropBounds
public Rectangle getCropBounds()Returns
#getCroppedImage() returnssetCropBounds
public void setCropBounds(int x, int y, int w, int h)Parameters
xint- the left edge
yint- the top edge
wint- the width
hint- the height
getCropImageScale
public float getCropImageScale()Returns
setCropImageScale
public void setCropImageScale(float scale)Parameters
scalefloat- display pixels per image pixel
getCroppedImage
public Image getCroppedImage()#isCropCircle().
Outside crop mode this is the visible pan/zoom window, as
#getCroppedImage(int) with a black background returns it.Returns
setWidth
public void setWidth(int width)Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
widthint- the width of the component
See also
setHeight
public void setHeight(int height)Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
heightint- the height of the component
See also
isStickyDrag
protected boolean isStickyDrag()Returns
getAccessibilityText
public String getAccessibilityText()Returns
null if nonegetCroppedImage
public Image getCroppedImage(int backgroundColor)Parameters
backgroundColorint- The background color, visible for letterboxing.
Returns
getCroppedImage
public Image getCroppedImage(int width, int height, int backgroundColor)Parameters
widthint- The width of the cropped image. Use -1 to match aspect ratio of the ImageViewer component. Either height or width must be positive.
heightint- The height of the cropped image. Use -1 to match aspect ratio of the ImageViewer component. Either height or width must be positive.
backgroundColorint- Background color to use for letterboxing.
Returns
calcPreferredSize
protected Dimension calcPreferredSize()Returns
animate
public boolean animate()com.codename1.ui.Display class.Returns
isAllowScaleDown
public boolean isAllowScaleDown()Returns
setAllowScaleDown
public void setAllowScaleDown(boolean allowScaleDown)Parameters
allowScaleDownboolean- the allowScaleDown to set
paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
paintBackground
protected void paintBackground(Graphics g)Parameters
gGraphics- the component graphics
getImage
public Image getImage()Returns
setImage
public final void setImage(Image image)Parameters
imageImage- the image to set
setImageNoReposition
public void setImageNoReposition(Image image)Parameters
imageImage- new image instance
getImageList
public ListModel<Image> getImageList()Returns
setImageList
public void setImageList(ListModel<Image> model)Parameters
modelListModel<Image>- a list of images
setAnimateZoom
public void setAnimateZoom(boolean animateZoom)Parameters
animateZoomboolean- true if zoom is animated
isAnimatedZoom
public boolean isAnimatedZoom()Returns
isThumbnailsVisible
public boolean isThumbnailsVisible()Returns
true if the thumbnail strip is visible.setThumbnailsVisible
public void setThumbnailsVisible(boolean thumbnailsVisible)Parameters
thumbnailsVisiblebooleantrueto show thumbnails.
getThumbnailBarHeight
public float getThumbnailBarHeight()Returns
setThumbnailBarHeight
public void setThumbnailBarHeight(float thumbnailBarHeight)Parameters
thumbnailBarHeightfloat- Height of the thumbnail strip in millimeters.
getZoom
public float getZoom()Returns
setZoom
public void setZoom(float zoom)Parameters
zoomfloat- the zoom to set
setZoom
public void setZoom(float zoom, float panPositionX, float panPositionY)Parameters
zoomfloat- the zoom to set
panPositionXfloat- A float value between 0 and 1 to set the image x position
panPositionYfloat- A float value between 0 and 1 to set the image y position
getSwipePlaceholder
public Image getSwipePlaceholder()Returns
setSwipePlaceholder
public void setSwipePlaceholder(Image swipePlaceholder)Parameters
swipePlaceholderImage- the swipePlaceholder to set
isEagerLock
public boolean isEagerLock()Returns
setEagerLock
public void setEagerLock(boolean eagerLock)Parameters
eagerLockboolean- the eagerLock to set
isCycleLeft
public boolean isCycleLeft()Returns
setCycleLeft
public void setCycleLeft(boolean cycleLeft)Parameters
cycleLeftboolean- the cycle left to set
isCycleRight
public boolean isCycleRight()Returns
setCycleRight
public void setCycleRight(boolean cycleRight)Parameters
cycleRightboolean- the cycle right to set
getSwipeThreshold
public float getSwipeThreshold()Returns
setSwipeThreshold
public void setSwipeThreshold(float swipeThreshold)Parameters
swipeThresholdfloat- the swipeThreshold to set
setImageInitialPosition
public void setImageInitialPosition(int imageInitialPosition)Parameters
imageInitialPositionint- values can be IMAGE_FILL or IMAGE_FIT