Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ArgoFigGroup |
|
| 2.142857142857143;2.143 |
1 | /* $Id: ArgoFigGroup.java 17753 2010-01-11 19:49:55Z linus $ | |
2 | ******************************************************************************* | |
3 | * Copyright (c) 2010 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Tom Morris | |
11 | * Bob Tarling | |
12 | ******************************************************************************* | |
13 | * | |
14 | * Some portions of this file were previously release using the BSD License: | |
15 | */ | |
16 | // $Id: ArgoFigGroup.java 17753 2010-01-11 19:49:55Z linus $ | |
17 | // Copyright (c) 2007-2009 The Regents of the University of California. All | |
18 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
19 | // software and its documentation without fee, and without a written | |
20 | // agreement is hereby granted, provided that the above copyright notice | |
21 | // and this paragraph appear in all copies. This software program and | |
22 | // documentation are copyrighted by The Regents of the University of | |
23 | // California. The software program and documentation are supplied "AS | |
24 | // IS", without any accompanying services from The Regents. The Regents | |
25 | // does not warrant that the operation of the program will be | |
26 | // uninterrupted or error-free. The end-user understands that the program | |
27 | // was developed for research purposes and is advised not to rely | |
28 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
29 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
30 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
31 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
32 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
33 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
34 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
35 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
36 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
37 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
38 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
39 | ||
40 | package org.argouml.uml.diagram.ui; | |
41 | ||
42 | import java.util.List; | |
43 | ||
44 | import org.apache.log4j.Logger; | |
45 | import org.argouml.kernel.Project; | |
46 | import org.argouml.uml.diagram.DiagramSettings; | |
47 | import org.tigris.gef.presentation.Fig; | |
48 | import org.tigris.gef.presentation.FigGroup; | |
49 | ||
50 | /** | |
51 | * A Fig which contains other Figs. ArgoUMLs version of GEF's FigGroup. <p> | |
52 | * | |
53 | * It implements the additional methods of the ArgoFig interface. | |
54 | * | |
55 | * @author Tom Morris <tfmorris@gmail.com> | |
56 | */ | |
57 | public abstract class ArgoFigGroup extends FigGroup implements ArgoFig { | |
58 | ||
59 | 0 | private static final Logger LOG = Logger.getLogger(ArgoFigGroup.class); |
60 | ||
61 | // TODO: Make this final asap. | |
62 | private DiagramSettings settings; | |
63 | ||
64 | /** | |
65 | * Construct an empty FigGroup with the given DiagramSettings. | |
66 | * object. | |
67 | * @param owner owning UML element | |
68 | * @param renderSettings render settings to use | |
69 | */ | |
70 | public ArgoFigGroup(Object owner, DiagramSettings renderSettings) { | |
71 | 0 | super(); |
72 | 0 | super.setOwner(owner); |
73 | 0 | settings = renderSettings; |
74 | 0 | } |
75 | ||
76 | /** | |
77 | * This optional method is not implemented. It will throw an | |
78 | * {@link UnsupportedOperationException} if used. Figs are | |
79 | * added to a GraphModel which is, in turn, owned by a project.<p> | |
80 | * | |
81 | * @param project the project | |
82 | * @deprecated | |
83 | */ | |
84 | @SuppressWarnings("deprecation") | |
85 | @Deprecated | |
86 | public void setProject(Project project) { | |
87 | 0 | throw new UnsupportedOperationException(); |
88 | } | |
89 | ||
90 | /** | |
91 | * @deprecated for 0.27.2 by tfmorris. Implementations should have all | |
92 | * the information that they require in the DiagramSettings object. | |
93 | * | |
94 | * @return the owning project | |
95 | * @see org.argouml.uml.diagram.ui.ArgoFig#getProject() | |
96 | */ | |
97 | @SuppressWarnings("deprecation") | |
98 | @Deprecated | |
99 | public Project getProject() { | |
100 | 0 | return ArgoFigUtil.getProject(this); |
101 | } | |
102 | ||
103 | public void renderingChanged() { | |
104 | // Get all our sub Figs and hit them with the big stick too | |
105 | 0 | for (Fig fig : (List<Fig>) getFigs()) { |
106 | 0 | if (fig instanceof ArgoFig) { |
107 | 0 | ((ArgoFig) fig).renderingChanged(); |
108 | } else { | |
109 | 0 | LOG.debug("Found non-Argo fig nested"); |
110 | } | |
111 | } | |
112 | 0 | } |
113 | ||
114 | ||
115 | public DiagramSettings getSettings() { | |
116 | // TODO: This is a temporary crutch to use until all Figs are updated | |
117 | // to use the constructor that accepts a DiagramSettings object | |
118 | 0 | if (settings == null) { |
119 | 0 | Project p = getProject(); |
120 | 0 | if (p != null) { |
121 | 0 | return p.getProjectSettings().getDefaultDiagramSettings(); |
122 | } | |
123 | } | |
124 | 0 | return settings; |
125 | } | |
126 | ||
127 | /** | |
128 | * @deprecated for 0.29.3 by Bob Tarling. The diagram settings are | |
129 | * provided to the constructor and then should never change. | |
130 | * When this method is removed the "settings" variable can become final. | |
131 | */ | |
132 | public void setSettings(DiagramSettings renderSettings) { | |
133 | 0 | settings = renderSettings; |
134 | 0 | renderingChanged(); |
135 | 0 | } |
136 | ||
137 | /** | |
138 | * Setting the owner of the Fig must be done in the constructor and not | |
139 | * changed afterwards for all ArgoUML figs. | |
140 | * | |
141 | * @param owner owning UML element | |
142 | * @throws UnsupportedOperationException | |
143 | * @deprecated for 0.27.3 by tfmorris. Set owner in constructor. This method | |
144 | * is implemented in GEF, so we'll leave this implementation | |
145 | * here to block any attempts to use it within ArgoUML. | |
146 | */ | |
147 | @SuppressWarnings("deprecation") | |
148 | @Deprecated | |
149 | public void setOwner(Object owner) { | |
150 | 0 | if (owner != getOwner()) { |
151 | 0 | throw new UnsupportedOperationException( |
152 | "Owner must be set in constructor and left unchanged"); | |
153 | } | |
154 | 0 | } |
155 | ||
156 | } |