001: /*
002: * @(#)GraphModelEvent.java 1.0 03-JUL-04
003: *
004: * Copyright (c) 2001-2005 Gaudenz Alder
005: *
006: * See LICENSE file in distribution for licensing details of this source file
007: */
008: package org.jgraph.event;
009:
010: import java.util.EventObject;
011:
012: import org.jgraph.graph.CellView;
013: import org.jgraph.graph.ConnectionSet;
014: import org.jgraph.graph.GraphLayoutCache;
015: import org.jgraph.graph.ParentMap;
016:
017: /**
018: * Encapsulates information describing changes to a graph model, and is used to
019: * notify graph model listeners of the change.
020: *
021: * @author Gaudenz Alder
022: * @version 1.0 1/1/2
023: *
024: */
025:
026: public class GraphModelEvent extends EventObject {
027:
028: /**
029: * The object that constitutes the change.
030: */
031: protected GraphModelChange change;
032:
033: /**
034: * Used to create an event when cells have been changed, inserted, or
035: * removed, identifying the change as a ModelChange object.
036: *
037: * @param source
038: * the Object responsible for generating the event (typically the
039: * creator of the event object passes <code>this</code> for its
040: * value)
041: * @param change
042: * the object that describes the change
043: * @see org.jgraph.graph.GraphCell
044: *
045: */
046: public GraphModelEvent(Object source, GraphModelChange change) {
047: super (source);
048: this .change = change;
049: }
050:
051: /**
052: * Returns the object that constitutes the change.
053: *
054: * @return the object that constitutes the change.
055: */
056: public GraphModelChange getChange() {
057: return change;
058: }
059:
060: /**
061: * Defines the interface for objects that may be included into a
062: * GraphModelEvent to describe a model change.
063: */
064: public static interface GraphModelChange extends
065: GraphLayoutCacheEvent.GraphLayoutCacheChange {
066:
067: /**
068: * Returns a connection set representing the graph structure after the
069: * change was applied
070: *
071: * @return the connection set of the graph after the change
072: */
073: public ConnectionSet getConnectionSet();
074:
075: /**
076: * Returns a connection set representing the graph structure before the
077: * change was applied ( an "undo" of the change).
078: *
079: * @return the connection set of the graph before the change
080: */
081: public ConnectionSet getPreviousConnectionSet();
082:
083: /**
084: * Returns a parent map representing the group structure after the
085: * change was applied
086: *
087: * @return the changed parent map
088: */
089: public ParentMap getParentMap();
090:
091: /**
092: * Returns a parent map representing the group structure before the
093: * change was applied ( an "undo" of the change )
094: *
095: * @return the previous parent map
096: */
097: public ParentMap getPreviousParentMap();
098:
099: /**
100: * Allows a <code>GraphLayoutCache</code> to store cell views for
101: * cells that have been removed. Such cell views are used for
102: * re-insertion and restoring the visual attributes.
103: *
104: * @param view
105: * the <code>GraphLayoutCache</code> to store the removed
106: * cells
107: * @param cellViews
108: * the cell views to be stored
109: */
110: public void putViews(GraphLayoutCache view, CellView[] cellViews);
111:
112: /**
113: * Allows a <code>GraphLayoutCache</code> to retrieve an array of
114: * <code>CellViews</code> that was previously stored with
115: * <code>putViews(GraphLayoutCache, CellView[])</code>.
116: *
117: * @param view
118: * the <code>GraphLayoutCache</code> whose stored cells are
119: * to be retrieved
120: */
121: public CellView[] getViews(GraphLayoutCache view);
122:
123: }
124:
125: }
|