1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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 }