View Javadoc

1   /*
2   
3   nextobjects Copyright (C) 2001-2005 Emmanuel Florent
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by the
7   Free Software Foundation; either version 2 of the License, or (at your
8   option) any later version.
9   
10  This program is distributed in the hope that it will
11  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the GNU General Public License for more details.
14  
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc., 59
17  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  
19  */
20  
21  package org.devaki.nextobjects.workspace.models.graphics;
22  
23  import java.io.Serializable;
24  import java.awt.Graphics;
25  import java.awt.Graphics2D;
26  import org.devaki.nextobjects.constants.CstGraphics;
27  import org.devaki.nextobjects.workspace.models.objects.Association;
28  
29  /***
30   * This class is responsible for drawing an Association
31   * in the Merise formalism
32   * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
33   */
34  public class AssociationView extends ClassView implements Serializable
35  {
36      /***
37       * Construct a new 'AssociationView' object
38       * @param pAssociation the context association
39       */
40      public AssociationView(Association pAssociation)
41      {
42          super(pAssociation);
43          // Define size
44          this.setSize(CstGraphics.DEFAULT_ASSOCIATION_SIZE);
45          oldRectangle.setSize(rectangle.getSize());
46          oldRectangle.setLocation(rectangle.getLocation());
47      }
48  
49      /***
50       * Paint the association
51       * @param g the graphics
52       */
53      public void paint(Graphics g)
54      {
55          Graphics2D g2= (Graphics2D) g;
56          /*** Start drawing... **/
57          /*** Background **/
58          g2.setPaint(CstGraphics.MODEL_BACKGROUND_COLOR);
59          g.fillRect(0, 0, (int) this.getSize().getWidth(), (int) this.getSize().getHeight());
60          g2.setPaint(this.myStyle.getBackgroundColor());
61          g.fillRoundRect(0, 0, (int) this.getSize().getWidth(), (int) this.getSize().getHeight(), 15, 15);
62          /*** Border **/
63          g.setColor(this.myStyle.getBorderColor());
64          g.drawRoundRect(0, 0, (int) this.getSize().getWidth() - 1, (int) this.getSize().getHeight() - 1, 15, 15);
65          this.printColumns(g2, 0, 0);
66      }
67  }