| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ClassdiagramModelElementFactory |
|
| 7.0;7 |
| 1 | /* $Id: ClassdiagramModelElementFactory.java 17863 2010-01-12 20:07:22Z linus $ | |
| 2 | ***************************************************************************** | |
| 3 | * Copyright (c) 2009 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 | * tfmorris | |
| 11 | ***************************************************************************** | |
| 12 | * | |
| 13 | * Some portions of this file was previously release using the BSD License: | |
| 14 | */ | |
| 15 | ||
| 16 | // Copyright (c) 1996-2008 The Regents of the University of California. All | |
| 17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
| 18 | // software and its documentation without fee, and without a written | |
| 19 | // agreement is hereby granted, provided that the above copyright notice | |
| 20 | // and this paragraph appear in all copies. This software program and | |
| 21 | // documentation are copyrighted by The Regents of the University of | |
| 22 | // California. The software program and documentation are supplied "AS | |
| 23 | // IS", without any accompanying services from The Regents. The Regents | |
| 24 | // does not warrant that the operation of the program will be | |
| 25 | // uninterrupted or error-free. The end-user understands that the program | |
| 26 | // was developed for research purposes and is advised not to rely | |
| 27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
| 28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
| 29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
| 30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
| 31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
| 32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
| 33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
| 35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
| 36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
| 37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
| 38 | ||
| 39 | package org.argouml.uml.diagram.static_structure.layout; | |
| 40 | ||
| 41 | import org.apache.log4j.Logger; | |
| 42 | import org.argouml.uml.diagram.layout.LayoutedObject; | |
| 43 | import org.argouml.uml.diagram.static_structure.ui.FigComment; | |
| 44 | import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote; | |
| 45 | import org.argouml.uml.diagram.ui.FigAbstraction; | |
| 46 | import org.argouml.uml.diagram.ui.FigAssociation; | |
| 47 | import org.argouml.uml.diagram.ui.FigGeneralization; | |
| 48 | import org.argouml.uml.diagram.ui.FigNodeModelElement; | |
| 49 | import org.tigris.gef.presentation.FigNode; | |
| 50 | ||
| 51 | /** a class to get the proper layouter for a Fig. | |
| 52 | * Currently this deals only with Generalizations and Realizations. | |
| 53 | * | |
| 54 | * @author Markus Klink | |
| 55 | * @stereotype singleton | |
| 56 | */ | |
| 57 | public class ClassdiagramModelElementFactory | |
| 58 | { | |
| 59 | 0 | private static final Logger LOG = |
| 60 | Logger.getLogger(ClassdiagramModelElementFactory.class); | |
| 61 | ||
| 62 | /** | |
| 63 | * The singleton. | |
| 64 | */ | |
| 65 | 0 | public static final ClassdiagramModelElementFactory SINGLETON = |
| 66 | new ClassdiagramModelElementFactory(); | |
| 67 | ||
| 68 | 0 | private ClassdiagramModelElementFactory() { } |
| 69 | ||
| 70 | /** create layouter object from a Fig.* | |
| 71 | * | |
| 72 | * @param f Object which contains the Fig | |
| 73 | * @return Layouter for the Edge or Classnode or null if none exists. | |
| 74 | */ | |
| 75 | public LayoutedObject getInstance(Object f) { | |
| 76 | 0 | if (f instanceof FigComment) { |
| 77 | 0 | return (new ClassdiagramNote((FigComment) f)); |
| 78 | 0 | } else if (f instanceof FigNodeModelElement) { |
| 79 | 0 | return (new ClassdiagramNode((FigNode) f)); |
| 80 | 0 | } else if (f instanceof FigGeneralization) { |
| 81 | 0 | return new ClassdiagramGeneralizationEdge((FigGeneralization) f); |
| 82 | 0 | } else if (f instanceof FigAbstraction) { |
| 83 | 0 | return (new ClassdiagramRealizationEdge((FigAbstraction) f)); |
| 84 | 0 | } else if (f instanceof FigAssociation) { |
| 85 | 0 | return (new ClassdiagramAssociationEdge((FigAssociation) f)); |
| 86 | 0 | } else if (f instanceof FigEdgeNote) { |
| 87 | 0 | return (new ClassdiagramNoteEdge((FigEdgeNote) f)); |
| 88 | } | |
| 89 | 0 | LOG.debug("Do not know how to deal with: " + f.getClass().getName() |
| 90 | + "\nUsing standard layout"); | |
| 91 | 0 | return null; |
| 92 | } | |
| 93 | } |