View Javadoc

1   package org.devaki.nextobjects.workspace.models.objects;
2   /*
3   
4   nextobjects Copyright (C) 2001-2005 Emmanuel Florent
5   
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by the
8   Free Software Foundation; either version 2 of the License, or (at your
9   option) any later version.
10  
11  This program is distributed in the hope that it will
12  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the GNU General Public License for more details.
15  
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc., 59
18  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  
20  */
21  import java.io.Serializable;
22  import org.devaki.nextobjects.workspace.models.ConceptualModel;
23  import org.devaki.nextobjects.workspace.models.graphics.AssociationLinkView;
24  import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
25  /***
26   * This class describe an association link
27   * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
28   */
29  public class AssociationLink extends BaseLine implements Serializable
30  {
31      /***
32       * the AssociationLinkView
33       */
34      private AssociationLinkView associationLinkView;
35      /***
36       * the cardinalities
37       */
38      private int card = ConceptualModel.ASSO_0N;
39      /***
40       * Create a new 'AssociationLink' object while dragging
41       * @param pAssociation the new association
42       * @param pEntity the linked entity
43       * @param pCard the cardinality of the relation
44       */
45      public AssociationLink(
46          final Association pAssociation,
47          final Entity pEntity,
48          final int pCard)
49      {
50          super(pAssociation.getMyModel());
51          this.setChildClass(pEntity);
52          this.setParentClass(pAssociation);
53          this.card = pCard;
54          // Set the name
55          this.setName(
56              new StringBuffer()
57                  .append("Association Link ")
58                  .append(
59                      ((ConceptualModel) pEntity.getMyModel())
60                          .countAssociationLinks())
61                  .toString());
62          // Set the object view
63          this.associationLinkView = new AssociationLinkView(this);
64      }
65      /***
66       * Clone an  'AssociationLink' object
67       * @param pObject the association link to clone
68       */
69      public AssociationLink(final AssociationLink pObject)
70      {
71          super(pObject);
72          this.card = pObject.getCard();
73          this.associationLinkView = new AssociationLinkView(this);
74      }
75      /***
76       * Get the cardinality
77       * @return the cardianlity of the half association.
78       */
79      public final int getCard()
80      {
81          return this.card;
82      }
83      /***
84       * Set the cardinality
85       * @param pCard the cardinality
86       */
87      public final void setCard(final int pCard)
88      {
89          this.card = pCard;
90      }
91      /***
92       * get the associationLinkView
93       * @return associationLinkView
94       */
95      public final ObjectView getObjectView()
96      {
97          return associationLinkView;
98      }
99  }