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 classa special value of history entry which has an image, and it's source file pathstatic classanImageObserverfor obtaining the size of an imagestatic interfacesupport object forgetRenderedImage(GuiMappingContext, Object)static classimpl of the support interfaceNested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothingNested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone, GuiRepresentation.TreeString, GuiRepresentation.TreeStringComposite, GuiRepresentation.TreeStringValue -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static GuiReprValueImagePanethe 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 TypeMethodDescriptionvoidaddHistoryValue(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 BufferedImagegetBufferedImageWithSupport(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) impl.getImagePath(Image image) static GuiReprValueImagePanereturn the default global instance of the class, useful forgetImagePath(Image).getRenderedImage(GuiMappingContext context, Object source) static RenderedImagegetRenderedImageWithSupport(GuiReprValueImagePane.RenderedImageGetterSupport support, Object source) impl.getSize(GuiMappingContext context, Image image) booleanisHistoryValueStored(Object value) only images which have beensetImagePath(Image, Path)will be stored as its path throughGuiReprValueImagePane.ImageHistoryEntry.booleanbooleanmatchValueType(Class<?> cls) voidsetImagePath(Image image, Path path) toHumanReadableStringTree(GuiMappingContext context, Object source) toJson(GuiMappingContext context, Object source) convert the source into JSON formatvoidupdateFromGui(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, updateWithParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromJsonWithNamed, isTaskRunnerUsedFor, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toHumanReadableString, 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:
matchValueTypein classGuiReprValue
-
updateValue
-
getSize
-
isHistoryValueStored
only images which have beensetImagePath(Image, Path)will be stored as its path throughGuiReprValueImagePane.ImageHistoryEntry. Currently,GuiReprValueImagePane.ImageHistoryEntrywill not appear to non-history related arguments (like update(...newValue...)- Overrides:
isHistoryValueStoredin classGuiReprValue- Parameters:
value-GuiReprValueImagePane.ImageHistoryEntryorImage- Returns:
- true only if
GuiReprValueImagePane.ImageHistoryEntryor null (loading)
-
toJson
Description copied from interface:GuiRepresentationconvert the source into JSON format- Specified by:
toJsonin interfaceGuiRepresentation- Overrides:
toJsonin classGuiReprValue- Parameters:
context- a context holds the representationsource- the converted objectImageorGuiReprValueImagePane.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:GuiRepresentationcreate 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:
fromJsonin interfaceGuiRepresentation- Overrides:
fromJsonin classGuiReprValue- Parameters:
context- the target context, ignoredtarget- the target object, ignoredjson- a string with format ofdata:...orfile://...- Returns:
- an
Imageor anGuiReprValueImagePane.ImageHistoryEntrywith lazy loading (at the loading,setImagePath(Image, Path)will be called and the path is stored).
-
toHumanReadableStringTree
public GuiRepresentation.TreeString toHumanReadableStringTree(GuiMappingContext context, Object source) - Parameters:
context- the context of the reprsource- convert to string- Returns:
- tree string of source, can be encoded by
Object.toString()(used byGuiRepresentation.toHumanReadableString(GuiMappingContext, Object)
-
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:GuiReprValuecall the setter by editing on GUI, andGuiMappingContext.updateSourceFromGui(Object).- add
newValueto 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:
updateFromGuiin 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:
addHistoryValuein classGuiReprValue
-