Package adams.data.io.output
Class ObjectLocationsSpreadSheetWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractReportWriter<Report>
-
- adams.data.io.output.ObjectLocationsSpreadSheetWriter
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<AbstractReportWriter>
,SizeOfHandler
,ReportWriter<Report>
,StringReportWriter<Report>
,Serializable
,Comparable
public class ObjectLocationsSpreadSheetWriter extends AbstractReportWriter<Report> implements StringReportWriter<Report>
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-output <adams.core.io.PlaceholderFile> (property: output) The file to write the report to. default: ${TMP}/out.*
-writer <adams.data.io.output.SpreadSheetWriter> (property: writer) The writer to use for writing the spreadsheet. default: adams.data.io.output.CsvSpreadSheetWriter
-finder <adams.data.objectfinder.ObjectFinder> (property: finder) The object finder to use for selecting a subset of objects before generating the spreadsheet. default: adams.data.objectfinder.AllFinder
-col-left <java.lang.String> (property: colLeft) The column containing the left coordinate. default:
-col-top <java.lang.String> (property: colTop) The column containing the top coordinate. default:
-col-right <java.lang.String> (property: colRight) The column containing the right coordinate. default:
-col-bottom <java.lang.String> (property: colBottom) The column containing the bottom coordinate. default:
-col-width <java.lang.String> (property: colWidth) The column containing the width coordinate. default:
-col-height <java.lang.String> (property: colHeight) The column containing the height coordinate. default:
-col-polygon-x <java.lang.String> (property: colPolygonX) The column containing the X coordinates of the polygon (comma-separated list of coordinates); cannot be used without bounding box. default:
-col-polygon-y <java.lang.String> (property: colPolygonY) The column containing the Y coordinates of the polygon (comma-separated list of coordinates); cannot be used without bounding box. default:
-col-type <java.lang.String> (property: colType) The column containing the object label. default:
-meta-data-key-type <java.lang.String> (property: metaDataKeyType) The meta-data key for the type (= label). default: type
-meta-data-keys <adams.core.base.BaseString> [-meta-data-keys ...] (property: metaDataKeys) The keys of the meta-data values to output as well (keys are used as column names). default:
-output-normalized <boolean> (property: outputNormalized) If enabled, normalized coordinates/dimensions (0-1) are output as well with a 'n' suffix in the column name. default: false
-width <int> (property: width) The width of the image to use when reading normalized coordinates/dimensions. default: 1000 minimum: 1
-height <int> (property: height) The height of the image to use when reading normalized coordinates/dimensions. default: 1000 minimum: 1
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_ColBottom
the column with the bottom coordinate.protected String
m_ColHeight
the column with the height.protected String
m_ColLeft
the column with the left coordinate.protected String
m_ColPolygonX
the column with the polygon X coordinates.protected String
m_ColPolygonY
the column with the polygon Y coordinates.protected String
m_ColRight
the column with the right coordinate.protected String
m_ColTop
the column with the top coordinate.protected String
m_ColType
the column with the label.protected String
m_ColWidth
the column with the width.protected ObjectFinder
m_Finder
the row finder to apply before extracting the objects.protected int
m_Height
the image height to use as basis for normalized coordinates/dimensions.protected BaseString[]
m_MetaDataKeys
the meta-data keys to output as well (comma-separated).protected String
m_MetaDataKeyType
the meta-data key for the type.protected boolean
m_OutputNormalized
whether to use normalized coordinates/dimensions.protected int
m_Width
the image width to use as basis for normalized coordinates/dimensions.protected SpreadSheetWriter
m_Writer
the spreadsheet writer to use.-
Fields inherited from class adams.data.io.output.AbstractReportWriter
m_Output
-
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 ObjectLocationsSpreadSheetWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
colBottomTipText()
Returns the tip text for this property.String
colHeightTipText()
Returns the tip text for this property.String
colLeftTipText()
Returns the tip text for this property.String
colPolygonXTipText()
Returns the tip text for this property.String
colPolygonYTipText()
Returns the tip text for this property.String
colRightTipText()
Returns the tip text for this property.String
colTopTipText()
Returns the tip text for this property.String
colTypeTipText()
Returns the tip text for this property.String
colWidthTipText()
Returns the tip text for this property.protected SpreadSheet
convert(Report data)
Converts the report into a spreadsheet.void
defineOptions()
Adds options to the internal list of options.String
finderTipText()
Returns the tip text for this property.String
getColBottom()
Returns the column containing the bottom coordinate.String
getColHeight()
Returns the column containing the height coordinate.String
getColLeft()
Returns the column containing the left coordinate.String
getColPolygonX()
Returns the column containing the X coordinates of the polygon (comma-separated list of coordinates).String
getColPolygonY()
Returns the column containing the Y coordinates of the polygon (comma-separated list of coordinates).String
getColRight()
Returns the column containing the right coordinate.String
getColTop()
Returns the column containing the top coordinate.String
getColType()
Returns the column containing the object label.String
getColWidth()
Returns the column containing the width coordinate.ObjectFinder
getFinder()
Returns the row finder to use for selecting a subset before extracting object locations.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.int
getHeight()
Returns the height of the image to use when reading normalized coordinates/dimensions.BaseString[]
getMetaDataKeys()
Returns the range of columns to store as meta-data.String
getMetaDataKeyType()
Returns the meta-data key containing the object label.boolean
getOutputNormalized()
Returns whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).int
getWidth()
Returns the width of the image to use when reading normalized coordinates/dimensions.SpreadSheetWriter
getWriter()
Returns the spreadsheet writer in use.String
globalInfo()
Returns a string describing the object.String
heightTipText()
Returns the tip text for this property.String
metaDataKeysTipText()
Returns the tip text for this property.String
metaDataKeyTypeTipText()
Returns the tip text for this property.protected double
normalizeX(int x)
Normalizes the x value.protected double[]
normalizeX(int[] x)
Normalizes the x values.protected double
normalizeY(int y)
Normalizes the y value.protected double[]
normalizeY(int[] y)
Normalizes the y values.String
outputNormalizedTipText()
Returns the tip text for this property.void
setColBottom(String value)
Sets the column containing the bottom coordinate.void
setColHeight(String value)
Sets the column containing the height coordinate.void
setColLeft(String value)
Sets the column containing the left coordinate.void
setColPolygonX(String value)
Sets the column containing the X coordinates of the polygon (comma-separated list of coordinates).void
setColPolygonY(String value)
Sets the column containing the Y coordinates of the polygon (comma-separated list of coordinates).void
setColRight(String value)
Sets the column containing the right coordinate.void
setColTop(String value)
Sets the column containing the top coordinate.void
setColType(String value)
Sets the column containing the object label.void
setColWidth(String value)
Sets the column containing the width coordinate.void
setFinder(ObjectFinder value)
Sets the row finder to use for selecting a subset before extracting object locations.void
setHeight(int value)
Sets the height of the image to use when reading normalized coordinates/dimensions.void
setMetaDataKeys(BaseString[] value)
Sets the meta-data keys to output as well.void
setMetaDataKeyType(String value)
Sets the meta-data key containing the object label.void
setOutputNormalized(boolean value)
Sets whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).void
setWidth(int value)
Sets the width of the image to use when reading normalized coordinates/dimensions.void
setWriter(SpreadSheetWriter value)
Sets the spreadsheet writer to use.String
widthTipText()
Returns the tip text for this property.String
write(Report data, MessageCollection errors)
Performs checks and converts the report to a string.protected boolean
writeData(Report data)
Performs the actual writing.String
writerTipText()
Returns the tip text for this property.-
Methods inherited from class adams.data.io.output.AbstractReportWriter
checkData, cleanUp, compareTo, destroy, equals, forCommandLine, forName, getDefaultFormatExtension, getOutput, getWriters, outputTipText, reset, setOutput, shallowCopy, shallowCopy, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.data.io.output.ReportWriter
getOutput, outputTipText, setOutput, write
-
-
-
-
Field Detail
-
m_Writer
protected SpreadSheetWriter m_Writer
the spreadsheet writer to use.
-
m_Finder
protected ObjectFinder m_Finder
the row finder to apply before extracting the objects.
-
m_ColLeft
protected String m_ColLeft
the column with the left coordinate.
-
m_ColTop
protected String m_ColTop
the column with the top coordinate.
-
m_ColRight
protected String m_ColRight
the column with the right coordinate.
-
m_ColBottom
protected String m_ColBottom
the column with the bottom coordinate.
-
m_ColWidth
protected String m_ColWidth
the column with the width.
-
m_ColHeight
protected String m_ColHeight
the column with the height.
-
m_ColPolygonX
protected String m_ColPolygonX
the column with the polygon X coordinates.
-
m_ColPolygonY
protected String m_ColPolygonY
the column with the polygon Y coordinates.
-
m_ColType
protected String m_ColType
the column with the label.
-
m_MetaDataKeyType
protected String m_MetaDataKeyType
the meta-data key for the type.
-
m_MetaDataKeys
protected BaseString[] m_MetaDataKeys
the meta-data keys to output as well (comma-separated).
-
m_OutputNormalized
protected boolean m_OutputNormalized
whether to use normalized coordinates/dimensions.
-
m_Width
protected int m_Width
the image width to use as basis for normalized coordinates/dimensions.
-
m_Height
protected int m_Height
the image height to use as basis for normalized coordinates/dimensions.
-
-
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 classAbstractReportWriter<Report>
-
setWriter
public void setWriter(SpreadSheetWriter value)
Sets the spreadsheet writer to use.- Parameters:
value
- the writer
-
getWriter
public SpreadSheetWriter getWriter()
Returns the spreadsheet writer in use.- Returns:
- the writer
-
writerTipText
public String writerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFinder
public void setFinder(ObjectFinder value)
Sets the row finder to use for selecting a subset before extracting object locations.- Parameters:
value
- the finder
-
getFinder
public ObjectFinder getFinder()
Returns the row finder to use for selecting a subset before extracting object locations.- Returns:
- the finder
-
finderTipText
public String finderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColLeft
public void setColLeft(String value)
Sets the column containing the left coordinate.- Parameters:
value
- the column
-
getColLeft
public String getColLeft()
Returns the column containing the left coordinate.- Returns:
- the column
-
colLeftTipText
public String colLeftTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColTop
public void setColTop(String value)
Sets the column containing the top coordinate.- Parameters:
value
- the column
-
getColTop
public String getColTop()
Returns the column containing the top coordinate.- Returns:
- the column
-
colTopTipText
public String colTopTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColRight
public void setColRight(String value)
Sets the column containing the right coordinate.- Parameters:
value
- the column
-
getColRight
public String getColRight()
Returns the column containing the right coordinate.- Returns:
- the column
-
colRightTipText
public String colRightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColBottom
public void setColBottom(String value)
Sets the column containing the bottom coordinate.- Parameters:
value
- the column
-
getColBottom
public String getColBottom()
Returns the column containing the bottom coordinate.- Returns:
- the column
-
colBottomTipText
public String colBottomTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColWidth
public void setColWidth(String value)
Sets the column containing the width coordinate.- Parameters:
value
- the column
-
getColWidth
public String getColWidth()
Returns the column containing the width coordinate.- Returns:
- the column
-
colWidthTipText
public String colWidthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColHeight
public void setColHeight(String value)
Sets the column containing the height coordinate.- Parameters:
value
- the column
-
getColHeight
public String getColHeight()
Returns the column containing the height coordinate. Cannot be used without bounding box.- Returns:
- the column
-
colHeightTipText
public String colHeightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColPolygonX
public void setColPolygonX(String value)
Sets the column containing the X coordinates of the polygon (comma-separated list of coordinates). Cannot be used without bounding box.- Parameters:
value
- the column
-
getColPolygonX
public String getColPolygonX()
Returns the column containing the X coordinates of the polygon (comma-separated list of coordinates).- Returns:
- the column
-
colPolygonXTipText
public String colPolygonXTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColPolygonY
public void setColPolygonY(String value)
Sets the column containing the Y coordinates of the polygon (comma-separated list of coordinates). Cannot be used without bounding box.- Parameters:
value
- the column
-
getColPolygonY
public String getColPolygonY()
Returns the column containing the Y coordinates of the polygon (comma-separated list of coordinates). Cannot be used without bounding box.- Returns:
- the column
-
colPolygonYTipText
public String colPolygonYTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColType
public void setColType(String value)
Sets the column containing the object label.- Parameters:
value
- the column
-
getColType
public String getColType()
Returns the column containing the object label.- Returns:
- the column
-
colTypeTipText
public String colTypeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMetaDataKeyType
public void setMetaDataKeyType(String value)
Sets the meta-data key containing the object label.- Parameters:
value
- the key
-
getMetaDataKeyType
public String getMetaDataKeyType()
Returns the meta-data key containing the object label.- Returns:
- the key
-
metaDataKeyTypeTipText
public String metaDataKeyTypeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOutputNormalized
public void setOutputNormalized(boolean value)
Sets whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).- Parameters:
value
- true if to output
-
getOutputNormalized
public boolean getOutputNormalized()
Returns whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).- Returns:
- true if to output
-
outputNormalizedTipText
public String outputNormalizedTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWidth
public void setWidth(int value)
Sets the width of the image to use when reading normalized coordinates/dimensions.- Parameters:
value
- the image width
-
getWidth
public int getWidth()
Returns the width of the image to use when reading normalized coordinates/dimensions.- Returns:
- the image width
-
widthTipText
public String widthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setHeight
public void setHeight(int value)
Sets the height of the image to use when reading normalized coordinates/dimensions.- Parameters:
value
- the image height
-
getHeight
public int getHeight()
Returns the height of the image to use when reading normalized coordinates/dimensions.- Returns:
- the image height
-
heightTipText
public String heightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMetaDataKeys
public void setMetaDataKeys(BaseString[] value)
Sets the meta-data keys to output as well.- Parameters:
value
- the column range
-
getMetaDataKeys
public BaseString[] getMetaDataKeys()
Returns the range of columns to store as meta-data.- Returns:
- the column range
-
metaDataKeysTipText
public String metaDataKeysTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in classAbstractReportWriter<Report>
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in classAbstractReportWriter<Report>
- Returns:
- the extension(s) (without the dot!)
-
normalizeX
protected double normalizeX(int x)
Normalizes the x value.- Parameters:
x
- the value to normalize- Returns:
- the normalized value
-
normalizeX
protected double[] normalizeX(int[] x)
Normalizes the x values.- Parameters:
x
- the values to normalize- Returns:
- the normalized values
-
normalizeY
protected double normalizeY(int y)
Normalizes the y value.- Parameters:
y
- the value to normalize- Returns:
- the normalized value
-
normalizeY
protected double[] normalizeY(int[] y)
Normalizes the y values.- Parameters:
y
- the values to normalize- Returns:
- the normalized values
-
convert
protected SpreadSheet convert(Report data)
Converts the report into a spreadsheet.- Parameters:
data
- the report to convert- Returns:
- the generated spreadsheet
-
writeData
protected boolean writeData(Report data)
Performs the actual writing.- Specified by:
writeData
in classAbstractReportWriter<Report>
- Parameters:
data
- the data to write- Returns:
- true if successfully written
-
write
public String write(Report data, MessageCollection errors)
Performs checks and converts the report to a string.- Specified by:
write
in interfaceStringReportWriter<Report>
- Parameters:
data
- the data to writeerrors
- for collecting errors- Returns:
- the generated data, null in case of failure
-
-