Package adams.gui.visualization.image
Class ObjectLocationsOverlayFromReport
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.image.AbstractImageOverlay
-
- adams.gui.visualization.image.AbstractObjectOverlayFromReport
-
- adams.gui.visualization.image.ObjectLocationsOverlayFromReport
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<AbstractImageOverlay>
,SizeOfHandler
,PopupMenuCustomizer<ImagePanel.PaintPanel>
,ImageOverlay
,TypeColorProvider
,Serializable
public class ObjectLocationsOverlayFromReport extends AbstractObjectOverlayFromReport
Displays the locations of objects in the image, using data from the attached report.
Suffixes:
.x
.y
.width
.height
Optionally, if type information is available per object, the locations can be displayed in distinct colors per type. The type itself can be displayed as well.
If polygon data should be available (.poly_x and .poly_y), then this takes precedence over the rectangle coordinates.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-enabled <boolean> (property: enabled) If enabled, this overlay is painted over the image. default: true
-prefix <java.lang.String> (property: prefix) The prefix of fields in the report to identify as object location, eg 'Object. '. default: Object.
-color <java.awt.Color> (property: color) The color to use for the objects. default: #ff0000
-use-colors-per-type <boolean> (property: useColorsPerType) If enabled, individual colors per type are used. default: false
-type-color-provider <adams.gui.visualization.core.ColorProvider> (property: typeColorProvider) The color provider to use for the various types. default: adams.gui.visualization.core.DefaultColorProvider
-type-suffix <java.lang.String> (property: typeSuffix) The suffix of fields in the report to identify the type. default: .type
-type-regexp <adams.core.base.BaseRegExp> (property: typeRegExp) The regular expression that the types must match in order to get drawn ( eg only plotting a subset). default: .* more: https://docs.oracle.com/javase/tutorial/essential/regex/ https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
-label-format <java.lang.String> (property: labelFormat) The label format string to use for the rectangles; '#' for index, '@' for type and '$' for short type (type suffix must be defined for '@' and '$' ), '{BLAH}' gets replaced with the value associated with the meta-data key 'BLAH'; for instance: '# @' or '# {BLAH}'; in case of numeric values, use '|.X' to limit the number of decimals, eg '{BLAH|.2}' for a maximum of decimals after the decimal point. default: #
-label-font <java.awt.Font> (property: labelFont) The font to use for the labels. default: Display-PLAIN-14
-label-anchor <TOP_LEFT|TOP_CENTER|TOP_RIGHT|MIDDLE_LEFT|MIDDLE_CENTER|MIDDLE_RIGHT|BOTTOM_LEFT|BOTTOM_CENTER|BOTTOM_RIGHT> (property: labelAnchor) The anchor for the label. default: TOP_RIGHT
-label-offset-x <int> (property: labelOffsetX) The X offset for the label; values of 0 or greater are interpreted as absolute pixels, -1 uses left as anchor, -2 the center and -3 the right. default: 0
-label-offset-y <int> (property: labelOffsetY) The Y offset for the label values of 0 or greater are interpreted as absolute pixels, -1 uses top as anchor, -2 the middle and -3 the bottom. default: 0
-predefined-labels <adams.core.base.BaseString> [-predefined-labels ...] (property: predefinedLabels) The predefined labels to use for setting up the colors; avoids constants changing in color pallet. default:
-vary-shape-color <boolean> (property: varyShapeColor) If enabled, the shape colors get varied. default: false
-shape-color-provider <adams.gui.visualization.core.ColorProvider> (property: shapeColorProvider) The color provider to use when varying the shape colors. default: adams.gui.visualization.core.TranslucentColorProvider -provider adams.gui.visualization.core.DefaultColorProvider
-filled <boolean> (property: filled) If enabled, the shape is drawn filled. default: false
-polygon-bounds <boolean> (property: polygonBounds) If enabled, the polygon bounds are drawn as well. default: false
-bounding-box-fallback-ratio <double> (property: boundingBoxFallbackRatio) The threshold for the ratio between the areas (shape / bbox), below which the bounding box is used over the polygon (ie bad masks/shapes). default: 0.0 minimum: 0.0 maximum: 1.0
-stroke-thickness <float> (property: strokeThickness) The thickness of the stroke. default: 1.0 minimum: 0.01
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.gui.visualization.image.AbstractObjectOverlayFromReport
AbstractObjectOverlayFromReport.LocatedObjectsPanel, AbstractObjectOverlayFromReport.SelectedObjectFilter
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Filled
whether to draw the shape filled.protected int
m_OutlineAlpha
the alpha value to use for the polygon bounds.protected Map<Color,Color>
m_OutlineColors
the colors for the polygon bounds.protected boolean
m_PolygonBounds
whether to draw the bounds of the polygon as well.protected float
m_StrokeThickness
the thickness of the stroke.-
Fields inherited from class adams.gui.visualization.image.AbstractObjectOverlayFromReport
m_LocationsUpdatedListeners, m_Overlays, m_Owner, m_PanelObjects, m_ShowObjectPanel, PREFIX_DEFAULT
-
Fields inherited from class adams.gui.visualization.image.AbstractImageOverlay
m_Enabled
-
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 ObjectLocationsOverlayFromReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyStroke(Graphics g, float stroke)
Applies the stroke thickness.String
boundingBoxFallbackRatioTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected void
doPaintObjects(ImagePanel.PaintPanel panel, Graphics g, List<Polygon> locations)
Performs the actual painting of the objects.String
filledTipText()
Returns the tip text for this property.double
getBoundingBoxFallbackRatio()
Returns the ratio between shape area over bbox area.boolean
getFilled()
Returns whether to draw the shape filled.int
getOutlineAlpha()
Returns the alpha value to use when drawing the outlines.boolean
getPolygonBounds()
Returns whether to draw the polygon bounds.float
getStrokeThickness()
Returns the current stroke thickness.protected float
getStrokeWidth(Graphics g, float defValue)
Returns the thickness of the stroke.String
globalInfo()
Returns a string describing the object.String
outlineAlphaTipText()
Returns the tip text for this property.String
polygonBoundsTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setBoundingBoxFallbackRatio(double value)
Sets the ratio between shape area over bbox area.void
setFilled(boolean value)
Sets whether to draw the shape filled.void
setOutlineAlpha(int value)
Sets the alpha value to use when drawing the outlines.void
setPolygonBounds(boolean value)
Sets whether to draw the polygon bounds.void
setStrokeThickness(float value)
Sets the stroke thickness to use.String
strokeThicknessTipText()
Returns the tip text for this property.-
Methods inherited from class adams.gui.visualization.image.AbstractObjectOverlayFromReport
addLocationsUpdatedListeners, cleanUp, colorTipText, customizePopupMenu, doImageChanged, doPaintOverlay, getColor, getDefaultLabelAnchor, getDefaultLabelOffsetX, getDefaultLabelOffsetY, getLabelAnchor, getLabelFont, getLabelFormat, getLabelOffsetX, getLabelOffsetY, getLocatedObjectsPanel, getOverlays, getOwner, getPredefinedLabels, getPrefix, getShapeColorProvider, getShowObjectPanel, getTypeColor, getTypeColorProvider, getTypeRegExp, getTypeSuffix, getUseColorsPerType, getVaryShapeColor, hasTypeColor, initialize, labelAnchorTipText, labelFontTipText, labelFormatTipText, labelOffsetXTipText, labelOffsetYTipText, notifyLocationsUpdatedListeners, overlayAdded, overlayRemoved, predefinedLabelsTipText, prefixTipText, removeLocationsUpdatedListeners, setColor, setLabelAnchor, setLabelFont, setLabelFormat, setLabelOffsetX, setLabelOffsetY, setPredefinedLabels, setPrefix, setShapeColorProvider, setShowObjectPanel, setTypeColorProvider, setTypeRegExp, setTypeSuffix, setUseColorsPerType, setVaryShapeColor, shapeColorProviderTipText, showObjectPanelTipText, typeColorProviderTipText, typeRegExpTipText, typeSuffixTipText, useColorsPerTypeTipText, varyShapeColorTipText
-
Methods inherited from class adams.gui.visualization.image.AbstractImageOverlay
enabledTipText, imageChanged, isEnabled, paintOverlay, setEnabled, shallowCopy, shallowCopy
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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.Destroyable
destroy
-
Methods inherited from interface adams.gui.visualization.image.ImageOverlay
imageChanged, paintOverlay
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Filled
protected boolean m_Filled
whether to draw the shape filled.
-
m_OutlineAlpha
protected int m_OutlineAlpha
the alpha value to use for the polygon bounds.
-
m_OutlineColors
protected transient Map<Color,Color> m_OutlineColors
the colors for the polygon bounds.
-
m_PolygonBounds
protected boolean m_PolygonBounds
whether to draw the bounds of the polygon as well.
-
m_StrokeThickness
protected float m_StrokeThickness
the thickness of the stroke.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractObjectOverlayFromReport
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
setFilled
public void setFilled(boolean value)
Sets whether to draw the shape filled.- Parameters:
value
- true if to fill
-
getFilled
public boolean getFilled()
Returns whether to draw the shape filled.- Returns:
- true if to fill
-
filledTipText
public String filledTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPolygonBounds
public void setPolygonBounds(boolean value)
Sets whether to draw the polygon bounds.- Parameters:
value
- true if to draw bounds
-
getPolygonBounds
public boolean getPolygonBounds()
Returns whether to draw the polygon bounds.- Returns:
- true if to draw bounds
-
polygonBoundsTipText
public String polygonBoundsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOutlineAlpha
public void setOutlineAlpha(int value)
Sets the alpha value to use when drawing the outlines.- Parameters:
value
- the alpha value (0: transparent, 255: opaque)
-
getOutlineAlpha
public int getOutlineAlpha()
Returns the alpha value to use when drawing the outlines.- Returns:
- the alpha value (0: transparent, 255: opaque)
-
outlineAlphaTipText
public String outlineAlphaTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBoundingBoxFallbackRatio
public void setBoundingBoxFallbackRatio(double value)
Sets the ratio between shape area over bbox area. If below the bbox is used instead of the polygon.- Parameters:
value
- the ratio
-
getBoundingBoxFallbackRatio
public double getBoundingBoxFallbackRatio()
Returns the ratio between shape area over bbox area. If below the bbox is used instead of the polygon.- Returns:
- the ratio
-
boundingBoxFallbackRatioTipText
public String boundingBoxFallbackRatioTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStrokeThickness
public void setStrokeThickness(float value)
Sets the stroke thickness to use.- Parameters:
value
- the thickness
-
getStrokeThickness
public float getStrokeThickness()
Returns the current stroke thickness.- Returns:
- the thickness
-
strokeThicknessTipText
public String strokeThicknessTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getStrokeWidth
protected float getStrokeWidth(Graphics g, float defValue)
Returns the thickness of the stroke.- Parameters:
g
- graphics context to get the thickness fromdefValue
- the default value to return in case of failure- Returns:
- the stroke, default value if failed to extract
-
applyStroke
protected void applyStroke(Graphics g, float stroke)
Applies the stroke thickness.- Parameters:
stroke
- the thickness to apply
-
doPaintObjects
protected void doPaintObjects(ImagePanel.PaintPanel panel, Graphics g, List<Polygon> locations)
Performs the actual painting of the objects.- Specified by:
doPaintObjects
in classAbstractObjectOverlayFromReport
- Parameters:
panel
- the panel this overlay is forg
- the graphics contextlocations
- the locations to paint
-
-