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.graph.event;
005    
006    import graphlab.graph.graph.EdgeModel;
007    import graphlab.graph.graph.GraphPoint;
008    
009    /**
010     * An event which indicates that a Edge action occurred.
011     *
012     * @author Azin Azadi ,roozbeh ebrahimi
013     * @see graphlab.graph.event.GraphEvent
014     */
015    public class EdgeEvent {
016        public final static String EVENT_KEY = "EdgeEvent";
017        public static final int CLICKED = 0;
018        public static final int RELEASED = 1;
019        public static final int DRAGGING = 2;
020        public static final int DRAGGING_STARTED = 3;
021        /**
022         * dropped is not implemented yet
023         */
024    //    public static final int DROPPED = 4;
025    
026        public int eventType;
027        public EdgeModel e;
028    
029        //position of mouse according to top left point of edge
030        public GraphPoint mousePos;
031        public int mouseBtn;
032    
033        /**
034         * in the case that event occurs because of a EDGE_MOUSE_ENTERED_EXITED event
035         * isMouseEntered will show that is mouse entered to the vertex (true) otherwise mouse exited
036         * from the vertex (false)
037         */
038        public boolean isMouseEntered;
039    
040    
041        public EdgeEvent(int eventType, EdgeModel e, GraphPoint mousePos, int mouseBtn, boolean isNotified, boolean isMouseEntered) {
042            this.eventType = eventType;
043            this.e = e;
044            this.mousePos = mousePos;
045            this.mouseBtn = mouseBtn;
046            this.isMouseEntered = isMouseEntered;
047        }
048    
049        public static EdgeEvent clicked(EdgeModel e, GraphPoint mousePos, int mouseBtn) {
050            return new EdgeEvent(CLICKED, e, mousePos, mouseBtn, false, false);
051        }
052    
053        public static EdgeEvent released(EdgeModel e, GraphPoint mousePos, int mouseBtn) {
054            return new EdgeEvent(RELEASED, e, mousePos, mouseBtn, false, false);
055        }
056    
057        public static EdgeEvent draggingStarted(EdgeModel e, GraphPoint mousePos, int mouseBtn) {
058            return new EdgeEvent(DRAGGING_STARTED, e, mousePos, mouseBtn, false, false);
059        }
060    
061    //    public static EdgeEvent dropped(EdgeModel e, GraphPoint mousePos, int mouseBtn) {
062    //        return new EdgeEvent(DROPPED, e, mousePos, mouseBtn, false, false);
063    //    }
064    
065        public static EdgeEvent dragging(EdgeModel e, GraphPoint mousePos, int mouseBtn) {
066            return new EdgeEvent(DRAGGING, e, mousePos, mouseBtn, false, false);
067        }
068    }