/* * Moonlight|3D Copyright (C) 2007 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 Mar 14, 2007 */ package ml.backend.document; import ml.core.exceptions.Exception; public class Document implements ml.core.document.Document { private String filename; private ml.backend.selection.Manager selectionManager; // TODO check if this really should ge here private ml.backend.anim.Manager animationManager; private ml.backend.og.Manager ogManager; private ml.backend.sg.Manager sgManager; private ml.backend.cache.Manager cacheManager; private ml.backend.renderer.Manager rendererManager; Document() { selectionManager=new ml.backend.selection.Manager(); animationManager=new ml.backend.anim.Manager(this); ogManager=new ml.backend.og.Manager(this); sgManager=new ml.backend.sg.Manager(); cacheManager=new ml.backend.cache.Manager(); rendererManager=new ml.backend.renderer.Manager(); try { selectionManager.registerRootPathElement(animationManager); selectionManager.registerRootPathElement(ogManager); } catch (Exception e) { // this exception cannot be thrown here; this block is actually unreachable } } public void update() { try { ogManager.update(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void close() { selectionManager.clearSelections(); ogManager.clear(); cacheManager.clear(); try { ogManager.update(); } catch (Exception e) { e.printStackTrace(); } } void setFilename(String filename) { this.filename=filename; } public String getFilename() { return filename; } public boolean hasUnsavedChanges() { // TODO make this a flag that gets only set on changes to the document return true; } public void save(String filename) throws Exception { this.filename=filename; new FileWriter(this,filename).run(); } public String getTypeName() { return "MoonlightScene"; } public ml.backend.selection.Manager getSelectionManager() { return selectionManager; } public ml.backend.anim.Manager getAnimationManager() { return animationManager; } public ml.backend.cache.Manager getCacheManager() { return cacheManager; } public ml.backend.og.Manager getOGManager() { return ogManager; } public ml.backend.sg.Manager getSGManager() { return sgManager; } public ml.backend.renderer.Manager getRendererManager() { return rendererManager; } }