1 files renamed
52 files modified
| .. | .. |
|---|
| 1189 | 1189 | timelinePanel = new JPanel(new BorderLayout()); |
|---|
| 1190 | 1190 | timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
|---|
| 1191 | 1191 | |
|---|
| 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 | + |
|---|
| 1192 | 1199 | centralPanel.add(cameraView); |
|---|
| 1193 | 1200 | //frame.setJMenuBar(timelineMenubar); |
|---|
| 1194 | 1201 | //centralPanel.add(timelinePanel); |
|---|
| .. | .. |
|---|
| 2996 | 3003 | if (timeline) |
|---|
| 2997 | 3004 | { |
|---|
| 2998 | 3005 | centralPanel.remove(cameraView); |
|---|
| 2999 | | - centralPanel.add(timelinePanel); |
|---|
| 3006 | + cameraPanel.add(cameraView); |
|---|
| 3007 | + centralPanel.add(cameraPanel); |
|---|
| 3000 | 3008 | frame.setJMenuBar(timelineMenubar); |
|---|
| 3001 | 3009 | wasFullScreen = CameraPane.FULLSCREEN; |
|---|
| 3002 | 3010 | if (!CameraPane.FULLSCREEN) |
|---|
| .. | .. |
|---|
| 3005 | 3013 | } |
|---|
| 3006 | 3014 | else |
|---|
| 3007 | 3015 | { |
|---|
| 3008 | | - centralPanel.remove(timelinePanel); |
|---|
| 3016 | + centralPanel.remove(cameraPanel); |
|---|
| 3009 | 3017 | centralPanel.add(cameraView); |
|---|
| 3010 | 3018 | frame.setJMenuBar(null); |
|---|
| 3011 | 3019 | if (!wasFullScreen) |
|---|
| .. | .. |
|---|
| 4533 | 4541 | JPanel bigThree; |
|---|
| 4534 | 4542 | JTabbedPane scenePanel; |
|---|
| 4535 | 4543 | JPanel centralPanel; |
|---|
| 4544 | + JSplitPane cameraPanel; |
|---|
| 4536 | 4545 | JPanel timelinePanel; |
|---|
| 4537 | 4546 | JMenuBar timelineMenubar; |
|---|
| 4538 | 4547 | JSplitPane framePanel; |
|---|
| .. | .. |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | public class TimeflowApp extends JFrame |
|---|
| 27 | 27 | { |
|---|
| 28 | | - public TFModel model = new TFModel(); |
|---|
| 28 | + public TimeflowModel model = new TimeflowModel(); |
|---|
| 29 | 29 | public JFileChooser fileChooser; |
|---|
| 30 | 30 | AboutWindow splash; |
|---|
| 31 | 31 | String[][] examples; |
|---|
| .. | .. |
|---|
| 84 | 84 | examples[i][0] = s; |
|---|
| 85 | 85 | examples[i][1] = "settings/examples/" + ex[i]; |
|---|
| 86 | 86 | } |
|---|
| 87 | + |
|---|
| 87 | 88 | templates = getVisibleFiles("settings/templates"); |
|---|
| 88 | 89 | fileChooser = new JFileChooser(state.getCurrentFile()); |
|---|
| 89 | 90 | |
|---|
| .. | .. |
|---|
| 180 | 181 | JMenu fileMenu = new JMenu("File"); |
|---|
| 181 | 182 | menubar.add(fileMenu); |
|---|
| 182 | 183 | |
|---|
| 183 | | - fileMenu.add(new NewDataAction(this)); |
|---|
| 184 | + TimeflowAction tlAction = new NewDataAction(this); |
|---|
| 185 | + fileMenu.add(tlAction); |
|---|
| 186 | + tlAction.actionPerformed(null); |
|---|
| 184 | 187 | fileMenu.add(new CopySchemaAction(this)); |
|---|
| 185 | 188 | |
|---|
| 186 | 189 | JMenu templateMenu = new JMenu("New From Template"); |
|---|
| .. | .. |
|---|
| 202 | 205 | } |
|---|
| 203 | 206 | |
|---|
| 204 | 207 | fileMenu.addSeparator(); |
|---|
| 205 | | - |
|---|
| 206 | 208 | |
|---|
| 207 | 209 | JMenuItem open = new JMenuItem("Open..."); |
|---|
| 208 | 210 | fileMenu.add(open); |
|---|
| .. | .. |
|---|
| 32 | 32 | if (n==1) |
|---|
| 33 | 33 | { |
|---|
| 34 | 34 | String fieldName=p.name.getText(); |
|---|
| 35 | | - TFModel model=getModel(); |
|---|
| 35 | + TimeflowModel model=getModel(); |
|---|
| 36 | 36 | if (fieldName.trim().length()==0) |
|---|
| 37 | 37 | app.showUserError("Field names can't be all spaces!"); |
|---|
| 38 | 38 | else if (model.getDB().getField(fieldName)!=null) |
|---|
| .. | .. |
|---|
| 11 | 11 | import javax.swing.*; |
|---|
| 12 | 12 | import java.util.*; |
|---|
| 13 | 13 | |
|---|
| 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 | + } |
|---|
| 15 | 21 | |
|---|
| 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 | + } |
|---|
| 26 | 27 | } |
|---|
| .. | .. |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | if (fieldToDelete!=null) |
|---|
| 35 | 35 | { |
|---|
| 36 | | - TFModel model=getModel(); |
|---|
| 36 | + TimeflowModel model=getModel(); |
|---|
| 37 | 37 | Field f=model.getDB().getField(fieldToDelete); |
|---|
| 38 | 38 | model.getDB().deleteField(f); |
|---|
| 39 | 39 | model.noteSchemaChange(this); |
|---|
| .. | .. |
|---|
| 9 | 9 | import javax.swing.*; |
|---|
| 10 | 10 | import java.util.*; |
|---|
| 11 | 11 | |
|---|
| 12 | +public class DeleteSelectedAction extends TimeflowAction |
|---|
| 13 | +{ |
|---|
| 12 | 14 | |
|---|
| 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 | + } |
|---|
| 14 | 19 | |
|---|
| 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 | + { |
|---|
| 50 | 23 | |
|---|
| 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 | + } |
|---|
| 51 | 56 | } |
|---|
| .. | .. |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | @Override |
|---|
| 19 | 19 | public void actionPerformed(ActionEvent e) { |
|---|
| 20 | | - TFModel model=getModel(); |
|---|
| 20 | + TimeflowModel model=getModel(); |
|---|
| 21 | 21 | String source = (String)JOptionPane.showInputDialog( |
|---|
| 22 | 22 | app, |
|---|
| 23 | 23 | null, |
|---|
| .. | .. |
|---|
| 10 | 10 | import javax.swing.*; |
|---|
| 11 | 11 | import java.util.*; |
|---|
| 12 | 12 | |
|---|
| 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'); |
|---|
| 14 | 19 | |
|---|
| 15 | | - public NewDataAction(TimeflowApp app) |
|---|
| 16 | | - { |
|---|
| 17 | | - super(app, "New", null, "Create a new, blank database"); |
|---|
| 18 | | - accelerate('N'); |
|---|
| 20 | + } |
|---|
| 19 | 21 | |
|---|
| 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 | + } |
|---|
| 27 | 29 | } |
|---|
| .. | .. |
|---|
| 12 | 12 | |
|---|
| 13 | 13 | public class QuitAction extends TimeflowAction { |
|---|
| 14 | 14 | |
|---|
| 15 | | - public QuitAction(TimeflowApp app, TFModel model) |
|---|
| 15 | + public QuitAction(TimeflowApp app, TimeflowModel model) |
|---|
| 16 | 16 | { |
|---|
| 17 | 17 | super(app, "Quit", null, "Quit the program"); |
|---|
| 18 | 18 | } |
|---|
| .. | .. |
|---|
| 27 | 27 | } |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | |
|---|
| 30 | | - protected TFModel getModel() |
|---|
| 30 | + protected TimeflowModel getModel() |
|---|
| 31 | 31 | { |
|---|
| 32 | 32 | return app.model; |
|---|
| 33 | 33 | } |
|---|
| .. | .. |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | Field oldColor; |
|---|
| 22 | 22 | |
|---|
| 23 | | - public ColorLegendPanel(TFModel model) |
|---|
| 23 | + public ColorLegendPanel(TimeflowModel model) |
|---|
| 24 | 24 | { |
|---|
| 25 | 25 | super(model); |
|---|
| 26 | 26 | setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 8 | 8 | int numComps=0; |
|---|
| 9 | 9 | int x1=80; |
|---|
| 10 | 10 | int width=200; |
|---|
| 11 | | - int compH=30; |
|---|
| 11 | + int compH=20; |
|---|
| 12 | 12 | DottedLine line=new DottedLine(); |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | public ComponentCluster(String name) |
|---|
| .. | .. |
|---|
| 25 | 25 | { |
|---|
| 26 | 26 | add(c); |
|---|
| 27 | 27 | 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); |
|---|
| 29 | 29 | numComps++; |
|---|
| 30 | | - line.setBounds(x1-10,10,1,numComps*compH-5); |
|---|
| 30 | + line.setBounds(x1-10,10,0,numComps*compH); |
|---|
| 31 | 31 | } |
|---|
| 32 | 32 | |
|---|
| 33 | 33 | public Dimension getPreferredSize() |
|---|
| .. | .. |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | public class DateFieldPanel extends JPanel |
|---|
| 17 | 17 | { |
|---|
| 18 | | - TFModel model; |
|---|
| 18 | + TimeflowModel model; |
|---|
| 19 | 19 | int numRows; |
|---|
| 20 | 20 | HashMap<String, Integer> numBad=new HashMap<String, Integer>(); |
|---|
| 21 | 21 | private static String[] mappable={VirtualField.START, VirtualField.END}; |
|---|
| .. | .. |
|---|
| 23 | 23 | FieldMap[] panels=new FieldMap[mappable.length]; |
|---|
| 24 | 24 | JButton submit, cancel; |
|---|
| 25 | 25 | |
|---|
| 26 | | - public DateFieldPanel(TFModel model, boolean hasButtons) |
|---|
| 26 | + public DateFieldPanel(TimeflowModel model, boolean hasButtons) |
|---|
| 27 | 27 | { |
|---|
| 28 | 28 | this.model=model; |
|---|
| 29 | 29 | |
|---|
| .. | .. |
|---|
| 154 | 154 | return new Dimension(400,80+mappable.length*25); |
|---|
| 155 | 155 | } |
|---|
| 156 | 156 | |
|---|
| 157 | | - public static void popWindow(TFModel model) |
|---|
| 157 | + public static void popWindow(TimeflowModel model) |
|---|
| 158 | 158 | { |
|---|
| 159 | 159 | final JFrame window=new JFrame("Date Fields"); |
|---|
| 160 | 160 | window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|---|
| .. | .. |
|---|
| 20 | 20 | HashMap<Field, EditValuePanel> fieldUI = new HashMap<Field, EditValuePanel>(); |
|---|
| 21 | 21 | JButton submit, cancel; |
|---|
| 22 | 22 | Dimension idealSize = new Dimension(); |
|---|
| 23 | | - TFModel model; |
|---|
| 23 | + TimeflowModel model; |
|---|
| 24 | 24 | |
|---|
| 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) |
|---|
| 26 | 26 | { |
|---|
| 27 | 27 | 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); |
|---|
| 29 | 29 | final EditRecordPanel editor = new EditRecordPanel(model, act); |
|---|
| 30 | 30 | window.getContentPane().setLayout(new GridLayout(1, 1)); |
|---|
| 31 | 31 | window.getContentPane().add(editor); |
|---|
| .. | .. |
|---|
| 58 | 58 | window.setVisible(true); |
|---|
| 59 | 59 | } |
|---|
| 60 | 60 | |
|---|
| 61 | | - public static void edit(TFModel model, Act act) |
|---|
| 61 | + public static void edit(TimeflowModel model, Act act) |
|---|
| 62 | 62 | { |
|---|
| 63 | 63 | edit(model, act, false); |
|---|
| 64 | 64 | } |
|---|
| 65 | 65 | |
|---|
| 66 | | - public static void add(TFModel model) |
|---|
| 66 | + public static void add(TimeflowModel model) |
|---|
| 67 | 67 | { |
|---|
| 68 | 68 | Act act = model.getDB().createAct(); |
|---|
| 69 | 69 | edit(model, act, true); |
|---|
| 70 | 70 | } |
|---|
| 71 | 71 | |
|---|
| 72 | | - public static void add(TFModel model, RoughTime r) |
|---|
| 72 | + public static void add(TimeflowModel model, RoughTime r) |
|---|
| 73 | 73 | { |
|---|
| 74 | 74 | Act act = model.getDB().createAct(); |
|---|
| 75 | 75 | act.set(act.getDB().getField(VirtualField.START), r); |
|---|
| 76 | 76 | edit(model, act, true); |
|---|
| 77 | 77 | } |
|---|
| 78 | 78 | |
|---|
| 79 | | - public EditRecordPanel(TFModel model, Act act) |
|---|
| 79 | + public EditRecordPanel(TimeflowModel model, Act act) |
|---|
| 80 | 80 | { |
|---|
| 81 | 81 | this.model = model; |
|---|
| 82 | 82 | this.act = act; |
|---|
| .. | .. |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | public class EditValuePanel extends JPanel |
|---|
| 12 | 12 | { |
|---|
| 13 | | - |
|---|
| 14 | 13 | FieldFormat parser; |
|---|
| 15 | 14 | boolean longField; |
|---|
| 16 | 15 | JLabel feedback = new JLabel() |
|---|
| .. | .. |
|---|
| 21 | 21 | JPanel globalControls = new JPanel(); |
|---|
| 22 | 22 | CardLayout localCards = new CardLayout(); |
|---|
| 23 | 23 | |
|---|
| 24 | | - public GlobalDisplayPanel(TFModel model, FilterControlPanel filterControls) |
|---|
| 24 | + public GlobalDisplayPanel(TimeflowModel model, FilterControlPanel filterControls) |
|---|
| 25 | 25 | { |
|---|
| 26 | 26 | super(model); |
|---|
| 27 | 27 | setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 56 | 56 | }; |
|---|
| 57 | 57 | label.setBackground(Color.lightGray); |
|---|
| 58 | 58 | label.setForeground(Color.darkGray); |
|---|
| 59 | | - globalLabel.add(label, BorderLayout.CENTER); |
|---|
| 59 | + //globalLabel.add(label, BorderLayout.CENTER); |
|---|
| 60 | 60 | p.add(globalLabel, BorderLayout.NORTH); |
|---|
| 61 | 61 | |
|---|
| 62 | 62 | JPanel global = new JPanel(); |
|---|
| 63 | 63 | global.setLayout(new BorderLayout()); |
|---|
| 64 | | - global.add(new StatusPanel(model, filterControls), BorderLayout.NORTH); |
|---|
| 64 | + //global.add(new StatusPanel(model, filterControls), BorderLayout.NORTH); |
|---|
| 65 | 65 | |
|---|
| 66 | 66 | encodings.setLayout(new GridLayout(4, 1)); |
|---|
| 67 | 67 | encodings.setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 74 | 74 | |
|---|
| 75 | 75 | public void showLocalControl(String name) |
|---|
| 76 | 76 | { |
|---|
| 77 | | - localCards.show(localControls, name); |
|---|
| 77 | + //localCards.show(localControls, name); |
|---|
| 78 | 78 | } |
|---|
| 79 | 79 | |
|---|
| 80 | 80 | public void addLocalControl(String name, JComponent control) |
|---|
| 81 | 81 | { |
|---|
| 82 | | - localControls.add(control, name); |
|---|
| 82 | + if (name.equals("Timeline")) |
|---|
| 83 | + localControls.add(control, name); |
|---|
| 83 | 84 | } |
|---|
| 84 | 85 | |
|---|
| 85 | 86 | void makeEncodingPanel() |
|---|
| .. | .. |
|---|
| 24 | 24 | SchemaPanel schemaPanel; |
|---|
| 25 | 25 | boolean exitOnClose=false; // for testing! |
|---|
| 26 | 26 | JScrollPane scroller; |
|---|
| 27 | | - TFModel model; |
|---|
| 27 | + TimeflowModel model; |
|---|
| 28 | 28 | JLabel numLinesLabel=new JLabel(); |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | // for testing: |
|---|
| .. | .. |
|---|
| 33 | 33 | System.out.println("Starting test of ImportEditor"); |
|---|
| 34 | 34 | String file="data/probate.tsv"; |
|---|
| 35 | 35 | String[][] data=DelimitedFormat.readArrayGuessDelim(file, System.out); |
|---|
| 36 | | - ImportDelimitedPanel editor=new ImportDelimitedPanel(new TFModel()); |
|---|
| 36 | + ImportDelimitedPanel editor=new ImportDelimitedPanel(new TimeflowModel()); |
|---|
| 37 | 37 | editor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|---|
| 38 | 38 | editor.setFileName(file); |
|---|
| 39 | 39 | editor.setData(data); |
|---|
| .. | .. |
|---|
| 42 | 42 | editor.exitOnClose=true; |
|---|
| 43 | 43 | } |
|---|
| 44 | 44 | |
|---|
| 45 | | - public ImportDelimitedPanel(final TFModel model) |
|---|
| 45 | + public ImportDelimitedPanel(final TimeflowModel model) |
|---|
| 46 | 46 | { |
|---|
| 47 | 47 | super("Import File"); |
|---|
| 48 | 48 | this.model=model; |
|---|
| .. | .. |
|---|
| 15 | 15 | TableView table; |
|---|
| 16 | 16 | ActList keepers; |
|---|
| 17 | 17 | |
|---|
| 18 | | - public MassDeletePanel(TFModel model, ActList keepers, String title) |
|---|
| 18 | + public MassDeletePanel(TimeflowModel model, ActList keepers, String title) |
|---|
| 19 | 19 | { |
|---|
| 20 | 20 | super(model); |
|---|
| 21 | 21 | this.keepers=keepers; |
|---|
| .. | .. |
|---|
| 61 | 61 | |
|---|
| 62 | 62 | public void detachFromModel() |
|---|
| 63 | 63 | { |
|---|
| 64 | | - TFModel model=getModel(); |
|---|
| 64 | + TimeflowModel model=getModel(); |
|---|
| 65 | 65 | model.removeListener(table); |
|---|
| 66 | 66 | model.removeListener(this); |
|---|
| 67 | 67 | } |
|---|
| .. | .. |
|---|
| 14 | 14 | { |
|---|
| 15 | 15 | TableView table; |
|---|
| 16 | 16 | |
|---|
| 17 | | - public ReorderFieldsPanel(TFModel model) |
|---|
| 17 | + public ReorderFieldsPanel(TimeflowModel model) |
|---|
| 18 | 18 | { |
|---|
| 19 | 19 | super(model); |
|---|
| 20 | 20 | setLayout(new BorderLayout()); |
|---|
| .. | .. |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | public void detachFromModel() |
|---|
| 51 | 51 | { |
|---|
| 52 | | - TFModel model=getModel(); |
|---|
| 52 | + TimeflowModel model=getModel(); |
|---|
| 53 | 53 | model.removeListener(table); |
|---|
| 54 | 54 | model.removeListener(this); |
|---|
| 55 | 55 | } |
|---|
| .. | .. |
|---|
| 13 | 13 | Field sizeField; |
|---|
| 14 | 14 | double min, max; |
|---|
| 15 | 15 | |
|---|
| 16 | | - public SizeLegendPanel(TFModel model) |
|---|
| 16 | + public SizeLegendPanel(TimeflowModel model) |
|---|
| 17 | 17 | { |
|---|
| 18 | 18 | super(model); |
|---|
| 19 | 19 | setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 44 | 44 | g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
|---|
| 45 | 45 | int w=getSize().width; |
|---|
| 46 | 46 | int h=getSize().height; |
|---|
| 47 | | - TFModel model=getModel(); |
|---|
| 47 | + TimeflowModel model=getModel(); |
|---|
| 48 | 48 | Display display=model.getDisplay(); |
|---|
| 49 | 49 | g.setColor(getBackground()); |
|---|
| 50 | 50 | g.setFont(display.plain()); |
|---|
| .. | .. |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | static final DecimalFormat niceFormat=new DecimalFormat("###,###"); |
|---|
| 32 | 32 | |
|---|
| 33 | | - public StatusPanel(TFModel model, final FilterControlPanel filterControls) { |
|---|
| 33 | + public StatusPanel(TimeflowModel model, final FilterControlPanel filterControls) { |
|---|
| 34 | 34 | super(model); |
|---|
| 35 | 35 | setLayout(new BorderLayout()); |
|---|
| 36 | 36 | setBackground(new Color(245, 245, 245)); |
|---|
| .. | .. |
|---|
| 11 | 11 | import java.awt.*; |
|---|
| 12 | 12 | import java.awt.event.*; |
|---|
| 13 | 13 | |
|---|
| 14 | | -public class FilterCategoryPanel extends FilterDefinitionPanel |
|---|
| 14 | +public class FilterCategoryPanel extends FilterDefinitionPanel |
|---|
| 15 | 15 | { |
|---|
| 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)); |
|---|
| 30 | 16 | |
|---|
| 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; |
|---|
| 91 | 19 | |
|---|
| 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 | + } |
|---|
| 113 | 24 | |
|---|
| 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)); |
|---|
| 133 | 31 | |
|---|
| 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); |
|---|
| 158 | 33 | |
|---|
| 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 | + } |
|---|
| 164 | 190 | } |
|---|
| .. | .. |
|---|
| 23 | 23 | JMenu menuToSyncWith; |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | |
|---|
| 26 | | - public FilterControlPanel(TFModel model, JMenu menuToSyncWith) |
|---|
| 26 | + public FilterControlPanel(TimeflowModel model, JMenu menuToSyncWith) |
|---|
| 27 | 27 | { |
|---|
| 28 | 28 | super(model); |
|---|
| 29 | 29 | this.menuToSyncWith=menuToSyncWith; |
|---|
| .. | .. |
|---|
| 16 | 16 | // NumberFilterPanel. |
|---|
| 17 | 17 | // but, i'm not sure how to do it in a way that doesn't make the code |
|---|
| 18 | 18 | // seem too complicated. |
|---|
| 19 | | - |
|---|
| 20 | | -public class FilterDatePanel extends FilterDefinitionPanel |
|---|
| 19 | +public class FilterDatePanel extends FilterDefinitionPanel |
|---|
| 21 | 20 | { |
|---|
| 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 | | - } |
|---|
| 147 | 21 | |
|---|
| 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"); |
|---|
| 160 | 29 | |
|---|
| 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); |
|---|
| 168 | 38 | |
|---|
| 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 | + } |
|---|
| 173 | 183 | } |
|---|
| .. | .. |
|---|
| 14 | 14 | JTextField entry; |
|---|
| 15 | 15 | JCheckBox invert; |
|---|
| 16 | 16 | |
|---|
| 17 | | - public SearchPanel(TFModel model, final FilterControlPanel f) { |
|---|
| 17 | + public SearchPanel(TimeflowModel model, final FilterControlPanel f) { |
|---|
| 18 | 18 | super(model); |
|---|
| 19 | 19 | setBackground(Color.white); |
|---|
| 20 | 20 | setBorder(BorderFactory.createEmptyBorder(15, 5,0,0)); |
|---|
| .. | .. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | import timeflow.data.db.filter.ActFilter; |
|---|
| 6 | 6 | |
|---|
| 7 | | -public interface ActDB extends Iterable<Act> { |
|---|
| 8 | | - |
|---|
| 7 | +public interface ActDB extends Iterable<Act> |
|---|
| 8 | +{ |
|---|
| 9 | + // Source |
|---|
| 9 | 10 | public String getSource(); |
|---|
| 10 | 11 | public String getDescription(); |
|---|
| 11 | 12 | public void setSource(String source); |
|---|
| 12 | 13 | public void setDescription(String description); |
|---|
| 13 | | - |
|---|
| 14 | + |
|---|
| 15 | + // Fields |
|---|
| 14 | 16 | public List<String> getFieldKeys(); |
|---|
| 15 | 17 | public List<Field> getFields(); |
|---|
| 16 | 18 | public List<Field> getFields(Class type); |
|---|
| .. | .. |
|---|
| 21 | 23 | public void setNewFieldOrder(List<Field> newOrder); |
|---|
| 22 | 24 | public void renameField(Field field, String name); |
|---|
| 23 | 25 | |
|---|
| 26 | + // Acts |
|---|
| 24 | 27 | public void delete(Act act); |
|---|
| 25 | 28 | public Act createAct(); |
|---|
| 26 | 29 | public ActList select(ActFilter filter); |
|---|
| .. | .. |
|---|
| 1 | 1 | package timeflow.data.db; |
|---|
| 2 | 2 | |
|---|
| 3 | +public class Field |
|---|
| 4 | +{ |
|---|
| 3 | 5 | |
|---|
| 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; |
|---|
| 26 | 10 | |
|---|
| 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 | + } |
|---|
| 35 | 16 | |
|---|
| 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 | + } |
|---|
| 45 | 23 | |
|---|
| 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 | + } |
|---|
| 50 | 53 | } |
|---|
| .. | .. |
|---|
| 3 | 3 | import java.util.Calendar; |
|---|
| 4 | 4 | import java.util.Date; |
|---|
| 5 | 5 | |
|---|
| 6 | | -public class RoughTime implements Comparable { |
|---|
| 6 | +public class RoughTime implements Comparable |
|---|
| 7 | +{ |
|---|
| 7 | 8 | |
|---|
| 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; |
|---|
| 96 | 12 | |
|---|
| 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 | + } |
|---|
| 122 | 23 | |
|---|
| 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 | + } |
|---|
| 127 | 28 | |
|---|
| 29 | + public long getTime() |
|---|
| 30 | + { |
|---|
| 31 | + return time; |
|---|
| 32 | + } |
|---|
| 128 | 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 | + { |
|---|
| 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 | + } |
|---|
| 129 | 143 | } |
|---|
| .. | .. |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | public class TimeUnit |
|---|
| 7 | 7 | { |
|---|
| 8 | | - |
|---|
| 9 | 8 | public static final TimeUnit YEAR = new TimeUnit("Years", Calendar.YEAR, 365 * 24 * 60 * 60 * 1000L, "yyyy", "yyyy"); |
|---|
| 10 | 9 | public static final TimeUnit MONTH = new TimeUnit("Months", Calendar.MONTH, 30 * 24 * 60 * 60 * 1000L, "MMM", "MMM yyyy"); |
|---|
| 11 | 10 | public static final TimeUnit WEEK = new TimeUnit("Weeks", Calendar.WEEK_OF_YEAR, 7 * 24 * 60 * 60 * 1000L, "d", "MMM d yyyy"); |
|---|
| 12 | 11 | public static final TimeUnit DAY = new TimeUnit("Days", Calendar.DAY_OF_MONTH, 24 * 60 * 60 * 1000L, "d", "MMM d yyyy"); |
|---|
| 13 | 12 | 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 | + |
|---|
| 17 | 18 | public static final TimeUnit DECADE = multipleYears(10); |
|---|
| 18 | 19 | public static final TimeUnit CENTURY = multipleYears(100); |
|---|
| 19 | 20 | private static final double DAY_SIZE = 24 * 60 * 60 * 1000L; |
|---|
| .. | .. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | import timeflow.data.time.*; |
|---|
| 6 | 6 | |
|---|
| 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; |
|---|
| 23 | 13 | |
|---|
| 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 | + } |
|---|
| 30 | 18 | |
|---|
| 19 | + void note(String s) |
|---|
| 20 | + { |
|---|
| 21 | + add(scoreFormatMatch(s)); |
|---|
| 22 | + } |
|---|
| 31 | 23 | |
|---|
| 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 | + } |
|---|
| 64 | 68 | } |
|---|
| .. | .. |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | public interface Export { |
|---|
| 8 | 8 | public String getName(); |
|---|
| 9 | | - public void export(TFModel model, BufferedWriter out) throws Exception; |
|---|
| 9 | + public void export(TimeflowModel model, BufferedWriter out) throws Exception; |
|---|
| 10 | 10 | } |
|---|
| .. | .. |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | public class HtmlFormat implements Export |
|---|
| 11 | 11 | { |
|---|
| 12 | | - TFModel model; |
|---|
| 12 | + TimeflowModel model; |
|---|
| 13 | 13 | java.util.List<Field> fields; |
|---|
| 14 | 14 | Field title; |
|---|
| 15 | 15 | |
|---|
| .. | .. |
|---|
| 17 | 17 | { |
|---|
| 18 | 18 | } |
|---|
| 19 | 19 | |
|---|
| 20 | | - public HtmlFormat(TFModel model) |
|---|
| 20 | + public HtmlFormat(TimeflowModel model) |
|---|
| 21 | 21 | { |
|---|
| 22 | 22 | setModel(model); |
|---|
| 23 | 23 | } |
|---|
| 24 | 24 | |
|---|
| 25 | | - public void setModel(TFModel model) |
|---|
| 25 | + public void setModel(TimeflowModel model) |
|---|
| 26 | 26 | { |
|---|
| 27 | 27 | this.model = model; |
|---|
| 28 | 28 | fields = model.getDB().getFields(); |
|---|
| .. | .. |
|---|
| 30 | 30 | } |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | @Override |
|---|
| 33 | | - public void export(TFModel model, BufferedWriter out) throws Exception |
|---|
| 33 | + public void export(TimeflowModel model, BufferedWriter out) throws Exception |
|---|
| 34 | 34 | { |
|---|
| 35 | 35 | setModel(model); |
|---|
| 36 | 36 | out.write(makeHeader()); |
|---|
| .. | .. |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | public class TimeflowFormat implements Import, Export |
|---|
| 15 | 15 | { |
|---|
| 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 | | - |
|---|
| 29 | 16 | |
|---|
| 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. ====="; |
|---|
| 38 | 19 | |
|---|
| 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 | + } |
|---|
| 148 | 24 | |
|---|
| 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(); |
|---|
| 153 | 30 | |
|---|
| 154 | | - @Override |
|---|
| 155 | | - public ActDB importFile(File file) throws Exception { |
|---|
| 156 | | - return read(file, System.out); |
|---|
| 157 | | - } |
|---|
| 158 | 31 | |
|---|
| 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 | + } |
|---|
| 163 | 180 | } |
|---|
| .. | .. |
|---|
| 360 | 360 | return lines; |
|---|
| 361 | 361 | } |
|---|
| 362 | 362 | |
|---|
| 363 | | - public boolean emptyMessage(Graphics g, TFModel model) |
|---|
| 363 | + public boolean emptyMessage(Graphics g, TimeflowModel model) |
|---|
| 364 | 364 | { |
|---|
| 365 | 365 | if (model.getActs() == null || model.getActs().size() == 0) |
|---|
| 366 | 366 | { |
|---|
| .. | .. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | public abstract class ModelPanel extends JPanel implements TFListener { |
|---|
| 6 | 6 | |
|---|
| 7 | | - TFModel model; |
|---|
| 7 | + TimeflowModel model; |
|---|
| 8 | 8 | |
|---|
| 9 | | - public ModelPanel(TFModel model) |
|---|
| 9 | + public ModelPanel(TimeflowModel model) |
|---|
| 10 | 10 | { |
|---|
| 11 | 11 | this.model=model; |
|---|
| 12 | 12 | } |
|---|
| .. | .. |
|---|
| 26 | 26 | model.removeListener(this); |
|---|
| 27 | 27 | } |
|---|
| 28 | 28 | |
|---|
| 29 | | - public TFModel getModel() |
|---|
| 29 | + public TimeflowModel getModel() |
|---|
| 30 | 30 | { |
|---|
| 31 | 31 | return model; |
|---|
| 32 | 32 | } |
|---|
| .. | .. |
|---|
| 1 | 1 | package timeflow.model; |
|---|
| 2 | 2 | |
|---|
| 3 | | -public interface TFListener { |
|---|
| 4 | | - public void note(TFEvent e); |
|---|
| 3 | +public interface TFListener |
|---|
| 4 | +{ |
|---|
| 5 | + public void note(TFEvent e); |
|---|
| 5 | 6 | } |
|---|
similarity index 99%rename from timeflow/model/TFModel.javarename to timeflow/model/TimeflowModel.java| .. | .. |
|---|
| 10 | 10 | // encapsulates all properties of a timeline model: |
|---|
| 11 | 11 | // data, display properties, etc. |
|---|
| 12 | 12 | // also does listening, etc. |
|---|
| 13 | | -public class TFModel |
|---|
| 13 | +public class TimeflowModel |
|---|
| 14 | 14 | { |
|---|
| 15 | | - |
|---|
| 16 | 15 | private ActDB db; |
|---|
| 17 | 16 | private ActList acts; |
|---|
| 18 | 17 | private ActFilter filter = new ConstFilter(true); |
|---|
| .. | .. |
|---|
| 15 | 15 | JPanel panel; |
|---|
| 16 | 16 | ActDB lastDrawn, lastNotified; |
|---|
| 17 | 17 | |
|---|
| 18 | | - public AbstractView(TFModel model) |
|---|
| 18 | + public AbstractView(TimeflowModel model) |
|---|
| 19 | 19 | { |
|---|
| 20 | 20 | super(model); |
|---|
| 21 | 21 | } |
|---|
| .. | .. |
|---|
| 45 | 45 | }; |
|---|
| 46 | 46 | controlLabel.setBackground(Color.lightGray); |
|---|
| 47 | 47 | controlLabel.setForeground(Color.darkGray); |
|---|
| 48 | | - panel.add(controlLabel, BorderLayout.NORTH); |
|---|
| 48 | + //panel.add(controlLabel, BorderLayout.NORTH); |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | return panel; |
|---|
| 51 | 51 | } |
|---|
| .. | .. |
|---|
| 22 | 22 | Point mouse = new Point(-10000, 0), firstMouse = new Point(); |
|---|
| 23 | 23 | boolean mouseIsDown; |
|---|
| 24 | 24 | ArrayList<Mouseover> objectLocations = new ArrayList<Mouseover>(); |
|---|
| 25 | | - TFModel model; |
|---|
| 25 | + TimeflowModel model; |
|---|
| 26 | 26 | Act selectedAct; |
|---|
| 27 | 27 | RoughTime selectedTime; |
|---|
| 28 | 28 | Set<JMenuItem> urlItems = new HashSet<JMenuItem>(); |
|---|
| 29 | 29 | |
|---|
| 30 | | - public AbstractVisualizationView(TFModel model) |
|---|
| 30 | + public AbstractVisualizationView(TimeflowModel model) |
|---|
| 31 | 31 | { |
|---|
| 32 | 32 | this.model = model; |
|---|
| 33 | 33 | |
|---|
| .. | .. |
|---|
| 176 | 176 | return null; |
|---|
| 177 | 177 | } |
|---|
| 178 | 178 | |
|---|
| 179 | | - public TFModel getModel() |
|---|
| 179 | + public TimeflowModel getModel() |
|---|
| 180 | 180 | { |
|---|
| 181 | 181 | return model; |
|---|
| 182 | 182 | } |
|---|
| .. | .. |
|---|
| 28 | 28 | Aggregate agg; |
|---|
| 29 | 29 | JComboBox splitFieldChoice, numFieldChoice; |
|---|
| 30 | 30 | |
|---|
| 31 | | - public BarGraphView(TFModel model) |
|---|
| 31 | + public BarGraphView(TimeflowModel model) |
|---|
| 32 | 32 | { |
|---|
| 33 | 33 | super(model); |
|---|
| 34 | 34 | |
|---|
| .. | .. |
|---|
| 55 | 55 | int ch = 25, pad = 5, cw = 160; |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | controls.removeAll(); |
|---|
| 58 | | - TFModel model = getModel(); |
|---|
| 58 | + TimeflowModel model = getModel(); |
|---|
| 59 | 59 | if (model.getDB() == null || model.getDB().size() == 0) |
|---|
| 60 | 60 | { |
|---|
| 61 | 61 | JLabel empty = new JLabel("Empty database"); |
|---|
| .. | .. |
|---|
| 267 | 267 | int w = getSize().width, h = getSize().height; |
|---|
| 268 | 268 | g.setColor(Color.white); |
|---|
| 269 | 269 | g.fillRect(0, 0, w, h); |
|---|
| 270 | | - TFModel model = getModel(); |
|---|
| 270 | + TimeflowModel model = getModel(); |
|---|
| 271 | 271 | Display display = model.getDisplay(); |
|---|
| 272 | 272 | |
|---|
| 273 | 273 | if (display.emptyMessage(g, model)) |
|---|
| .. | .. |
|---|
| 32 | 32 | return controls; |
|---|
| 33 | 33 | } |
|---|
| 34 | 34 | |
|---|
| 35 | | - public CalendarView(TFModel model) |
|---|
| 35 | + public CalendarView(TimeflowModel model) |
|---|
| 36 | 36 | { |
|---|
| 37 | 37 | super(model); |
|---|
| 38 | 38 | calendarPanel=new CalendarPanel(model); |
|---|
| .. | .. |
|---|
| 276 | 276 | class CalendarPanel extends AbstractVisualizationView |
|---|
| 277 | 277 | { |
|---|
| 278 | 278 | |
|---|
| 279 | | - CalendarPanel(TFModel model) |
|---|
| 279 | + CalendarPanel(TimeflowModel model) |
|---|
| 280 | 280 | { |
|---|
| 281 | 281 | super(model); |
|---|
| 282 | 282 | setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 14 | 14 | JTextArea content; |
|---|
| 15 | 15 | JComponent controls; |
|---|
| 16 | 16 | |
|---|
| 17 | | - public DescriptionView(TFModel model) { |
|---|
| 17 | + public DescriptionView(TimeflowModel model) { |
|---|
| 18 | 18 | super(model); |
|---|
| 19 | 19 | setLayout(new BorderLayout()); |
|---|
| 20 | 20 | JPanel left=new Pad(5,5); |
|---|
| .. | .. |
|---|
| 34 | 34 | Image image; |
|---|
| 35 | 35 | Image repeat; |
|---|
| 36 | 36 | |
|---|
| 37 | | - public IntroView(TFModel model) |
|---|
| 37 | + public IntroView(TimeflowModel model) |
|---|
| 38 | 38 | { |
|---|
| 39 | 39 | super(model); |
|---|
| 40 | 40 | setBackground(Color.white); |
|---|
| .. | .. |
|---|
| 35 | 35 | private boolean changing = false; |
|---|
| 36 | 36 | private JPanel controls; |
|---|
| 37 | 37 | |
|---|
| 38 | | - public ListView(TFModel model) |
|---|
| 38 | + public ListView(TimeflowModel model) |
|---|
| 39 | 39 | { |
|---|
| 40 | 40 | super(model); |
|---|
| 41 | 41 | |
|---|
| .. | .. |
|---|
| 27 | 27 | private Interval range; |
|---|
| 28 | 28 | private JComponent controls; |
|---|
| 29 | 29 | |
|---|
| 30 | | - public SummaryView(TFModel model) |
|---|
| 30 | + public SummaryView(TimeflowModel model) |
|---|
| 31 | 31 | { |
|---|
| 32 | 32 | super(model); |
|---|
| 33 | 33 | analysisDisplay = HtmlDisplay.create(); |
|---|
| .. | .. |
|---|
| 23 | 23 | private boolean editable=true; |
|---|
| 24 | 24 | private JPanel controls; |
|---|
| 25 | 25 | |
|---|
| 26 | | - public TableView(TFModel model) |
|---|
| 26 | + public TableView(TimeflowModel model) |
|---|
| 27 | 27 | { |
|---|
| 28 | 28 | super(model); |
|---|
| 29 | 29 | |
|---|
| .. | .. |
|---|
| 37 | 37 | return controls; |
|---|
| 38 | 38 | } |
|---|
| 39 | 39 | |
|---|
| 40 | | - public TimelineView(TFModel model) |
|---|
| 40 | + public TimelineView(TimeflowModel model) |
|---|
| 41 | 41 | { |
|---|
| 42 | 42 | super(model); |
|---|
| 43 | 43 | visuals = new TimelineVisuals(model); |
|---|
| .. | .. |
|---|
| 65 | 65 | bottom.add(slider, BorderLayout.CENTER); |
|---|
| 66 | 66 | |
|---|
| 67 | 67 | controls = new JPanel(); |
|---|
| 68 | | - controls.setBackground(Color.white); |
|---|
| 68 | + controls.setBackground(Color.red); |
|---|
| 69 | 69 | controls.setLayout(new BorderLayout());//new GridLayout(2,1)); |
|---|
| 70 | 70 | |
|---|
| 71 | 71 | // top part of grid: zoom buttons. |
|---|
| .. | .. |
|---|
| 123 | 123 | moveTime(visuals.getFitToVisibleRange()); |
|---|
| 124 | 124 | }}); |
|---|
| 125 | 125 | */ |
|---|
| 126 | | - controls.add(buttons, BorderLayout.NORTH); |
|---|
| 126 | + controls.add(buttons, BorderLayout.SOUTH); |
|---|
| 127 | 127 | |
|---|
| 128 | 128 | // ok, now do second part of grid: layout style buttons. |
|---|
| 129 | 129 | ComponentCluster layoutPanel = new ComponentCluster("Layout"); |
|---|
| .. | .. |
|---|
| 151 | 151 | graph.addActionListener(new LayoutSetter(TimelineVisuals.Layout.GRAPH)); |
|---|
| 152 | 152 | layoutGroup.add(graph); |
|---|
| 153 | 153 | |
|---|
| 154 | | - controls.add(layoutPanel, BorderLayout.CENTER); |
|---|
| 154 | + //controls.add(layoutPanel, BorderLayout.CENTER); |
|---|
| 155 | 155 | } |
|---|
| 156 | 156 | |
|---|
| 157 | 157 | class LayoutSetter implements ActionListener |
|---|
| .. | .. |
|---|
| 325 | 325 | |
|---|
| 326 | 326 | class TimelinePanel extends AbstractVisualizationView |
|---|
| 327 | 327 | { |
|---|
| 328 | | - public TimelinePanel(TFModel model) |
|---|
| 328 | + public TimelinePanel(TimeflowModel model) |
|---|
| 329 | 329 | { |
|---|
| 330 | 330 | super(model); |
|---|
| 331 | 331 | |
|---|
| .. | .. |
|---|
| 10 | 10 | import timeflow.data.db.ActDB; |
|---|
| 11 | 11 | import timeflow.data.db.ActList; |
|---|
| 12 | 12 | import timeflow.data.db.Field; |
|---|
| 13 | | -import timeflow.model.TFModel; |
|---|
| 13 | +import timeflow.model.TimeflowModel; |
|---|
| 14 | 14 | import timeflow.model.VirtualField; |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | public class VisualActFactory |
|---|
| .. | .. |
|---|
| 60 | 60 | return list; |
|---|
| 61 | 61 | } |
|---|
| 62 | 62 | |
|---|
| 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) |
|---|
| 64 | 64 | { |
|---|
| 65 | 65 | // Does everything fit? Because, if so, we're already good to go. |
|---|
| 66 | 66 | int area = bounds.width * bounds.height; |
|---|
| .. | .. |
|---|
| 9 | 9 | public class VisualEncoder |
|---|
| 10 | 10 | { |
|---|
| 11 | 11 | |
|---|
| 12 | | - private TFModel model; |
|---|
| 12 | + private TimeflowModel model; |
|---|
| 13 | 13 | private java.util.List<VisualAct> visualActs = new ArrayList<VisualAct>(); |
|---|
| 14 | 14 | private double maxSize = 0; |
|---|
| 15 | 15 | |
|---|
| 16 | | - public VisualEncoder(TFModel model) |
|---|
| 16 | + public VisualEncoder(TimeflowModel model) |
|---|
| 17 | 17 | { |
|---|
| 18 | 18 | this.model = model; |
|---|
| 19 | 19 | } |
|---|
| .. | .. |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | public class CalendarVisuals { |
|---|
| 13 | 13 | VisualEncoder encoder; |
|---|
| 14 | | - TFModel model; |
|---|
| 14 | + TimeflowModel model; |
|---|
| 15 | 15 | Rectangle bounds=new Rectangle(); |
|---|
| 16 | 16 | public Grid grid; |
|---|
| 17 | 17 | |
|---|
| .. | .. |
|---|
| 24 | 24 | public enum FitStyle {LOOSE, TIGHT}; |
|---|
| 25 | 25 | FitStyle fitStyle=FitStyle.LOOSE; |
|---|
| 26 | 26 | |
|---|
| 27 | | - public CalendarVisuals(TFModel model) |
|---|
| 27 | + public CalendarVisuals(TimeflowModel model) |
|---|
| 28 | 28 | { |
|---|
| 29 | 29 | this.model=model; |
|---|
| 30 | 30 | encoder=new VisualEncoder(model); |
|---|
| .. | .. |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | public void render(Graphics2D g, Collection<Mouseover> objectLocations) |
|---|
| 22 | 22 | { |
|---|
| 23 | | - TFModel model = visuals.getModel(); |
|---|
| 23 | + TimeflowModel model = visuals.getModel(); |
|---|
| 24 | 24 | g.setColor(model.getDisplay().getColor("chart.background")); |
|---|
| 25 | 25 | Rectangle bounds = visuals.getBounds(); |
|---|
| 26 | 26 | |
|---|
| .. | .. |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | void render(AxisTicMarks t, Graphics2D g, int x, int y, int h, int top, boolean full, Collection<Mouseover> objectLocations) |
|---|
| 43 | 43 | { |
|---|
| 44 | | - TFModel model = visuals.getModel(); |
|---|
| 44 | + TimeflowModel model = visuals.getModel(); |
|---|
| 45 | 45 | |
|---|
| 46 | 46 | int n = t.tics.size(); |
|---|
| 47 | 47 | for (int i = 0; i < n - 1; i++) |
|---|
| .. | .. |
|---|
| 36 | 36 | g.setTransform(AffineTransform.getTranslateInstance(0, -dy)); |
|---|
| 37 | 37 | |
|---|
| 38 | 38 | g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
|---|
| 39 | | - TFModel model = visuals.getModel(); |
|---|
| 39 | + TimeflowModel model = visuals.getModel(); |
|---|
| 40 | 40 | Display display = model.getDisplay(); |
|---|
| 41 | 41 | ActDB db = model.getDB(); |
|---|
| 42 | 42 | |
|---|
| .. | .. |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | public enum Layout |
|---|
| 30 | 30 | { |
|---|
| 31 | | - |
|---|
| 32 | 31 | TIGHT, LOOSE, GRAPH |
|---|
| 33 | 32 | }; |
|---|
| 33 | + |
|---|
| 34 | 34 | private Layout layoutStyle = Layout.TIGHT; |
|---|
| 35 | 35 | private VisualEncoder encoder; |
|---|
| 36 | | - private TFModel model; |
|---|
| 36 | + private TimeflowModel model; |
|---|
| 37 | 37 | private int fullHeight; |
|---|
| 38 | 38 | |
|---|
| 39 | 39 | public int getFullHeight() |
|---|
| .. | .. |
|---|
| 41 | 41 | return fullHeight; |
|---|
| 42 | 42 | } |
|---|
| 43 | 43 | |
|---|
| 44 | | - public TimelineVisuals(TFModel model) |
|---|
| 44 | + public TimelineVisuals(TimeflowModel model) |
|---|
| 45 | 45 | { |
|---|
| 46 | 46 | this.model = model; |
|---|
| 47 | 47 | encoder = new VisualEncoder(model); |
|---|
| .. | .. |
|---|
| 224 | 224 | layout(); |
|---|
| 225 | 225 | } |
|---|
| 226 | 226 | |
|---|
| 227 | | - public TFModel getModel() |
|---|
| 227 | + public TimeflowModel getModel() |
|---|
| 228 | 228 | { |
|---|
| 229 | 229 | return model; |
|---|
| 230 | 230 | } |
|---|