java.lang.Object
org.autogui.base.mapping.GuiReprValue
org.autogui.swing.mapping.GuiReprValueImagePane
- All Implemented Interfaces:
GuiRepresentation
a GUI representation for a property holding an
Image
.
the representation depends on some AWT classes (java.desktop module)
@GuiIncluded public Image imageProp;
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a special value of history entry which has an image, and it's source file pathstatic class
anImageObserver
for obtaining the size of an imagestatic interface
support object forgetRenderedImage(GuiMappingContext, Object)
static class
impl of the support interfaceNested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothing
Nested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static GuiReprValueImagePane
the global instance set byGuiReprValueImagePane(boolean)
with trueFields inherited from class org.autogui.base.mapping.GuiReprValue
NONE, NONE_WITH_CACHE
-
Constructor Summary
ConstructorsConstructorDescriptionthe created instance will not be the global instanceGuiReprValueImagePane
(boolean processGlobal) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHistoryValue
(GuiMappingContext context, Object value) fromHumanReadableString
(GuiMappingContext context, String str) fromJson
(GuiMappingContext context, Object target, Object json) create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents.getBufferedImage
(GuiMappingContext context, Object source) static BufferedImage
getBufferedImageWithSupport
(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) impl.getImagePath
(Image image) static GuiReprValueImagePane
return the default global instance of the class, useful forgetImagePath(Image)
.getRenderedImage
(GuiMappingContext context, Object source) static RenderedImage
getRenderedImageWithSupport
(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) impl.getSize
(GuiMappingContext context, Image image) boolean
isHistoryValueStored
(Object value) only images which have beensetImagePath(Image, Path)
will be stored as its path throughGuiReprValueImagePane.ImageHistoryEntry
.boolean
boolean
matchValueType
(Class<?> cls) void
setImagePath
(Image image, Path path) toHumanReadableString
(GuiMappingContext context, Object source) method for constructing "toString" copy operations: the returned string will be separated by tabs and new-linestoJson
(GuiMappingContext context, Object source) convert the source into JSON formatvoid
updateFromGui
(GuiMappingContext context, Object newValue, GuiReprValue.ObjectSpecifier specifier, GuiTaskClock clock) call the setter by editing on GUI, andGuiMappingContext.updateSourceFromGui(Object)
.updateValue
(GuiMappingContext context, Object value) Methods inherited from class org.autogui.base.mapping.GuiReprValue
castOrMake, checkAndUpdateSource, convertLog, createNewValue, errorWhileAddHistoryValue, fromSource, fromSourceUpdated, getNoneSupplier, getParentSource, getUpdatedSource, getUpdatedValue, getUpdatedValueWithoutNoUpdate, getValue, getValueCollectionElement, getValueCollectionSize, getValueType, getValueWithoutNoUpdate, isEditable, isFromJsonTakingMapWithContextNameEntry, isHistoryValueStored, isHistoryValueSupported, isHistoryValueSupported, isUpdateContextSourceByUpdateFromGui, match, notifyUpdateWithParentSourceNone, setSource, toParentSource, toSource, toString, toUpdateValue, unwrapNoUpdate, update, updateCollectionElement, updateWithParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromJsonWithNamed, isTaskRunnerUsedFor, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toJsonWithNamed, toStringHeader
-
Field Details
-
imageToReference
-
instance
the global instance set byGuiReprValueImagePane(boolean)
with true- Since:
- 1.1
-
-
Constructor Details
-
GuiReprValueImagePane
public GuiReprValueImagePane()the created instance will not be the global instance -
GuiReprValueImagePane
public GuiReprValueImagePane(boolean processGlobal) - Parameters:
processGlobal
- if true, the instance will be held by the static field of the class, which can be obtained bygetInstance()
. This is useful for obtaining image paths- Since:
- 1.1
-
-
Method Details
-
getInstance
return the default global instance of the class, useful forgetImagePath(Image)
.void setImage(Image img) { ... Path p = GuiReprValueImagePane.getInstance().getImagePath(img); if (p != null) { ... //if the user drag an image file to the associated pane, p will be the path of the file. } }
- Returns:
- the global instance.
- Since:
- 1.1
-
matchValueType
- Overrides:
matchValueType
in classGuiReprValue
-
updateValue
-
getSize
-
isHistoryValueStored
only images which have beensetImagePath(Image, Path)
will be stored as its path throughGuiReprValueImagePane.ImageHistoryEntry
. Currently,GuiReprValueImagePane.ImageHistoryEntry
will not appear to non-history related arguments (like update(...newValue...)- Overrides:
isHistoryValueStored
in classGuiReprValue
- Parameters:
value
-GuiReprValueImagePane.ImageHistoryEntry
orImage
- Returns:
- true only if
GuiReprValueImagePane.ImageHistoryEntry
or null (loading)
-
toJson
Description copied from interface:GuiRepresentation
convert the source into JSON format- Specified by:
toJson
in interfaceGuiRepresentation
- Overrides:
toJson
in classGuiReprValue
- Parameters:
context
- a context holds the representationsource
- the converted objectImage
orGuiReprValueImagePane.ImageHistoryEntry
- Returns:
- image bytes encoded as PNG base64 String(
data:image/png;base64,...
), or source file path (file://...
) if the source is aGuiReprValueImagePane.ImageHistoryEntry
. The method does not check registered file paths bysetImagePath(Image, Path)
. For non-RenderedImage, it temporally creates a BufferedImage and renders the source to the image.
-
fromJson
Description copied from interface:GuiRepresentation
create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents. the behavior can be varied by each representation, confirmed byGuiRepresentation.isJsonSetter()
.- Specified by:
fromJson
in interfaceGuiRepresentation
- Overrides:
fromJson
in classGuiReprValue
- Parameters:
context
- the target context, ignoredtarget
- the target object, ignoredjson
- a string with format ofdata:...
orfile://...
- Returns:
- an
Image
or anGuiReprValueImagePane.ImageHistoryEntry
with lazy loading (at the loading,setImagePath(Image, Path)
will be called and the path is stored).
-
toHumanReadableString
Description copied from interface:GuiRepresentation
method for constructing "toString" copy operations: the returned string will be separated by tabs and new-lines- Parameters:
context
- the context of the repr.source
- converted to string- Returns:
- a string representation of the source
-
fromHumanReadableString
-
isJsonSetter
public boolean isJsonSetter()- Returns:
- true means
GuiRepresentation.fromJson(GuiMappingContext, Object, Object)
takes a target object and set json properties to the target. otherwise, the method will return a new value, thus the target can be null
-
setImagePath
-
getImagePath
-
getRenderedImageWithSupport
public static RenderedImage getRenderedImageWithSupport(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) - Parameters:
support
- the non-null supportsource
- the source image object- Returns:
- source or if it is not an
RenderedImage
, it renders to a temporary buffered-image. - Since:
- 1.7
-
getBufferedImageWithSupport
public static BufferedImage getBufferedImageWithSupport(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) - Parameters:
support
- the non-null supportsource
- the source image object- Returns:
- source or if it is not an
RenderedImage
, it renders to a temporary buffered-image. - Since:
- 1.7
-
getRenderedImage
-
getBufferedImage
-
updateFromGui
public void updateFromGui(GuiMappingContext context, Object newValue, GuiReprValue.ObjectSpecifier specifier, GuiTaskClock clock) Description copied from class:GuiReprValue
call the setter by editing on GUI, andGuiMappingContext.updateSourceFromGui(Object)
.- add
newValue
to the history byGuiReprValue.addHistoryValue(GuiMappingContext, Object)
- obtain parent source and update
GuiReprValue.updateWithParentSource(GuiMappingContext, Object, ObjectSpecifier)
- check
GuiReprValue.isUpdateContextSourceByUpdateFromGui(GuiMappingContext)
andGuiMappingContext.updateSourceFromGui(Object)
: update the source and notify to listeners
- Overrides:
updateFromGui
in classGuiReprValue
- Parameters:
context
- the context of this repr.newValue
- the updated property valuespecifier
- the specifier of the valueclock
- the clock value of sender view
- add
-
addHistoryValue
- Overrides:
addHistoryValue
in classGuiReprValue
-