Package ca.corbett.extras.image
Class ImagePanelConfig
java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.image.ImagePanelConfig
- All Implemented Interfaces:
EventListener,ChangeListener
Represents configuration options for ImagePanel. This class is optional - if you
don't specify it when creating and using an ImagePanel, an instance will be created
automatically with default values set for all properties. You can modify any property
in this class and hand the new instance to ImagePanel.setPanelProperties().
- Since:
- 2017-11-07
- Author:
- scorbett
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Field Summary
Fields inherited from class ca.corbett.extras.properties.AbstractProperty
categoryName, DEFAULT_CATEGORY, DEFAULT_PROPERTY_NAME, extraAttributes, fullyQualifiedName, helpText, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, propertyLabel, propertyName, subCategoryName -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedImagePanelConfig(String fullyQualifiedName) Constructor is protected to force callers to use the factory methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic ImagePanelConfigcloneProperties(ImagePanelConfig other) Clones the given ImagePanelConfig into a new instance.static ImagePanelConfigcloneProperties(ImagePanelConfig other, String newName) static ImagePanelConfigCreates an ImagePanelConfig instance with all default values set.static ImagePanelConfigstatic ImagePanelConfigCreates an ImagePanelConfig suitable for simply display of a non-zoomable, non-scrollable image.static ImagePanelConfigprotected FormFieldDescendant classes must implement this method to generate a FormField associated with this property.The background colour of the panel, defaults to Color.DARK_GRAY.Returns the current DisplayMode.If enableZoomOnMouseClick or enableZoomOnMouseWheel are set, this cursor will be used when the mouse pointer is over the panel, as a visual clue to the user that zoom operations are supported.Returns a "null" cursor that can be used if the cursor is to be hidden.Gets the image rendering quality preference: QUICK_AND_DIRTY emphasizes speed over quality, while SLOW_AND_ACCURATE does the opposite.doubleWhen zooming in or out, represents the percentage step to apply up or down.booleanIf disabled, mouse cursor will be hidden while over the panel.booleanIf enabled, users can click and drag on a zoomed-in image to scroll it around within the panel.booleanEnables the use of mouse clicks to zoom: left click to zoom in, right click to zoom out.booleanEnables the use of mouse wheel for zooming: wheel up to zoom in, wheel down to zoom out.voidloadFromFormField(FormField field) Populates this Property's value(s) from the given form field, assuming the field is of the correct type.voidloadFromProps(Properties props) Loads the value(s) for this property from the given Properties instance, overwriting any current value.voidResets all properties back to their default values.voidsaveToProps(Properties props) Saves the current value(s) of this property to the given Properties instance.voidsetBgColor(Color bgColor) Sets the background colour of the panel, defaults to the panel bg color from the current Look and Feel.voidSets the DisplayMode.voidsetEnableMouseCursor(boolean enableMouseCursor) If disabled, mouse cursor will be hidden while over the panel.voidsetEnableMouseDragging(boolean enableMouseDragging) If enabled, users can click and drag on a zoomed-in image to scroll it around within the panel.voidsetEnableZoomOnMouseClick(boolean enableZoomOnMouseClick) Enables the use of mouse clicks to zoom: left click to zoom in, right click to zoom out.voidsetEnableZoomOnMouseWheel(boolean enableZoomOnMouseWheel) Enables the use of mouse wheel for zooming: wheel up to zoom in, wheel down to zoom out.voidsetMagnifierCursor(Cursor magnifierCursor) If enableZoomOnMouseClick or enableZoomOnMouseWheel are set, this cursor will be used when the mouse pointer is over the panel, as a visual clue to the user that zoom operations are supported.voidSets the image rendering quality preference: QUICK_AND_DIRTY emphasizes speed over quality, while SLOW_AND_ACCURATE does the opposite.voidsetZoomFactorIncrement(double zoomFactorIncrement) When zooming in or out, represents the percentage step to apply up or down.voidInvoked from LookAndFeelManager when the Look and Feel is changed.Methods inherited from class ca.corbett.extras.properties.AbstractProperty
addAllExtraAttributes, addFormFieldChangeListener, clearExtraAttribute, clearExtraAttributes, equals, fireFormFieldChangedEvent, generateFormField, generateFormField, getCategoryName, getExtraAttribute, getFullyQualifiedName, getHelpText, getPropertyLabel, getPropertyName, getSubCategoryName, hashCode, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, removeAllListeners, removeFormFieldChangeListener, setAllExtraAttributes, setEnabled, setExposed, setExtraAttribute, setHelpText, setInitiallyEditable, setInitiallyVisible, setPropertyLabel
-
Constructor Details
-
ImagePanelConfig
Constructor is protected to force callers to use the factory methods.
-
-
Method Details
-
createDefaultProperties
Creates an ImagePanelConfig instance with all default values set.- Returns:
- A default ImagePanelConfig instance.
-
createDefaultProperties
-
createSimpleReadOnlyProperties
Creates an ImagePanelConfig suitable for simply display of a non-zoomable, non-scrollable image.- Returns:
- An ImagePanelConfig configured for simple non-interactive display.
-
createSimpleReadOnlyProperties
-
cloneProperties
Clones the given ImagePanelConfig into a new instance. If you pass in null, you'll get back a defaulted instance, same as if you had called createDefaultProperties.- Parameters:
other- The ImagePanelConfig object to be cloned.- Returns:
- The new, cloned properties instance.
-
cloneProperties
-
resetToDefaults
public void resetToDefaults()Resets all properties back to their default values. -
getBgColor
The background colour of the panel, defaults to Color.DARK_GRAY.- Returns:
- The panel background colour.
-
setRenderingQuality
Sets the image rendering quality preference: QUICK_AND_DIRTY emphasizes speed over quality, while SLOW_AND_ACCURATE does the opposite.- Parameters:
quality- The desired rendering quality.
-
getRenderingQuality
Gets the image rendering quality preference: QUICK_AND_DIRTY emphasizes speed over quality, while SLOW_AND_ACCURATE does the opposite.- Returns:
- The current rendering quality.
-
setBgColor
Sets the background colour of the panel, defaults to the panel bg color from the current Look and Feel. This can also be set directly on the ImagePanel itself, as it is a JPanel property. It is here as a convenience.Note that explicitly setting a bgcolor here will override the current look and feel, and this instance will ignore any future look and feel changes in favour of the given bg color.
- Parameters:
bgColor- The desired background colour.
-
getMagnifierCursor
If enableZoomOnMouseClick or enableZoomOnMouseWheel are set, this cursor will be used when the mouse pointer is over the panel, as a visual clue to the user that zoom operations are supported. The default value is a magnifier cursor.- Returns:
- The currently set mouse cursor.
-
setMagnifierCursor
If enableZoomOnMouseClick or enableZoomOnMouseWheel are set, this cursor will be used when the mouse pointer is over the panel, as a visual clue to the user that zoom operations are supported. The default value is a magnifier cursor. If enableZoomOnMouseClick and enableZoomOnMouseWheel are both disabled, this property is ignored. You can set null here to force the use of the default system cursor even if zooming is enabled.- Parameters:
magnifierCursor- The mouse cursor to use.
-
getNullCursor
Returns a "null" cursor that can be used if the cursor is to be hidden.- Returns:
- An empty cursor.
-
isEnableZoomOnMouseClick
public boolean isEnableZoomOnMouseClick()Enables the use of mouse clicks to zoom: left click to zoom in, right click to zoom out. The default value is true.- Returns:
- Whether mouse clicks can be used to zoom in and out of the image.
-
setEnableZoomOnMouseClick
public void setEnableZoomOnMouseClick(boolean enableZoomOnMouseClick) Enables the use of mouse clicks to zoom: left click to zoom in, right click to zoom out. The default value is true.- Parameters:
enableZoomOnMouseClick- Whether mouse clicks can be used to zoom in and out of the image.
-
isEnableZoomOnMouseWheel
public boolean isEnableZoomOnMouseWheel()Enables the use of mouse wheel for zooming: wheel up to zoom in, wheel down to zoom out. The default value is true.- Returns:
- Whether the mouse wheel can be used to zoom in and out of the image.
-
setEnableZoomOnMouseWheel
public void setEnableZoomOnMouseWheel(boolean enableZoomOnMouseWheel) Enables the use of mouse wheel for zooming: wheel up to zoom in, wheel down to zoom out. The default value is true.- Parameters:
enableZoomOnMouseWheel- Whether the mouse wheel can be used to zoom in and out.
-
getDisplayMode
Returns the current DisplayMode.- NONE: just display the image unscaled at 0,0
- CENTER: center the image in the panel, but don't resize it
- BEST_FIT: center the image and scale it up or down as needed to fit the panel.
- STRETCH: distort the image so it fully fills the panel.
- CUSTOM: this is used internally when zooming in/out and should be ignored otherwise.
- Returns:
- The current display mode as outlined above.
-
setDisplayMode
Sets the DisplayMode.- NONE: just display the image unscaled at 0,0
- CENTER: center the image in the panel, but don't resize it
- BEST_FIT: center the image and scale it up or down as needed to fit the panel.
- STRETCH: distort the image so it fully fills the panel.
- CUSTOM: this is used internally when zooming in/out and should be ignored otherwise.
- Parameters:
mode- The DisplayMode to use, as outlined above.
-
isEnableMouseCursor
public boolean isEnableMouseCursor()If disabled, mouse cursor will be hidden while over the panel. This is enabled by default. The cursor will either be the system default cursor if enableZoomOnMouseClick and enableZoomOnMouseWheel are both disabled, or it will be set to the current magnifier cursor otherwise (see setMagnifierCursor).- Returns:
- Whether the mouse cursor will be visible over the panel.
-
setEnableMouseCursor
public void setEnableMouseCursor(boolean enableMouseCursor) If disabled, mouse cursor will be hidden while over the panel. This is enabled by default. The cursor will either be the system default cursor if enableZoomOnMouseClick and enableZoomOnMouseWheel are both disabled, or it will be set to the current magnifier cursor otherwise (see setMagnifierCursor).- Parameters:
enableMouseCursor- Whether the mouse cursor will be visible over the panel.
-
isEnableMouseDragging
public boolean isEnableMouseDragging()If enabled, users can click and drag on a zoomed-in image to scroll it around within the panel. Note that this property does nothing if the image is not zoomed in to the point where it is larger than the panel. The default value is true.- Returns:
- Whether mouse dragging is allowed to scroll zoomed-in images.
-
setEnableMouseDragging
public void setEnableMouseDragging(boolean enableMouseDragging) If enabled, users can click and drag on a zoomed-in image to scroll it around within the panel. Note that this property does nothing if the image is not zoomed in to the point where it is larger than the panel. The default value is true.- Parameters:
enableMouseDragging- Whether mouse dragging is allowed to scroll zoomed-in images.
-
getZoomFactorIncrement
public double getZoomFactorIncrement()When zooming in or out, represents the percentage step to apply up or down. The default value is 0.1, meaning the image will be scaled up in incrememts of 10% for each zoom operation.- Returns:
- The current zoom increment.
-
setZoomFactorIncrement
public void setZoomFactorIncrement(double zoomFactorIncrement) When zooming in or out, represents the percentage step to apply up or down. The default value is 0.1, meaning the image will be scaled up in incrememts of 10% for each zoom operation.- Parameters:
zoomFactorIncrement- The zoom increment to use.
-
saveToProps
Description copied from class:AbstractPropertySaves the current value(s) of this property to the given Properties instance.- Specified by:
saveToPropsin classAbstractProperty- Parameters:
props- Any Properties instance which will receive the value(s) of this property.
-
loadFromProps
Description copied from class:AbstractPropertyLoads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.- Specified by:
loadFromPropsin classAbstractProperty- Parameters:
props- Any Properties instance which contains value(s) for this property.
-
generateFormFieldImpl
Description copied from class:AbstractPropertyDescendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.- Specified by:
generateFormFieldImplin classAbstractProperty- Returns:
- A FormField associated with this property.
-
loadFromFormField
Description copied from class:AbstractPropertyPopulates this Property's value(s) from the given form field, assuming the field is of the correct type.- Specified by:
loadFromFormFieldin classAbstractProperty- Parameters:
field- The FormField containing a value for this property.
-
stateChanged
Invoked from LookAndFeelManager when the Look and Feel is changed. If we have never been given an explicit background color, then we'll auto-set it according to the new look and feel.- Specified by:
stateChangedin interfaceChangeListener- Parameters:
e- a ChangeEvent object
-