Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libUIComponent / src / org / gvsig / gui / beans / table / models / ROIsTableModel.java @ 30043

History | View | Annotate | Download (1.53 KB)

1
package org.gvsig.gui.beans.table.models;
2

    
3
import java.awt.Color;
4

    
5
import javax.swing.JButton;
6
import javax.swing.table.DefaultTableModel;
7

    
8
public class ROIsTableModel extends DefaultTableModel implements IModel {
9
        private static final long serialVersionUID = 8716862990277121681L;
10

    
11
        
12
        private static boolean[]        canEdit = new boolean[] { true, false, false, false, true };
13
        private static Class[]           types   = new Class[] { String.class, Integer.class, Integer.class, Integer.class, JButton.class };
14
        private static Color[]           colors  = new Color[] {Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, Color.MAGENTA, Color.CYAN,
15
                Color.ORANGE, Color.PINK, Color.WHITE, Color.BLACK};
16
        
17
        public ROIsTableModel(String[] columnNames) {
18
                super(new Object[0][5], columnNames);
19
        }
20
        
21
        /*
22
         * (non-Javadoc)
23
         * @see org.gvsig.gui.beans.table.models.IModel#getNewLine()
24
         */
25
        public Object[] getNewLine() {
26
                Color color = null;
27
                if (this.getRowCount() < colors.length) {
28
                        color = colors[this.getRowCount()];
29
                }
30
                else{
31
                        color = new Color((float)Math.random(),(float)Math.random(),(float)Math.random());
32
                }
33
                return new Object[] {"", new Integer(0), new Integer(0), new Integer(0), color};
34
        }
35

    
36
        /*
37
         * (non-Javadoc)
38
         * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
39
         */
40
        public Class getColumnClass(int columnIndex) {
41
                return types [columnIndex];
42
        }
43

    
44
        /*
45
         * (non-Javadoc)
46
         * @see javax.swing.table.DefaultTableModel#isCellEditable(int, int)
47
         */
48
        public boolean isCellEditable(int rowIndex, int columnIndex) {
49
                return canEdit [columnIndex];
50
        }
51
}