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 Stringm_ColBottomthe column with the bottom coordinate.protected Stringm_ColHeightthe column with the height.protected Stringm_ColLeftthe column with the left coordinate.protected Stringm_ColPolygonXthe column with the polygon X coordinates.protected Stringm_ColPolygonYthe column with the polygon Y coordinates.protected Stringm_ColRightthe column with the right coordinate.protected Stringm_ColTopthe column with the top coordinate.protected Stringm_ColTypethe column with the label.protected Stringm_ColWidththe column with the width.protected ObjectFinderm_Finderthe row finder to apply before extracting the objects.protected intm_Heightthe image height to use as basis for normalized coordinates/dimensions.protected BaseString[]m_MetaDataKeysthe meta-data keys to output as well (comma-separated).protected Stringm_MetaDataKeyTypethe meta-data key for the type.protected booleanm_OutputNormalizedwhether to use normalized coordinates/dimensions.protected intm_Widththe image width to use as basis for normalized coordinates/dimensions.protected SpreadSheetWriterm_Writerthe 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 StringcolBottomTipText()Returns the tip text for this property.StringcolHeightTipText()Returns the tip text for this property.StringcolLeftTipText()Returns the tip text for this property.StringcolPolygonXTipText()Returns the tip text for this property.StringcolPolygonYTipText()Returns the tip text for this property.StringcolRightTipText()Returns the tip text for this property.StringcolTopTipText()Returns the tip text for this property.StringcolTypeTipText()Returns the tip text for this property.StringcolWidthTipText()Returns the tip text for this property.protected SpreadSheetconvert(Report data)Converts the report into a spreadsheet.voiddefineOptions()Adds options to the internal list of options.StringfinderTipText()Returns the tip text for this property.StringgetColBottom()Returns the column containing the bottom coordinate.StringgetColHeight()Returns the column containing the height coordinate.StringgetColLeft()Returns the column containing the left coordinate.StringgetColPolygonX()Returns the column containing the X coordinates of the polygon (comma-separated list of coordinates).StringgetColPolygonY()Returns the column containing the Y coordinates of the polygon (comma-separated list of coordinates).StringgetColRight()Returns the column containing the right coordinate.StringgetColTop()Returns the column containing the top coordinate.StringgetColType()Returns the column containing the object label.StringgetColWidth()Returns the column containing the width coordinate.ObjectFindergetFinder()Returns the row finder to use for selecting a subset before extracting object locations.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.intgetHeight()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.StringgetMetaDataKeyType()Returns the meta-data key containing the object label.booleangetOutputNormalized()Returns whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).intgetWidth()Returns the width of the image to use when reading normalized coordinates/dimensions.SpreadSheetWritergetWriter()Returns the spreadsheet writer in use.StringglobalInfo()Returns a string describing the object.StringheightTipText()Returns the tip text for this property.StringmetaDataKeysTipText()Returns the tip text for this property.StringmetaDataKeyTypeTipText()Returns the tip text for this property.protected doublenormalizeX(int x)Normalizes the x value.protected double[]normalizeX(int[] x)Normalizes the x values.protected doublenormalizeY(int y)Normalizes the y value.protected double[]normalizeY(int[] y)Normalizes the y values.StringoutputNormalizedTipText()Returns the tip text for this property.voidsetColBottom(String value)Sets the column containing the bottom coordinate.voidsetColHeight(String value)Sets the column containing the height coordinate.voidsetColLeft(String value)Sets the column containing the left coordinate.voidsetColPolygonX(String value)Sets the column containing the X coordinates of the polygon (comma-separated list of coordinates).voidsetColPolygonY(String value)Sets the column containing the Y coordinates of the polygon (comma-separated list of coordinates).voidsetColRight(String value)Sets the column containing the right coordinate.voidsetColTop(String value)Sets the column containing the top coordinate.voidsetColType(String value)Sets the column containing the object label.voidsetColWidth(String value)Sets the column containing the width coordinate.voidsetFinder(ObjectFinder value)Sets the row finder to use for selecting a subset before extracting object locations.voidsetHeight(int value)Sets the height of the image to use when reading normalized coordinates/dimensions.voidsetMetaDataKeys(BaseString[] value)Sets the meta-data keys to output as well.voidsetMetaDataKeyType(String value)Sets the meta-data key containing the object label.voidsetOutputNormalized(boolean value)Sets whether to output normalized (0-1) coordinates/dimensions as well (with 'n' column suffix).voidsetWidth(int value)Sets the width of the image to use when reading normalized coordinates/dimensions.voidsetWriter(SpreadSheetWriter value)Sets the spreadsheet writer to use.StringwidthTipText()Returns the tip text for this property.Stringwrite(Report data, MessageCollection errors)Performs checks and converts the report to a string.protected booleanwriteData(Report data)Performs the actual writing.StringwriterTipText()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:
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 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:
getFormatDescriptionin interfaceFileFormatHandler- Specified by:
getFormatDescriptionin 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:
getFormatExtensionsin interfaceFileFormatHandler- Specified by:
getFormatExtensionsin 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:
writeDatain 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:
writein interfaceStringReportWriter<Report>- Parameters:
data- the data to writeerrors- for collecting errors- Returns:
- the generated data, null in case of failure
-
-