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 java.awt.Rectangle;
27  import org.devaki.nextobjects.constants.CstGraphics;
28  import org.devaki.nextobjects.workspace.models.objects.Table;
29  
30  /***
31   *  This class is responsible for drawing a Table in a Physical Data Model
32   * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
33   */
34  public class TableView extends ClassView implements Serializable
35  {
36      /***
37       * Construct a new 'TableView' object
38       * @param pTable the table context
39       */
40      public TableView(Table pTable)
41      {
42          super(pTable);
43          // Define size
44          this.setSize(CstGraphics.DEFAULT_TABLE_SIZE);
45          oldRectangle.setSize(rectangle.getSize());
46          oldRectangle.setLocation(rectangle.getLocation());
47      }
48  
49      /***
50       * Paint the table
51       * @param g the graphic context
52       */
53      public void paint(Graphics g)
54      {
55          Graphics2D g2= (Graphics2D) g;
56  
57          int x= 0;
58          int y= 0;
59          /*** Start drawing... **/
60          /*** Background **/
61          g2.setColor(this.myStyle.getBackgroundColor());
62          g2.fill(new Rectangle(x, y, (int) this.getSize().getWidth() - 1, (int) this.getSize().getHeight() - 1));
63          /*** Border **/
64          g2.setPaint(this.myStyle.getBorderColor());
65          g2.drawRect(x, y, (int) this.getSize().getWidth() - 1, (int) this.getSize().getHeight() - 1);
66          /*** Text **/
67          this.printColumns(g2, x, y);
68      }
69  }