01: /*
02: * $Id: JGraphpadGraphLayoutCache.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.pad.graph;
11:
12: import java.util.Set;
13:
14: import org.jgraph.graph.CellView;
15: import org.jgraph.graph.CellViewFactory;
16: import org.jgraph.graph.GraphLayoutCache;
17: import org.jgraph.graph.GraphModel;
18:
19: /**
20: * GraphLayoutCache to be used in JGraphpad files. Generally, due to the
21: * collapse/expand feature present in JGraphpad, all layout caches are partial.
22: */
23: public class JGraphpadGraphLayoutCache extends GraphLayoutCache {
24:
25: /**
26: * Constructs a new graph layout cache with a {@link JGraphpadGraphModel}
27: * and partial set to true.
28: */
29: public JGraphpadGraphLayoutCache() {
30: this (new JGraphpadGraphModel(), true);
31: }
32:
33: /**
34: * Constructs a new graph layout cache for the specified model.
35: *
36: * @param model
37: * The model to contruct the graph layout cache for.
38: * @param partial
39: * Whether the graph layout cache should be partial.
40: */
41: public JGraphpadGraphLayoutCache(GraphModel model, boolean partial) {
42: this (model, null, partial);
43: }
44:
45: /**
46: * Constructs a new graph layout cache which has all its state stored in the
47: * visible set, eg if the cache is partial, but does not contain view-local
48: * attributes.
49: *
50: * @param model
51: * The model to constructs the graph layout cache for.
52: * @param visibleSet
53: * The set of the visible cells.
54: * @param partial
55: * Whether the graph layout cache should be partial.
56: */
57: public JGraphpadGraphLayoutCache(GraphModel model, Set visibleSet,
58: boolean partial) {
59: super (model, new JGraphpadCellViewFactory(), partial);
60: if (visibleSet != null && !visibleSet.isEmpty()) {
61: setVisibleImpl(visibleSet.toArray(), true);
62: reloadRoots();
63: updatePorts();
64: }
65: }
66:
67: /**
68: * Constructs a new graph layout cache for the specified parameters.
69: */
70: public JGraphpadGraphLayoutCache(GraphModel model,
71: CellViewFactory factory, CellView[] cellViews,
72: CellView[] hiddenCellViews, boolean partial) {
73: super (model, factory, cellViews, hiddenCellViews, partial);
74: }
75:
76: /**
77: * Workaround for the XMLEncoder. The XMLEncoder, for some strange reason,
78: * does not call "isPartial" for this property.
79: */
80: public boolean getPartial() {
81: return isPartial();
82: }
83:
84: }
|