source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/gui/panels/OverviewWinSpike.java @ 88

Revision 88, 3.1 KB checked in by jdalbey, 9 years ago (diff)

IncidentTimelinePanel?.java: Added right-click context menu ("popup") with stubbed out functionality.

Line 
1package scriptbuilder.gui.panels;
2
3import java.awt.BorderLayout;
4import java.awt.Color;
5import java.awt.Component;
6import java.awt.FlowLayout;
7import java.awt.GridLayout;
8import java.io.File;
9import javax.swing.BorderFactory;
10import javax.swing.Box;
11import javax.swing.BoxLayout;
12import javax.swing.JFrame;
13import javax.swing.JPanel;
14import scriptbuilder.gui.drawers.RangeSlider;
15import scriptbuilder.structures.ScriptIncident;
16import scriptbuilder.structures.SimulationScript;
17
18/**
19 * Exploration (spike) for Overview Window.
20 * The background is a TimelineTickPanel.
21 * IncidentTimelinePanel objects sit over it.
22 * @author jdalbey
23 */
24public class OverviewWinSpike 
25{
26    /**
27     * Local main for viewing this panel only.
28     *
29     * @author jdalbey
30     * @param args not used
31     */
32    public static void main(String[] args)
33    {
34        JFrame frame = new JFrame("Overview Window Spike");
35
36        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
37
38        TimelineTickPanel pnl = new TimelineTickPanel();
39        //pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS));
40        //pnl.setLayout(new FlowLayout());
41        pnl.setLayout(new BorderLayout());
42        // Create a script
43        File inFile = new File("test/scriptbuilder/structures/test_input_file.xml");
44        SimulationScript script = new SimulationScript();
45        script.loadScriptFromFile(inFile);
46        ScriptIncident incident = script.incidents.get(2);
47       
48        IncidentNumberPanel inciNum = new IncidentNumberPanel();
49        inciNum.update(incident);
50        // Create yellow border during development for easy visualization
51        inciNum.setBorder(BorderFactory.createLineBorder(Color.yellow)); 
52
53        IncidentNumberPanel inciNum2 = new IncidentNumberPanel();
54        inciNum2.update(script.incidents.get(3));
55        //inciNum2.setSize(100,200);
56       
57        //Box col1 = new Box(BoxLayout.PAGE_AXIS);
58        JPanel col1 = new JPanel(new GridLayout(9,1));
59        col1.setOpaque(false);  // so tick lines will show throughut
60        col1.setAlignmentX(Component.LEFT_ALIGNMENT);
61        //row1.setSize(200, 500);
62        col1.add(inciNum);
63        col1.add(inciNum2);
64        col1.add(Box.createVerticalGlue());
65       
66        Box col2 = new Box(BoxLayout.PAGE_AXIS);
67        col2.setOpaque(false);  // so tick lines will show throughut
68        col2.setAlignmentX(Component.LEFT_ALIGNMENT);
69       
70        RangeSlider slider = new RangeSlider(0,25);
71        slider.setValue(5);
72        slider.setUpperValue(10);
73        slider.setAlignmentX(Component.LEFT_ALIGNMENT);
74        RangeSlider slider2 = new RangeSlider(0,25);
75        slider2.setValue(5);
76        slider2.setUpperValue(10);
77        slider2.setAlignmentX(Component.LEFT_ALIGNMENT);
78       
79        col2.add(Box.createVerticalStrut(50));
80        col2.add(slider);
81        col2.add(Box.createVerticalStrut(50));
82        col2.add(slider2);
83
84        pnl.add(col1, BorderLayout.LINE_START);
85        pnl.add(col2, BorderLayout.CENTER);
86       
87        // update this panel with the script
88        pnl.update(script);
89        frame.getContentPane().add(pnl, BorderLayout.CENTER);
90        frame.pack();
91
92        frame.setVisible(true);
93
94    }
95}
Note: See TracBrowser for help on using the repository browser.