de.grogra.texgen
Class DiamondSquareTexture

java.lang.Object
  extended by de.grogra.persistence.ShareableBase
      extended by de.grogra.imp.objects.ImageAdapter
          extended by de.grogra.texgen.SyntheticTexture
              extended by de.grogra.texgen.DiamondSquareTexture
All Implemented Interfaces:
Icon, IconSource, Manageable, Shareable

public class DiamondSquareTexture
extends SyntheticTexture


Nested Class Summary
static class DiamondSquareTexture.Type
           
 
Field Summary
static DiamondSquareTexture.Type $TYPE
           
static SCOType.Field a0$FIELD
           
static SCOType.Field a1$FIELD
           
static SCOType.Field a2$FIELD
           
static SCOType.Field a3$FIELD
           
static SCOType.Field height$FIELD
           
static SCOType.Field randomSeed$FIELD
           
static SCOType.Field useColor$FIELD
           
static SCOType.Field width$FIELD
           
 
Fields inherited from interface de.grogra.icon.Icon
DEFAULT, DISABLED
 
Constructor Summary
DiamondSquareTexture()
           
 
Method Summary
protected  void createImage()
          "helper function" to create an initial grid before the recursive function is called
protected  float displace(float width, float height, float num)
          Randomly displaces color value for midpoint depending on size of grid piece.
protected  void divideGrid(java.awt.Graphics g, float x, float y, float width, float height, float a0, float a1, float a2, float a3)
          This is the recursive function that implements the random midpoint displacement algorithm (diamond square).
 float getA0()
           
 float getA1()
           
 float getA2()
           
 float getA3()
           
 java.awt.image.BufferedImage getBufferedImage()
           
 int getHeight()
           
 ManageableType getManageableType()
           
 java.awt.Dimension getPreferredIconSize(boolean small)
           
 long getRandomSeed()
           
 int getWidth()
           
 boolean isUseColor()
           
 void setA0(float value)
           
 void setA1(float value)
           
 void setA2(float value)
           
 void setA3(float value)
           
 void setHeight(int value)
           
 void setRandomSeed(long value)
           
 void setUseColor(boolean value)
           
 void setWidth(int value)
           
 
Methods inherited from class de.grogra.texgen.SyntheticTexture
getNativeImage, isMutable
 
Methods inherited from class de.grogra.imp.objects.ImageAdapter
getIcon, getIconBounds, getIconSource, getImage, getImage, getImageSource, paintIcon, prepareIcon
 
Methods inherited from class de.grogra.persistence.ShareableBase
addReference, appendReferencesTo, fieldModified, getProvider, getStamp, initProvider, manageableReadResolve, manageableWriteReplace, removeReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$TYPE

public static final DiamondSquareTexture.Type $TYPE

a0$FIELD

public static final SCOType.Field a0$FIELD

a1$FIELD

public static final SCOType.Field a1$FIELD

a2$FIELD

public static final SCOType.Field a2$FIELD

a3$FIELD

public static final SCOType.Field a3$FIELD

height$FIELD

public static final SCOType.Field height$FIELD

randomSeed$FIELD

public static final SCOType.Field randomSeed$FIELD

useColor$FIELD

public static final SCOType.Field useColor$FIELD

width$FIELD

public static final SCOType.Field width$FIELD
Constructor Detail

DiamondSquareTexture

public DiamondSquareTexture()
Method Detail

createImage

protected void createImage()
"helper function" to create an initial grid before the recursive function is called


displace

protected float displace(float width,
                         float height,
                         float num)
Randomly displaces color value for midpoint depending on size of grid piece.


divideGrid

protected void divideGrid(java.awt.Graphics g,
                          float x,
                          float y,
                          float width,
                          float height,
                          float a0,
                          float a1,
                          float a2,
                          float a3)
This is the recursive function that implements the random midpoint displacement algorithm (diamond square). It will call itself until the grid pieces become smaller than one pixel.


getA0

public float getA0()

getA1

public float getA1()

getA2

public float getA2()

getA3

public float getA3()

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Specified by:
getBufferedImage in class ImageAdapter

getHeight

public int getHeight()

getManageableType

public ManageableType getManageableType()

getPreferredIconSize

public java.awt.Dimension getPreferredIconSize(boolean small)
Specified by:
getPreferredIconSize in interface IconSource
Overrides:
getPreferredIconSize in class ImageAdapter

getRandomSeed

public long getRandomSeed()

getWidth

public int getWidth()

isUseColor

public boolean isUseColor()

setA0

public void setA0(float value)

setA1

public void setA1(float value)

setA2

public void setA2(float value)

setA3

public void setA3(float value)

setHeight

public void setHeight(int value)

setRandomSeed

public void setRandomSeed(long value)

setUseColor

public void setUseColor(boolean value)

setWidth

public void setWidth(int value)