Package adams.gui.tools.previewbrowser
Class ImageClassificationHandler
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.tools.previewbrowser.AbstractContentHandler
-
- adams.gui.tools.previewbrowser.ImageClassificationHandler
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,ContentHandler
,Serializable
public class ImageClassificationHandler extends AbstractContentHandler
Overlays the annotations onto the image.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-image-reader <adams.data.io.input.AbstractImageReader> (property: imageReader) The image reader to use. default: adams.data.io.input.JAIImageReader
-file-suffix <java.lang.String> (property: fileSuffix) The forced suffix (incl ext) to append to the image name for generating the meta-data file name. default:
-reader <adams.data.io.input.AbstractReportReader> (property: reader) The reader setup to use for reading the object locations from the spreadsheet. default: adams.data.io.input.DefaultSimpleReportReader
-field-label <adams.data.report.Field> (property: fieldLabel) The field to store the label under. default: Classification[S]
-field-score <adams.data.report.Field> (property: fieldScore) The field to store the score under. default: Score[N]
-format <java.lang.String> (property: format) The label format string to use for the rectangles; '@' for type and '$' for short type, '{score}' gets replaced with the score (if present); for instance: '@' or '{score}'; in case of numeric values, use '|.X' to limit the number of decimals, eg '{score|.2}' for a maximum of decimals after the decimal point. default: $
-font <java.awt.Font> (property: font) The font to use for the labels. default: Display-PLAIN-14
-color <java.awt.Color> (property: color) The color of the text. default: #ff0000
-offset-x <int> (property: offsetX) 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: 20
-offset-y <int> (property: offsetY) 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: 20
- 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 of the text.protected Field
m_FieldLabel
the report field to get the label from.protected Field
m_FieldScore
the report file to get the score from.protected String
m_FileSuffix
the file suffix to force (incl extension).protected Font
m_Font
the label font.protected String
m_Format
the label for the label.protected ImageReader
m_ImageReader
the image reader to use.protected int
m_OffsetX
the x offset for the label.protected int
m_OffsetY
the y offset for the label.protected AbstractReportReader
m_Reader
the reader to use.-
Fields inherited from class adams.gui.tools.previewbrowser.AbstractContentHandler
m_Relation
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.gui.tools.previewbrowser.ContentHandler
MATCH_ALL
-
-
Constructor Summary
Constructors Constructor Description ImageClassificationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
applyLabelFormat(String label, Double score, String labelFormat)
Applies the label format to the object to generate a display string.String
colorTipText()
Returns the tip text for this property.PreviewPanel
createPreview(File file)
Creates the actual view.void
defineOptions()
Adds options to the internal list of options.String
fieldLabelTipText()
Returns the tip text for this property.String
fieldScoreTipText()
Returns the tip text for this property.String
fileSuffixTipText()
Returns the tip text for this property.String
fontTipText()
Returns the tip text for this property.String
formatTipText()
Returns the tip text for this property.Color
getColor()
Returns the color of the text.protected ImageReader
getDefaultImageReader()
Returns the default image reader.protected AbstractReportReader
getDefaultReader()
Returns the default reader.String[]
getExtensions()
Returns the list of extensions (without dot) that this handler can take care of.Field
getFieldLabel()
Returns the field for the label.Field
getFieldScore()
Returns the field for the score.String
getFileSuffix()
Returns the forced suffix (incl ext) to append to the image name for generating the meta-data file name.Font
getFont()
Returns the label font.String
getFormat()
Returns the label format.ImageReader
getImageReader()
Returns the image reader to use.int
getOffsetX()
Returns the X offset for the label.int
getOffsetY()
Returns the Y offset for the label.AbstractReportReader
getReader()
Returns the reader setup to use for reading the object locations from the spreadsheet.String
globalInfo()
Returns a string describing the object.String
imageReaderTipText()
Returns the tip text for this property.protected Report
loadAnnotations(ImagePanel panel, File file)
Loads the report associated with the image.String
offsetXTipText()
Returns the tip text for this property.String
offsetYTipText()
Returns the tip text for this property.String
readerTipText()
Returns the tip text for this property.PreviewPanel
reusePreview(File file, PreviewPanel previewPanel)
Reuses the last preview, if possible.void
setColor(Color value)
Sets the color of the text.void
setFieldLabel(Field value)
Sets the field for the label.void
setFieldScore(Field value)
Sets the field for the score.void
setFileSuffix(String value)
Sets the forced suffix (incl ext) to append to the image name for generating the meta-data file name.void
setFont(Font value)
Sets the label font.void
setFormat(String value)
Sets the label format.void
setImageReader(ImageReader value)
Sets the image reader to use.void
setOffsetX(int value)
Sets the X offset for the label.void
setOffsetY(int value)
Sets the Y offset for the label.void
setReader(AbstractReportReader value)
Sets the reader setup to use for reading the object locations from the spreadsheet.-
Methods inherited from class adams.gui.tools.previewbrowser.AbstractContentHandler
checkFile, getHandlers, getHandlersForFile, getHandlersForFile, getPreview, getRelation, hasHandler, hasHandler
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, 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.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_FileSuffix
protected String m_FileSuffix
the file suffix to force (incl extension).
-
m_ImageReader
protected ImageReader m_ImageReader
the image reader to use.
-
m_Reader
protected AbstractReportReader m_Reader
the reader to use.
-
m_FieldLabel
protected Field m_FieldLabel
the report field to get the label from.
-
m_FieldScore
protected Field m_FieldScore
the report file to get the score from.
-
m_Format
protected String m_Format
the label for the label.
-
m_Font
protected Font m_Font
the label font.
-
m_Color
protected Color m_Color
the color of the text.
-
m_OffsetX
protected int m_OffsetX
the x offset for the label.
-
m_OffsetY
protected int m_OffsetY
the y offset for the label.
-
-
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 classAbstractOptionHandler
-
getDefaultImageReader
protected ImageReader getDefaultImageReader()
Returns the default image reader.- Returns:
- the default
-
setImageReader
public void setImageReader(ImageReader value)
Sets the image reader to use.- Parameters:
value
- the reader
-
getImageReader
public ImageReader getImageReader()
Returns the image reader to use.- Returns:
- the reader
-
imageReaderTipText
public String imageReaderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultReader
protected AbstractReportReader getDefaultReader()
Returns the default reader.- Returns:
- the reader
-
setFileSuffix
public void setFileSuffix(String value)
Sets the forced suffix (incl ext) to append to the image name for generating the meta-data file name.- Parameters:
value
- the suffix
-
getFileSuffix
public String getFileSuffix()
Returns the forced suffix (incl ext) to append to the image name for generating the meta-data file name.- Returns:
- the suffix
-
fileSuffixTipText
public String fileSuffixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setReader
public void setReader(AbstractReportReader value)
Sets the reader setup to use for reading the object locations from the spreadsheet.- Parameters:
value
- the reader
-
getReader
public AbstractReportReader getReader()
Returns the reader setup to use for reading the object locations from the spreadsheet.- Returns:
- the reader
-
readerTipText
public String readerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFieldLabel
public void setFieldLabel(Field value)
Sets the field for the label.- Parameters:
value
- the field
-
getFieldLabel
public Field getFieldLabel()
Returns the field for the label.- Returns:
- the field
-
fieldLabelTipText
public String fieldLabelTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFieldScore
public void setFieldScore(Field value)
Sets the field for the score.- Parameters:
value
- the field
-
getFieldScore
public Field getFieldScore()
Returns the field for the score.- Returns:
- the field
-
fieldScoreTipText
public String fieldScoreTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFormat
public void setFormat(String value)
Sets the label format.- Parameters:
value
- the label format
-
getFormat
public String getFormat()
Returns the label format.- Returns:
- the label format
-
formatTipText
public String formatTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFont
public void setFont(Font value)
Sets the label font.- Parameters:
value
- the label font
-
getFont
public Font getFont()
Returns the label font.- Returns:
- the label font
-
fontTipText
public String fontTipText()
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 of the text.- Parameters:
value
- the color
-
getColor
public Color getColor()
Returns the color of the text.- 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.
-
setOffsetX
public void setOffsetX(int value)
Sets the X offset for the label.- Parameters:
value
- the X offset
-
getOffsetX
public int getOffsetX()
Returns the X offset for the label.- Returns:
- the X offset
-
offsetXTipText
public String offsetXTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOffsetY
public void setOffsetY(int value)
Sets the Y offset for the label.- Parameters:
value
- the Y offset
-
getOffsetY
public int getOffsetY()
Returns the Y offset for the label.- Returns:
- the Y offset
-
offsetYTipText
public String offsetYTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getExtensions
public String[] getExtensions()
Returns the list of extensions (without dot) that this handler can take care of.- Returns:
- the list of extensions (no dot)
-
applyLabelFormat
protected String applyLabelFormat(String label, Double score, String labelFormat)
Applies the label format to the object to generate a display string.- Parameters:
label
- the label to usescore
- the score to use, ignored if nulllabelFormat
- the label format to use- Returns:
- the generated label
-
loadAnnotations
protected Report loadAnnotations(ImagePanel panel, File file)
Loads the report associated with the image.- Parameters:
panel
- the context panelfile
- the image file- Returns:
- the report, null if failed to load report data or none available
-
createPreview
public PreviewPanel createPreview(File file)
Creates the actual view.- Specified by:
createPreview
in interfaceContentHandler
- Specified by:
createPreview
in classAbstractContentHandler
- Parameters:
file
- the file to create the view for- Returns:
- the view
-
reusePreview
public PreviewPanel reusePreview(File file, PreviewPanel previewPanel)
Reuses the last preview, if possible.- Specified by:
reusePreview
in interfaceContentHandler
- Overrides:
reusePreview
in classAbstractContentHandler
- Parameters:
file
- the file to create the view for- Returns:
- the view
-
-