Question: I have two Raphael canvases on a page, each containing a SVG drawing. One of them is hidden by default (its container has `display:none`). When I show the hidden container in IE9 or Chrome 17, the canvas is empty. In Firefox and Opera, its contents display fine. I'm confused. What gives?

You can see the problem at <http://www.mybgagent.com/search>. (The button in the bottom right corner of the map ("view map of Varna") toggles between the two canvases.)

Answer: 
here:   

```
import java.util.*;

class Part {

  public String toString() {

    return getClass().getSimpleName();

  }

  static List<Class> partFactories = new ArrayList<Class>();

  static {

    // Collections.addAll() gives an "unchecked generic

    // array creation ... for varargs parameter" warning.

    partFactories.add(FuelFilter.class);

    partFactories.add(AirFilter.class);

    partFactories.add(CabinAirFilter.class);

    partFactories.add(OilFilter.class);

    partFactories.add(FanBelt.class);

    partFactories.add(PowerSteeringBelt.class);

    partFactories.add(GeneratorBelt.class);
  }

  private static Random rand = new Random(47);

  public static Part createRandom() throws Exception {

    int n = rand.nextInt(partFactories.size());

    return (Part)(partFactories.get(n).newInstance());

  }

}

class Filter extends Part {}

class FuelFilter extends Filter {
}
class AirFilter extends Filter {
}
class CabinAirFilter extends Filter {
}
class OilFilter extends Filter {
}
class Belt extends Part {}
class FanBelt extends Belt {
}
class GeneratorBelt extends Belt {
}
class PowerSteeringBelt extends Belt {
}

public class aa{

  public static void main(String[] args) {

    for(int i = 0; i < 10; i++)

      try {System.out.println(Part.createRandom()); }catch (Exception e) {}

  }

}

```
`static List<Factory<? extends Part>> partFactories`  

thats the list,  

it contains several factories and is initiated in the static block.   

this code randomly creates objects via their factories using createRandom method   

the idea is that instead of creating an object by calling new, you create one using its factory  

all factories here implement the interface Factory, which means they have a method called create()  
 that returns a new instance of the desired class (the one the factory belongs to)