com.monkeycoder.monkeyfractal.base
Class FractalBuffer

java.lang.Object
  extended by com.monkeycoder.monkeyfractal.base.FractalBuffer

public class FractalBuffer
extends java.lang.Object

This class represents a buffer full of calculated fractal data.

Originally part of the MonkeyFractal project.

Author:
David Stephens

Constructor Summary
FractalBuffer(int inWidth, int inHeight)
          Creates a new FractalBuffer initialized to hold inWidth by inHeight worth of data.
 
Method Summary
 FractalBuffer copy()
          Produces a full copy of this FractalBuffer.
 double get(int inX, int inY)
          Gets the value at a a specific position in the buffer.
 int getHeight()
          Gets the height of the buffer.
 int getWidth()
          Gets the width of the buffer.
 boolean isEmpty()
          Does a scan of the entire buffer to determine if it is empty.
 boolean merge(FractalBuffer inSourceFb, java.awt.Point inUpperLeft)
          Merges an entire FractalBuffer into this one.
 boolean merge(FractalBuffer inSourceFb, java.awt.Rectangle inSection, java.awt.Point inUpperLeft)
          Merges a partial FractalBuffer into this one.
 void set(int inX, int inY, double inValue)
          Sets a specific position in the buffer to the supplied value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FractalBuffer

public FractalBuffer(int inWidth,
                     int inHeight)
Creates a new FractalBuffer initialized to hold inWidth by inHeight worth of data.

Parameters:
inWidth - The width of the FractalBuffer.
inHeight - The height of the FractalBuffer.
Method Detail

set

public void set(int inX,
                int inY,
                double inValue)
Sets a specific position in the buffer to the supplied value. All values are expected to be in the range: 0 <= value <= 1.

Parameters:
inX - The X coordinate of the position to set.
inY - The Y coordinate of the position to set.
inValue - The value to be placed in that position.

get

public double get(int inX,
                  int inY)
Gets the value at a a specific position in the buffer. All values are expected to be in the range: 0 <= value <= 1.

Parameters:
inX - The X coordinate of the position to get.
inY - The Y coordinate of the position to get.
Returns:
The value at that position.

getWidth

public int getWidth()
Gets the width of the buffer.

Returns:
The width of the buffer.

getHeight

public int getHeight()
Gets the height of the buffer.

Returns:
The height of the buffer.

isEmpty

public boolean isEmpty()
Does a scan of the entire buffer to determine if it is empty.

Returns:
Whether or not this FractalBuffer is empty.

copy

public FractalBuffer copy()
Produces a full copy of this FractalBuffer.

Returns:
A new FractalBuffer that is the same as this one.

merge

public boolean merge(FractalBuffer inSourceFb,
                     java.awt.Point inUpperLeft)
Merges an entire FractalBuffer into this one. The passed in FractalBuffer is positioned with its upper left corner positioned at the point specified. The entire FractalBuffer is used in the merge and all data from the passed in FractalBuffer overwrites data in this one. Any portion that goes beyond the borders of this FractalBuffer is cropped. This function is equivelent to calling:
merge( inSourceFb, new Rectangle( 0, 0, inSourceFb.getWidth(), inSourceFb.getHeight() ), inUpperLeft )

Parameters:
inSourceFb - The source FractalBuffer that will be entirely merged into this one.
inUpperLeft - The point that will be the upper left position of the passed in FractalBuffer.
Returns:
True if the merge was successful. False if it failed for some reason.
See Also:
merge( FractalBuffer, Rectangle, Point )

merge

public boolean merge(FractalBuffer inSourceFb,
                     java.awt.Rectangle inSection,
                     java.awt.Point inUpperLeft)
Merges a partial FractalBuffer into this one. The portion of the passed in FractalBuffer specified by the inSection is positioned with its upper left corner positioned at the point specified. All data from the passed in FractalBuffer overwrites data in this one. Any portion that goes beyond the borders of this FractalBuffer is cropped.

Parameters:
inSourceFb - The source FractalBuffer that will be entirely merged into this one.
inSection - The area within the source FractalBuffer to use in the merge.
inUpperLeft - The point that will be the upper left position of the passed in FractalBuffer.
Returns:
True if the merge was successful. False if it failed for some reason.