@BeanSettings(acceptChildren=true, useXdevCustomizer=true) public class XdevPicture extends XdevComponent implements ImageFormularComponent<XdevPicture>
Provides methods to load and change pictures.
Supported image formats: see
ImageFileFilter.getSupportedImageExtensions()
XdevComponent
,
FormularComponent
,
Serialized FormJPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
FormularComponent.ValueChangeListener
Modifier and Type | Field and Description |
---|---|
static String |
AUTO_RESIZE_PROPERTY |
static String |
IMAGE_PROPERTY |
static String |
OUTPUT_FORMAT_PROPERTY |
static int |
RESIZE_FIT |
static String |
RESIZE_MODE_PROPERTY |
static int |
RESIZE_STRETCH |
alpha, alphaColors, alphaCondition, alphaFilter, alphaTolerance, clip, filteredImage, imageBounds, remakeImages, style, useAlphaFilter
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DATA_FIELD_SEPARATOR
DATA_FIELD, FORMULAR_CONDITION_FILTER, FORMULAR_CONDITION_PRECISION, FORMULAR_FILTER_OPERATOR, FORMULAR_SKIP, FORMULAR_VERIFIER, TAG_DATA
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
XdevPicture()
Creates an empty
XdevPicture . |
XdevPicture(Image image)
Creates an
XdevPicture and load the image. |
XdevPicture(String imagePath)
Creates an
XdevPicture and load the image from the
imagePath immediately. |
XdevPicture(String imagePath,
boolean loadImmediately)
Creates an
XdevPicture with the given imagePath . |
XdevPicture(XdevImage image)
Creates an
XdevPicture and load the image. |
Modifier and Type | Method and Description |
---|---|
void |
addValidator(Validator validator)
Adds a validator to this component
|
void |
addValueChangeListener(FormularComponent.ValueChangeListener l)
Registers a
FormularComponent.ValueChangeListener . |
void |
clear() |
protected void |
finalize() |
String |
getDataField()
Returns the name of the bound data field of this formular component.
|
Operator |
getFilterOperator()
Returns the operator used in
Formular.createCondition(String) |
String |
getFormularName()
Returns the name of the component in the formular context.
|
Object |
getFormularValue()
Returns the value of the component.
|
XdevImage |
getImage()
Returns the image of this
ImageFormularComponent . |
String |
getImagePath()
Returns the image path of this
XdevPicture . |
String |
getOutputFormat()
Returns the output format of this
XdevPicture . |
XdevImage |
getResizedImage()
Returns the resized image, may be the same as
getImage() if the
component's size matches the size of the image. |
int |
getResizeMode()
|
Validator[] |
getValidators()
Returns all validators of this component.
|
boolean |
hasStateChanged()
Checks if the component's state since the last call of
FormularComponent.saveState() has changed. |
protected void |
imageLoaded(Image image,
boolean resize)
|
boolean |
isAutoResize()
Returns
true if this XdevPicture is auto resizable. |
boolean |
isMultiSelect()
Returns whether the component supports multi selection or not.
|
boolean |
isOpaque() |
boolean |
isReadOnly()
Determines whether this component is only used to display values.
|
protected Image |
loadImage() |
void |
loadImage(byte[] data) |
void |
loadImage(byte[] data,
boolean resize) |
void |
loadImage(File file) |
void |
loadImage(File file,
boolean resize) |
void |
loadImage(InputStream in) |
void |
loadImage(InputStream in,
boolean resize) |
void |
loadImage(String path) |
void |
loadImage(String path,
boolean resize) |
void |
loadImage(URL url) |
void |
loadImage(URL url,
boolean resize) |
protected boolean |
paintComponent() |
protected void |
paintImage(Graphics2D g)
TODO
|
void |
refresh()
Refresh this
XdevPicture . |
void |
refresh(boolean resize)
Refresh this
XdevPicture . |
protected void |
refresh(boolean resize,
boolean inThread) |
void |
removeNotify() |
void |
removeValidator(Validator validator)
Removes a validator from this component
|
protected Image |
resizeImage(Image image) |
void |
restoreState()
Restores the internally saved state of the component.
|
void |
saveState()
Saves the state of the component internally.
|
void |
setAutoResize(boolean autoResize) |
void |
setDataField(String dataField)
Sets the name of the bound data field of this formular component.
|
void |
setFilterOperator(Operator filterOperator)
Sets the filter operator used in
Formular.createCondition(String) |
void |
setFont(Font font) |
void |
setForeground(Color fg) |
void |
setFormularValue(VirtualTable vt,
int col,
Object value)
Deprecated.
|
void |
setFormularValue(VirtualTable vt,
Map<String,Object> record)
Sets the value of the component, taking the value(s) of the record
according to
FormularComponent.getDataField() . |
void |
setImage(Image image) |
void |
setImage(Image image,
boolean resize) |
void |
setImage(String imagePath)
Sets the path of the image and load the picture.
|
void |
setImage(String imagePath,
boolean resize)
Sets the path of the image and loads the picture.
|
void |
setImage(XdevImage image)
|
void |
setImage(XdevImage image,
boolean resize) |
void |
setImagePath(String path)
Sets the path of the image.
|
void |
setOutputFormat(String outputFormat)
Sets the output format of this
XdevPicture . |
void |
setReadOnly(boolean readOnly)
Sets if this form component is only used to display values.
|
void |
setResizeMode(int resizeMode)
Sets the resize mode and refresh the
XdevPicture . |
void |
validateState()
Calls
Validator.validate(Object) of all registered
Validator s. |
void |
validateState(Validation validation)
Calls
Validator.validate(Object) of all registered
Validator s. |
boolean |
verify()
Returns whether the component's value adheres all set constraints.
|
checkAlphaUse, createG2D, drawTexture, forcePaint, getAlpha, getAlphaColors, getAlphaCondition, getAlphaTolerance, getBackgroundType, getBorderInsets, getGradientAlign, getGradientColor1, getGradientColor2, getSizeForFilter, getTexture, getTextureOption, getTexturePath, paintBackground, paintComponent, setAlpha, setAlphaColors, setAlphaCondition, setAlphaTolerance, setBackgroundType, setBorderTitle, setGradientAlign, setGradientColor1, setGradientColor2, setTexture, setTextureOption, setTexturePath, toString, update
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getClientProperty, isEnabled, isVisible, putClientProperty
public static final String RESIZE_MODE_PROPERTY
public static final String AUTO_RESIZE_PROPERTY
public static final String OUTPUT_FORMAT_PROPERTY
public static final String IMAGE_PROPERTY
public static final int RESIZE_STRETCH
public static final int RESIZE_FIT
public XdevPicture()
XdevPicture
.XdevPicture(String, boolean)
public XdevPicture(String imagePath)
XdevPicture
and load the image from the
imagePath
immediately.imagePath
- the path of the imageXdevPicture(String, boolean)
public XdevPicture(String imagePath, boolean loadImmediately)
XdevPicture
with the given imagePath
.imagePath
- the path of the imageloadImmediately
- true
if the picture is loaded immediately,
otherwise false
refresh(boolean, boolean)
public XdevPicture(XdevImage image)
XdevPicture
and load the image. The
XdevPicture
is not resizeable.image
- the XdevImage
XdevPicture(Image)
public XdevPicture(Image image)
XdevPicture
and load the image. The
XdevPicture
is not resizeable.image
- the imageXdevPicture(String, boolean)
public boolean isOpaque()
isOpaque
in class XdevComponent
protected boolean paintComponent()
paintComponent
in class XdevComponent
public void setResizeMode(int resizeMode) throws IllegalArgumentException
XdevPicture
.resizeMode
- RESIZE_STRETCH
or RESIZE_FIT
IllegalArgumentException
- if the resizeMode
is not supportedrefresh()
public int getResizeMode()
int
public void setAutoResize(boolean autoResize)
public boolean isAutoResize()
true
if this XdevPicture
is auto resizable.true
if this XdevPicture
is auto resizable,
otherwise false
public void setOutputFormat(String outputFormat) throws IllegalArgumentException
XdevPicture
.
Default supported formats are: JPG, PNG, GIF and BMP.
outputFormat
- a String
with the new output formatIllegalArgumentException
- if the outputFormat
is null
or not
supportedImageFileFilter.getSupportedImageExtensions()
,
ImageFileFilter.checkImageFormat(String)
public String getOutputFormat()
XdevPicture
. (Standard output
format is PNG
)
Default supported formats are: JPG, PNG, GIF and BMP.
public XdevImage getImage()
ImageFormularComponent
.getImage
in interface ImageFormularComponent<XdevPicture>
XdevImage
including the image of this
ImageFormularComponent
; if the image is null
, null
is returnedpublic XdevImage getResizedImage()
getImage()
if the
component's size matches the size of the image.public void setImage(XdevImage image)
setImage
in interface ImageFormularComponent<XdevPicture>
image
- XdevImage
to be displayedpublic void setImage(XdevImage image, boolean resize)
public void setImage(Image image)
public void setImage(Image image, boolean resize)
public void setImage(String imagePath)
This is an alias for setImage(String, boolean)
.
imagePath
- the image pathpublic void setImage(String imagePath, boolean resize)
imagePath
- the path of the imageresize
- true
to adjust the component's sizerefresh(boolean)
public String getImagePath()
XdevPicture
.public void setImagePath(String path)
path
- the image pathpublic void loadImage(InputStream in) throws IOException
IOException
public void loadImage(InputStream in, boolean resize) throws IOException
IOException
public void loadImage(File file) throws IOException
IOException
public void loadImage(File file, boolean resize) throws IOException
IOException
public void loadImage(URL url) throws IOException
IOException
public void loadImage(URL url, boolean resize) throws IOException
IOException
public void loadImage(byte[] data)
public void loadImage(byte[] data, boolean resize)
public void loadImage(String path)
public void loadImage(String path, boolean resize)
public void refresh()
XdevPicture
.
This is an alias for refresh(boolean)
.
public void refresh(boolean resize)
XdevPicture
.
This is an alias for refresh(boolean, boolean)
.
resize
- protected void refresh(boolean resize, boolean inThread)
protected Image loadImage()
protected void imageLoaded(Image image, boolean resize)
image
- Image
to be displayedresize
- true
to adjust the component's sizepublic void clear()
protected void paintImage(Graphics2D g)
paintImage
in class XdevComponent
public String getFormularName()
getFormularName
in interface FormularComponent<XdevPicture>
public void setDataField(String dataField)
setDataField
in interface FormularComponent<XdevPicture>
dataField
- the new bound data fieldpublic String getDataField()
getDataField
in interface FormularComponent<XdevPicture>
@Deprecated public final void setFormularValue(VirtualTable vt, int col, Object value)
value
. The value is formatted using the column format of the
provided VirtualTable
and columnIndex
.setFormularValue
in interface FormularComponent<XdevPicture>
vt
- VirtualTable
to use the format fromcol
- of the column to use the format fromvalue
- value to setpublic void setFormularValue(VirtualTable vt, Map<String,Object> record)
FormularComponent.getDataField()
.setFormularValue
in interface FormularComponent<XdevPicture>
vt
- the underlying virtual tablerecord
- the data <column,value>public Object getFormularValue()
getFormularValue
in interface FormularComponent<XdevPicture>
public void saveState()
A saved state can be restored using FormularComponent.restoreState()
.
saveState
in interface FormularComponent<XdevPicture>
public void restoreState()
The state of the component can be saved using FormularComponent.saveState()
.
restoreState
in interface FormularComponent<XdevPicture>
public boolean hasStateChanged()
FormularComponent.saveState()
has changed.hasStateChanged
in interface FormularComponent<XdevPicture>
true
if the component's state has changed,
false
otherwisepublic void addValueChangeListener(FormularComponent.ValueChangeListener l)
FormularComponent.ValueChangeListener
.addValueChangeListener
in interface FormularComponent<XdevPicture>
l
- the listener to registerpublic boolean isMultiSelect()
A component that supports multi selection can have more than one selected item / value.
isMultiSelect
in interface FormularComponent<XdevPicture>
true
if the component supports multi
selection, false
otherwise.public boolean verify()
This is a alternative method for FormularComponent.validateState()
, but this
method returns a boolean depending on the validation's result and doesn't
throw an ValidationException
.
verify
in interface FormularComponent<XdevPicture>
true
if the value of the component adheres all set
constraints; otherwise false
.public void addValidator(Validator validator)
addValidator
in interface FormularComponent<XdevPicture>
validator
- the validator to addFormularComponent.validateState()
public void removeValidator(Validator validator)
removeValidator
in interface FormularComponent<XdevPicture>
validator
- the validator to removeFormularComponent.validateState()
public Validator[] getValidators()
If no validator is present an empty array is returned.
getValidators
in interface FormularComponent<XdevPicture>
public void validateState() throws ValidationException
Validator.validate(Object)
of all registered
Validator
s.validateState
in interface FormularComponent<XdevPicture>
ValidationException
FormularComponent.verify()
public void validateState(Validation validation) throws ValidationException
Validator.validate(Object)
of all registered
Validator
s.
Every ValidationException
is recorded in the
validation
object, and if
Validation.continueValidation(ValidationException)
returns
false
this exception is re-thrown by this method.
validateState
in interface FormularComponent<XdevPicture>
validation
- the validation process objectValidationException
FormularComponent.verify()
public void setFilterOperator(Operator filterOperator)
Formular.createCondition(String)
setFilterOperator
in interface FormularComponent<XdevPicture>
filterOperator
- the new filter operatorpublic Operator getFilterOperator()
Formular.createCondition(String)
getFilterOperator
in interface FormularComponent<XdevPicture>
public void setReadOnly(boolean readOnly)
setReadOnly
in interface FormularComponent<XdevPicture>
readOnly
- true
to only display valuespublic boolean isReadOnly()
isReadOnly
in interface FormularComponent<XdevPicture>
true
if this component is only used to display
values.public void removeNotify()
removeNotify
in class JComponent
protected void finalize() throws Throwable
public void setForeground(Color fg)
setForeground
in class JComponent
public void setFont(Font font)
setFont
in class JComponent
Copyright © 2003–2022 XDEV Software. All rights reserved.