001: /*
002: * $Id: JGraphpadLibrary.java,v 1.2 2005/10/15 16:36:17 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.Map;
013:
014: import org.jgraph.graph.GraphLayoutCache;
015: import org.jgraph.graph.GraphModel;
016:
017: import com.jgraph.editor.JGraphEditorDiagram;
018: import com.jgraph.pad.graph.JGraphpadGraphLayoutCache;
019:
020: /**
021: * Represents a library in the JGraphpad editor. A library is a file and at the
022: * same time a diagram which contains a set of groups to be used as template
023: * cells.
024: */
025: public class JGraphpadLibrary extends JGraphpadFile implements
026: JGraphEditorDiagram {
027:
028: /**
029: * Specifies if the library can be changed. Default is false.
030: * Note: There is no way to change this setting via the UI.
031: * Please use a file edit to change the setting within the
032: * XML file that represents this library.
033: */
034: protected boolean isReadOnly = false;
035:
036: /**
037: * Holds the graph layout cache that contains the cells.
038: */
039: protected GraphLayoutCache graphLayoutCache;
040:
041: /**
042: * Constructs a new library.
043: */
044: public JGraphpadLibrary() {
045: this (null);
046: }
047:
048: /**
049: * Constructs a new file using the filename as the user object and a
050: * {@link JGraphpadGraphLayoutCache} to hold the cells.
051: *
052: * @param filename
053: * The user object of the parent object.
054: */
055: public JGraphpadLibrary(String filename) {
056: this (filename, new JGraphpadGraphLayoutCache());
057: }
058:
059: /**
060: * Constructs a new library with the specified filename as the user object
061: * and the specified graph layout cache to hold the cells.
062: *
063: * @param filename
064: * The user object of the parent object.
065: * @param graphLayoutCache
066: * The graph layout cache that contains the cells.
067: */
068: public JGraphpadLibrary(String filename,
069: GraphLayoutCache graphLayoutCache) {
070: super (filename);
071: this .graphLayoutCache = graphLayoutCache;
072: }
073:
074: /*
075: * (non-Javadoc)
076: */
077: public void setGraphLayoutCache(GraphLayoutCache graphLayoutCache) {
078: this .graphLayoutCache = graphLayoutCache;
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see com.jgraph.editor.core.JGraphEditorDiagram#getGraphLayoutCache()
085: */
086: public GraphLayoutCache getGraphLayoutCache() {
087: return graphLayoutCache;
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see com.jgraph.editor.core.JGraphEditorDiagram#getGraphLayoutCache()
094: */
095: public GraphModel getModel() {
096: return graphLayoutCache.getModel();
097: }
098:
099: /*
100: * (non-Javadoc)
101: *
102: * @see com.jgraph.editor.core.JGraphEditorDiagram#setName(java.lang.String)
103: */
104: public void setName(String name) {
105: setFilename(name);
106: }
107:
108: /*
109: * (non-Javadoc)
110: *
111: * @see com.jgraph.editor.core.JGraphEditorDiagram#getName()
112: */
113: public String getName() {
114: return toString();
115: }
116:
117: /**
118: * @return Returns the isReadOnly.
119: */
120: public boolean isReadOnly() {
121: return isReadOnly;
122: }
123:
124: /**
125: * @param isReadOnly The isReadOnly to set.
126: */
127: public void setReadOnly(boolean isReadOnly) {
128: this .isReadOnly = isReadOnly;
129: }
130:
131: /*
132: * (non-Javadoc)
133: */
134: public Map getProperties() {
135: return null;
136: }
137:
138: }
|