Changeset 88 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder
- Timestamp:
- 08/28/2017 01:17:11 PM (9 years ago)
- Location:
- trunk/src/scriptbuilder/gui/panels
- Files:
-
- 2 edited
-
IncidentTimelinePanel.java (modified) (4 diffs)
-
OverviewWinSpike.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java
r79 r88 7 7 import java.awt.Graphics; 8 8 import java.awt.Graphics2D; 9 import java.awt.event.ActionEvent; 10 import java.awt.event.ActionListener; 9 11 import java.awt.event.MouseEvent; 10 12 import java.io.File; … … 12 14 import java.util.Map; 13 15 import javax.swing.JFrame; 16 import javax.swing.JMenuItem; 17 import javax.swing.JOptionPane; 14 18 import javax.swing.JPanel; 19 import javax.swing.JPopupMenu; 15 20 import javax.swing.event.MouseInputAdapter; 16 21 import scriptbuilder.gui.IncidentEditorFrame; … … 95 100 } 96 101 102 /* 103 * Popup menu for incident actions 104 */ 105 private JPopupMenu createPopup() 106 { 107 JPopupMenu menu = new JPopupMenu(); 108 JMenuItem eventsMenuItem = new JMenuItem("Events"); 109 JMenuItem propsMenuItem = new JMenuItem("Properties"); 110 JMenuItem deleteMenuItem = new JMenuItem("Delete"); 111 eventsMenuItem.setActionCommand("Edit Events"); 112 propsMenuItem.setActionCommand("Modify Incident Properties"); 113 deleteMenuItem.setActionCommand("Delete Incident"); 114 115 PopupMenuItemListener menuItemListener = new PopupMenuItemListener(); 116 117 eventsMenuItem.addActionListener(menuItemListener); 118 propsMenuItem.addActionListener(menuItemListener); 119 deleteMenuItem.addActionListener(menuItemListener); 120 121 menu.add(eventsMenuItem); 122 menu.add(propsMenuItem); 123 menu.add(deleteMenuItem); 124 return menu; 125 } 126 127 class PopupMenuItemListener implements ActionListener 128 { 129 130 public void actionPerformed(ActionEvent e) 131 { 132 JOptionPane.showMessageDialog(null, e.getActionCommand() + " will be handled here."); 133 } 134 } 135 @Override 136 public void mousePressed(MouseEvent e) 137 { 138 int currentMouseX = e.getX(); 139 int currentMouseY = e.getY(); 140 141 // Does user want a popup menu? 142 if (e.isPopupTrigger()) 143 { 144 JPopupMenu popup = createPopup(); 145 popup.show(e.getComponent(), currentMouseX, currentMouseY); 146 } 147 } 97 148 /** 98 149 * Determine if the mouse click happened within a valid timeSlice on … … 118 169 x = cursorTime = e.getX(); 119 170 y = e.getY(); 120 171 121 172 if (e.getX() % ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 122 173 > ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK / 2) -
trunk/src/scriptbuilder/gui/panels/OverviewWinSpike.java
r86 r88 2 2 3 3 import java.awt.BorderLayout; 4 import java.awt.Color; 5 import java.awt.Component; 6 import java.awt.FlowLayout; 7 import java.awt.GridLayout; 4 8 import java.io.File; 9 import javax.swing.BorderFactory; 10 import javax.swing.Box; 5 11 import javax.swing.BoxLayout; 6 12 import javax.swing.JFrame; … … 31 37 32 38 TimelineTickPanel pnl = new TimelineTickPanel(); 33 pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS)); 39 //pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS)); 40 //pnl.setLayout(new FlowLayout()); 41 pnl.setLayout(new BorderLayout()); 34 42 // Create a script 35 43 File inFile = new File("test/scriptbuilder/structures/test_input_file.xml"); … … 37 45 script.loadScriptFromFile(inFile); 38 46 ScriptIncident incident = script.incidents.get(2); 47 39 48 IncidentNumberPanel inciNum = new IncidentNumberPanel(); 40 49 inciNum.update(incident); 41 JPanel row1 = new JPanel(); 42 row1.setOpaque(false); // so tick lines will show through 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); 43 61 //row1.setSize(200, 500); 44 row1.add(inciNum); 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 45 70 RangeSlider slider = new RangeSlider(0,25); 46 71 slider.setValue(5); 47 72 slider.setUpperValue(10); 48 row1.add(slider); 49 pnl.add(row1); 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 50 87 // update this panel with the script 51 88 pnl.update(script);
Note: See TracChangeset
for help on using the changeset viewer.
