jezuch.utils.starmapper.encoders
Class ImageEncoder

java.lang.Object
  |
  +--jezuch.utils.starmapper.encoders.ImageEncoder

public abstract class ImageEncoder
extends java.lang.Object

Starmapper's image encoding interface (abstract class), which can be subclassed by users to enhance Starmapper by ability to do whatever possible with produced galaxy map; it can be outputted to a file in any image format, it can be even sent over the network, I don't care :) Subclasses of this class must have public constructor with empty argument list, or Starmapper will generate error. They also have to be in package jezuch.utils.starmapper.encoders After you compile you have to put the class files in the package folder (jezuch/utils/starmapper/encoders) and put the folder in a zip (or jar) file named <encoder_name>.zip (case sensitive). That's the form in which you can distribute your plugin. Then you put the zip (jar) in "encoders" subdirectory of Starmapper's install dir and it should work.


Nested Class Summary
static class ImageEncoder.Parameter
          Class containing information for one encoder parameter.
 
Constructor Summary
ImageEncoder()
          Every Starmapper's ImageEncoder must have a public no-arg constructor.
 
Method Summary
abstract  void addImage(jezuch.utils.starmapper.encoders.RawImage img, int year)
          Encodes another image (for a given Stars!
abstract  void close()
          Closes encoder - useful for animated files, like animated GIF.
 java.lang.String getName()
          Returns name of this encoder.
abstract  ImageEncoder.Parameter[] getParameters()
          Returns list of parameters accepted by this encoder in Properties passed to initialise() as array of instances of ImageEncoder.Parameter classes.
abstract  void initialise(java.lang.String signature, java.util.Properties props)
          Initializes encoder - useful for animated files, like animated GIF.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageEncoder

public ImageEncoder()
Every Starmapper's ImageEncoder must have a public no-arg constructor. It is impossible to enforce it by design, but encoder won't be recognized if it doesn't have it.

Method Detail

initialise

public abstract void initialise(java.lang.String signature,
                                java.util.Properties props)
                         throws EncoderException
Initializes encoder - useful for animated files, like animated GIF. For formats without support for animation implementation of this method is usually empty. This method is always called by Starmapper before first image is sent to the encoder. It is passing to it runtime parameters in instance of java.util.Properties.

Parameters:
signature - a signature of game usually used to name images
props - instance of class Properties containing parameters specified at command line, usually format of output image. Set of properties can be empty, names of properties are dependent on encoder implementation and should be properly documented.
Throws:
EncoderException - thrown on general encoding failure

addImage

public abstract void addImage(jezuch.utils.starmapper.encoders.RawImage img,
                              int year)
                       throws EncoderException
Encodes another image (for a given Stars! year) - writes it to individual file or adds it to animation sequence.

Parameters:
img - RawImage containing all needed image information
year - Stars! year which this map comes from
Throws:
EncoderException - thrown on general encoding failure
See Also:
RawImage

close

public abstract void close()
                    throws EncoderException
Closes encoder - useful for animated files, like animated GIF. For formats without support for animation implementation of this method is usually empty.

Throws:
EncoderException - thrown on general encoding failure

getParameters

public abstract ImageEncoder.Parameter[] getParameters()
Returns list of parameters accepted by this encoder in Properties passed to initialise() as array of instances of ImageEncoder.Parameter classes. If no parameters are needed by this encoder, this method return 0-length array.

Returns:
list of encoder's parameters
See Also:
ImageEncoder.Parameter

getName

public final java.lang.String getName()
Returns name of this encoder. Name is generated automatically, so subclasses aren't allowed to override this method. This method is equivalent to:
 String className=getClass().getName();
 String pckgName=getClass().getPackage().getName();
 return className.substring(pckgName.length()+1);
 

Returns:
name of this encoder