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: import java.util.Map;
012:
013: /**
014: * Encapsulates information describing changes to a graph layout cache, and is
015: * used to notify graph layout cache listeners of the change. Note that graph
016: * layout cache events do not repeat information in graph model events if there
017: * is no view specific information. The idea of this event is to provide
018: * information on what has changed in the graph layout cache only.
019: */
020: public class GraphLayoutCacheEvent extends EventObject {
021:
022: /**
023: * The object that constitutes the change.
024: */
025: protected GraphLayoutCacheChange change;
026:
027: /**
028: * Used to create an event when cells have been changed, inserted, or
029: * removed, identifying the change as a GraphLayoutCacheChange object.
030: *
031: * @param source
032: * the Object responsible for generating the event (typically the
033: * creator of the event object passes <code>this</code> for its
034: * value)
035: *
036: * @param change
037: * the object that describes the change
038: */
039: public GraphLayoutCacheEvent(Object source,
040: GraphLayoutCacheChange change) {
041: super (source);
042: this .change = change;
043: }
044:
045: /**
046: * Returns the object that constitutes the change.
047: *
048: * @return the object that constitutes the change
049: */
050: public GraphLayoutCacheChange getChange() {
051: return change;
052: }
053:
054: /**
055: * Defines the interface for objects that may be used to represent a change
056: * to the graph layout cache.
057: */
058: public static interface GraphLayoutCacheChange {
059:
060: /**
061: * Returns the source of this change. This can either be a view or a
062: * model, if this change is a GraphModelChange. Note: This is not
063: * necessarily the same as the source of the event and is used
064: * separately in the graphundomanager.
065: *
066: * @return the source fo this change
067: */
068: public Object getSource();
069:
070: /**
071: * Returns the cells that have changed.
072: *
073: * @return the cell changed
074: */
075: public Object[] getChanged();
076:
077: /**
078: * Returns the cells that have been inserted.
079: *
080: * @return the cells that were inserted by the change
081: */
082: public Object[] getInserted();
083:
084: /**
085: * Returns the cells that have been removed.
086: *
087: * @return the cells that were removed by the change
088: */
089: public Object[] getRemoved();
090:
091: /**
092: * Returns a map that contains (object, map) pairs which holds the new
093: * attributes for each changed cell. Note: This returns a map of (cell,
094: * map) pairs for an insert on a model that is not an attribute store.
095: * Use getPreviousAttributes to access the attributes that have been
096: * stored in the model.
097: */
098: public Map getAttributes();
099:
100: /**
101: * Returns a map that contains (object, map) pairs which holds the
102: * previous attributes for the changed cells.
103: *
104: * @return map of attributes before the change
105: */
106: public Map getPreviousAttributes();
107:
108: /**
109: * Returns the objects that have not changed explicitly, but implicitly
110: * because one of their dependent cells has changed. This is typically
111: * used to return the edges that are attached to vertices, which in turn
112: * have been resized or moved.
113: *
114: * @return array of contextual cells
115: */
116: public Object[] getContext();
117:
118: }
119:
120: }
|