Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ActivityDiagramRenderer |
|
| 5.0;5 |
1 | /* $Id: ActivityDiagramRenderer.java 18729 2010-09-10 16:10:34Z bobtarling $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009-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 was previously release using the BSD License: | |
15 | */ | |
16 | ||
17 | // Copyright (c) 2003-2008 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 | ||
41 | package org.argouml.uml.diagram.activity.ui; | |
42 | ||
43 | import java.util.Map; | |
44 | ||
45 | import org.argouml.uml.diagram.state.ui.StateDiagramRenderer; | |
46 | import org.argouml.uml.diagram.ui.UMLDiagram; | |
47 | import org.tigris.gef.base.Diagram; | |
48 | import org.tigris.gef.base.Layer; | |
49 | import org.tigris.gef.base.LayerPerspective; | |
50 | import org.tigris.gef.graph.GraphModel; | |
51 | import org.tigris.gef.presentation.FigNode; | |
52 | ||
53 | ||
54 | /** | |
55 | * This class defines a renderer object for UML Activity Diagrams. In a | |
56 | * Activity Diagram the following UML objects are displayed with the | |
57 | * following Figs: <p> | |
58 | * <pre> | |
59 | * UML Object --- Fig | |
60 | * --------------------------------------- | |
61 | * ActionState --- FigActionState | |
62 | * FinalState --- FigFinalState | |
63 | * Pseudostate --- FigPseudostate | |
64 | * Inititial --- FigInitialState | |
65 | * Choice (Branch) --- FigBranchState | |
66 | * Junction --- FigJunctionState | |
67 | * Fork --- FigForkState | |
68 | * Join --- FigJoinState | |
69 | * DeepHistory --- FigDeepHistoryState | |
70 | * ShallowHistory --- FigShallowistoryState | |
71 | * Transition --- FigTransition | |
72 | * CallState --- FigCallState | |
73 | * ObjectFlowState --- FigObjectFlowState | |
74 | * Partition --- FigPartition | |
75 | * SubactivityState --- FigSubactivityState | |
76 | * more... | |
77 | * </pre> | |
78 | * | |
79 | * @author mkl | |
80 | * | |
81 | */ | |
82 | 19 | public class ActivityDiagramRenderer extends StateDiagramRenderer { |
83 | ||
84 | /* | |
85 | * @see org.tigris.gef.graph.GraphNodeRenderer#getFigNodeFor( | |
86 | * org.tigris.gef.graph.GraphModel, org.tigris.gef.base.Layer, | |
87 | * java.lang.Object, java.util.Map) | |
88 | */ | |
89 | @Override | |
90 | public FigNode getFigNodeFor(GraphModel gm, Layer lay, Object node, | |
91 | Map styleAttributes) { | |
92 | ||
93 | 0 | FigNode figNode = null; |
94 | // Although not generally true for GEF, for Argo we know that the layer | |
95 | // is a LayerPerspective which knows the associated diagram | |
96 | 0 | Diagram diag = ((LayerPerspective) lay).getDiagram(); |
97 | 0 | if (diag instanceof UMLDiagram |
98 | && ((UMLDiagram) diag).doesAccept(node)) { | |
99 | 0 | figNode = (FigNode) ((UMLDiagram) diag).drop(node, null); |
100 | } else { | |
101 | 0 | figNode = super.getFigNodeFor(gm, lay, node, styleAttributes); |
102 | 0 | if (figNode == null) { |
103 | 0 | return null; |
104 | } | |
105 | } | |
106 | ||
107 | 0 | lay.add(figNode); |
108 | 0 | return figNode; |
109 | } | |
110 | } |