1 /***
2 * ValueIndexedTableColorModel.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2002 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.swing.table.colormodel;
27
28 import org.jcreme.swing.table.TableColorModelEvent;
29
30 /***
31 * The purpose of this class is to have a specific background color for the
32 * lines that have a given reference column above a given Threshold value. (the
33 * value of a specified column is at a specified value).
34 *
35 * @author $Author: dbregeon $
36 * @version $Revision: 1.2 $
37 */
38 public class ValueIndexedTableColorModel extends
39 AbstractValueIndexedTableColorModel {
40 /***
41 * The treshold over which the color changes.
42 */
43 private Comparable thresholdValue = null;
44
45 /***
46 * Sets the treshold value over which the task will be considered complete.
47 *
48 * @param value
49 * The value to use as a treshold.
50 */
51 public void setThresholdValue(Comparable value) {
52 if (this.thresholdValue != value) {
53 this.thresholdValue = value;
54 fireTableColorModelChanged(new TableColorModelEvent(this));
55 }
56 }
57
58 protected boolean testThreshold(Object value) {
59 return (this.thresholdValue != null)
60 && (this.thresholdValue.compareTo(value) <= 0);
61 }
62 }