Normand Briere
2018-12-17 86f4e9c75951153ae9825f4772633e45698cb602
Timeflow clean-up.
52 files modified
1 files renamed
1707 ■■■■ changed files
ObjEditor.java 13 ●●●● patch | view | raw | blame | history
timeflow/app/TimeflowApp.java 8 ●●●●● patch | view | raw | blame | history
timeflow/app/actions/AddFieldAction.java 2 ●●● patch | view | raw | blame | history
timeflow/app/actions/AddRecordAction.java 23 ●●●● patch | view | raw | blame | history
timeflow/app/actions/DeleteFieldAction.java 2 ●●● patch | view | raw | blame | history
timeflow/app/actions/DeleteSelectedAction.java 77 ●●●● patch | view | raw | blame | history
timeflow/app/actions/EditSourceAction.java 2 ●●● patch | view | raw | blame | history
timeflow/app/actions/NewDataAction.java 26 ●●●● patch | view | raw | blame | history
timeflow/app/actions/QuitAction.java 2 ●●● patch | view | raw | blame | history
timeflow/app/actions/TimeflowAction.java 2 ●●● patch | view | raw | blame | history
timeflow/app/ui/ColorLegendPanel.java 2 ●●● patch | view | raw | blame | history
timeflow/app/ui/ComponentCluster.java 6 ●●●● patch | view | raw | blame | history
timeflow/app/ui/DateFieldPanel.java 6 ●●●● patch | view | raw | blame | history
timeflow/app/ui/EditRecordPanel.java 14 ●●●● patch | view | raw | blame | history
timeflow/app/ui/EditValuePanel.java 1 ●●●● patch | view | raw | blame | history
timeflow/app/ui/GlobalDisplayPanel.java 11 ●●●● patch | view | raw | blame | history
timeflow/app/ui/ImportDelimitedPanel.java 6 ●●●● patch | view | raw | blame | history
timeflow/app/ui/MassDeletePanel.java 4 ●●●● patch | view | raw | blame | history
timeflow/app/ui/ReorderFieldsPanel.java 4 ●●●● patch | view | raw | blame | history
timeflow/app/ui/SizeLegendPanel.java 4 ●●●● patch | view | raw | blame | history
timeflow/app/ui/StatusPanel.java 2 ●●● patch | view | raw | blame | history
timeflow/app/ui/filter/FilterCategoryPanel.java 314 ●●●● patch | view | raw | blame | history
timeflow/app/ui/filter/FilterControlPanel.java 2 ●●● patch | view | raw | blame | history
timeflow/app/ui/filter/FilterDatePanel.java 310 ●●●● patch | view | raw | blame | history
timeflow/app/ui/filter/SearchPanel.java 2 ●●● patch | view | raw | blame | history
timeflow/data/db/ActDB.java 9 ●●●●● patch | view | raw | blame | history
timeflow/data/db/Field.java 89 ●●●● patch | view | raw | blame | history
timeflow/data/time/RoughTime.java 250 ●●●● patch | view | raw | blame | history
timeflow/data/time/TimeUnit.java 9 ●●●●● patch | view | raw | blame | history
timeflow/format/field/FieldFormat.java 112 ●●●● patch | view | raw | blame | history
timeflow/format/file/Export.java 2 ●●● patch | view | raw | blame | history
timeflow/format/file/HtmlFormat.java 8 ●●●● patch | view | raw | blame | history
timeflow/format/file/TimeflowFormat.java 301 ●●●● patch | view | raw | blame | history
timeflow/model/Display.java 2 ●●● patch | view | raw | blame | history
timeflow/model/ModelPanel.java 6 ●●●● patch | view | raw | blame | history
timeflow/model/TFListener.java 5 ●●●●● patch | view | raw | blame | history
timeflow/model/TimeflowModel.java 3 ●●●● patch | view | raw | blame | history
timeflow/views/AbstractView.java 4 ●●●● patch | view | raw | blame | history
timeflow/views/AbstractVisualizationView.java 6 ●●●● patch | view | raw | blame | history
timeflow/views/BarGraphView.java 6 ●●●● patch | view | raw | blame | history
timeflow/views/CalendarView.java 4 ●●●● patch | view | raw | blame | history
timeflow/views/DescriptionView.java 2 ●●● patch | view | raw | blame | history
timeflow/views/IntroView.java 2 ●●● patch | view | raw | blame | history
timeflow/views/ListView.java 2 ●●● patch | view | raw | blame | history
timeflow/views/SummaryView.java 2 ●●● patch | view | raw | blame | history
timeflow/views/TableView.java 2 ●●● patch | view | raw | blame | history
timeflow/views/TimelineView.java 10 ●●●● patch | view | raw | blame | history
timeflow/vis/VisualActFactory.java 4 ●●●● patch | view | raw | blame | history
timeflow/vis/VisualEncoder.java 4 ●●●● patch | view | raw | blame | history
timeflow/vis/calendar/CalendarVisuals.java 4 ●●●● patch | view | raw | blame | history
timeflow/vis/timeline/AxisRenderer.java 4 ●●●● patch | view | raw | blame | history
timeflow/vis/timeline/TimelineRenderer.java 2 ●●● patch | view | raw | blame | history
timeflow/vis/timeline/TimelineVisuals.java 8 ●●●● patch | view | raw | blame | history
ObjEditor.java
....@@ -1189,6 +1189,13 @@
11891189 timelinePanel = new JPanel(new BorderLayout());
11901190 timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11911191
1192
+ cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
1193
+ cameraPanel.setContinuousLayout(true);
1194
+ cameraPanel.setOneTouchExpandable(true);
1195
+// cameraPanel.setDividerLocation(0.9);
1196
+// cameraPanel.setDividerSize(9);
1197
+ cameraPanel.setResizeWeight(1.0);
1198
+
11921199 centralPanel.add(cameraView);
11931200 //frame.setJMenuBar(timelineMenubar);
11941201 //centralPanel.add(timelinePanel);
....@@ -2996,7 +3003,8 @@
29963003 if (timeline)
29973004 {
29983005 centralPanel.remove(cameraView);
2999
- centralPanel.add(timelinePanel);
3006
+ cameraPanel.add(cameraView);
3007
+ centralPanel.add(cameraPanel);
30003008 frame.setJMenuBar(timelineMenubar);
30013009 wasFullScreen = CameraPane.FULLSCREEN;
30023010 if (!CameraPane.FULLSCREEN)
....@@ -3005,7 +3013,7 @@
30053013 }
30063014 else
30073015 {
3008
- centralPanel.remove(timelinePanel);
3016
+ centralPanel.remove(cameraPanel);
30093017 centralPanel.add(cameraView);
30103018 frame.setJMenuBar(null);
30113019 if (!wasFullScreen)
....@@ -4533,6 +4541,7 @@
45334541 JPanel bigThree;
45344542 JTabbedPane scenePanel;
45354543 JPanel centralPanel;
4544
+ JSplitPane cameraPanel;
45364545 JPanel timelinePanel;
45374546 JMenuBar timelineMenubar;
45384547 JSplitPane framePanel;
timeflow/app/TimeflowApp.java
....@@ -25,7 +25,7 @@
2525
2626 public class TimeflowApp extends JFrame
2727 {
28
- public TFModel model = new TFModel();
28
+ public TimeflowModel model = new TimeflowModel();
2929 public JFileChooser fileChooser;
3030 AboutWindow splash;
3131 String[][] examples;
....@@ -84,6 +84,7 @@
8484 examples[i][0] = s;
8585 examples[i][1] = "settings/examples/" + ex[i];
8686 }
87
+
8788 templates = getVisibleFiles("settings/templates");
8889 fileChooser = new JFileChooser(state.getCurrentFile());
8990
....@@ -180,7 +181,9 @@
180181 JMenu fileMenu = new JMenu("File");
181182 menubar.add(fileMenu);
182183
183
- fileMenu.add(new NewDataAction(this));
184
+ TimeflowAction tlAction = new NewDataAction(this);
185
+ fileMenu.add(tlAction);
186
+ tlAction.actionPerformed(null);
184187 fileMenu.add(new CopySchemaAction(this));
185188
186189 JMenu templateMenu = new JMenu("New From Template");
....@@ -202,7 +205,6 @@
202205 }
203206
204207 fileMenu.addSeparator();
205
-
206208
207209 JMenuItem open = new JMenuItem("Open...");
208210 fileMenu.add(open);
timeflow/app/actions/AddFieldAction.java
....@@ -32,7 +32,7 @@
3232 if (n==1)
3333 {
3434 String fieldName=p.name.getText();
35
- TFModel model=getModel();
35
+ TimeflowModel model=getModel();
3636 if (fieldName.trim().length()==0)
3737 app.showUserError("Field names can't be all spaces!");
3838 else if (model.getDB().getField(fieldName)!=null)
timeflow/app/actions/AddRecordAction.java
....@@ -11,16 +11,17 @@
1111 import javax.swing.*;
1212 import java.util.*;
1313
14
-public class AddRecordAction extends TimeflowAction {
14
+public class AddRecordAction extends TimeflowAction
15
+{
16
+ public AddRecordAction(TimeflowApp app)
17
+ {
18
+ super(app, "Add Record...", null, "Add a record to this database");
19
+ accelerate('A');
20
+ }
1521
16
- public AddRecordAction(TimeflowApp app)
17
- {
18
- super(app, "Add Record...", null, "Add a record to this database");
19
- accelerate('A');
20
- }
21
-
22
- @Override
23
- public void actionPerformed(ActionEvent e) {
24
- EditRecordPanel.add(getModel());
25
- }
22
+ @Override
23
+ public void actionPerformed(ActionEvent e)
24
+ {
25
+ EditRecordPanel.add(getModel());
26
+ }
2627 }
timeflow/app/actions/DeleteFieldAction.java
....@@ -33,7 +33,7 @@
3333
3434 if (fieldToDelete!=null)
3535 {
36
- TFModel model=getModel();
36
+ TimeflowModel model=getModel();
3737 Field f=model.getDB().getField(fieldToDelete);
3838 model.getDB().deleteField(f);
3939 model.noteSchemaChange(this);
timeflow/app/actions/DeleteSelectedAction.java
....@@ -9,43 +9,48 @@
99 import javax.swing.*;
1010 import java.util.*;
1111
12
+public class DeleteSelectedAction extends TimeflowAction
13
+{
1214
13
-public class DeleteSelectedAction extends TimeflowAction {
15
+ public DeleteSelectedAction(TimeflowApp app)
16
+ {
17
+ super(app, "Delete Selected Items...", null, "Delete the currently visible events");
18
+ }
1419
15
- public DeleteSelectedAction(TimeflowApp app)
16
- {
17
- super(app, "Delete Selected Items...", null, "Delete the currently visible events");
18
- }
19
-
20
- @Override
21
- public void actionPerformed(ActionEvent e) {
22
-
23
- HashSet<Act> keepers=new HashSet<Act>(); // switching between sets and lists
24
- keepers.addAll(getModel().getDB().all()); // for efficiency. maybe silly?
25
- ActList selected=getModel().getActs();
26
- for (Act a: selected)
27
- keepers.remove(a);
28
- ActList keepList=new ActList(getModel().getDB());
29
- keepList.addAll(keepers);
30
-
31
- MassDeletePanel panel=new MassDeletePanel(getModel(), keepList,
32
- "Delete all selected items.");
33
- Object[] options = {"Cancel", "Proceed"};
34
- int n = JOptionPane.showOptionDialog(app,
35
- panel,
36
- "Delete Selected",
37
- JOptionPane.YES_NO_CANCEL_OPTION,
38
- JOptionPane.PLAIN_MESSAGE,
39
- null,
40
- options,
41
- "Proceed");
42
- panel.detachFromModel();
43
- if (n==1)
44
- {
45
- panel.applyAction();
46
- app.clearFilters();
47
- getModel().noteSchemaChange(this);
48
- }
49
- }
20
+ @Override
21
+ public void actionPerformed(ActionEvent e)
22
+ {
5023
24
+ HashSet<Act> keepers = new HashSet<Act>(); // switching between sets and lists
25
+ keepers.addAll(getModel().getDB().all()); // for efficiency. maybe silly?
26
+ ActList selected = getModel().getActs();
27
+ for (Act a : selected)
28
+ {
29
+ keepers.remove(a);
30
+ }
31
+ ActList keepList = new ActList(getModel().getDB());
32
+ keepList.addAll(keepers);
33
+
34
+ MassDeletePanel panel = new MassDeletePanel(getModel(), keepList,
35
+ "Delete all selected items.");
36
+ Object[] options =
37
+ {
38
+ "Cancel", "Proceed"
39
+ };
40
+ int n = JOptionPane.showOptionDialog(app,
41
+ panel,
42
+ "Delete Selected",
43
+ JOptionPane.YES_NO_CANCEL_OPTION,
44
+ JOptionPane.PLAIN_MESSAGE,
45
+ null,
46
+ options,
47
+ "Proceed");
48
+ panel.detachFromModel();
49
+ if (n == 1)
50
+ {
51
+ panel.applyAction();
52
+ app.clearFilters();
53
+ getModel().noteSchemaChange(this);
54
+ }
55
+ }
5156 }
timeflow/app/actions/EditSourceAction.java
....@@ -17,7 +17,7 @@
1717
1818 @Override
1919 public void actionPerformed(ActionEvent e) {
20
- TFModel model=getModel();
20
+ TimeflowModel model=getModel();
2121 String source = (String)JOptionPane.showInputDialog(
2222 app,
2323 null,
timeflow/app/actions/NewDataAction.java
....@@ -10,18 +10,20 @@
1010 import javax.swing.*;
1111 import java.util.*;
1212
13
-public class NewDataAction extends TimeflowAction {
13
+public class NewDataAction extends TimeflowAction
14
+{
15
+ public NewDataAction(TimeflowApp app)
16
+ {
17
+ super(app, "New", null, "Create a new, blank database");
18
+ accelerate('N');
1419
15
- public NewDataAction(TimeflowApp app)
16
- {
17
- super(app, "New", null, "Create a new, blank database");
18
- accelerate('N');
20
+ }
1921
20
- }
21
-
22
- public void actionPerformed(ActionEvent e)
23
- {
24
- if (app.checkSaveStatus())
25
- getModel().setDB(new BasicDB("Unspecified"), "[new data]", true, this);
26
- }
22
+ public void actionPerformed(ActionEvent e)
23
+ {
24
+ if (app.checkSaveStatus())
25
+ {
26
+ getModel().setDB(new BasicDB("Unspecified"), "[new data]", true, this);
27
+ }
28
+ }
2729 }
timeflow/app/actions/QuitAction.java
....@@ -12,7 +12,7 @@
1212
1313 public class QuitAction extends TimeflowAction {
1414
15
- public QuitAction(TimeflowApp app, TFModel model)
15
+ public QuitAction(TimeflowApp app, TimeflowModel model)
1616 {
1717 super(app, "Quit", null, "Quit the program");
1818 }
timeflow/app/actions/TimeflowAction.java
....@@ -27,7 +27,7 @@
2727 }
2828
2929
30
- protected TFModel getModel()
30
+ protected TimeflowModel getModel()
3131 {
3232 return app.model;
3333 }
timeflow/app/ui/ColorLegendPanel.java
....@@ -20,7 +20,7 @@
2020
2121 Field oldColor;
2222
23
- public ColorLegendPanel(TFModel model)
23
+ public ColorLegendPanel(TimeflowModel model)
2424 {
2525 super(model);
2626 setBackground(Color.white);
timeflow/app/ui/ComponentCluster.java
....@@ -8,7 +8,7 @@
88 int numComps=0;
99 int x1=80;
1010 int width=200;
11
- int compH=30;
11
+ int compH=20;
1212 DottedLine line=new DottedLine();
1313
1414 public ComponentCluster(String name)
....@@ -25,9 +25,9 @@
2525 {
2626 add(c);
2727 c.setBorder(null);
28
- c.setBounds(x1,10+numComps*compH, c.getPreferredSize().width, c.getPreferredSize().height);
28
+ c.setBounds(x1,numComps*compH, c.getPreferredSize().width, c.getPreferredSize().height);
2929 numComps++;
30
- line.setBounds(x1-10,10,1,numComps*compH-5);
30
+ line.setBounds(x1-10,10,0,numComps*compH);
3131 }
3232
3333 public Dimension getPreferredSize()
timeflow/app/ui/DateFieldPanel.java
....@@ -15,7 +15,7 @@
1515
1616 public class DateFieldPanel extends JPanel
1717 {
18
- TFModel model;
18
+ TimeflowModel model;
1919 int numRows;
2020 HashMap<String, Integer> numBad=new HashMap<String, Integer>();
2121 private static String[] mappable={VirtualField.START, VirtualField.END};
....@@ -23,7 +23,7 @@
2323 FieldMap[] panels=new FieldMap[mappable.length];
2424 JButton submit, cancel;
2525
26
- public DateFieldPanel(TFModel model, boolean hasButtons)
26
+ public DateFieldPanel(TimeflowModel model, boolean hasButtons)
2727 {
2828 this.model=model;
2929
....@@ -154,7 +154,7 @@
154154 return new Dimension(400,80+mappable.length*25);
155155 }
156156
157
- public static void popWindow(TFModel model)
157
+ public static void popWindow(TimeflowModel model)
158158 {
159159 final JFrame window=new JFrame("Date Fields");
160160 window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
timeflow/app/ui/EditRecordPanel.java
....@@ -20,12 +20,12 @@
2020 HashMap<Field, EditValuePanel> fieldUI = new HashMap<Field, EditValuePanel>();
2121 JButton submit, cancel;
2222 Dimension idealSize = new Dimension();
23
- TFModel model;
23
+ TimeflowModel model;
2424
25
- private static void edit(final TFModel model, final Act act, final boolean isAdd)
25
+ private static void edit(final TimeflowModel model, final Act act, final boolean isAdd)
2626 {
2727 final JFrame window = new JFrame(isAdd ? "Add Record" : "Edit Record");
28
- window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
28
+ //window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
2929 final EditRecordPanel editor = new EditRecordPanel(model, act);
3030 window.getContentPane().setLayout(new GridLayout(1, 1));
3131 window.getContentPane().add(editor);
....@@ -58,25 +58,25 @@
5858 window.setVisible(true);
5959 }
6060
61
- public static void edit(TFModel model, Act act)
61
+ public static void edit(TimeflowModel model, Act act)
6262 {
6363 edit(model, act, false);
6464 }
6565
66
- public static void add(TFModel model)
66
+ public static void add(TimeflowModel model)
6767 {
6868 Act act = model.getDB().createAct();
6969 edit(model, act, true);
7070 }
7171
72
- public static void add(TFModel model, RoughTime r)
72
+ public static void add(TimeflowModel model, RoughTime r)
7373 {
7474 Act act = model.getDB().createAct();
7575 act.set(act.getDB().getField(VirtualField.START), r);
7676 edit(model, act, true);
7777 }
7878
79
- public EditRecordPanel(TFModel model, Act act)
79
+ public EditRecordPanel(TimeflowModel model, Act act)
8080 {
8181 this.model = model;
8282 this.act = act;
timeflow/app/ui/EditValuePanel.java
....@@ -10,7 +10,6 @@
1010
1111 public class EditValuePanel extends JPanel
1212 {
13
-
1413 FieldFormat parser;
1514 boolean longField;
1615 JLabel feedback = new JLabel()
timeflow/app/ui/GlobalDisplayPanel.java
....@@ -21,7 +21,7 @@
2121 JPanel globalControls = new JPanel();
2222 CardLayout localCards = new CardLayout();
2323
24
- public GlobalDisplayPanel(TFModel model, FilterControlPanel filterControls)
24
+ public GlobalDisplayPanel(TimeflowModel model, FilterControlPanel filterControls)
2525 {
2626 super(model);
2727 setBackground(Color.white);
....@@ -56,12 +56,12 @@
5656 };
5757 label.setBackground(Color.lightGray);
5858 label.setForeground(Color.darkGray);
59
- globalLabel.add(label, BorderLayout.CENTER);
59
+ //globalLabel.add(label, BorderLayout.CENTER);
6060 p.add(globalLabel, BorderLayout.NORTH);
6161
6262 JPanel global = new JPanel();
6363 global.setLayout(new BorderLayout());
64
- global.add(new StatusPanel(model, filterControls), BorderLayout.NORTH);
64
+ //global.add(new StatusPanel(model, filterControls), BorderLayout.NORTH);
6565
6666 encodings.setLayout(new GridLayout(4, 1));
6767 encodings.setBackground(Color.white);
....@@ -74,12 +74,13 @@
7474
7575 public void showLocalControl(String name)
7676 {
77
- localCards.show(localControls, name);
77
+ //localCards.show(localControls, name);
7878 }
7979
8080 public void addLocalControl(String name, JComponent control)
8181 {
82
- localControls.add(control, name);
82
+ if (name.equals("Timeline"))
83
+ localControls.add(control, name);
8384 }
8485
8586 void makeEncodingPanel()
timeflow/app/ui/ImportDelimitedPanel.java
....@@ -24,7 +24,7 @@
2424 SchemaPanel schemaPanel;
2525 boolean exitOnClose=false; // for testing!
2626 JScrollPane scroller;
27
- TFModel model;
27
+ TimeflowModel model;
2828 JLabel numLinesLabel=new JLabel();
2929
3030 // for testing:
....@@ -33,7 +33,7 @@
3333 System.out.println("Starting test of ImportEditor");
3434 String file="data/probate.tsv";
3535 String[][] data=DelimitedFormat.readArrayGuessDelim(file, System.out);
36
- ImportDelimitedPanel editor=new ImportDelimitedPanel(new TFModel());
36
+ ImportDelimitedPanel editor=new ImportDelimitedPanel(new TimeflowModel());
3737 editor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
3838 editor.setFileName(file);
3939 editor.setData(data);
....@@ -42,7 +42,7 @@
4242 editor.exitOnClose=true;
4343 }
4444
45
- public ImportDelimitedPanel(final TFModel model)
45
+ public ImportDelimitedPanel(final TimeflowModel model)
4646 {
4747 super("Import File");
4848 this.model=model;
timeflow/app/ui/MassDeletePanel.java
....@@ -15,7 +15,7 @@
1515 TableView table;
1616 ActList keepers;
1717
18
- public MassDeletePanel(TFModel model, ActList keepers, String title)
18
+ public MassDeletePanel(TimeflowModel model, ActList keepers, String title)
1919 {
2020 super(model);
2121 this.keepers=keepers;
....@@ -61,7 +61,7 @@
6161
6262 public void detachFromModel()
6363 {
64
- TFModel model=getModel();
64
+ TimeflowModel model=getModel();
6565 model.removeListener(table);
6666 model.removeListener(this);
6767 }
timeflow/app/ui/ReorderFieldsPanel.java
....@@ -14,7 +14,7 @@
1414 {
1515 TableView table;
1616
17
- public ReorderFieldsPanel(TFModel model)
17
+ public ReorderFieldsPanel(TimeflowModel model)
1818 {
1919 super(model);
2020 setLayout(new BorderLayout());
....@@ -49,7 +49,7 @@
4949
5050 public void detachFromModel()
5151 {
52
- TFModel model=getModel();
52
+ TimeflowModel model=getModel();
5353 model.removeListener(table);
5454 model.removeListener(this);
5555 }
timeflow/app/ui/SizeLegendPanel.java
....@@ -13,7 +13,7 @@
1313 Field sizeField;
1414 double min, max;
1515
16
- public SizeLegendPanel(TFModel model)
16
+ public SizeLegendPanel(TimeflowModel model)
1717 {
1818 super(model);
1919 setBackground(Color.white);
....@@ -44,7 +44,7 @@
4444 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
4545 int w=getSize().width;
4646 int h=getSize().height;
47
- TFModel model=getModel();
47
+ TimeflowModel model=getModel();
4848 Display display=model.getDisplay();
4949 g.setColor(getBackground());
5050 g.setFont(display.plain());
timeflow/app/ui/StatusPanel.java
....@@ -30,7 +30,7 @@
3030
3131 static final DecimalFormat niceFormat=new DecimalFormat("###,###");
3232
33
- public StatusPanel(TFModel model, final FilterControlPanel filterControls) {
33
+ public StatusPanel(TimeflowModel model, final FilterControlPanel filterControls) {
3434 super(model);
3535 setLayout(new BorderLayout());
3636 setBackground(new Color(245, 245, 245));
timeflow/app/ui/filter/FilterCategoryPanel.java
....@@ -11,154 +11,180 @@
1111 import java.awt.*;
1212 import java.awt.event.*;
1313
14
-public class FilterCategoryPanel extends FilterDefinitionPanel
14
+public class FilterCategoryPanel extends FilterDefinitionPanel
1515 {
16
- public JList dataList=new JList();
17
- Field field;
18
-
19
- public FilterCategoryPanel(final Field field, final ModelPanel parent)
20
- {
21
- this(field.getName(), field, parent);
22
- }
23
-
24
- public FilterCategoryPanel(String title, final Field field, final ModelPanel parent)
25
- {
26
- this.field=field;
27
- setLayout(new BorderLayout());
28
- setBackground(Color.white);
29
- setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
3016
31
- add(new FilterTitle(title, field, parent, true), BorderLayout.NORTH);
32
-
33
-
34
- JScrollPane scroller=new JScrollPane(dataList);
35
- scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
36
- scroller.setBorder(null);
37
- add(scroller, BorderLayout.CENTER);
38
- dataList.setForeground(Color.darkGray);
39
- dataList.setSelectionForeground(Color.black);
40
- dataList.setSelectionBackground(new Color(220,235,255));
41
- dataList.setFont(parent.getModel().getDisplay().small());
42
- scroller.getVerticalScrollBar().setBackground(Color.white);
43
-
44
-
45
- // ok, the following is ugly code to insert a new mouselistener
46
- // that lets the user deselect items when they are clicked.
47
- // i tried a bunch of stuff but this is all that would work--
48
- // and searching the web yielded only solutions similar to this.
49
- // also, there's a weird dance with consuming/not consuming events
50
- // that is designed to allow a certain kind of multi-selection behavior
51
- // with the mouse, while letting you scroll through items one at a time
52
- // with the keyboard. this was the product of a long series of
53
- // conversations with target users.
54
- MouseListener[] old = dataList.getMouseListeners();
55
- for (MouseListener m: old)
56
- dataList.removeMouseListener(m);
57
-
58
- dataList.addMouseListener(new MouseAdapter()
59
- {
60
- public void mousePressed(MouseEvent e)
61
- {
62
- if (e.isControlDown() || e.isMetaDown() || e.isShiftDown())
63
- return;
64
- final int index = dataList.locationToIndex(e.getPoint());
65
- if (dataList.isSelectedIndex(index))
66
- {
67
- SwingUtilities.invokeLater(new Runnable()
68
- {
69
- public void run()
70
- {
71
- dataList.removeSelectionInterval(index, index);
72
-
73
- }
74
- });
75
- e.consume();
76
- }
77
- else
78
- {
79
- SwingUtilities.invokeLater(new Runnable()
80
- {
81
- public void run()
82
- {
83
- dataList.addSelectionInterval(index, index);
84
-
85
- }
86
- });
87
- e.consume();
88
- }
89
- }
90
- });
17
+ public JList dataList = new JList();
18
+ Field field;
9119
92
- for (MouseListener m: old)
93
- dataList.addMouseListener(m);
94
-
95
- dataList.setCellRenderer(new DefaultListCellRenderer() {
96
- @Override
97
- public Component getListCellRendererComponent(JList list,
98
- Object value, int index, boolean isSelected,
99
- boolean cellHasFocus) {
100
- Component c=super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
101
- if (field==parent.getModel().getColorField())
102
- {
103
- String text=value.toString();
104
- int n=text.lastIndexOf('-');
105
- if (n>1)
106
- text=text.substring(0,n-1);
107
- c.setForeground(parent.getModel().getDisplay().makeColor(text));
108
- }
109
- return c;
110
- }});
111
-
112
- }
20
+ public FilterCategoryPanel(final Field field, final ModelPanel parent)
21
+ {
22
+ this(field.getName(), field, parent);
23
+ }
11324
114
- public void setData(Bag<String> data)
115
- {
116
- dataList.removeAll();
117
- java.util.List<String> items=data.list();
118
- String[] s=(String[])items.toArray(new String[0]);
119
- for (int i=0; i<s.length; i++)
120
- {
121
- int num=data.num(s[i]);
122
- if (s[i]==null || s[i].length()==0)
123
- s[i]="(missing)";
124
- s[i]+=" - "+num;
125
- }
126
- dataList.setListData(s);
127
- }
128
-
129
- public Dimension getPreferredSize()
130
- {
131
- return new Dimension(200,200);
132
- }
25
+ public FilterCategoryPanel(String title, final Field field, final ModelPanel parent)
26
+ {
27
+ this.field = field;
28
+ setLayout(new BorderLayout());
29
+ setBackground(Color.white);
30
+ setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
13331
134
- @Override
135
- public ActFilter defineFilter() {
136
- Object[] o=dataList.getSelectedValues();
137
- if (o==null || o.length==0)
138
- return null;
139
-
140
- int n=o.length;
141
- String[] s=new String[n];
142
- for (int i=0; i<n; i++)
143
- {
144
- String w=(String)o[i];
145
- int m=w.lastIndexOf('-');
146
- s[i]=w.substring(0, m-1);
147
- if ("(missing)".equals(s[i]))
148
- s[i]="";
149
- }
150
-
151
- if (s.length==1)
152
- return new FieldValueFilter(field, s[0]);
153
- FieldValueSetFilter f=new FieldValueSetFilter(field);
154
- for (int i=0; i<s.length; i++)
155
- f.addValue(s[i]);
156
- return f;
157
- }
32
+ add(new FilterTitle(title, field, parent, true), BorderLayout.NORTH);
15833
159
- @Override
160
- public void clearFilter() {
161
- dataList.clearSelection();
162
- }
163
-
34
+
35
+ JScrollPane scroller = new JScrollPane(dataList);
36
+ scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
37
+ scroller.setBorder(null);
38
+ add(scroller, BorderLayout.CENTER);
39
+ dataList.setForeground(Color.darkGray);
40
+ dataList.setSelectionForeground(Color.black);
41
+ dataList.setSelectionBackground(new Color(220, 235, 255));
42
+ dataList.setFont(parent.getModel().getDisplay().small());
43
+ scroller.getVerticalScrollBar().setBackground(Color.white);
44
+
45
+
46
+ // ok, the following is ugly code to insert a new mouselistener
47
+ // that lets the user deselect items when they are clicked.
48
+ // i tried a bunch of stuff but this is all that would work--
49
+ // and searching the web yielded only solutions similar to this.
50
+ // also, there's a weird dance with consuming/not consuming events
51
+ // that is designed to allow a certain kind of multi-selection behavior
52
+ // with the mouse, while letting you scroll through items one at a time
53
+ // with the keyboard. this was the product of a long series of
54
+ // conversations with target users.
55
+ MouseListener[] old = dataList.getMouseListeners();
56
+ for (MouseListener m : old)
57
+ {
58
+ dataList.removeMouseListener(m);
59
+ }
60
+
61
+ dataList.addMouseListener(new MouseAdapter()
62
+ {
63
+
64
+ public void mousePressed(MouseEvent e)
65
+ {
66
+ if (e.isControlDown() || e.isMetaDown() || e.isShiftDown())
67
+ {
68
+ return;
69
+ }
70
+ final int index = dataList.locationToIndex(e.getPoint());
71
+ if (dataList.isSelectedIndex(index))
72
+ {
73
+ SwingUtilities.invokeLater(new Runnable()
74
+ {
75
+
76
+ public void run()
77
+ {
78
+ dataList.removeSelectionInterval(index, index);
79
+
80
+ }
81
+ });
82
+ e.consume();
83
+ } else
84
+ {
85
+ SwingUtilities.invokeLater(new Runnable()
86
+ {
87
+
88
+ public void run()
89
+ {
90
+ dataList.addSelectionInterval(index, index);
91
+
92
+ }
93
+ });
94
+ e.consume();
95
+ }
96
+ }
97
+ });
98
+
99
+ for (MouseListener m : old)
100
+ {
101
+ dataList.addMouseListener(m);
102
+ }
103
+
104
+ dataList.setCellRenderer(new DefaultListCellRenderer()
105
+ {
106
+
107
+ @Override
108
+ public Component getListCellRendererComponent(JList list,
109
+ Object value, int index, boolean isSelected,
110
+ boolean cellHasFocus)
111
+ {
112
+ Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
113
+ if (field == parent.getModel().getColorField())
114
+ {
115
+ String text = value.toString();
116
+ int n = text.lastIndexOf('-');
117
+ if (n > 1)
118
+ {
119
+ text = text.substring(0, n - 1);
120
+ }
121
+ c.setForeground(parent.getModel().getDisplay().makeColor(text));
122
+ }
123
+ return c;
124
+ }
125
+ });
126
+
127
+ }
128
+
129
+ public void setData(Bag<String> data)
130
+ {
131
+ dataList.removeAll();
132
+ java.util.List<String> items = data.list();
133
+ String[] s = (String[]) items.toArray(new String[0]);
134
+ for (int i = 0; i < s.length; i++)
135
+ {
136
+ int num = data.num(s[i]);
137
+ if (s[i] == null || s[i].length() == 0)
138
+ {
139
+ s[i] = "(missing)";
140
+ }
141
+ s[i] += " - " + num;
142
+ }
143
+ dataList.setListData(s);
144
+ }
145
+
146
+ public Dimension getPreferredSize()
147
+ {
148
+ return new Dimension(200, 200);
149
+ }
150
+
151
+ @Override
152
+ public ActFilter defineFilter()
153
+ {
154
+ Object[] o = dataList.getSelectedValues();
155
+ if (o == null || o.length == 0)
156
+ {
157
+ return null;
158
+ }
159
+
160
+ int n = o.length;
161
+ String[] s = new String[n];
162
+ for (int i = 0; i < n; i++)
163
+ {
164
+ String w = (String) o[i];
165
+ int m = w.lastIndexOf('-');
166
+ s[i] = w.substring(0, m - 1);
167
+ if ("(missing)".equals(s[i]))
168
+ {
169
+ s[i] = "";
170
+ }
171
+ }
172
+
173
+ if (s.length == 1)
174
+ {
175
+ return new FieldValueFilter(field, s[0]);
176
+ }
177
+ FieldValueSetFilter f = new FieldValueSetFilter(field);
178
+ for (int i = 0; i < s.length; i++)
179
+ {
180
+ f.addValue(s[i]);
181
+ }
182
+ return f;
183
+ }
184
+
185
+ @Override
186
+ public void clearFilter()
187
+ {
188
+ dataList.clearSelection();
189
+ }
164190 }
timeflow/app/ui/filter/FilterControlPanel.java
....@@ -23,7 +23,7 @@
2323 JMenu menuToSyncWith;
2424
2525
26
- public FilterControlPanel(TFModel model, JMenu menuToSyncWith)
26
+ public FilterControlPanel(TimeflowModel model, JMenu menuToSyncWith)
2727 {
2828 super(model);
2929 this.menuToSyncWith=menuToSyncWith;
timeflow/app/ui/filter/FilterDatePanel.java
....@@ -16,158 +16,168 @@
1616 // NumberFilterPanel.
1717 // but, i'm not sure how to do it in a way that doesn't make the code
1818 // seem too complicated.
19
-
20
-public class FilterDatePanel extends FilterDefinitionPanel
19
+public class FilterDatePanel extends FilterDefinitionPanel
2120 {
22
- BabyHistogram histogram;
23
- Field field;
24
- JTextField startEntry;
25
- JTextField endEntry;
26
- JCheckBox nullBox;
27
- Runnable action;
28
- SimpleDateFormat df=new SimpleDateFormat("MMM dd yyyy");
29
-
30
- public FilterDatePanel(final Field field, final Runnable action, final FilterControlPanel parent)
31
- {
32
- this.field=field;
33
- this.action=action;
34
- setLayout(new BorderLayout());
35
- setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
36
- setBackground(Color.white);
37
- add(new FilterTitle(field, parent, false), BorderLayout.NORTH);
38
-
39
- Runnable fullAction=new Runnable()
40
- {
41
- public void run()
42
- {
43
- startEntry.setText(format(histogram.getLow()));
44
- endEntry.setText(format(histogram.getHigh()));
45
- action.run();
46
- }
47
- };
48
-
49
- histogram=new BabyHistogram(fullAction);
50
-
51
- add(histogram, BorderLayout.CENTER);
52
-
53
- JPanel bottomStuff=new JPanel();
54
- bottomStuff.setLayout(new GridLayout(2,1));
55
- add(bottomStuff, BorderLayout.SOUTH);
56
-
57
- JPanel lowHighPanel=new JPanel();
58
- bottomStuff.add(lowHighPanel);
59
- lowHighPanel.setBackground(Color.white);
60
- lowHighPanel.setLayout(new BorderLayout());
61
- Font small=parent.getModel().getDisplay().small();
62
-
63
- startEntry=new JTextField(7);
64
- startEntry.addActionListener(new ActionListener() {
65
- @Override
66
- public void actionPerformed(ActionEvent e) {
67
- setLowFromText();
68
- action.run();
69
- }});
70
- lowHighPanel.add(startEntry, BorderLayout.WEST);
71
- startEntry.setFont(small);
72
-
73
- JLabel rangeLabel=new JLabel("to", JLabel.CENTER);
74
- rangeLabel.setForeground(Color.gray);
75
- rangeLabel.setFont(small);
76
- lowHighPanel.add(rangeLabel, BorderLayout.CENTER);
77
- endEntry=new JTextField(7);
78
- lowHighPanel.add(endEntry, BorderLayout.EAST);
79
- endEntry.addActionListener(new ActionListener() {
80
- @Override
81
- public void actionPerformed(ActionEvent e) {
82
- setHighFromText();
83
- action.run();
84
- }});
85
- endEntry.setFont(small);
86
-
87
- nullBox=new JCheckBox("Include Missing Values");
88
- nullBox.addActionListener(new ActionListener() {
89
- @Override
90
- public void actionPerformed(ActionEvent e) {
91
- action.run();
92
- }});
93
- bottomStuff.add(nullBox);
94
- bottomStuff.setBackground(Color.white);
95
- nullBox.setBackground(Color.white);
96
- nullBox.setForeground(Color.gray);
97
- nullBox.setFont(small);
98
-
99
- }
100
-
101
- String format(double x)
102
- {
103
- Date date=new Date((long)x);
104
- return df.format(date);
105
- }
106
-
107
- void setLowFromText()
108
- {
109
- try
110
- {
111
- long low=df.parse(startEntry.getText()).getTime();
112
- long high=(long)histogram.getHigh();
113
- if (low>high)
114
- {
115
- high=low;
116
- endEntry.setText(startEntry.getText());
117
- }
118
- histogram.setTrueRange(low,high);
119
-
120
- }
121
- catch (Exception e)
122
- {
123
-
124
- }
125
- }
126
-
127
-
128
- void setHighFromText()
129
- {
130
- try
131
- {
132
- long high=df.parse(endEntry.getText()).getTime();
133
- double low=(long)histogram.getLow();
134
- if (low>high)
135
- {
136
- low=high;
137
- startEntry.setText(endEntry.getText());
138
- }
139
- histogram.setTrueRange(low,high);
140
-
141
- }
142
- catch (Exception e)
143
- {
144
-
145
- }
146
- }
14721
148
- public void setData(double[] data)
149
- {
150
- histogram.setData(data);
151
- startEntry.setText(format(histogram.getLow()));
152
- endEntry.setText(format(histogram.getHigh()));
153
- repaint();
154
- }
155
-
156
- public Dimension getPreferredSize()
157
- {
158
- return new Dimension(200,160);
159
- }
22
+ BabyHistogram histogram;
23
+ Field field;
24
+ JTextField startEntry;
25
+ JTextField endEntry;
26
+ JCheckBox nullBox;
27
+ Runnable action;
28
+ SimpleDateFormat df = new SimpleDateFormat("MMM dd yyyy");
16029
161
- @Override
162
- public ActFilter defineFilter() {
163
- long low=(long)histogram.getLow();
164
- long high=(long)histogram.getHigh();
165
- boolean acceptNull=nullBox.isSelected();
166
- return new TimeIntervalFilter(low, high, acceptNull, field);
167
- }
30
+ public FilterDatePanel(final Field field, final Runnable action, final FilterControlPanel parent)
31
+ {
32
+ this.field = field;
33
+ this.action = action;
34
+ setLayout(new BorderLayout());
35
+ setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
36
+ setBackground(Color.white);
37
+ add(new FilterTitle(field, parent, false), BorderLayout.NORTH);
16838
169
- @Override
170
- public void clearFilter() {
171
- histogram.setRelRange(0, 1);
172
- }
39
+ Runnable fullAction = new Runnable()
40
+ {
41
+
42
+ public void run()
43
+ {
44
+ startEntry.setText(format(histogram.getLow()));
45
+ endEntry.setText(format(histogram.getHigh()));
46
+ action.run();
47
+ }
48
+ };
49
+
50
+ histogram = new BabyHistogram(fullAction);
51
+
52
+ add(histogram, BorderLayout.CENTER);
53
+
54
+ JPanel bottomStuff = new JPanel();
55
+ bottomStuff.setLayout(new GridLayout(2, 1));
56
+ add(bottomStuff, BorderLayout.SOUTH);
57
+
58
+ JPanel lowHighPanel = new JPanel();
59
+ bottomStuff.add(lowHighPanel);
60
+ lowHighPanel.setBackground(Color.white);
61
+ lowHighPanel.setLayout(new BorderLayout());
62
+ Font small = parent.getModel().getDisplay().small();
63
+
64
+ startEntry = new JTextField(7);
65
+ startEntry.addActionListener(new ActionListener()
66
+ {
67
+
68
+ @Override
69
+ public void actionPerformed(ActionEvent e)
70
+ {
71
+ setLowFromText();
72
+ action.run();
73
+ }
74
+ });
75
+ lowHighPanel.add(startEntry, BorderLayout.WEST);
76
+ startEntry.setFont(small);
77
+
78
+ JLabel rangeLabel = new JLabel("to", JLabel.CENTER);
79
+ rangeLabel.setForeground(Color.gray);
80
+ rangeLabel.setFont(small);
81
+ lowHighPanel.add(rangeLabel, BorderLayout.CENTER);
82
+ endEntry = new JTextField(7);
83
+ lowHighPanel.add(endEntry, BorderLayout.EAST);
84
+ endEntry.addActionListener(new ActionListener()
85
+ {
86
+
87
+ @Override
88
+ public void actionPerformed(ActionEvent e)
89
+ {
90
+ setHighFromText();
91
+ action.run();
92
+ }
93
+ });
94
+ endEntry.setFont(small);
95
+
96
+ nullBox = new JCheckBox("Include Missing Values");
97
+ nullBox.addActionListener(new ActionListener()
98
+ {
99
+
100
+ @Override
101
+ public void actionPerformed(ActionEvent e)
102
+ {
103
+ action.run();
104
+ }
105
+ });
106
+ bottomStuff.add(nullBox);
107
+ bottomStuff.setBackground(Color.white);
108
+ nullBox.setBackground(Color.white);
109
+ nullBox.setForeground(Color.gray);
110
+ nullBox.setFont(small);
111
+
112
+ }
113
+
114
+ String format(double x)
115
+ {
116
+ Date date = new Date((long) x);
117
+ return df.format(date);
118
+ }
119
+
120
+ void setLowFromText()
121
+ {
122
+ try
123
+ {
124
+ long low = df.parse(startEntry.getText()).getTime();
125
+ long high = (long) histogram.getHigh();
126
+ if (low > high)
127
+ {
128
+ high = low;
129
+ endEntry.setText(startEntry.getText());
130
+ }
131
+ histogram.setTrueRange(low, high);
132
+
133
+ } catch (Exception e)
134
+ {
135
+ }
136
+ }
137
+
138
+ void setHighFromText()
139
+ {
140
+ try
141
+ {
142
+ long high = df.parse(endEntry.getText()).getTime();
143
+ double low = (long) histogram.getLow();
144
+ if (low > high)
145
+ {
146
+ low = high;
147
+ startEntry.setText(endEntry.getText());
148
+ }
149
+ histogram.setTrueRange(low, high);
150
+
151
+ } catch (Exception e)
152
+ {
153
+ }
154
+ }
155
+
156
+ public void setData(double[] data)
157
+ {
158
+ histogram.setData(data);
159
+ startEntry.setText(format(histogram.getLow()));
160
+ endEntry.setText(format(histogram.getHigh()));
161
+ repaint();
162
+ }
163
+
164
+ public Dimension getPreferredSize()
165
+ {
166
+ return new Dimension(200, 160);
167
+ }
168
+
169
+ @Override
170
+ public ActFilter defineFilter()
171
+ {
172
+ long low = (long) histogram.getLow();
173
+ long high = (long) histogram.getHigh();
174
+ boolean acceptNull = nullBox.isSelected();
175
+ return new TimeIntervalFilter(low, high, acceptNull, field);
176
+ }
177
+
178
+ @Override
179
+ public void clearFilter()
180
+ {
181
+ histogram.setRelRange(0, 1);
182
+ }
173183 }
timeflow/app/ui/filter/SearchPanel.java
....@@ -14,7 +14,7 @@
1414 JTextField entry;
1515 JCheckBox invert;
1616
17
- public SearchPanel(TFModel model, final FilterControlPanel f) {
17
+ public SearchPanel(TimeflowModel model, final FilterControlPanel f) {
1818 super(model);
1919 setBackground(Color.white);
2020 setBorder(BorderFactory.createEmptyBorder(15, 5,0,0));
timeflow/data/db/ActDB.java
....@@ -4,13 +4,15 @@
44
55 import timeflow.data.db.filter.ActFilter;
66
7
-public interface ActDB extends Iterable<Act> {
8
-
7
+public interface ActDB extends Iterable<Act>
8
+{
9
+ // Source
910 public String getSource();
1011 public String getDescription();
1112 public void setSource(String source);
1213 public void setDescription(String description);
13
-
14
+
15
+ // Fields
1416 public List<String> getFieldKeys();
1517 public List<Field> getFields();
1618 public List<Field> getFields(Class type);
....@@ -21,6 +23,7 @@
2123 public void setNewFieldOrder(List<Field> newOrder);
2224 public void renameField(Field field, String name);
2325
26
+ // Acts
2427 public void delete(Act act);
2528 public Act createAct();
2629 public ActList select(ActFilter filter);
timeflow/data/db/Field.java
....@@ -1,50 +1,53 @@
11 package timeflow.data.db;
22
3
+public class Field
4
+{
35
4
-public class Field {
5
- private String name;
6
- private Class type;
7
- int index;
8
- private int recommendedSize=-1;
9
-
10
- public Field(String name, Class type)
11
- {
12
- this.name=name;
13
- this.type=type;
14
- }
15
-
16
- public Field(String name, Class type, int recommendedSize)
17
- {
18
- this.name=name;
19
- this.type=type;
20
- this.recommendedSize=recommendedSize;
21
- }
22
-
23
- public int getRecommendedSize() {
24
- return recommendedSize;
25
- }
6
+ private String name;
7
+ private Class type;
8
+ int index;
9
+ private int recommendedSize = -1;
2610
27
- public void setRecommendedSize(int recommendedSize) {
28
- this.recommendedSize = recommendedSize;
29
- }
30
-
31
- void setName(String name)
32
- {
33
- this.name=name;
34
- }
11
+ public Field(String name, Class type)
12
+ {
13
+ this.name = name;
14
+ this.type = type;
15
+ }
3516
36
- public String getName()
37
- {
38
- return name;
39
- }
40
-
41
- public Class getType()
42
- {
43
- return type;
44
- }
17
+ public Field(String name, Class type, int recommendedSize)
18
+ {
19
+ this.name = name;
20
+ this.type = type;
21
+ this.recommendedSize = recommendedSize;
22
+ }
4523
46
- public String toString()
47
- {
48
- return "[Field: name='"+name+"', type="+type+", index="+index+"]";
49
- }
24
+ public int getRecommendedSize()
25
+ {
26
+ return recommendedSize;
27
+ }
28
+
29
+ public void setRecommendedSize(int recommendedSize)
30
+ {
31
+ this.recommendedSize = recommendedSize;
32
+ }
33
+
34
+ void setName(String name)
35
+ {
36
+ this.name = name;
37
+ }
38
+
39
+ public String getName()
40
+ {
41
+ return name;
42
+ }
43
+
44
+ public Class getType()
45
+ {
46
+ return type;
47
+ }
48
+
49
+ public String toString()
50
+ {
51
+ return "[Field: name='" + name + "', type=" + type + ", index=" + index + "]";
52
+ }
5053 }
timeflow/data/time/RoughTime.java
....@@ -3,127 +3,141 @@
33 import java.util.Calendar;
44 import java.util.Date;
55
6
-public class RoughTime implements Comparable {
6
+public class RoughTime implements Comparable
7
+{
78
8
- public static final long UNKNOWN=Long.MIN_VALUE;
9
- private TimeUnit units;
10
- private long time;
11
-
12
- public RoughTime(TimeUnit units)
13
- {
14
- time=UNKNOWN;
15
- this.units=units;
16
- }
17
-
18
- public RoughTime(long time, TimeUnit units)
19
- {
20
- this.time=time;
21
- this.units=units;
22
- }
23
-
24
- public boolean isDefined()
25
- {
26
- return time!=UNKNOWN;
27
- }
28
-
29
- public long getTime()
30
- {
31
- return time;
32
- }
33
-
34
- public void setTime(long time)
35
- {
36
- this.time=time;
37
- }
38
-
39
- public Date toDate()
40
- {
41
- return new Date(time);
42
- }
43
-
44
- public boolean after(RoughTime t)
45
- {
46
- return t.time<time;
47
- }
48
-
49
- public boolean before(RoughTime t)
50
- {
51
- return t.time>time;
52
- }
53
-
54
- public RoughTime plus(int numUnits)
55
- {
56
- return plus(units, numUnits);
57
- }
58
-
59
- public RoughTime plus(TimeUnit unit, int times)
60
- {
61
- RoughTime r=copy();
62
- unit.addTo(r,times);
63
- return r;
64
- }
65
-
66
- public String toString()
67
- {
68
- if (isKnown())
69
- return new Date(time).toString();
70
- return "unknown";
71
- }
72
-
73
- public boolean isKnown()
74
- {
75
- return time!=UNKNOWN;
76
- }
77
-
78
- public boolean equals(Object o)
79
- {
80
- if (!(o instanceof RoughTime))
81
- return false;
82
- RoughTime t=(RoughTime)o;
83
- return t.units==units && t.time==time;
84
- }
85
-
86
- public RoughTime copy()
87
- {
88
- RoughTime t=new RoughTime(time, units);
89
- return t;
90
- }
91
-
92
- public void setUnits(TimeUnit units)
93
- {
94
- this.units=units;
95
- }
9
+ public static final long UNKNOWN = Long.MIN_VALUE;
10
+ private TimeUnit units;
11
+ private long time;
9612
97
- public TimeUnit getUnits() {
98
- return units;
99
- }
100
-
101
- public String format()
102
- {
103
- //return units.formatFull(time);
104
- return TimeUnit.SECOND.formatFull(time);
105
- }
106
-
107
- public static int compare(RoughTime t1, RoughTime t2)
108
- {
109
- if (t1==t2)
110
- return 0;
111
- if (t1==null)
112
- return -1;
113
- if (t2==null)
114
- return 1;
115
- long dt= t1.time-t2.time;
116
- if (dt==0)
117
- return 0;
118
- if (dt>0)
119
- return 1;
120
- return -1;
121
- }
13
+// public RoughTime(TimeUnit units)
14
+// {
15
+// time=UNKNOWN;
16
+// this.units=units;
17
+// }
18
+ public RoughTime(long time, TimeUnit units)
19
+ {
20
+ this.time = time;
21
+ this.units = units;
22
+ }
12223
123
- @Override
124
- public int compareTo(Object o) {
125
- return compare(this, (RoughTime)o);
126
- }
24
+ public boolean isDefined()
25
+ {
26
+ return time != UNKNOWN;
27
+ }
12728
29
+ public long getTime()
30
+ {
31
+ return time;
32
+ }
12833
34
+ public void setTime(long time)
35
+ {
36
+ this.time = time;
37
+ }
38
+
39
+ public Date toDate()
40
+ {
41
+ return new Date(time);
42
+ }
43
+
44
+ public boolean after(RoughTime t)
45
+ {
46
+ return t.time < time;
47
+ }
48
+
49
+ public boolean before(RoughTime t)
50
+ {
51
+ return t.time > time;
52
+ }
53
+
54
+ public RoughTime plus(int numUnits)
55
+ {
56
+ return plus(units, numUnits);
57
+ }
58
+
59
+ public RoughTime plus(TimeUnit unit, int times)
60
+ {
61
+ RoughTime r = copy();
62
+ unit.addTo(r, times);
63
+ return r;
64
+ }
65
+
66
+ public String toString()
67
+ {
68
+ if (isKnown())
69
+ {
70
+ return new Date(time).toString();
71
+ }
72
+ return "unknown";
73
+ }
74
+
75
+ public boolean isKnown()
76
+ {
77
+ return time != UNKNOWN;
78
+ }
79
+
80
+ public boolean equals(Object o)
81
+ {
82
+ if (!(o instanceof RoughTime))
83
+ {
84
+ return false;
85
+ }
86
+ RoughTime t = (RoughTime) o;
87
+ return t.units == units && t.time == time;
88
+ }
89
+
90
+ public RoughTime copy()
91
+ {
92
+ RoughTime t = new RoughTime(time, units);
93
+ return t;
94
+ }
95
+
96
+ public void setUnits(TimeUnit units)
97
+ {
98
+ this.units = units;
99
+ }
100
+
101
+ public TimeUnit getUnits()
102
+ {
103
+ return units;
104
+ }
105
+
106
+ public String format()
107
+ {
108
+ //return units.formatFull(time);
109
+ return TimeUnit.SECOND.formatFull(time);
110
+ }
111
+
112
+ public static int compare(RoughTime t1, RoughTime t2)
113
+ {
114
+ if (t1 == t2)
115
+ {
116
+ return 0;
117
+ }
118
+ if (t1 == null)
119
+ {
120
+ return -1;
121
+ }
122
+ if (t2 == null)
123
+ {
124
+ return 1;
125
+ }
126
+ long dt = t1.time - t2.time;
127
+ if (dt == 0)
128
+ {
129
+ return 0;
130
+ }
131
+ if (dt > 0)
132
+ {
133
+ return 1;
134
+ }
135
+ return -1;
136
+ }
137
+
138
+ @Override
139
+ public int compareTo(Object o)
140
+ {
141
+ return compare(this, (RoughTime) o);
142
+ }
129143 }
timeflow/data/time/TimeUnit.java
....@@ -5,15 +5,16 @@
55
66 public class TimeUnit
77 {
8
-
98 public static final TimeUnit YEAR = new TimeUnit("Years", Calendar.YEAR, 365 * 24 * 60 * 60 * 1000L, "yyyy", "yyyy");
109 public static final TimeUnit MONTH = new TimeUnit("Months", Calendar.MONTH, 30 * 24 * 60 * 60 * 1000L, "MMM", "MMM yyyy");
1110 public static final TimeUnit WEEK = new TimeUnit("Weeks", Calendar.WEEK_OF_YEAR, 7 * 24 * 60 * 60 * 1000L, "d", "MMM d yyyy");
1211 public static final TimeUnit DAY = new TimeUnit("Days", Calendar.DAY_OF_MONTH, 24 * 60 * 60 * 1000L, "d", "MMM d yyyy");
1312 public static final TimeUnit DAY_OF_WEEK = new TimeUnit("Days", Calendar.DAY_OF_WEEK, 24 * 60 * 60 * 1000L, "d", "MMM d yyyy");
14
- public static final TimeUnit HOUR = new TimeUnit("Hours", Calendar.HOUR_OF_DAY, 60 * 60 * 1000L, "kk:mm", "MMM d yyyy kk:mm");
15
- public static final TimeUnit MINUTE = new TimeUnit("Minutes", Calendar.MINUTE, 60 * 1000L, ":mm", "MMM d yyyy kk:mm");
16
- public static final TimeUnit SECOND = new TimeUnit("Seconds", Calendar.SECOND, 1000L, ":ss", "MMM d yyyy kk:mm:ss");
13
+ public static final TimeUnit HOUR = new TimeUnit("Hours", Calendar.HOUR_OF_DAY, 60 * 60 * 1000L, "HH:mm", "MMM d yyyy HH:mm");
14
+ public static final TimeUnit MINUTE = new TimeUnit("Minutes", Calendar.MINUTE, 60 * 1000L, ":mm", "MMM d yyyy HH:mm");
15
+ public static final TimeUnit SECOND = new TimeUnit("Seconds", Calendar.SECOND, 1000L, ":ss", "MMM d yyyy HH:mm:ss");
16
+ public static final TimeUnit REALTIME = new TimeUnit("Realtime", Calendar.MILLISECOND, 8L, ":SSS", "MMM d yyyy HH:mm:ss:SSS");
17
+
1718 public static final TimeUnit DECADE = multipleYears(10);
1819 public static final TimeUnit CENTURY = multipleYears(100);
1920 private static final double DAY_SIZE = 24 * 60 * 60 * 1000L;
timeflow/format/field/FieldFormat.java
....@@ -4,61 +4,65 @@
44
55 import timeflow.data.time.*;
66
7
-public abstract class FieldFormat {
8
- protected String lastInput;
9
- protected Object lastValue;
10
- protected boolean understood=true;
11
-
12
- double value;
13
-
14
- void add(double x)
15
- {
16
- value+=x;
17
- }
18
-
19
- void note(String s)
20
- {
21
- add(scoreFormatMatch(s));
22
- }
7
+public abstract class FieldFormat
8
+{
9
+ protected String lastInput;
10
+ protected Object lastValue;
11
+ protected boolean understood = true;
12
+ double value;
2313
24
-
25
- protected abstract Object _parse(String s) throws Exception;
26
- public abstract String format(Object o);
27
- public abstract Class getType();
28
- public abstract double scoreFormatMatch(String s);
29
- public abstract String getHumanName();
14
+ void add(double x)
15
+ {
16
+ value += x;
17
+ }
3018
19
+ void note(String s)
20
+ {
21
+ add(scoreFormatMatch(s));
22
+ }
3123
32
- public void setValue(Object o)
33
- {
34
- lastValue=o;
35
- lastInput=o==null ? "" : format(o);
36
- }
37
-
38
- public Object parse(String s) throws Exception
39
- {
40
- lastInput=s;
41
- lastValue=null;
42
- understood=false;
43
- lastValue=_parse(s);
44
- understood=true;
45
- return lastValue;
46
- }
47
-
48
- public Object getLastValue()
49
- {
50
- return lastValue;
51
- }
52
-
53
- public String feedback()
54
- {
55
- if (!understood)
56
- return "Couldn't understand";
57
- return lastValue==null ? "(missing)" : "Read: "+format(lastValue);
58
- }
59
-
60
- public boolean isUnderstood()
61
- {
62
- return understood;
63
- }
24
+ protected abstract Object _parse(String s) throws Exception;
25
+
26
+ public abstract String format(Object o);
27
+
28
+ public abstract Class getType();
29
+
30
+ public abstract double scoreFormatMatch(String s);
31
+
32
+ public abstract String getHumanName();
33
+
34
+ public void setValue(Object o)
35
+ {
36
+ lastValue = o;
37
+ lastInput = o == null ? "" : format(o);
38
+ }
39
+
40
+ public Object parse(String s) throws Exception
41
+ {
42
+ lastInput = s;
43
+ lastValue = null;
44
+ understood = false;
45
+ lastValue = _parse(s);
46
+ understood = true;
47
+ return lastValue;
48
+ }
49
+
50
+ public Object getLastValue()
51
+ {
52
+ return lastValue;
53
+ }
54
+
55
+ public String feedback()
56
+ {
57
+ if (!understood)
58
+ {
59
+ return "Couldn't understand";
60
+ }
61
+ return lastValue == null ? "(missing)" : "Read: " + format(lastValue);
62
+ }
63
+
64
+ public boolean isUnderstood()
65
+ {
66
+ return understood;
67
+ }
6468 }
timeflow/format/file/Export.java
....@@ -6,5 +6,5 @@
66
77 public interface Export {
88 public String getName();
9
- public void export(TFModel model, BufferedWriter out) throws Exception;
9
+ public void export(TimeflowModel model, BufferedWriter out) throws Exception;
1010 }
timeflow/format/file/HtmlFormat.java
....@@ -9,7 +9,7 @@
99
1010 public class HtmlFormat implements Export
1111 {
12
- TFModel model;
12
+ TimeflowModel model;
1313 java.util.List<Field> fields;
1414 Field title;
1515
....@@ -17,12 +17,12 @@
1717 {
1818 }
1919
20
- public HtmlFormat(TFModel model)
20
+ public HtmlFormat(TimeflowModel model)
2121 {
2222 setModel(model);
2323 }
2424
25
- public void setModel(TFModel model)
25
+ public void setModel(TimeflowModel model)
2626 {
2727 this.model = model;
2828 fields = model.getDB().getFields();
....@@ -30,7 +30,7 @@
3030 }
3131
3232 @Override
33
- public void export(TFModel model, BufferedWriter out) throws Exception
33
+ public void export(TimeflowModel model, BufferedWriter out) throws Exception
3434 {
3535 setModel(model);
3636 out.write(makeHeader());
timeflow/format/file/TimeflowFormat.java
....@@ -13,151 +13,168 @@
1313
1414 public class TimeflowFormat implements Import, Export
1515 {
16
- private static final String END_OF_SCHEMA="#TIMEFLOW\tend-metadata";
17
- private static final String END_OF_METADATA="#TIMEFLOW\t====== End of Header. Data below is in tab-delimited format. =====";
18
- public ActDB readFile(String fileName, PrintStream messages) throws Exception
19
- {
20
- return read(new File(fileName), messages);
21
- }
22
-
23
- public static ActDB read(File file, PrintStream out) throws Exception
24
- {
25
- String text=IO.read(file.getAbsolutePath());
26
- DelimitedText quote=new DelimitedText('\t');
27
- Iterator<String[]> lines=quote.read(text).iterator();
28
-
2916
30
- ActDB db=null;
31
- List<String> fieldNames=new ArrayList<String>();
32
- List<Class> fieldTypes=new ArrayList<Class>();
33
- List<Integer> fieldSizes=new ArrayList<Integer>();
34
- String source="[unknown]", description="";
35
- for (;;)
36
- {
37
- String[] t=lines.next();
17
+ private static final String END_OF_SCHEMA = "#TIMEFLOW\tend-metadata";
18
+ private static final String END_OF_METADATA = "#TIMEFLOW\t====== End of Header. Data below is in tab-delimited format. =====";
3819
39
- if (t[1].equals("field"))
40
- {
41
- fieldNames.add(t[2]);
42
- fieldTypes.add(FieldFormatCatalog.javaClass(t[3]));
43
- if (t.length>4)
44
- {
45
- fieldSizes.add(Integer.parseInt(t[4]));
46
- }
47
- else
48
- fieldSizes.add(-1);
49
- }
50
- else if (t[1].equals("source"))
51
- {
52
- source=t[2];
53
- }
54
- else if (t[1].equals("description"))
55
- {
56
- description=t[2];
57
-
58
- }
59
- else if (t[1].equals("end-metadata"))
60
- break;
61
- }
62
- db=new ArrayDB((String[])fieldNames.toArray(new String[0]),
63
- (Class[])fieldTypes.toArray(new Class[0]), source);
64
- db.setDescription(description);
65
- for (int i=0; i<fieldNames.size(); i++)
66
- if (fieldSizes.get(i)>0)
67
- db.getField(fieldNames.get(i)).setRecommendedSize(fieldSizes.get(i));
68
- for (;;)
69
- {
70
- String[] t=lines.next();
71
- if (t[1].startsWith("==="))
72
- break;
73
- if (t[1].equals("alias"))
74
- db.setAlias(db.getField(t[3]), t[2]);
75
- }
76
-
77
- // note: in some cases headers may be in a different order than in
78
- // metadata section, so we will read these.
79
- String[] headers=lines.next();
80
- if (headers.length!=fieldNames.size())
81
- throw new IllegalArgumentException("Different number of headers than fields!");
82
-
83
-
84
- while (lines.hasNext())
85
- {
86
- String[] t=lines.next();
87
- Act a=db.createAct();
88
- for (int i=0; i<t.length; i++)
89
- {
90
- Field f=db.getField(headers[i]);
91
- FieldFormat format=FieldFormatCatalog.getFormat(f.getType());
92
- a.set(f, format.parse(t[i]));
93
- }
94
- }
95
-
96
- return db;
97
- }
98
-
99
- public static void write(ActList acts, BufferedWriter bw) throws IOException
100
- {
101
- ActDB db=acts.getDB();
102
-
103
- PrintWriter out=new PrintWriter(bw);
104
-
105
- DelimitedText tab=new DelimitedText('\t');
106
-
107
- // Write version
108
- out.println("#TIMEFLOW\tformat version\t1");
109
-
110
- // Write source of data.
111
- out.println("#TIMEFLOW\tsource\t"+tab.write(db.getSource()));
112
-
113
- // Write description of data.
114
- out.println("#TIMEFLOW\tdescription\t"+tab.write(db.getDescription()));
115
-
116
- // Write schema.
117
- List<Field> fields=db.getFields();
118
- for (Field f: fields)
119
- {
120
- String recSize=f.getRecommendedSize()<=0 ? "" : "\t"+f.getRecommendedSize();
121
- out.println("#TIMEFLOW\tfield\t"+tab.write(f.getName())+
122
- "\t"+FieldFormatCatalog.humanName(f.getType())+recSize);
123
- }
124
-
125
- out.println(END_OF_SCHEMA);
126
-
127
- // Write column mappings.
128
- List<String> aliases=DBUtils.getFieldAliases(db);
129
- for (String a:aliases)
130
- out.println("#TIMEFLOW\talias\t"+a+"\t"+tab.write(db.getField(a).getName()));
131
-
132
- // Write end of header indicator
133
- out.println(END_OF_METADATA);
134
-
135
- // Write data!
136
- new DelimitedFormat('\t').writeDelimited(db, acts, out);
137
-
138
- out.flush();
139
- out.close();
140
- }
141
-
142
- public static void main(String[] args) throws Exception
143
- {
144
- System.out.println("Reading");
145
- ActDB db=read(new File("test/monet.txt"), System.out);
146
- System.out.println("# lines: "+db.size());
147
- }
20
+ public ActDB readFile(String fileName, PrintStream messages) throws Exception
21
+ {
22
+ return read(new File(fileName), messages);
23
+ }
14824
149
- @Override
150
- public String getName() {
151
- return "TimeFlow Format";
152
- }
25
+ public static ActDB read(File file, PrintStream out) throws Exception
26
+ {
27
+ String text = IO.read(file.getAbsolutePath());
28
+ DelimitedText quote = new DelimitedText('\t');
29
+ Iterator<String[]> lines = quote.read(text).iterator();
15330
154
- @Override
155
- public ActDB importFile(File file) throws Exception {
156
- return read(file, System.out);
157
- }
15831
159
- @Override
160
- public void export(TFModel model, BufferedWriter out) throws Exception {
161
- write(model.getDB().all(), out);
162
- }
32
+ ActDB db = null;
33
+ List<String> fieldNames = new ArrayList<String>();
34
+ List<Class> fieldTypes = new ArrayList<Class>();
35
+ List<Integer> fieldSizes = new ArrayList<Integer>();
36
+ String source = "[unknown]", description = "";
37
+ for (;;)
38
+ {
39
+ String[] t = lines.next();
40
+
41
+ if (t[1].equals("field"))
42
+ {
43
+ fieldNames.add(t[2]);
44
+ fieldTypes.add(FieldFormatCatalog.javaClass(t[3]));
45
+ if (t.length > 4)
46
+ {
47
+ fieldSizes.add(Integer.parseInt(t[4]));
48
+ } else
49
+ {
50
+ fieldSizes.add(-1);
51
+ }
52
+ } else if (t[1].equals("source"))
53
+ {
54
+ source = t[2];
55
+ } else if (t[1].equals("description"))
56
+ {
57
+ description = t[2];
58
+
59
+ } else if (t[1].equals("end-metadata"))
60
+ {
61
+ break;
62
+ }
63
+ }
64
+ db = new ArrayDB((String[]) fieldNames.toArray(new String[0]),
65
+ (Class[]) fieldTypes.toArray(new Class[0]), source);
66
+ db.setDescription(description);
67
+ for (int i = 0; i < fieldNames.size(); i++)
68
+ {
69
+ if (fieldSizes.get(i) > 0)
70
+ {
71
+ db.getField(fieldNames.get(i)).setRecommendedSize(fieldSizes.get(i));
72
+ }
73
+ }
74
+ for (;;)
75
+ {
76
+ String[] t = lines.next();
77
+ if (t[1].startsWith("==="))
78
+ {
79
+ break;
80
+ }
81
+ if (t[1].equals("alias"))
82
+ {
83
+ db.setAlias(db.getField(t[3]), t[2]);
84
+ }
85
+ }
86
+
87
+ // note: in some cases headers may be in a different order than in
88
+ // metadata section, so we will read these.
89
+ String[] headers = lines.next();
90
+ if (headers.length != fieldNames.size())
91
+ {
92
+ throw new IllegalArgumentException("Different number of headers than fields!");
93
+ }
94
+
95
+
96
+ while (lines.hasNext())
97
+ {
98
+ String[] t = lines.next();
99
+ Act a = db.createAct();
100
+ for (int i = 0; i < t.length; i++)
101
+ {
102
+ Field f = db.getField(headers[i]);
103
+ FieldFormat format = FieldFormatCatalog.getFormat(f.getType());
104
+ a.set(f, format.parse(t[i]));
105
+ }
106
+ }
107
+
108
+ return db;
109
+ }
110
+
111
+ public static void write(ActList acts, BufferedWriter bw) throws IOException
112
+ {
113
+ ActDB db = acts.getDB();
114
+
115
+ PrintWriter out = new PrintWriter(bw);
116
+
117
+ DelimitedText tab = new DelimitedText('\t');
118
+
119
+ // Write version
120
+ out.println("#TIMEFLOW\tformat version\t1");
121
+
122
+ // Write source of data.
123
+ out.println("#TIMEFLOW\tsource\t" + tab.write(db.getSource()));
124
+
125
+ // Write description of data.
126
+ out.println("#TIMEFLOW\tdescription\t" + tab.write(db.getDescription()));
127
+
128
+ // Write schema.
129
+ List<Field> fields = db.getFields();
130
+ for (Field f : fields)
131
+ {
132
+ String recSize = f.getRecommendedSize() <= 0 ? "" : "\t" + f.getRecommendedSize();
133
+ out.println("#TIMEFLOW\tfield\t" + tab.write(f.getName())
134
+ + "\t" + FieldFormatCatalog.humanName(f.getType()) + recSize);
135
+ }
136
+
137
+ out.println(END_OF_SCHEMA);
138
+
139
+ // Write column mappings.
140
+ List<String> aliases = DBUtils.getFieldAliases(db);
141
+ for (String a : aliases)
142
+ {
143
+ out.println("#TIMEFLOW\talias\t" + a + "\t" + tab.write(db.getField(a).getName()));
144
+ }
145
+
146
+ // Write end of header indicator
147
+ out.println(END_OF_METADATA);
148
+
149
+ // Write data!
150
+ new DelimitedFormat('\t').writeDelimited(db, acts, out);
151
+
152
+ out.flush();
153
+ out.close();
154
+ }
155
+
156
+ public static void main(String[] args) throws Exception
157
+ {
158
+ System.out.println("Reading");
159
+ ActDB db = read(new File("test/monet.txt"), System.out);
160
+ System.out.println("# lines: " + db.size());
161
+ }
162
+
163
+ @Override
164
+ public String getName()
165
+ {
166
+ return "TimeFlow Format";
167
+ }
168
+
169
+ @Override
170
+ public ActDB importFile(File file) throws Exception
171
+ {
172
+ return read(file, System.out);
173
+ }
174
+
175
+ @Override
176
+ public void export(TimeflowModel model, BufferedWriter out) throws Exception
177
+ {
178
+ write(model.getDB().all(), out);
179
+ }
163180 }
timeflow/model/Display.java
....@@ -360,7 +360,7 @@
360360 return lines;
361361 }
362362
363
- public boolean emptyMessage(Graphics g, TFModel model)
363
+ public boolean emptyMessage(Graphics g, TimeflowModel model)
364364 {
365365 if (model.getActs() == null || model.getActs().size() == 0)
366366 {
timeflow/model/ModelPanel.java
....@@ -4,9 +4,9 @@
44
55 public abstract class ModelPanel extends JPanel implements TFListener {
66
7
- TFModel model;
7
+ TimeflowModel model;
88
9
- public ModelPanel(TFModel model)
9
+ public ModelPanel(TimeflowModel model)
1010 {
1111 this.model=model;
1212 }
....@@ -26,7 +26,7 @@
2626 model.removeListener(this);
2727 }
2828
29
- public TFModel getModel()
29
+ public TimeflowModel getModel()
3030 {
3131 return model;
3232 }
timeflow/model/TFListener.java
....@@ -1,5 +1,6 @@
11 package timeflow.model;
22
3
-public interface TFListener {
4
- public void note(TFEvent e);
3
+public interface TFListener
4
+{
5
+ public void note(TFEvent e);
56 }
timeflow/model/TFModel.java
similarity index 99%rename from timeflow/model/TFModel.javarename to timeflow/model/TimeflowModel.java
....@@ -10,9 +10,8 @@
1010 // encapsulates all properties of a timeline model:
1111 // data, display properties, etc.
1212 // also does listening, etc.
13
-public class TFModel
13
+public class TimeflowModel
1414 {
15
-
1615 private ActDB db;
1716 private ActList acts;
1817 private ActFilter filter = new ConstFilter(true);
timeflow/views/AbstractView.java
....@@ -15,7 +15,7 @@
1515 JPanel panel;
1616 ActDB lastDrawn, lastNotified;
1717
18
- public AbstractView(TFModel model)
18
+ public AbstractView(TimeflowModel model)
1919 {
2020 super(model);
2121 }
....@@ -45,7 +45,7 @@
4545 };
4646 controlLabel.setBackground(Color.lightGray);
4747 controlLabel.setForeground(Color.darkGray);
48
- panel.add(controlLabel, BorderLayout.NORTH);
48
+ //panel.add(controlLabel, BorderLayout.NORTH);
4949
5050 return panel;
5151 }
timeflow/views/AbstractVisualizationView.java
....@@ -22,12 +22,12 @@
2222 Point mouse = new Point(-10000, 0), firstMouse = new Point();
2323 boolean mouseIsDown;
2424 ArrayList<Mouseover> objectLocations = new ArrayList<Mouseover>();
25
- TFModel model;
25
+ TimeflowModel model;
2626 Act selectedAct;
2727 RoughTime selectedTime;
2828 Set<JMenuItem> urlItems = new HashSet<JMenuItem>();
2929
30
- public AbstractVisualizationView(TFModel model)
30
+ public AbstractVisualizationView(TimeflowModel model)
3131 {
3232 this.model = model;
3333
....@@ -176,7 +176,7 @@
176176 return null;
177177 }
178178
179
- public TFModel getModel()
179
+ public TimeflowModel getModel()
180180 {
181181 return model;
182182 }
timeflow/views/BarGraphView.java
....@@ -28,7 +28,7 @@
2828 Aggregate agg;
2929 JComboBox splitFieldChoice, numFieldChoice;
3030
31
- public BarGraphView(TFModel model)
31
+ public BarGraphView(TimeflowModel model)
3232 {
3333 super(model);
3434
....@@ -55,7 +55,7 @@
5555 int ch = 25, pad = 5, cw = 160;
5656
5757 controls.removeAll();
58
- TFModel model = getModel();
58
+ TimeflowModel model = getModel();
5959 if (model.getDB() == null || model.getDB().size() == 0)
6060 {
6161 JLabel empty = new JLabel("Empty database");
....@@ -267,7 +267,7 @@
267267 int w = getSize().width, h = getSize().height;
268268 g.setColor(Color.white);
269269 g.fillRect(0, 0, w, h);
270
- TFModel model = getModel();
270
+ TimeflowModel model = getModel();
271271 Display display = model.getDisplay();
272272
273273 if (display.emptyMessage(g, model))
timeflow/views/CalendarView.java
....@@ -32,7 +32,7 @@
3232 return controls;
3333 }
3434
35
- public CalendarView(TFModel model)
35
+ public CalendarView(TimeflowModel model)
3636 {
3737 super(model);
3838 calendarPanel=new CalendarPanel(model);
....@@ -276,7 +276,7 @@
276276 class CalendarPanel extends AbstractVisualizationView
277277 {
278278
279
- CalendarPanel(TFModel model)
279
+ CalendarPanel(TimeflowModel model)
280280 {
281281 super(model);
282282 setBackground(Color.white);
timeflow/views/DescriptionView.java
....@@ -14,7 +14,7 @@
1414 JTextArea content;
1515 JComponent controls;
1616
17
- public DescriptionView(TFModel model) {
17
+ public DescriptionView(TimeflowModel model) {
1818 super(model);
1919 setLayout(new BorderLayout());
2020 JPanel left=new Pad(5,5);
timeflow/views/IntroView.java
....@@ -34,7 +34,7 @@
3434 Image image;
3535 Image repeat;
3636
37
- public IntroView(TFModel model)
37
+ public IntroView(TimeflowModel model)
3838 {
3939 super(model);
4040 setBackground(Color.white);
timeflow/views/ListView.java
....@@ -35,7 +35,7 @@
3535 private boolean changing = false;
3636 private JPanel controls;
3737
38
- public ListView(TFModel model)
38
+ public ListView(TimeflowModel model)
3939 {
4040 super(model);
4141
timeflow/views/SummaryView.java
....@@ -27,7 +27,7 @@
2727 private Interval range;
2828 private JComponent controls;
2929
30
- public SummaryView(TFModel model)
30
+ public SummaryView(TimeflowModel model)
3131 {
3232 super(model);
3333 analysisDisplay = HtmlDisplay.create();
timeflow/views/TableView.java
....@@ -23,7 +23,7 @@
2323 private boolean editable=true;
2424 private JPanel controls;
2525
26
- public TableView(TFModel model)
26
+ public TableView(TimeflowModel model)
2727 {
2828 super(model);
2929
timeflow/views/TimelineView.java
....@@ -37,7 +37,7 @@
3737 return controls;
3838 }
3939
40
- public TimelineView(TFModel model)
40
+ public TimelineView(TimeflowModel model)
4141 {
4242 super(model);
4343 visuals = new TimelineVisuals(model);
....@@ -65,7 +65,7 @@
6565 bottom.add(slider, BorderLayout.CENTER);
6666
6767 controls = new JPanel();
68
- controls.setBackground(Color.white);
68
+ controls.setBackground(Color.red);
6969 controls.setLayout(new BorderLayout());//new GridLayout(2,1));
7070
7171 // top part of grid: zoom buttons.
....@@ -123,7 +123,7 @@
123123 moveTime(visuals.getFitToVisibleRange());
124124 }});
125125 */
126
- controls.add(buttons, BorderLayout.NORTH);
126
+ controls.add(buttons, BorderLayout.SOUTH);
127127
128128 // ok, now do second part of grid: layout style buttons.
129129 ComponentCluster layoutPanel = new ComponentCluster("Layout");
....@@ -151,7 +151,7 @@
151151 graph.addActionListener(new LayoutSetter(TimelineVisuals.Layout.GRAPH));
152152 layoutGroup.add(graph);
153153
154
- controls.add(layoutPanel, BorderLayout.CENTER);
154
+ //controls.add(layoutPanel, BorderLayout.CENTER);
155155 }
156156
157157 class LayoutSetter implements ActionListener
....@@ -325,7 +325,7 @@
325325
326326 class TimelinePanel extends AbstractVisualizationView
327327 {
328
- public TimelinePanel(TFModel model)
328
+ public TimelinePanel(TimeflowModel model)
329329 {
330330 super(model);
331331
timeflow/vis/VisualActFactory.java
....@@ -10,7 +10,7 @@
1010 import timeflow.data.db.ActDB;
1111 import timeflow.data.db.ActList;
1212 import timeflow.data.db.Field;
13
-import timeflow.model.TFModel;
13
+import timeflow.model.TimeflowModel;
1414 import timeflow.model.VirtualField;
1515
1616 public class VisualActFactory
....@@ -60,7 +60,7 @@
6060 return list;
6161 }
6262
63
- public static Collection<VisualAct> makeEmFit(TFModel model, ArrayList<VisualAct> vacts, Rectangle bounds)
63
+ public static Collection<VisualAct> makeEmFit(TimeflowModel model, ArrayList<VisualAct> vacts, Rectangle bounds)
6464 {
6565 // Does everything fit? Because, if so, we're already good to go.
6666 int area = bounds.width * bounds.height;
timeflow/vis/VisualEncoder.java
....@@ -9,11 +9,11 @@
99 public class VisualEncoder
1010 {
1111
12
- private TFModel model;
12
+ private TimeflowModel model;
1313 private java.util.List<VisualAct> visualActs = new ArrayList<VisualAct>();
1414 private double maxSize = 0;
1515
16
- public VisualEncoder(TFModel model)
16
+ public VisualEncoder(TimeflowModel model)
1717 {
1818 this.model = model;
1919 }
timeflow/vis/calendar/CalendarVisuals.java
....@@ -11,7 +11,7 @@
1111
1212 public class CalendarVisuals {
1313 VisualEncoder encoder;
14
- TFModel model;
14
+ TimeflowModel model;
1515 Rectangle bounds=new Rectangle();
1616 public Grid grid;
1717
....@@ -24,7 +24,7 @@
2424 public enum FitStyle {LOOSE, TIGHT};
2525 FitStyle fitStyle=FitStyle.LOOSE;
2626
27
- public CalendarVisuals(TFModel model)
27
+ public CalendarVisuals(TimeflowModel model)
2828 {
2929 this.model=model;
3030 encoder=new VisualEncoder(model);
timeflow/vis/timeline/AxisRenderer.java
....@@ -20,7 +20,7 @@
2020
2121 public void render(Graphics2D g, Collection<Mouseover> objectLocations)
2222 {
23
- TFModel model = visuals.getModel();
23
+ TimeflowModel model = visuals.getModel();
2424 g.setColor(model.getDisplay().getColor("chart.background"));
2525 Rectangle bounds = visuals.getBounds();
2626
....@@ -41,7 +41,7 @@
4141
4242 void render(AxisTicMarks t, Graphics2D g, int x, int y, int h, int top, boolean full, Collection<Mouseover> objectLocations)
4343 {
44
- TFModel model = visuals.getModel();
44
+ TimeflowModel model = visuals.getModel();
4545
4646 int n = t.tics.size();
4747 for (int i = 0; i < n - 1; i++)
timeflow/vis/timeline/TimelineRenderer.java
....@@ -36,7 +36,7 @@
3636 g.setTransform(AffineTransform.getTranslateInstance(0, -dy));
3737
3838 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
39
- TFModel model = visuals.getModel();
39
+ TimeflowModel model = visuals.getModel();
4040 Display display = model.getDisplay();
4141 ActDB db = model.getDB();
4242
timeflow/vis/timeline/TimelineVisuals.java
....@@ -28,12 +28,12 @@
2828
2929 public enum Layout
3030 {
31
-
3231 TIGHT, LOOSE, GRAPH
3332 };
33
+
3434 private Layout layoutStyle = Layout.TIGHT;
3535 private VisualEncoder encoder;
36
- private TFModel model;
36
+ private TimeflowModel model;
3737 private int fullHeight;
3838
3939 public int getFullHeight()
....@@ -41,7 +41,7 @@
4141 return fullHeight;
4242 }
4343
44
- public TimelineVisuals(TFModel model)
44
+ public TimelineVisuals(TimeflowModel model)
4545 {
4646 this.model = model;
4747 encoder = new VisualEncoder(model);
....@@ -224,7 +224,7 @@
224224 layout();
225225 }
226226
227
- public TFModel getModel()
227
+ public TimeflowModel getModel()
228228 {
229229 return model;
230230 }