Changeset 54 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels/TimelineTickPanel.java
- Timestamp:
- 08/09/2017 04:12:39 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
