Changeset 54 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels
- Timestamp:
- 08/09/2017 04:12:39 PM (9 years ago)
- Location:
- trunk/src/scriptbuilder/gui/panels
- Files:
-
- 3 edited
-
ScriptBuilderTimelinePanel.java (modified) (4 diffs)
-
TimeStampPanel.java (modified) (1 diff)
-
TimelineTickPanel.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/gui/panels/ScriptBuilderTimelinePanel.java
r53 r54 11 11 import javax.swing.JPanel; 12 12 import javax.swing.event.MouseInputAdapter; 13 import scriptbuilder.gui.IncidentEditorFrame; 13 14 import scriptbuilder.gui.ScriptBuilderFrame; 14 15 import scriptbuilder.gui.ScriptBuilderGuiConstants; … … 100 101 { 101 102 Editor ed = new Editor(); 102 ScriptBuilderFrame f = (ScriptBuilderFrame) getTopLevelAncestor(); 103 ScriptBuilderFrame f = null; 104 IncidentEditorFrame g = null; 105 if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 106 { 107 f = (ScriptBuilderFrame) getTopLevelAncestor(); 108 } 109 else if (getTopLevelAncestor() instanceof IncidentEditorFrame) 110 { 111 g = (IncidentEditorFrame) getTopLevelAncestor(); 112 } 103 113 104 114 x = cursorTime = e.getX(); … … 142 152 if (e.getButton() == MouseEvent.BUTTON1) 143 153 { 144 if (f.currentEventType != null) 145 { 146 I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 147 ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 148 if (incident.slices.get(newSlice) == null) 154 if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 155 { 156 if (f.currentEventType != null) 149 157 { 150 incident.addNewEvent(s, newSlice); 158 I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 159 ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 160 if (incident.slices.get(newSlice) == null) 161 { 162 incident.addNewEvent(s, newSlice); 163 } 164 else 165 { 166 incident.slices.get(newSlice).addEvent(s); 167 } 168 f.update(f.getScript(), f.getScript()); 151 169 } 152 else 170 } 171 if (getTopLevelAncestor() instanceof IncidentEditorFrame) 172 { 173 if (g.currentEventType != null) 153 174 { 154 incident.slices.get(newSlice).addEvent(s); 175 I_ScriptEvent s = ScriptEvent.factoryByType(g.currentEventType); 176 ed.addProperty(eventTypeToPropertyMap.get(g.currentEventType), s); 177 if (incident.slices.get(newSlice) == null) 178 { 179 incident.addNewEvent(s, newSlice); 180 } 181 else 182 { 183 incident.slices.get(newSlice).addEvent(s); 184 } 185 g.update(null, g.getIncident()); 155 186 } 156 f.update(f.getScript(), f.getScript());157 187 } 158 188 } … … 294 324 295 325 Graphics2D g2d = (Graphics2D) g; 296 IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 326 if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 327 { 328 IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 329 } 330 if (getTopLevelAncestor() instanceof IncidentEditorFrame) 331 { 332 IncidentTimelineDrawer.DrawIncidentTimeline(g2d, incident, false); 333 } 297 334 298 335 if (focused) 299 336 { 300 337 CursorDrawer.DrawCursor(g2d, cursorTime, false); 301 if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 302 { 303 EventIconDrawer.DrawEventIcon(g2d, 304 ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 305 x + 5, y + 10); 338 if (this.getTopLevelAncestor() instanceof ScriptBuilderFrame) 339 { 340 if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 341 { 342 EventIconDrawer.DrawEventIcon(g2d, 343 ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 344 x + 5, y + 10); 345 } 346 } 347 if (this.getTopLevelAncestor() instanceof IncidentEditorFrame) 348 { 349 if (((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType != null) 350 { 351 EventIconDrawer.DrawEventIcon(g2d, 352 ((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType, 353 x + 5, y + 10); 354 } 306 355 } 307 356 } -
trunk/src/scriptbuilder/gui/panels/TimeStampPanel.java
r1 r54 89 89 90 90 /** 91 * Update the length interval and the dimensions of the panel. NOTE: This 92 * method implementation is an exact duplication of the update method in 93 * panels.TimelineTickPanel. I'm not sure if it actually accomplishes 94 * anything here. 95 * 96 * @param script The simulation script model 97 */ 98 public void update(ScriptIncident incident) 99 { 100 longestLength = ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH; 101 102 // Get the stats on the incidents 103 int height = ScriptBuilderGuiConstants.TICK_TOP_MARGIN * 4; 104 if (incident != null) 105 { 106 height += incident.collapsed 107 ? ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT 108 : ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT; 109 if ((incident.length + incident.offset) > longestLength) 110 { 111 longestLength = incident.length + incident.offset; 112 } 113 } 114 115 if (incident != null && incident.number == 100) 116 { 117 incident.length = longestLength; 118 incident.offset = 0; 119 } 120 121 Dimension newSize = new Dimension(longestLength 122 / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 123 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 124 + ScriptBuilderGuiConstants.TICK_TIMELINE_LEFT_MARGIN + 50, 125 height); 126 this.setPreferredSize(newSize); 127 this.setSize(newSize); 128 129 this.invalidate(); 130 } 131 132 /** 91 133 * Refresh the panel. Draw the timestamps for the appropriate intervals 92 134 * based on zoom level. -
trunk/src/scriptbuilder/gui/panels/TimelineTickPanel.java
r31 r54 7 7 import javax.swing.JPanel; 8 8 import javax.swing.event.MouseInputAdapter; 9 import scriptbuilder.gui.IncidentEditorFrame; 9 10 import scriptbuilder.gui.ScriptBuilderFrame; 10 11 import scriptbuilder.gui.ScriptBuilderGuiConstants; … … 130 131 131 132 /** 133 * Update the panel's dimensions based on number of events, zoom level, and 134 * which events are collapsed. 135 * 136 * @param script The main script model 137 */ 138 public void update(ScriptIncident incident) 139 { 140 longestLength = ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH; 141 142 // Get the stats on the incidents 143 int height = ScriptBuilderGuiConstants.TICK_TOP_MARGIN * 4; 144 145 if (incident != null) 146 { 147 height += incident.collapsed 148 ? ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT 149 : ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT; 150 if ((incident.length + incident.offset) > longestLength) 151 { 152 longestLength = incident.length + incident.offset; 153 } 154 155 } 156 157 Dimension newSize = new Dimension(longestLength 158 / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 159 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 160 + ScriptBuilderGuiConstants.TICK_TIMELINE_LEFT_MARGIN + 50, 161 height); 162 this.setPreferredSize(newSize); 163 this.setSize(newSize); 164 165 this.invalidate(); 166 } 167 168 /** 132 169 * Refresh the panel. Redraw the ticks based on zoom level, panel 133 170 * dimensions, and offset. If the user is trying to add an event, draw that … … 182 219 paintChildren(g); 183 220 184 if (focused 185 && ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 186 { 187 EventIconDrawer.DrawEventIcon(g2d, 188 ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 189 x, y); 221 if (this.getTopLevelAncestor() instanceof ScriptBuilderFrame) 222 { 223 if (focused 224 && ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 225 { 226 EventIconDrawer.DrawEventIcon(g2d, 227 ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 228 x, y); 229 } 230 } 231 if (this.getTopLevelAncestor() instanceof IncidentEditorFrame) 232 { 233 if (focused 234 && ((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType != null) 235 { 236 EventIconDrawer.DrawEventIcon(g2d, 237 ((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType, 238 x, y); 239 } 190 240 } 191 241 }
Note: See TracChangeset
for help on using the changeset viewer.
