Class 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 Detail

      • 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.
    • Constructor Detail

      • ObjectLocationsSpreadSheetWriter

        public ObjectLocationsSpreadSheetWriter()
    • Method Detail

      • 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.
      • 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 class AbstractReportWriter<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 interface StringReportWriter<Report>
        Parameters:
        data - the data to write
        errors - for collecting errors
        Returns:
        the generated data, null in case of failure