// 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.awt.Rectangle; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import xaal.objects.AddGraphicalPrimitive; import xaal.objects.AddStructure; import xaal.objects.Group; import xaal.objects.Xaal; import xaal.objects.XaalObject; import xaal.objects.animation.timing.Timing; import xaal.objects.graphical.GraphicalPrimitive; import xaal.objects.structures.DataStructure; import xaal.objects.structures.Structure; /** * @author vkaravir@cs.hut.fi */ public class AnimationOperation extends XaalObject implements AddGraphicalPrimitive, AddStructure, Cloneable { protected List gp; protected List str; private Map objectData; private Timing timing; /** * */ public AnimationOperation(Xaal xaalDoc) { super(xaalDoc); gp = new ArrayList(); str = new ArrayList(); objectData = new HashMap(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * @return Returns the id. */ /*public String getId() { return id; }*/ /** * @param id The id to set. */ /*public void setId(String id) { this.id = id; }*/ public void setTiming(Timing t) { this.timing = t; } public Timing getTiming() { return timing; } public void apply(HashMap state) { System.out.println("animation operation not supported:" + getClass().getName()); } public Rectangle getBounds() { return new Rectangle(0,0,0,0); } 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 addObject(Object o, Object data) { addObject(o); objectData.put(o, data); } public void setObjectData(Object o, Object data) { if (gp.contains(o) || str.contains(o)) { objectData.put(o, data); } } public Object getObjectData(Object o) { return objectData.get(o); } 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); } public List getGraphicalsList() { return new ArrayList(gp); } }