KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > inspector > InspectorModel


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org);
7  *
8  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25
26 package org.jrobin.inspector;
27
28 import java.io.File JavaDoc;
29 import java.text.DecimalFormat JavaDoc;
30
31 class InspectorModel {
32     private MainTreeModel mainTreeModel = new MainTreeModel();
33     private HeaderTableModel generalTableModel = new HeaderTableModel();
34     private DatasourceTableModel datasourceTableModel = new DatasourceTableModel();
35     private ArchiveTableModel archiveTableModel = new ArchiveTableModel();
36     private DataTableModel dataTableModel = new DataTableModel();
37     private File JavaDoc file;
38     private boolean ok = false;
39
40     MainTreeModel getMainTreeModel() {
41         return mainTreeModel;
42     }
43
44     HeaderTableModel getGeneralTableModel() {
45         return generalTableModel;
46     }
47
48     DatasourceTableModel getDatasourceTableModel() {
49         return datasourceTableModel;
50     }
51
52     DataTableModel getDataTableModel() {
53         return dataTableModel;
54     }
55
56     ArchiveTableModel getArchiveTableModel() {
57         return archiveTableModel;
58     }
59
60     void setFile(File JavaDoc file) {
61         this.file = file;
62         this.ok = mainTreeModel.setFile(file);
63         generalTableModel.setFile(file);
64         datasourceTableModel.setFile(file);
65         archiveTableModel.setFile(file);
66         dataTableModel.setFile(file);
67     }
68
69     void refresh() {
70         setFile(file);
71     }
72
73     void selectModel(int dsIndex, int arcIndex) {
74         datasourceTableModel.setIndex(dsIndex);
75         archiveTableModel.setIndex(dsIndex, arcIndex);
76         dataTableModel.setIndex(dsIndex, arcIndex);
77     }
78
79     File JavaDoc getFile() {
80         return file;
81     }
82
83     boolean isOk() {
84         return ok;
85     }
86
87     private static String JavaDoc DOUBLE_FORMAT = "0.0000000000E00";
88     private static final DecimalFormat JavaDoc df = new DecimalFormat JavaDoc(DOUBLE_FORMAT);
89
90     static String JavaDoc formatDouble(double x, String JavaDoc nanString) {
91         if(Double.isNaN(x)) {
92             return nanString;
93         }
94         return df.format(x);
95     }
96
97     static String JavaDoc formatDouble(double x) {
98         return formatDouble(x, "" + Double.NaN);
99     }
100 }
101
Popular Tags