// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.objects.animation; import java.util.Iterator; import java.util.List; import xaal.objects.Group; import xaal.objects.Xaal; import xaal.objects.graphical.GraphicalPrimitive; import xaal.objects.structures.DataStructure; import xaal.objects.structures.Structure; public class GroupOperation extends GraphicalOperation { private Group group; public GroupOperation(Xaal xaalDoc, String name) { super(xaalDoc); this.group = new Group(xaalDoc, name); xaalDoc.addObject(name, this.group); } public Group getGroup() { return group; } public Iterator getStructures() { return str.iterator(); } public void addObject(GraphicalPrimitive gp) { this.gp.add(gp); } public void addObject(Structure str) { this.str.add(str); } public void addObjects(List lst) { Iterator iter = lst.iterator(); addObjects(iter); } public void addObjects(Iterator iter) { while (iter.hasNext()) { Object next = iter.next(); addObject(next); } } public void addObject(Object o) { if (o instanceof GraphicalPrimitive) gp.add((GraphicalPrimitive) o); else if (o instanceof Structure) str.add((Structure) o); else if (o instanceof Group) { addObjects(((Group) o).getGraphicals()); addObjects(((Group) o).getStructures()); } } public void addGraphical(GraphicalPrimitive gp) { this.addObject(gp); } public Iterator getGraphicals() { return gp.iterator(); } public void setGraphical(List l) { this.gp = l; } public void addStructure(Structure s) { addObject(s); } public void addStructure(DataStructure ds) { addObject(ds); } }