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 java.awt.Rectangle;
27 import org.devaki.nextobjects.constants.CstGraphics;
28 import org.devaki.nextobjects.workspace.models.objects.Entity;
29
30
31 /***
32 * The representation of an entity
33 * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
34 */
35 public class EntityView extends ClassView implements Serializable
36 {
37 /***
38 * Construct a new 'EntityView' object
39 * @param pEntity the context entity
40 */
41 public EntityView(Entity pEntity)
42 {
43 super(pEntity);
44
45 this.setSize(CstGraphics.DEFAULT_ENTITY_SIZE);
46 this.oldRectangle.setSize(rectangle.getSize());
47 this.oldRectangle.setLocation(rectangle.getLocation());
48 }
49
50
51 /***
52 * Update graphics
53 * @param g the graphics
54 */
55 public void update(Graphics g)
56 {
57 Graphics2D g2 = (Graphics2D)g;
58 Rectangle rect = new Rectangle(0, 0, (int) this.getSize().getWidth() - 1,
59 (int) this.getSize().getHeight() - 1);
60 /*** Start drawing... **/
61 /*** Background **/
62 g2.setColor(this.myStyle.getBackgroundColor());
63 g2.fill(rect);
64 /*** Border **/
65 g2.setPaint(this.myStyle.getBorderColor());
66 g2.drawRect(0, 0, (int) rect.getSize().getWidth(),
67 (int) rect.getSize().getHeight());
68 /*** Name **/
69 this.printColumns(g2, 0, 0);
70 }
71
72
73 /***
74 * Paint
75 * @param g the graphics
76 */
77 public void paint(Graphics g)
78 {
79 update(g);
80 }
81 }