1 /*
2 * File: DefaultRowHeader.java
3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
4 * A commercial license is available, see http://www.jaret.de.
5 *
6 * This program 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 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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 this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.jaret.util.ui.timebars.model;
21
22 import de.jaret.util.misc.PropertyObservableBase;
23
24 /**
25 * A very simple object with a bound property that can be used as a RowHeader in the TimeBarRow.
26 *
27 * @author Peter Kliem
28 * @version $Id: DefaultRowHeader.java 800 2008-12-27 22:27:33Z kliem $
29 */
30 public class DefaultRowHeader extends PropertyObservableBase implements TimeBarRowHeader {
31 /** the label. */
32 protected String _label;
33
34 /** the row of the header. */
35 protected TimeBarRow _row;
36
37 /**
38 * Constructor supplying a label and the row. This should most probably be used.
39 *
40 * @param label the label
41 * @param row the row
42 */
43 public DefaultRowHeader(String label, TimeBarRow row) {
44 _label = label;
45 _row = row;
46 }
47
48 /**
49 * Constructor supplying a label.
50 *
51 * @param label label to use
52 */
53 public DefaultRowHeader(String label) {
54 this(label, null);
55 }
56
57 /**
58 * Set the header label.
59 *
60 * @param label new header label
61 */
62 public void setLabel(String label) {
63 String oldVal = _label;
64 _label = label;
65 firePropertyChange("Label", oldVal, label);
66 }
67
68 /**
69 * Straight forward toString method.
70 *
71 * @return the label
72 */
73 public String toString() {
74 return _label;
75 }
76
77 /**
78 * {@inheritDoc}
79 */
80 public String getLabel() {
81 return _label;
82 }
83
84 /**
85 * {@inheritDoc}
86 */
87 public TimeBarRow getRow() {
88 return _row;
89 }
90 }