Package adams.data.io.output
Class ApacheCommonsImageWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractImageWriter<BufferedImageContainer>
-
- adams.data.io.output.ApacheCommonsImageWriter
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,ImageWriter<BufferedImageContainer>
,OutputStreamImageWriter<BufferedImageContainer>
,Serializable
public class ApacheCommonsImageWriter extends AbstractImageWriter<BufferedImageContainer> implements OutputStreamImageWriter<BufferedImageContainer>
Apache Commons Imaging image writer for: bmp, gif, ico, pbm, pgm, png, pnm, ppm, tif, tiff
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.imaging.ImageFormats
m_ImageFormat
the image format to use (uses file extension to determine it if UNKNOWN).-
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 ApacheCommonsImageWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected String
doWrite(PlaceholderFile file, BufferedImageContainer cont)
Performs the actual writing of the image file.ImageReader
getCorrespondingReader()
Returns, if available, the corresponding reader.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.org.apache.commons.imaging.ImageFormats
getImageFormat()
Returns the image format to use.String
globalInfo()
Returns a string describing the object.String
imageFormatTipText()
Returns the tip text for this property.void
setImageFormat(org.apache.commons.imaging.ImageFormats value)
Sets the image format to use.String
write(OutputStream stream, BufferedImageContainer cont)
Writes the image to the stream.-
Methods inherited from class adams.data.io.output.AbstractImageWriter
check, getDefaultFormatExtension, getWriters, isAvailable, write
-
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.io.FileFormatHandler
getDefaultFormatExtension
-
Methods inherited from interface adams.data.io.output.ImageWriter
isAvailable, write
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
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
-
setImageFormat
public void setImageFormat(org.apache.commons.imaging.ImageFormats value)
Sets the image format to use. Requires an explicit format (other thanImageFormats.UNKNOWN
) when writing to a stream.- Parameters:
value
- the format
-
getImageFormat
public org.apache.commons.imaging.ImageFormats getImageFormat()
Returns the image format to use. Requires an explicit format (other thanImageFormats.UNKNOWN
) when writing to a stream.- Returns:
- the format
-
imageFormatTipText
public String imageFormatTipText()
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 classAbstractImageWriter<BufferedImageContainer>
- 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 classAbstractImageWriter<BufferedImageContainer>
- Returns:
- the extension(s) (without the dot!)
-
getCorrespondingReader
public ImageReader getCorrespondingReader()
Returns, if available, the corresponding reader.- Specified by:
getCorrespondingReader
in interfaceImageWriter<BufferedImageContainer>
- Specified by:
getCorrespondingReader
in classAbstractImageWriter<BufferedImageContainer>
- Returns:
- the reader, null if none available
-
doWrite
protected String doWrite(PlaceholderFile file, BufferedImageContainer cont)
Performs the actual writing of the image file.- Specified by:
doWrite
in classAbstractImageWriter<BufferedImageContainer>
- Parameters:
file
- the file to write tocont
- the image container to write- Returns:
- null if successful, otherwise error message
-
write
public String write(OutputStream stream, BufferedImageContainer cont)
Writes the image to the stream. Callers must close the stream.- Specified by:
write
in interfaceOutputStreamImageWriter<BufferedImageContainer>
- Parameters:
stream
- the stream to write tocont
- the image container to write- Returns:
- null if successfully written, otherwise error message
-
-