1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.devaki.nextobjects.workspace.models.graphics;
21 import java.awt.Graphics;
22 import java.awt.Font;
23 import java.awt.Point;
24 import javax.swing.UIManager;
25 import org.devaki.nextobjects.constants.CstGraphics;
26 import org.devaki.nextobjects.workspace.models.objects.ModelTitle;
27 import org.devaki.nextobjects.workspace.models.ConceptualModel;
28 import org.devaki.nextobjects.workspace.models.PhysicalModel;
29 /***
30 * This class is responsible for drawing a "cartouche"
31 * around the graphic.
32 *
33 * @author eflorent
34 *
35 */
36 public class ModelTitleView extends ClassView
37 {
38 String modelKind = "";
39 Font font =
40 new Font(
41 ((Font) UIManager.get("Label.font")).getName(),
42 Font.PLAIN,
43 ((Font) UIManager.get("Label.font")).getSize());
44 int ascent = font.getSize() + 2;
45 /***
46 * Constructor
47 * @param pObject the model title
48 */
49 public ModelTitleView(ModelTitle pObject)
50 {
51 super(pObject);
52 if (pObject.getMyModel() instanceof ConceptualModel)
53 {
54 modelKind = "<<Conceptual Model>>";
55 }
56 else
57 if (pObject.getMyModel() instanceof PhysicalModel)
58 {
59 modelKind = "<<Physical Model>>";
60 }
61 this.setSize(CstGraphics.DEFAULT_MODELTITLE_SIZE);
62 Point p = new Point(CstGraphics.MODEL_INITIAL_POSITION);
63 this.setLocation(p);
64
65 oldRectangle.setSize(rectangle.getSize());
66 oldRectangle.setLocation(rectangle.getLocation());
67 }
68 /***
69 * Paint the "cartouche"
70 * @param g the graphic context
71 */
72 public void paint(Graphics g)
73 {
74
75
76
77
78
79
80
81
82
83
84 g.setColor(CstGraphics.MODEL_BACKGROUND_COLOR);
85 g.fillRect(0, 0, this.getSize().width, this.getSize().height);
86 g.setColor(CstGraphics.DEFAULT_MODELTITLE_COLOR);
87 g.drawRect(0, 0, this.getSize().width - 1, this.getSize().height - 1);
88
89
90
91
92
93
94 g.drawRect(
95 0,
96 (this.getMiddlePoint().y - this.getLocation().y),
97 this.getSize().width / 2,
98 this.getSize().height / 2);
99
100
101
102
103
104
105 g.drawRect(
106 (this.getMiddlePoint().x - this.getLocation().x),
107 (this.getMiddlePoint().y - this.getLocation().y),
108 this.getSize().width / 2,
109 this.getSize().height / 2);
110 printText(g);
111 }
112 /***
113 * Draw the texts
114 * @param g the graphic context
115 */
116 public void printText(Graphics g)
117 {
118 g.drawString(this.myObject.getMyModel().getName(), 4, ascent);
119 g.drawString(modelKind, 4, ascent + this.getSize().height / 2);
120 g.drawString(
121 this.myObject.getMyModel().getAuthorEmail(),
122 4 + this.getSize().width / 2,
123 ascent + this.getSize().height / 2);
124 }
125 }