com.anji.imaging
Class Java2DSurface

java.lang.Object
  extended bycom.anji.imaging.Java2DSurface
All Implemented Interfaces:
Configurable, Surface

public class Java2DSurface
extends java.lang.Object
implements Surface, Configurable

A 2-d matrix of int values (this could be a graphical image or a game board) used by FloatingEye. Also contains logic to transform surface image to eye image. init() and one of tne of the setImage() functions must be called before this object is fully initialized.

Author:
Philip Tucker

Field Summary
 
Fields inherited from interface com.anji.imaging.Surface
SURFACE_HEIGHT_KEY, SURFACE_WIDTH_KEY, TRANSFORMER_CLASS_KEY
 
Constructor Summary
Java2DSurface()
          default ctor
 
Method Summary
 java.awt.image.BufferedImage getBufferedImage()
           
 int[] getData()
           
 int getHeight()
           
 int getValue(int x, int y)
           
 int getWidth()
           
 void init(Properties props)
           
 void setImage(java.awt.image.BufferedImage newData)
          set values of 2-d rectangular surface BufferedImage; this image is larger than specified dimension so floating eye can go off the edge; these "off the edge" spaces are set to aNonviewableSpaceValue
 void setImage(java.io.File imageFile)
          Set source data of image.
 java.lang.String toString()
           
 java.lang.String toXml()
           
 int[] transform(TransformParameters parms)
          transform image via translate, rotate, scale, crop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Java2DSurface

public Java2DSurface()
default ctor

Method Detail

setImage

public void setImage(java.io.File imageFile)
              throws java.io.IOException
Description copied from interface: Surface
Set source data of image. The image file is scaled (using area averaging) to surface size.

Specified by:
setImage in interface Surface
Parameters:
imageFile -
Throws:
java.io.IOException
See Also:
Surface.setImage(File), setImage(BufferedImage)

setImage

public void setImage(java.awt.image.BufferedImage newData)
set values of 2-d rectangular surface BufferedImage; this image is larger than specified dimension so floating eye can go off the edge; these "off the edge" spaces are set to aNonviewableSpaceValue

Parameters:
newData -

getWidth

public int getWidth()
Specified by:
getWidth in interface Surface
Returns:
x dimension (aka width) of square 2-d surface

getHeight

public int getHeight()
Specified by:
getHeight in interface Surface
Returns:
y dimension (aka height) of square 2-d surface

getValue

public int getValue(int x,
                    int y)
Specified by:
getValue in interface Surface
Parameters:
x -
y -
Returns:
value for space at position x,y

toXml

public java.lang.String toXml()
Returns:
String XML representation of object

toString

public java.lang.String toString()
See Also:
Object.toString()

getData

public int[] getData()
Specified by:
getData in interface Surface
Returns:
viewable surface dataPlusGutter
See Also:
Surface.getData()

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Returns:
BufferedImage dataPlusGutter, not including "gutter"

transform

public int[] transform(TransformParameters parms)
Description copied from interface: Surface
transform image via translate, rotate, scale, crop

Specified by:
transform in interface Surface
Parameters:
parms -
Returns:
transformed image flattened into 1D array
See Also:
Surface.transform(com.anji.imaging.TransformParameters)

init

public void init(Properties props)
          throws java.lang.Exception
Specified by:
init in interface Configurable
Parameters:
props - configuration parameters
Throws:
java.lang.Exception
See Also:
Configurable.init(com.anji.util.Properties)