001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.plugins.main.core.actions.vertex; 005 006 007 import graphlab.graph.graph.GraphModel; 008 import graphlab.graph.graph.GraphPoint; 009 import graphlab.graph.graph.VertexModel; 010 import graphlab.platform.core.AbstractAction; 011 import graphlab.platform.core.BlackBoard; 012 import graphlab.plugins.commonplugin.undo.Undoable; 013 import graphlab.plugins.commonplugin.undo.UndoableActionOccuredData; 014 015 /** 016 * @author Ruzbeh 017 */ 018 public class MoveVertex extends AbstractAction implements Undoable { 019 public MoveVertex(BlackBoard bb) { 020 super(bb); 021 listen4Event(VertexMoveData.EVENT_KEY); 022 } 023 024 VertexModel v; 025 026 public void performAction(String eventName, Object value) { 027 VertexMoveData vmd = blackboard.getData(VertexMoveData.EVENT_KEY); 028 // GraphModel g = blackboard.get(GraphAttrSet.name); 029 030 VertexModel v1 = vmd.v; 031 v1.setLocation(vmd.newPosition); 032 } 033 034 035 public void undo(UndoableActionOccuredData uaod) { 036 VertexModel v = (VertexModel) uaod.properties.get("MovedVertex"); 037 GraphPoint oldPos = (GraphPoint) uaod.properties.get("OldPos"); 038 // int oldX = (Integer) uaod.properties.get("OldX"); 039 // int oldY = (Integer) uaod.properties.get("OldY"); 040 GraphModel g = (GraphModel) uaod.properties.get("Graph"); 041 v.setLocation(oldPos); 042 043 } 044 045 public void redo(UndoableActionOccuredData uaod) { 046 VertexModel v = (VertexModel) uaod.properties.get("MovedVertex"); 047 GraphPoint newPosition = (GraphPoint) uaod.properties.get("NewPos"); 048 // int oldX = (Integer) uaod.properties.get("OldX"); 049 // int oldY = (Integer) uaod.properties.get("OldY"); 050 GraphModel g = (GraphModel) uaod.properties.get("Graph"); 051 v.setLocation(newPosition); 052 053 } 054 }