net.aerith.misao.image
Class Buffer

java.lang.Object
  |
  +--net.aerith.misao.image.Buffer
Direct Known Subclasses:
ByteBuffer, DoubleBuffer, FloatBuffer, IntBuffer, ShortBuffer

public abstract class Buffer
extends java.lang.Object
implements Statisticable

The Buffer is an abstract class of an image buffer. This is the base class of ByteBuffer, IntBuffer, etc.


Field Summary
protected  boolean signed_flag
          If the value is to be considered as signed, it is true.
protected  Size size
          The image size.
 
Constructor Summary
Buffer()
           
 
Method Summary
abstract  Buffer cloneBuffer()
          Creates a clone image buffer.
 int getDataCount()
          Gets the number of data.
 Size getSize()
          Gets the image size.
abstract  double getValue(int x, int y)
          Gets pixel value of a specified position.
 double getValueAt(int index)
          Gets the value of data at the specified location.
abstract  void inverse()
          Inverses white and black.
abstract  void read(java.io.DataInput input, Size size)
          Reads pixel values and set pixel values into the buffer.
abstract  void reverseHorizontally()
          Reverses left to the right.
abstract  void reverseVertically()
          Reverses upside down.
 void setSigned()
          Sets the flag to be signed.
abstract  void setValue(int x, int y, double value)
          Sets pixel value of a specified position.
abstract  void write(java.io.DataOutput output)
          Write pixel values into the specified stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

size

protected Size size
The image size.

signed_flag

protected boolean signed_flag
If the value is to be considered as signed, it is true.
Constructor Detail

Buffer

public Buffer()
Method Detail

getSize

public Size getSize()
Gets the image size.
Returns:
the image size.

setSigned

public void setSigned()
Sets the flag to be signed. It only effects in the case of short type FITS image to be read and saved.

getDataCount

public int getDataCount()
Gets the number of data.
Specified by:
getDataCount in interface Statisticable
Returns:
the number of data.

getValueAt

public double getValueAt(int index)
                  throws java.lang.IndexOutOfBoundsException
Gets the value of data at the specified location.
Specified by:
getValueAt in interface Statisticable
Parameters:
index - the location of the data.
Returns:
the value of data at the specified location.
Throws:
java.lang.IndexOutOfBoundsException - if specified location is out of the data buffer.

getValue

public abstract double getValue(int x,
                                int y)
                         throws java.lang.IndexOutOfBoundsException
Gets pixel value of a specified position.
Parameters:
x - the x position.
y - the y position.
Returns:
the pixel value of the position.
Throws:
java.lang.IndexOutOfBoundsException - if specified position is out of the image area.

setValue

public abstract void setValue(int x,
                              int y,
                              double value)
                       throws java.lang.IndexOutOfBoundsException
Sets pixel value of a specified position. The value is forcedly converted into the data type of image buffer.
Parameters:
x - the x position.
y - the y position.
value - the value to set.
Throws:
java.lang.IndexOutOfBoundsException - if specified position is out of the image area.

read

public abstract void read(java.io.DataInput input,
                          Size size)
                   throws java.io.IOException
Reads pixel values and set pixel values into the buffer.
Parameters:
input - the input stream pointing to the start of int data.
size - the size of image.
Throws:
java.io.IOException - if I/O error occurs.

write

public abstract void write(java.io.DataOutput output)
                    throws java.io.IOException
Write pixel values into the specified stream.
Parameters:
output - the output stream.
Throws:
java.io.IOException - if I/O error occurs.

inverse

public abstract void inverse()
Inverses white and black.

reverseVertically

public abstract void reverseVertically()
Reverses upside down.

reverseHorizontally

public abstract void reverseHorizontally()
Reverses left to the right.

cloneBuffer

public abstract Buffer cloneBuffer()
Creates a clone image buffer.
Returns:
the new clone image buffer.