Class PolygonAnnotator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.object.annotator.AbstractAnnotator
-
- adams.gui.visualization.object.annotator.AbstractReportBasedAnnotator
-
- adams.gui.visualization.object.annotator.AbstractRectangleBasedAnnotator
-
- adams.gui.visualization.object.annotator.PolygonAnnotator
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,ObjectPrefixHandler
,LabelSuffixHandler
,Serializable
public class PolygonAnnotator extends AbstractRectangleBasedAnnotator implements LabelSuffixHandler
For annotating object shapes with polygons boxes.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Color
m_Color
the color to use.protected boolean
m_Dragged
whether dragging has happened at all.protected String
m_LabelSuffix
the label suffix to use.protected int
m_MinDistance
the minimum distance in pixels that the trace pixels must be apart.protected MouseListener
m_MouseListener
the mouse listener to install.protected MouseMotionListener
m_MouseMotionListener
the mouse motion listener to install.protected Point
m_SelectionFrom
the starting corner of the selection box.protected Point
m_SelectionTo
the finishing corner of the selection box.protected List<Point>
m_SelectionTrace
the selection trace.protected float
m_StrokeThickness
the thickness of the stroke.-
Fields inherited from class adams.gui.visualization.object.annotator.AbstractRectangleBasedAnnotator
m_Locations, m_NumDigits
-
Fields inherited from class adams.gui.visualization.object.annotator.AbstractReportBasedAnnotator
m_Prefix
-
Fields inherited from class adams.gui.visualization.object.annotator.AbstractAnnotator
m_Owner, m_Selecting
-
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 PolygonAnnotator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canAddTracePoint(Point p)
Returns whether the current point is at least the specified distance away from the last one.String
colorTipText()
Returns the tip text for this property.protected MouseListener
createMouseListener()
Creates the listener for mouse events.protected MouseMotionListener
createMouseMotionListener()
Creates the listener for mouse motion events.void
defineOptions()
Adds options to the internal list of options.protected void
doInstall()
Installs the annotator with the owner.protected void
doPaintSelection(Graphics g)
Paints the selection.protected void
doUninstall()
Uninstalls the annotator with the owner.Color
getColor()
Returns the color to use.protected String
getDefaultLabelSuffix()
Returns the default suffix to use for the label.String
getLabelSuffix()
Returns the suffix to use for the label.int
getMinDistance()
Returns the minimum distance in pixels that a new point must be away from the last trace point.float
getStrokeThickness()
Returns the current stroke thickness.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.String
labelSuffixTipText()
Returns the tip text for this property.String
minDistanceTipText()
Returns the tip text for this property.protected void
processSelection(int modifiersEx)
Processes the selection.void
setColor(Color value)
Sets the color to use.void
setLabelSuffix(String value)
Sets the suffix to use for the label.void
setMinDistance(int value)
Sets the minimum distance in pixels that a new point must be away from the last trace point.void
setStrokeThickness(float value)
Sets the stroke thickness to use.String
strokeThicknessTipText()
Returns the tip text for this property.Polygon
traceToPolygon()
Turns the trace into a polygon.-
Methods inherited from class adams.gui.visualization.object.annotator.AbstractRectangleBasedAnnotator
annotationsChanged, getDefaultNumDigits, getDefaultPrefix, getLocations, getNumDigits, numDigitsTipText, reset, setNumDigits
-
Methods inherited from class adams.gui.visualization.object.annotator.AbstractReportBasedAnnotator
findLastIndex, getPrefix, prefixTipText, removeIndex, setPrefix, valuesForIndex
-
Methods inherited from class adams.gui.visualization.object.annotator.AbstractAnnotator
applyStroke, cleanUp, getCurrentLabel, getOwner, getStrokeWidth, hasCurrentLabel, install, labelChanged, paintSelection, setOwner, uninstall
-
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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Color
protected Color m_Color
the color to use.
-
m_StrokeThickness
protected float m_StrokeThickness
the thickness of the stroke.
-
m_MinDistance
protected int m_MinDistance
the minimum distance in pixels that the trace pixels must be apart.
-
m_LabelSuffix
protected String m_LabelSuffix
the label suffix to use.
-
m_Dragged
protected boolean m_Dragged
whether dragging has happened at all.
-
m_SelectionFrom
protected Point m_SelectionFrom
the starting corner of the selection box.
-
m_SelectionTo
protected Point m_SelectionTo
the finishing corner of the selection box.
-
m_MouseListener
protected MouseListener m_MouseListener
the mouse listener to install.
-
m_MouseMotionListener
protected MouseMotionListener m_MouseMotionListener
the mouse motion listener to install.
-
-
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 classAbstractRectangleBasedAnnotator
-
setColor
public void setColor(Color value)
Sets the color to use.- Parameters:
value
- the color
-
getColor
public Color getColor()
Returns the color to use.- 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.
-
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.
-
setMinDistance
public void setMinDistance(int value)
Sets the minimum distance in pixels that a new point must be away from the last trace point.- Parameters:
value
- the distance
-
getMinDistance
public int getMinDistance()
Returns the minimum distance in pixels that a new point must be away from the last trace point.- Returns:
- the distance
-
minDistanceTipText
public String minDistanceTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultLabelSuffix
protected String getDefaultLabelSuffix()
Returns the default suffix to use for the label.- Returns:
- the default
-
setLabelSuffix
public void setLabelSuffix(String value)
Sets the suffix to use for the label.- Specified by:
setLabelSuffix
in interfaceLabelSuffixHandler
- Parameters:
value
- the suffix
-
getLabelSuffix
public String getLabelSuffix()
Returns the suffix to use for the label.- Specified by:
getLabelSuffix
in interfaceLabelSuffixHandler
- Returns:
- the suffix
-
labelSuffixTipText
public String labelSuffixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractAnnotator
-
createMouseListener
protected MouseListener createMouseListener()
Creates the listener for mouse events.- Returns:
- the instance
-
createMouseMotionListener
protected MouseMotionListener createMouseMotionListener()
Creates the listener for mouse motion events.- Returns:
- the instance
-
canAddTracePoint
public boolean canAddTracePoint(Point p)
Returns whether the current point is at least the specified distance away from the last one.- Parameters:
p
- the point to check- Returns:
- true if can be added
-
traceToPolygon
public Polygon traceToPolygon()
Turns the trace into a polygon.- Returns:
- the polygon, null if unable to convert (eg empty trace)
-
processSelection
protected void processSelection(int modifiersEx)
Processes the selection.- Parameters:
modifiersEx
- the associated modifiers
-
doInstall
protected void doInstall()
Installs the annotator with the owner.- Specified by:
doInstall
in classAbstractAnnotator
-
doUninstall
protected void doUninstall()
Uninstalls the annotator with the owner.- Specified by:
doUninstall
in classAbstractAnnotator
-
doPaintSelection
protected void doPaintSelection(Graphics g)
Paints the selection.- Specified by:
doPaintSelection
in classAbstractAnnotator
- Parameters:
g
- the graphics context
-
-