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 Lesser General Public License (LGPL): http://www.gnu.org/licenses/
004    
005    package graphlab.library.event;
006    
007    import graphlab.library.BaseEdge;
008    import graphlab.library.BaseGraph;
009    import graphlab.library.BaseVertex;
010    
011    /**
012     * @author Omid
013     */
014    public class VertexRequest<VertexType extends BaseVertex, EdgeType extends BaseEdge<VertexType>>
015            implements Event {
016    
017        private VertexType vertex;
018        public final BaseGraph<VertexType, EdgeType> graph;
019        public String message = "Please select a vertex";
020    
021        public VertexRequest(BaseGraph<VertexType, EdgeType> graph, String message) {
022            this.graph = graph;
023            this.message = message;
024        }
025    
026        public VertexRequest(BaseGraph<VertexType, EdgeType> graph) {
027            this.graph = graph;
028    
029        }
030    
031        /**
032         * @param vertex The vertex to set.
033         */
034        public void setVertex(VertexType vertex) {
035            if (vertex == null)
036                throw new NullPointerException("Null vertex supplied");
037    
038            graph.checkVertex(vertex);
039    
040            this.vertex = vertex;
041        }
042    
043        /**
044         * @return Returns the vertex.
045         */
046        public VertexType getVertex() {
047            return vertex;
048        }
049    
050        public String getID() {
051            return "VertexRequest";
052        }
053    
054        public String getDescription() {
055            return "Select a Vertex";
056        }
057    
058        public String getMessage() {
059            return message;
060        }
061    
062        public void setMessage(String message) {
063            this.message = message;
064        }
065    }