From 0ed2c1124cf1b9e49a2ec1fa0126a8df09f9e758 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 7 Oct 2014 09:18:11 +0200 Subject: Repackage to org.cristalise --- .../c2kernel/graph/model/GraphModelManager.java | 156 --------------------- 1 file changed, 156 deletions(-) delete mode 100644 src/main/java/com/c2kernel/graph/model/GraphModelManager.java (limited to 'src/main/java/com/c2kernel/graph/model/GraphModelManager.java') diff --git a/src/main/java/com/c2kernel/graph/model/GraphModelManager.java b/src/main/java/com/c2kernel/graph/model/GraphModelManager.java deleted file mode 100644 index a4209ce..0000000 --- a/src/main/java/com/c2kernel/graph/model/GraphModelManager.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * 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 3 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; with out 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.graph.model; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Observable; -import java.util.Stack; - -import com.c2kernel.graph.event.EntireModelChangedEvent; -import com.c2kernel.graph.event.ForcedNotifyEvent; -import com.c2kernel.graph.event.GraphModelEvent; -import com.c2kernel.utils.Logger; - - -public class GraphModelManager extends Observable -{ - - private GraphModel mGraphModel; - private EdgeFactory mEdgeFactory; - private VertexFactory mVertexFactory; - private VertexOutlineCreator mVertexOutlineCreator; - private final EntireModelChangedEvent mEntireModelChangedEvent = new EntireModelChangedEvent(); - private final ForcedNotifyEvent mForcedNotifyEvent = new ForcedNotifyEvent(); - private final Stack mParentModels = new Stack(); - private final ArrayList mParentIds = new ArrayList(); - private boolean mEditable = true; - - // Calling this constructor does not create a vertex outline creator - // which is required by the method addVertexAndCreateId() - public GraphModelManager() - { - mGraphModel = new GraphModel(); - mGraphModel.setManager(this); - } - - public GraphModelManager(GraphModel newModel) { - newModel.setManager(this); - mGraphModel = newModel; - } - - public void replace(GraphModel newModel) { - mParentModels.clear(); - - //zoom back to where we were - for (Iterator iter = mParentIds.iterator(); iter.hasNext();) { - Integer parentId = iter.next(); - GraphableVertex childModelVertex = (GraphableVertex)newModel.getVertexById(parentId.intValue()); - if (childModelVertex == null) { // we've been deleted, stay here - Logger.msg(7, "Didn't find "+parentId+" in new model tree. Stopping here."); - do { iter.remove(); } while (iter.hasNext()); - break; - } - else { - mParentModels.push(newModel); - Logger.msg(7, "Pushing model and switching to "+parentId); - newModel = childModelVertex.getChildGraphModel(); - } - } - setModel(newModel); - } - - public void setModel(GraphModel newModel) { - // reset transient data - newModel.mNewEdgeOriginVertex = null; - newModel.mNewEdgeEndPoint = null; - - // copy factories over - newModel.setExternalEdgeFactory(mEdgeFactory); - newModel.setExternalVertexFactory(mVertexFactory); - newModel.setVertexOutlineCreator(mVertexOutlineCreator); - mVertexFactory.setCreationContext(newModel.getContainingVertex()); - newModel.setManager(this); - mGraphModel.setManager(null); - mGraphModel = newModel; - - // notify - notifyObservers(mEntireModelChangedEvent); - } - - public void zoomIn(Vertex child) { - GraphModel childModel = child.getChildGraphModel(); - if (childModel != null) { - mParentModels.push(mGraphModel); - mParentIds.add(Integer.valueOf(child.getID())); - setModel(childModel); - Logger.msg(7, "ZoomIn - Stack size: "+mParentModels.size()+" ids:"+mParentIds.size()); - } - } - - public void zoomOut() { - if (!mParentModels.empty()) { - setModel(mParentModels.pop()); - mParentIds.remove(mParentIds.size()-1); - } - Logger.msg(7, "ZoomOut - Stack size: "+mParentModels.size()+" ids:"+mParentIds.size()); - - } - - public void forceNotify() - { - notifyObservers(mForcedNotifyEvent); - } - - public GraphModel getModel() { - return mGraphModel; - } - - public void setExternalEdgeFactory(EdgeFactory newEdgeFactory) { - mEdgeFactory = newEdgeFactory; - mGraphModel.setExternalEdgeFactory(newEdgeFactory); - } - - public void setExternalVertexFactory(VertexFactory newVertexFactory) { - mVertexFactory = newVertexFactory; - mGraphModel.setExternalVertexFactory(newVertexFactory); - } - - public void setVertexOutlineCreator(VertexOutlineCreator newVertexOutlineCreator) { - mVertexOutlineCreator = newVertexOutlineCreator; - mGraphModel.setVertexOutlineCreator(newVertexOutlineCreator); - } - - public void notifyObservers(GraphModelEvent ev) { - setChanged(); - super.notifyObservers(ev); - } - - public void setEditable(boolean editable) { - mEditable = editable; - } - - public boolean isEditable() { - return mEditable; - } - - -} -- cgit v1.2.3