Wednesday, July 05, 2006

I rewrote a section of code to automagically assign the values from a set of hashsets to the waterfalls as they are instanced. It searches all the public local fields and if any match the names of stored parameters, sets them up:


try
{
Field[] myFields = getClass().getFields();
// hashtables to check for values
LookUp lookup[] = { LUInt, LUDouble, LUBoolean, LURest };
for (LookUp look : lookup)
for (Field f : myFields)
{
Object l = look.find(f.getName());
if (l != null)
{
f.set(this, l);
}
}
}
catch (IllegalAccessException e)
{
...

This means that instead of:

public class FREEZER_Dot extends FREEZER implements NOISE_Dot
{
public List getPoint()

{
int type = gInt("dotStyle");
System.err.println("type is given as "+dotStyle);

I can just:

public class FREEZER_Dot extends FREEZER implements NOISE_Dot
{
public int dotStyle;


public List getPoint()
{
System.err.println("type is given as "+dotStyle);


because it is able to associate the name in the variable list (dotStyle) with the local field dotStyle :) It also works with the inherited variables system I've got too (that parent waterfalls can set state for their children)

Next up is the point generators. I just decided to create three - spiral, rectilinear (manhatten) and concentric circles. These generators are used for positioning the blocks. I used wikipedia to find the parametric form of spirals.
Spiral, circular and block(with lots of noise) point layouts:

No comments:

Post a Comment