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 LocatedObjectsm_AllObjectsall located objects.protected Colorm_Colorthe color for the objects.protected HashMap<Polygon,Color>m_Colorsthe cached colors.protected LocatedObjectsm_FilteredObjectsthe filtered located objects.protected ImageAnchorm_LabelAnchorthe label anchor.protected Fontm_LabelFontthe label font.protected Stringm_LabelFormatthe label for the rectangles.protected intm_LabelOffsetXthe x offset for the label.protected intm_LabelOffsetYthe y offset for the label.protected HashMap<Polygon,String>m_Labelsthe labels.protected List<Polygon>m_Locationsthe cached locations.protected Map<LocatedObject,Polygon>m_ObjectLocationMappingsthe cached object/location relation.protected BaseString[]m_PredefinedLabelspredefined labels.protected Stringm_Prefixthe prefix for the objects in the report.protected ColorProviderm_TypeColorProviderthe color provider to use.protected HashMap<String,Color>m_TypeColorsthe type/color mapping.protected BaseRegExpm_TypeRegExpthe regular expression for the types to draw.protected Stringm_TypeSuffixthe suffix for the type.protected booleanm_UseColorsPerTypewhether 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 StringapplyFormatOptions(String value, String format)Applies further format options.protected StringapplyLabelFormat(LocatedObject object, String type)Applies the label format to the object to generate a display string.DimensioncalcStringDimenions(Graphics g, Font f, String s)Calculates the string dimensions in pixels.StringcolorTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.booleandetermineLocations(Report report)Determines the locations of the objects.abstract booleandetermineLocations(Report report, LocatedObjectFilter filter)Determines the locations of the objects.protected StringdetermineTypeSuffix()Returns the type suffix without the leading dot.voiddrawString(Graphics g, Rectangle rect, String label)Draws the string at the specified position.LocatedObjectsgetAllObjects()Returns all the objects.ColorgetColor()Returns the color to use for the objects.ColorgetColor(Polygon poly)Returns the color for the object.protected abstract StringgetDefaultPrefix()Returns the default prefix for the objects in the report.LocatedObjectsgetFilteredObjects()Returns the filtered objects.StringgetLabel(Polygon poly)Returns the label for the object.ImageAnchorgetLabelAnchor()Returns the anchor for the label.FontgetLabelFont()Returns the label font.StringgetLabelFormat()Returns the label format.intgetLabelOffsetX()Returns the X offset for the label.intgetLabelOffsetY()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.StringgetPrefix()Returns the prefix to use for the objects in the report.ColorgetTypeColor(String type)Returns the color for the object type.ColorProvidergetTypeColorProvider()Returns the color provider to use for the types.BaseRegExpgetTypeRegExp()Returns the regular expression that the types must match in order to get drawn.StringgetTypeSuffix()Returns the suffix to use for the types.booleangetUseColorsPerType()Returns whether to use colors per type.booleanhasAllObjects()Returns whether the objects have been initialized.booleanhasColor(Polygon poly)Checks whether a color has been stored for the given object.booleanhasFilteredObjects()Returns whether the objects have been initialized.booleanhasLabel(Polygon poly)Checks whether a label has been stored for the given object.booleanhasLocations()Checks whether any locations are available.booleanhasObjectLocationMappings()Checks whether any object/location mappings are available.booleanhasTypeColor(String type)Checks whether a color has been stored for the given object type.StringlabelAnchorTipText()Returns the tip text for this property.StringlabelFontTipText()Returns the tip text for this property.StringlabelFormatTipText()Returns the tip text for this property.StringlabelOffsetXTipText()Returns the tip text for this property.StringlabelOffsetYTipText()Returns the tip text for this property.StringpredefinedLabelsTipText()Returns the tip text for this property.StringprefixTipText()Returns the tip text for this property.voidreset()Resets the scheme.voidsetColor(Color value)Sets the color to use for the objects.voidsetLabelAnchor(ImageAnchor value)Sets the anchor for the label.voidsetLabelFont(Font value)Sets the label font.voidsetLabelFormat(String value)Sets the label format.voidsetLabelOffsetX(int value)Sets the X offset for the label.voidsetLabelOffsetY(int value)Sets the Y offset for the label.voidsetPredefinedLabels(BaseString[] value)Sets the predefined labels.voidsetPrefix(String value)Sets the prefix to use for the objects in the report.voidsetTypeColorProvider(ColorProvider value)Sets the color provider to use for the types.voidsetTypeRegExp(BaseRegExp value)Sets the regular expression that the types must match in order to get drawn.voidsetTypeSuffix(String value)Sets the suffix to use for the types.voidsetUseColorsPerType(boolean value)Sets whether to use colors per type.StringtypeColorProviderTipText()Returns the tip text for this property.StringtypeRegExpTipText()Returns the tip text for this property.StringtypeSuffixTipText()Returns the tip text for this property.StringuseColorsPerTypeTipText()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:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
reset
public void reset()
Resets the scheme.- Overrides:
resetin 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
-
-