Package adams.flow.transformer.draw
Class ObjectLocationsFromReport
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.transformer.draw.AbstractDrawOperation
-
- adams.flow.transformer.draw.AbstractDrawObjectsFromReport
-
- adams.flow.transformer.draw.ObjectLocationsFromReport
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,SizeOfHandler,Serializable
public class ObjectLocationsFromReport extends AbstractDrawObjectsFromReport
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
-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:
-stroke-thickness <float> (property: strokeThickness) The thickness of the stroke. default: 1.0 minimum: 0.01
-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
-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
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Filledwhether to draw the shape filled.protected intm_OutlineAlphathe alpha value to use for the outlines.protected Map<Color,Color>m_OutlineColorsthe colors for the polygon bounds.protected booleanm_PolygonBoundswhether to draw the bounds of the polygon as well.protected floatm_StrokeThicknessthe thickness of the stroke.-
Fields inherited from class adams.flow.transformer.draw.AbstractDrawObjectsFromReport
m_Overlays
-
Fields inherited from class adams.flow.transformer.draw.AbstractDrawOperation
m_Owner
-
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 ObjectLocationsFromReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyStroke(Graphics g, float stroke)Applies the stroke thickness.StringboundingBoxFallbackRatioTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoDraw(BufferedImageContainer image, List<Polygon> locations)Performs the actual drawing of the objects.StringfilledTipText()Returns the tip text for this property.doublegetBoundingBoxFallbackRatio()Returns the ratio between shape area over bbox area.booleangetFilled()Returns whether to draw the shape filled.intgetOutlineAlpha()Returns the alpha value to use when drawing the outlines.booleangetPolygonBounds()Returns whether to draw the polygon bounds.ColorProvidergetShapeColorProvider()Returns the color provider to use when varying the shape colors.floatgetStrokeThickness()Returns the current stroke thickness.protected floatgetStrokeWidth(Graphics g, float defValue)Returns the thickness of the stroke.booleangetVaryShapeColor()Returns whether to vary the colors of the shapes.StringglobalInfo()Returns a string describing the object.StringoutlineAlphaTipText()Returns the tip text for this property.StringpolygonBoundsTipText()Returns the tip text for this property.voidsetBoundingBoxFallbackRatio(double value)Sets the ratio between shape area over bbox area.voidsetFilled(boolean value)Sets whether to draw the shape filled.voidsetOutlineAlpha(int value)Sets the alpha value to use when drawing the outlines.voidsetPolygonBounds(boolean value)Sets whether to draw the polygon bounds.voidsetShapeColorProvider(ColorProvider value)Sets the color provider to use when varying the shape colors.voidsetStrokeThickness(float value)Sets the stroke thickness to use.voidsetVaryShapeColor(boolean value)Sets whether to vary the colors of the shapes.StringshapeColorProviderTipText()Returns the tip text for this property.StringstrokeThicknessTipText()Returns the tip text for this property.StringvaryShapeColorTipText()Returns the tip text for this property.-
Methods inherited from class adams.flow.transformer.draw.AbstractDrawObjectsFromReport
colorTipText, doDraw, getColor, getLabelAnchor, getLabelFont, getLabelFormat, getLabelOffsetX, getLabelOffsetY, getPredefinedLabels, getPrefix, getTypeColorProvider, getTypeRegExp, getTypeSuffix, getUseColorsPerType, initialize, labelAnchorTipText, labelFontTipText, labelFormatTipText, labelOffsetXTipText, labelOffsetYTipText, predefinedLabelsTipText, prefixTipText, setColor, setLabelAnchor, setLabelFont, setLabelFormat, setLabelOffsetX, setLabelOffsetY, setPredefinedLabels, setPrefix, setTypeColorProvider, setTypeRegExp, setTypeSuffix, setUseColorsPerType, typeColorProviderTipText, typeRegExpTipText, typeSuffixTipText, useColorsPerTypeTipText
-
Methods inherited from class adams.flow.transformer.draw.AbstractDrawOperation
check, draw, getOwner, getQuickInfo, setOwner
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, 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_StrokeThickness
protected float m_StrokeThickness
the thickness of the stroke.
-
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 outlines.
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractDrawObjectsFromReport
-
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.
-
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.
-
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.
-
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.
-
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.
-
setVaryShapeColor
public void setVaryShapeColor(boolean value)
Sets whether to vary the colors of the shapes.- Parameters:
value- true if to vary
-
getVaryShapeColor
public boolean getVaryShapeColor()
Returns whether to vary the colors of the shapes.- Returns:
- true if to vary
-
varyShapeColorTipText
public String varyShapeColorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setShapeColorProvider
public void setShapeColorProvider(ColorProvider value)
Sets the color provider to use when varying the shape colors.- Parameters:
value- the provider
-
getShapeColorProvider
public ColorProvider getShapeColorProvider()
Returns the color provider to use when varying the shape colors.- Returns:
- the provider
-
shapeColorProviderTipText
public String shapeColorProviderTipText()
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
-
doDraw
protected String doDraw(BufferedImageContainer image, List<Polygon> locations)
Performs the actual drawing of the objects.- Specified by:
doDrawin classAbstractDrawObjectsFromReport- Parameters:
image- the imagelocations- the locations to paint- Returns:
- null if OK, otherwise error message
-
-