1 /*
2 * Copyright (c) 2003-2008 by Cosylab d. d.
3 *
4 * This file is part of CosyBeans-Common.
5 *
6 * CosyBeans-Common is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CosyBeans-Common is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package com.cosylab.gui.components.table.renderers;
21
22 import com.cosylab.gui.components.table.cells.LongCell;
23
24 import java.awt.Component;
25
26 import javax.swing.JTable;
27
28
29 /**
30 * This is the default renderer for ObjectTable cells implementing LongCell
31 * interface.
32 *
33 * @author <a href="mailto:ales.pucelj@cosylab.com">Ales Pucelj</a>
34 * @version $id$
35 */
36 public class LongCellRenderer extends DefaultTableCellRenderer
37 {
38 private static final long serialVersionUID = 1L;
39
40 /**
41 * Constructs a new LongCellRenderer.
42 *
43 * @param decorateBorder if true decorated border will be used
44 * @param decorateBackground if true decorated background will be used
45 */
46 public LongCellRenderer(boolean decorateBorder, boolean decorateBackground)
47 {
48 super(decorateBorder, decorateBackground);
49 }
50
51 /**
52 * Constructs a new LongCellRenderer.
53 *
54 */
55 public LongCellRenderer()
56 {
57 super();
58 }
59
60 /*
61 * (non-Javadoc)
62 * @see com.cosylab.gui.components.table.renderers.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
63 */
64 public Component getTableCellRendererComponent(JTable table, Object cell,
65 boolean isSelected, boolean hasFocus, int row, int column)
66 {
67 super.getTableCellRendererComponent(table, cell, isSelected, hasFocus,
68 row, column);
69
70 if (cell instanceof LongCell) {
71 if (((LongCell)cell).isSuspended()) {
72 setText("");
73 } else {
74
75 String value = Long.toString(((LongCell)cell).getLongValue());
76 if (((LongCell)cell).isUnitsVisible()) {
77 value += " " + ((LongCell)cell).getUnits();
78 }
79 setText(value);
80
81 }
82 }
83
84 return this;
85 }
86 }
87
88 /* __oOo__ */