All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgrapht.event.GraphEdgeChangeEvent Maven / Gradle / Ivy

There is a newer version: 1.5.2
Show newest version
/*
 * (C) Copyright 2003-2017, by Barak Naveh and Contributors.
 *
 * JGraphT : a free Java graph-theory library
 *
 * This program and the accompanying materials are dual-licensed under
 * either
 *
 * (a) the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation, or (at your option) any
 * later version.
 *
 * or (per the licensee's choosing)
 *
 * (b) the terms of the Eclipse Public License v1.0 as published by
 * the Eclipse Foundation.
 */
package org.jgrapht.event;

/**
 * An event which indicates that a graph edge has changed, or is about to change. The event can be
 * used either as an indication after the edge has been added or removed, or before it
 * is added. The type of the event can be tested using the
 * {@link org.jgrapht.event.GraphChangeEvent#getType()} method.
 *
 * @param  the graph vertex type
 * @param  the graph edge type
 *
 * @author Barak Naveh
 * @since Aug 10, 2003
 */
public class GraphEdgeChangeEvent
    extends GraphChangeEvent
{
    private static final long serialVersionUID = 3618134563335844662L;

    /**
     * Before edge added event. This event is fired before an edge is added to a graph.
     */
    public static final int BEFORE_EDGE_ADDED = 21;

    /**
     * Before edge removed event. This event is fired before an edge is removed from a graph.
     */
    public static final int BEFORE_EDGE_REMOVED = 22;

    /**
     * Edge added event. This event is fired after an edge is added to a graph.
     */
    public static final int EDGE_ADDED = 23;

    /**
     * Edge removed event. This event is fired after an edge is removed from a graph.
     */
    public static final int EDGE_REMOVED = 24;

    /**
     * The edge that this event is related to.
     */
    protected E edge;

    /**
     * The source vertex of the edge that this event is related to.
     */
    protected V edgeSource;

    /**
     * The target vertex of the edge that this event is related to.
     */
    protected V edgeTarget;

    /**
     * Constructor for GraphEdgeChangeEvent.
     *
     * @param eventSource the source of this event.
     * @param type the event type of this event.
     * @param edge the edge that this event is related to.
     * @param edgeSource edge source vertex
     * @param edgeTarget edge target vertex
     */
    public GraphEdgeChangeEvent(Object eventSource, int type, E edge, V edgeSource, V edgeTarget)
    {
        super(eventSource, type);
        this.edge = edge;
        this.edgeSource = edgeSource;
        this.edgeTarget = edgeTarget;
    }

    /**
     * Returns the edge that this event is related to.
     *
     * @return event edge
     */
    public E getEdge()
    {
        return edge;
    }

    /**
     * Returns the source vertex that this event is related to.
     *
     * @return event source vertex
     */
    public V getEdgeSource()
    {
        return edgeSource;
    }

    /**
     * Returns the target vertex that this event is related to.
     *
     * @return event target vertex
     */
    public V getEdgeTarget()
    {
        return edgeTarget;
    }
}

// End GraphEdgeChangeEvent.java




© 2015 - 2024 Weber Informatics LLC | Privacy Policy