001: /*
002: * $Id: JGraphpadDiagram.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
003: * Copyright (c) 2001-2005, Gaudenz Alder
004: *
005: * All rights reserved.
006: *
007: * See LICENSE file for license details. If you are unable to locate
008: * this file please contact info (at) jgraph (dot) com.
009: */
010: package com.jgraph.pad;
011:
012: import java.util.Hashtable;
013: import java.util.Map;
014:
015: import javax.swing.tree.DefaultMutableTreeNode;
016:
017: import org.jgraph.graph.GraphLayoutCache;
018:
019: import com.jgraph.editor.JGraphEditorDiagram;
020: import com.jgraph.pad.graph.JGraphpadGraphLayoutCache;
021:
022: /**
023: * Represents a diagram to be contained in a {@link JGraphpadFile}. The diagram
024: * has a name, default settings for the graph that displays the diagram and a
025: * graph layout cache that contains the actual graph data.
026: */
027: public class JGraphpadDiagram extends DefaultMutableTreeNode implements
028: JGraphEditorDiagram {
029:
030: /**
031: * Holds the graph layout cache that defines the diagram.
032: */
033: protected GraphLayoutCache graphLayoutCache;
034:
035: /**
036: * Holds the diagram properties.
037: */
038: protected Map properties;
039:
040: /**
041: * Constructs a new diagram with the specified name and a
042: * {@link JGraphpadGraphLayoutCache} to hold the diagram.
043: *
044: * @param name
045: * The name of the new diagram.
046: */
047: public JGraphpadDiagram(String name) {
048: this (name, new JGraphpadGraphLayoutCache());
049: }
050:
051: /**
052: * Constructs a new diagram with the specified name using
053: * <code>graphLayoutCache</code> to hold the diagram.
054: *
055: * @param name
056: * The name of the diagram.
057: * @param graphLayoutCache
058: * The graph layout cache that makes up the diagram.
059: */
060: public JGraphpadDiagram(String name,
061: GraphLayoutCache graphLayoutCache) {
062: this (name, graphLayoutCache, new Hashtable());
063: }
064:
065: /**
066: * Constructs a new diagram with the specified name using
067: * <code>graphLayoutCache</code> to hold the diagram.
068: *
069: * @param name
070: * The name of the diagram.
071: * @param graphLayoutCache
072: * The graph layout cache that makes up the diagram.
073: * @param properties
074: * The properties to use for the diagram.
075: */
076: public JGraphpadDiagram(String name,
077: GraphLayoutCache graphLayoutCache, Map properties) {
078: super (name);
079: this .graphLayoutCache = graphLayoutCache;
080: this .properties = properties;
081: }
082:
083: /*
084: * (non-Javadoc)
085: *
086: * @see com.jgraph.editor.core.JGraphEditorDiagram#setGraphLayoutCache(org.jgraph.graph.GraphLayoutCache)
087: */
088: public void setGraphLayoutCache(GraphLayoutCache graphLayoutCache) {
089: this .graphLayoutCache = graphLayoutCache;
090: }
091:
092: /*
093: * (non-Javadoc)
094: *
095: * @see com.jgraph.editor.core.JGraphEditorDiagram#getGraphLayoutCache()
096: */
097: public GraphLayoutCache getGraphLayoutCache() {
098: return graphLayoutCache;
099: }
100:
101: /*
102: * (non-Javadoc)
103: *
104: * @see com.jgraph.editor.core.JGraphEditorDiagram#setName(java.lang.String)
105: */
106: public void setName(String name) {
107: setUserObject(name);
108: }
109:
110: /*
111: * (non-Javadoc)
112: *
113: * @see com.jgraph.editor.core.JGraphEditorDiagram#getName()
114: */
115: public String getName() {
116: return toString();
117: }
118:
119: /**
120: * Returns the diagram properties.
121: *
122: * @return Returns the properties.
123: */
124: public Map getProperties() {
125: return properties;
126: }
127:
128: /**
129: * Sets the diagram properties.
130: *
131: * @param properties
132: * The properties to set.
133: */
134: public void setProperties(Map properties) {
135: this.properties = properties;
136: }
137:
138: }
|