/* * Moonlight|3D * Copyright (C) 2006 The Moonlight|3D team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Created on Feb 6, 2006 */ package ml.backend.anim; /** * \package ml.backend.anim * * This contains the core animation functionality for Moonlight|3D. * The base classes and interfaces for the animation system are defined * here. * * This package is part of the core program. */ import java.util.ArrayList; import java.util.List; import ml.backend.document.Document; import ml.backend.selection.PathElement; import ml.backend.selection.RootPathElement; import ml.core.helper.NamePool; public class Manager implements RootPathElement { private NamePool animationNamePool; private ArrayList animations; private ArrayList listeners; private Document document; public Manager(Document document) { this.document=document; animationNamePool=new NamePool(); animations=new ArrayList(); listeners=new ArrayList(); } public void registerAnimationManagerListener(AnimationManagerListener listener) { listeners.add(listener); } public void unregisterAnimationManagerListener(AnimationManagerListener listener) { listeners.remove(listener); } public Document getDocument() { return document; } public Animation createAnimation(String name) { Animation animation=new Animation(this); if(!animationNamePool.isNameUnique(name)) { name=animationNamePool.generateUniqueName(name); } animation.setName(name); animations.add(animation); animationNamePool.add(animation); for(AnimationManagerListener listener : listeners) { listener.animationAdded(animation); } return animation; } public Animation getAnimationByName(String name) { for(Animation animation : animations) { if(animation.getName().equals(name)) { return animation; } } return null; } public List getAnimations() { return (ArrayList) animations.clone(); } public void removeAnimation(String name) { Animation animation=getAnimationByName(name); animations.remove(animation); for(AnimationManagerListener listener : listeners) { listener.animationRemoved(animation); } } public PathElement findChildElement(String childName) { return getAnimationByName(childName); } public boolean isValidAppendixName(String appendix) { return false; } public Object getFromAppendix(String appendix) { return null; } public String getName() { return "Animation"; } }