// 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; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Stack; import xaal.objects.graphical.GraphicalPrimitive; import xaal.objects.structures.DataStructure; import xaal.util.DepthComparator; /** * */ public class Initial implements AddDataStructure, AddGraphicalPrimitive { private List graphics; private Stack structures = new Stack(); private Xaal root; public Initial() { } /** * */ public Initial(Xaal x) { super(); setRoot(x); } public void addStructure(DataStructure ds) { if (structures == null) structures = new Stack(); structures.push(ds); } public String toString() { StringBuffer toStr = new StringBuffer(); for (Iterator iter = structures.iterator(); iter.hasNext();) { DataStructure element = (DataStructure) iter.next(); toStr.append("Structure: ").append(element.toString()).append("\n\n"); } return toStr.toString(); } public Iterator getStructures() { if (structures == null) structures = new Stack(); return structures.iterator(); } public void addGraphical(GraphicalPrimitive gp) { if (graphics == null) graphics = new ArrayList(); graphics.add(gp); } public Iterator getGraphicals() { if (graphics == null) graphics = new ArrayList(); //Collections.sort(graphics, new DepthComparator()); return graphics.iterator(); } public Xaal getRoot() { return root; } public void setRoot(Xaal root) { this.root = root; } public void setGraphical(List graphicalPrimitives) { graphics = graphicalPrimitives; } /** * Returns a copy of the list of graphical primitives in this container. * @return */ public List getGraphicalsList() { return new ArrayList(graphics); } }