Ejemplo n.º 1
0
 /**
  * Loads a scenario (an SVG file specifiing location and shape of surfaces and objects in the
  * arena)from a file.
  *
  * @param svgFileName specifies the file the scenario is loaded from.
  */
 public void loadScenario(String svgFileName) {
   this.svgFileName = svgFileName;
   SVGShapeLoader loader = new SVGShapeLoader(svgFileName);
   try {
     loader.start();
     loader.join();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   screenWidth = loader.getWidth();
   screenHeight = loader.getHeight();
   positions = new ArrayList<PositionMark>();
   paintable = new ArrayList<VivaeObject>();
   Vector<HashMap<String, Vector<Shape>>> shapeMap = loader.getShapesWithTypeMap();
   int l = 1;
   for (HashMap<String, Vector<Shape>> m : shapeMap) {
     if (m == null) ; // System.out.println("No shapes loaded on layer " + l);
     else {
       Vector<ArenaPart> v = ArenaPartsGenerator.createParts(m, l, this);
       for (ArenaPart vivae : v) {
         if (Surface.class.isAssignableFrom(vivae.getClass())) {
           addSurface((Surface) vivae);
         } else if (PositionMark.class.isAssignableFrom(vivae.getClass())) {
           addPosition((PositionMark) vivae);
         } else if (Passive.class.isAssignableFrom(vivae.getClass())) {
           addPassive((Passive) vivae);
           //                    this should not happen anymore - actives (robots added by
           // experiment, not SVG file !!!)
           // } else if (Active.class.isAssignableFrom(vivae.getClass())) {
           //                        activesPositions.add((Active) vivae);
         }
       }
     }
     l++;
   }
 }