Package adams.gui.visualization.image
Class AbstractReportBasedOverlayHelper
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.image.AbstractReportBasedOverlayHelper
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
ReportObjectOverlay
,ReportPointOverlay
public abstract class AbstractReportBasedOverlayHelper extends AbstractOptionHandler
Ancestor for overlay helper classes that use object locations from a report.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected LocatedObjects
m_AllObjects
all located objects.protected Color
m_Color
the color for the objects.protected HashMap<Polygon,Color>
m_Colors
the cached colors.protected LocatedObjects
m_FilteredObjects
the filtered located objects.protected ImageAnchor
m_LabelAnchor
the label anchor.protected Font
m_LabelFont
the label font.protected String
m_LabelFormat
the label for the rectangles.protected int
m_LabelOffsetX
the x offset for the label.protected int
m_LabelOffsetY
the y offset for the label.protected HashMap<Polygon,String>
m_Labels
the labels.protected List<Polygon>
m_Locations
the cached locations.protected Map<LocatedObject,Polygon>
m_ObjectLocationMappings
the cached object/location relation.protected BaseString[]
m_PredefinedLabels
predefined labels.protected String
m_Prefix
the prefix for the objects in the report.protected ColorProvider
m_TypeColorProvider
the color provider to use.protected HashMap<String,Color>
m_TypeColors
the type/color mapping.protected BaseRegExp
m_TypeRegExp
the regular expression for the types to draw.protected String
m_TypeSuffix
the suffix for the type.protected boolean
m_UseColorsPerType
whether to use colors per type.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractReportBasedOverlayHelper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
applyFormatOptions(String value, String format)
Applies further format options.protected String
applyLabelFormat(LocatedObject object, String type)
Applies the label format to the object to generate a display string.Dimension
calcStringDimenions(Graphics g, Font f, String s)
Calculates the string dimensions in pixels.String
colorTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.boolean
determineLocations(Report report)
Determines the locations of the objects.abstract boolean
determineLocations(Report report, LocatedObjectFilter filter)
Determines the locations of the objects.protected String
determineTypeSuffix()
Returns the type suffix without the leading dot.void
drawString(Graphics g, Rectangle rect, String label)
Draws the string at the specified position.LocatedObjects
getAllObjects()
Returns all the objects.Color
getColor()
Returns the color to use for the objects.Color
getColor(Polygon poly)
Returns the color for the object.protected abstract String
getDefaultPrefix()
Returns the default prefix for the objects in the report.LocatedObjects
getFilteredObjects()
Returns the filtered objects.String
getLabel(Polygon poly)
Returns the label for the object.ImageAnchor
getLabelAnchor()
Returns the anchor for the label.Font
getLabelFont()
Returns the label font.String
getLabelFormat()
Returns the label format.int
getLabelOffsetX()
Returns the X offset for the label.int
getLabelOffsetY()
Returns the Y offset for the label.List<Polygon>
getLocations()
Returns the current locations.Map<LocatedObject,Polygon>
getObjectLocationMappings()
Returns the current object/location mappings.BaseString[]
getPredefinedLabels()
Returns the predefined labels.String
getPrefix()
Returns the prefix to use for the objects in the report.Color
getTypeColor(String type)
Returns the color for the object type.ColorProvider
getTypeColorProvider()
Returns the color provider to use for the types.BaseRegExp
getTypeRegExp()
Returns the regular expression that the types must match in order to get drawn.String
getTypeSuffix()
Returns the suffix to use for the types.boolean
getUseColorsPerType()
Returns whether to use colors per type.boolean
hasAllObjects()
Returns whether the objects have been initialized.boolean
hasColor(Polygon poly)
Checks whether a color has been stored for the given object.boolean
hasFilteredObjects()
Returns whether the objects have been initialized.boolean
hasLabel(Polygon poly)
Checks whether a label has been stored for the given object.boolean
hasLocations()
Checks whether any locations are available.boolean
hasObjectLocationMappings()
Checks whether any object/location mappings are available.boolean
hasTypeColor(String type)
Checks whether a color has been stored for the given object type.String
labelAnchorTipText()
Returns the tip text for this property.String
labelFontTipText()
Returns the tip text for this property.String
labelFormatTipText()
Returns the tip text for this property.String
labelOffsetXTipText()
Returns the tip text for this property.String
labelOffsetYTipText()
Returns the tip text for this property.String
predefinedLabelsTipText()
Returns the tip text for this property.String
prefixTipText()
Returns the tip text for this property.void
reset()
Resets the scheme.void
setColor(Color value)
Sets the color to use for the objects.void
setLabelAnchor(ImageAnchor value)
Sets the anchor for the label.void
setLabelFont(Font value)
Sets the label font.void
setLabelFormat(String value)
Sets the label format.void
setLabelOffsetX(int value)
Sets the X offset for the label.void
setLabelOffsetY(int value)
Sets the Y offset for the label.void
setPredefinedLabels(BaseString[] value)
Sets the predefined labels.void
setPrefix(String value)
Sets the prefix to use for the objects in the report.void
setTypeColorProvider(ColorProvider value)
Sets the color provider to use for the types.void
setTypeRegExp(BaseRegExp value)
Sets the regular expression that the types must match in order to get drawn.void
setTypeSuffix(String value)
Sets the suffix to use for the types.void
setUseColorsPerType(boolean value)
Sets whether to use colors per type.String
typeColorProviderTipText()
Returns the tip text for this property.String
typeRegExpTipText()
Returns the tip text for this property.String
typeSuffixTipText()
Returns the tip text for this property.String
useColorsPerTypeTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Prefix
protected String m_Prefix
the prefix for the objects in the report.
-
m_Color
protected Color m_Color
the color for the objects.
-
m_UseColorsPerType
protected boolean m_UseColorsPerType
whether to use colors per type.
-
m_TypeColorProvider
protected ColorProvider m_TypeColorProvider
the color provider to use.
-
m_TypeSuffix
protected String m_TypeSuffix
the suffix for the type.
-
m_TypeRegExp
protected BaseRegExp m_TypeRegExp
the regular expression for the types to draw.
-
m_LabelFormat
protected String m_LabelFormat
the label for the rectangles.
-
m_LabelFont
protected Font m_LabelFont
the label font.
-
m_LabelAnchor
protected ImageAnchor m_LabelAnchor
the label anchor.
-
m_LabelOffsetX
protected int m_LabelOffsetX
the x offset for the label.
-
m_LabelOffsetY
protected int m_LabelOffsetY
the y offset for the label.
-
m_AllObjects
protected LocatedObjects m_AllObjects
all located objects.
-
m_FilteredObjects
protected LocatedObjects m_FilteredObjects
the filtered located objects.
-
m_ObjectLocationMappings
protected Map<LocatedObject,Polygon> m_ObjectLocationMappings
the cached object/location relation.
-
m_PredefinedLabels
protected BaseString[] m_PredefinedLabels
predefined labels.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
reset
public void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
getDefaultPrefix
protected abstract String getDefaultPrefix()
Returns the default prefix for the objects in the report.- Returns:
- the default
-
setPrefix
public void setPrefix(String value)
Sets the prefix to use for the objects in the report.- Parameters:
value
- the prefix
-
getPrefix
public String getPrefix()
Returns the prefix to use for the objects in the report.- Returns:
- the prefix
-
prefixTipText
public String prefixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColor
public void setColor(Color value)
Sets the color to use for the objects.- Parameters:
value
- the color
-
getColor
public Color getColor()
Returns the color to use for the objects.- Returns:
- the color
-
colorTipText
public String colorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseColorsPerType
public void setUseColorsPerType(boolean value)
Sets whether to use colors per type.- Parameters:
value
- true if to use colors per type
-
getUseColorsPerType
public boolean getUseColorsPerType()
Returns whether to use colors per type.- Returns:
- true if to use colors per type
-
useColorsPerTypeTipText
public String useColorsPerTypeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTypeColorProvider
public void setTypeColorProvider(ColorProvider value)
Sets the color provider to use for the types.- Parameters:
value
- the provider
-
getTypeColorProvider
public ColorProvider getTypeColorProvider()
Returns the color provider to use for the types.- Returns:
- the provider
-
typeColorProviderTipText
public String typeColorProviderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTypeSuffix
public void setTypeSuffix(String value)
Sets the suffix to use for the types.- Parameters:
value
- the suffix
-
getTypeSuffix
public String getTypeSuffix()
Returns the suffix to use for the types.- Returns:
- the suffix
-
typeSuffixTipText
public String typeSuffixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTypeRegExp
public void setTypeRegExp(BaseRegExp value)
Sets the regular expression that the types must match in order to get drawn.- Parameters:
value
- the expression
-
getTypeRegExp
public BaseRegExp getTypeRegExp()
Returns the regular expression that the types must match in order to get drawn.- Returns:
- the expression
-
typeRegExpTipText
public String typeRegExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelFormat
public void setLabelFormat(String value)
Sets the label format.- Parameters:
value
- the label format
-
getLabelFormat
public String getLabelFormat()
Returns the label format.- Returns:
- the label format
-
labelFormatTipText
public String labelFormatTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelFont
public void setLabelFont(Font value)
Sets the label font.- Parameters:
value
- the label font
-
getLabelFont
public Font getLabelFont()
Returns the label font.- Returns:
- the label font
-
labelFontTipText
public String labelFontTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelAnchor
public void setLabelAnchor(ImageAnchor value)
Sets the anchor for the label.- Parameters:
value
- the anchor
-
getLabelAnchor
public ImageAnchor getLabelAnchor()
Returns the anchor for the label.- Returns:
- the anchor
-
labelAnchorTipText
public String labelAnchorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelOffsetX
public void setLabelOffsetX(int value)
Sets the X offset for the label.- Parameters:
value
- the X offset
-
getLabelOffsetX
public int getLabelOffsetX()
Returns the X offset for the label.- Returns:
- the X offset
-
labelOffsetXTipText
public String labelOffsetXTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLabelOffsetY
public void setLabelOffsetY(int value)
Sets the Y offset for the label.- Parameters:
value
- the Y offset
-
getLabelOffsetY
public int getLabelOffsetY()
Returns the Y offset for the label.- Returns:
- the Y offset
-
labelOffsetYTipText
public String labelOffsetYTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPredefinedLabels
public void setPredefinedLabels(BaseString[] value)
Sets the predefined labels.- Parameters:
value
- the labels
-
getPredefinedLabels
public BaseString[] getPredefinedLabels()
Returns the predefined labels.- Returns:
- the labels
-
predefinedLabelsTipText
public String predefinedLabelsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
determineTypeSuffix
protected String determineTypeSuffix()
Returns the type suffix without the leading dot.- Returns:
- the sufix
-
applyFormatOptions
protected String applyFormatOptions(String value, String format)
Applies further format options. Does nothing if format or value are empty.- Parameters:
value
- the value to formatformat
- the format to apply- Returns:
- the processed value
-
applyLabelFormat
protected String applyLabelFormat(LocatedObject object, String type)
Applies the label format to the object to generate a display string.- Parameters:
object
- the object to use as basistype
- the meta-data key for the type- Returns:
- the generated label
-
determineLocations
public boolean determineLocations(Report report)
Determines the locations of the objects.- Parameters:
report
- the report to inspect- Returns:
- true if updated
-
determineLocations
public abstract boolean determineLocations(Report report, LocatedObjectFilter filter)
Determines the locations of the objects.- Parameters:
report
- the report to inspect- Returns:
- true if updated
-
hasColor
public boolean hasColor(Polygon poly)
Checks whether a color has been stored for the given object.- Parameters:
poly
- the object to check- Returns:
- true if custom color available
-
getColor
public Color getColor(Polygon poly)
Returns the color for the object.- Parameters:
poly
- the object to get the color for- Returns:
- the color, null if none available
-
hasTypeColor
public boolean hasTypeColor(String type)
Checks whether a color has been stored for the given object type.- Parameters:
type
- the type to check- Returns:
- true if custom color available
-
getTypeColor
public Color getTypeColor(String type)
Returns the color for the object type.- Parameters:
type
- the type to get the color for- Returns:
- the color, null if none available
-
hasLabel
public boolean hasLabel(Polygon poly)
Checks whether a label has been stored for the given object.- Parameters:
poly
- the object to check- Returns:
- true if custom label available
-
getLabel
public String getLabel(Polygon poly)
Returns the label for the object.- Parameters:
poly
- the object to get the label for- Returns:
- the label, null if none available
-
hasObjectLocationMappings
public boolean hasObjectLocationMappings()
Checks whether any object/location mappings are available.- Returns:
- true if mappings available
-
getObjectLocationMappings
public Map<LocatedObject,Polygon> getObjectLocationMappings()
Returns the current object/location mappings.- Returns:
- the mappings, null if not initialized
- See Also:
determineLocations(Report)
-
hasLocations
public boolean hasLocations()
Checks whether any locations are available.- Returns:
- true if locations available
-
getLocations
public List<Polygon> getLocations()
Returns the current locations.- Returns:
- the locations, null if not initialized
- See Also:
determineLocations(Report)
-
hasAllObjects
public boolean hasAllObjects()
Returns whether the objects have been initialized.- Returns:
- true if initialized
-
getAllObjects
public LocatedObjects getAllObjects()
Returns all the objects.- Returns:
- the objects, null if not initialized yet
-
hasFilteredObjects
public boolean hasFilteredObjects()
Returns whether the objects have been initialized.- Returns:
- true if initialized
-
getFilteredObjects
public LocatedObjects getFilteredObjects()
Returns the filtered objects.- Returns:
- the objects, null if not initialized yet
-
calcStringDimenions
public Dimension calcStringDimenions(Graphics g, Font f, String s)
Calculates the string dimensions in pixels.- Parameters:
g
- the graphics contextf
- the font to uses
- the string to measure- Returns:
- the dimensions in pixels
-
-