Changeset 53 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels
- Timestamp:
- 08/09/2017 10:03:37 AM (9 years ago)
- Location:
- trunk/src/scriptbuilder/gui/panels
- Files:
-
- 1 edited
- 3 copied
-
IncidentTimelineTickPanel.java (copied) (copied from trunk/src/scriptbuilder/gui/panels/TimelineTickPanel.java) (2 diffs)
-
IncidentsPanel.java (modified) (1 diff)
-
ScriptBuilderNumberPanel.java (copied) (copied from trunk/src/scriptbuilder/gui/panels/IncidentNumberPanel.java) (6 diffs)
-
ScriptBuilderTimelinePanel.java (copied) (copied from trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/gui/panels/IncidentTimelineTickPanel.java
r31 r53 21 21 * @author Bryan McGuffin 22 22 */ 23 public class TimelineTickPanel extends JPanel23 public class IncidentTimelineTickPanel extends JPanel 24 24 { 25 25 … … 82 82 * Constructor. Set up the mouse listener. 83 83 */ 84 public TimelineTickPanel()84 public IncidentTimelineTickPanel() 85 85 { 86 86 super(); -
trunk/src/scriptbuilder/gui/panels/IncidentsPanel.java
r1 r53 20 20 private SimulationScript script; 21 21 private TimelineTickPanel timelineTickPanel; 22 private List< IncidentTimelinePanel> incidentPanels;23 private List< IncidentNumberPanel> numberPanels;22 private List<ScriptBuilderTimelinePanel> incidentPanels; 23 private List<ScriptBuilderNumberPanel> numberPanels; 24 24 25 25 /** -
trunk/src/scriptbuilder/gui/panels/ScriptBuilderNumberPanel.java
r1 r53 26 26 * @author Bryan McGuffin 27 27 */ 28 public class IncidentNumberPanel extends JPanel28 public class ScriptBuilderNumberPanel extends JPanel 29 29 { 30 30 31 31 ScriptIncident incident; 32 32 boolean visible; 33 public boolean collapsed = false;34 private static Image collapseImage = null, expandImage = null;35 36 /**37 * Get the icon to use for the "collapse" button.38 *39 * @return Collapse.png40 */41 private static Image getCollapseImage()42 {43 if (collapseImage == null)44 {45 try46 {47 collapseImage = ImageIO.read(images.Images.getImage("Collapse.png"));48 }49 catch (IOException ex)50 {51 Logger.getLogger(IncidentNumberPanel.class.getName()).log(Level.SEVERE, null, ex);52 }53 }54 55 return collapseImage;56 }57 58 /**59 * Get the icon to use for the "expand" button.60 *61 * @return Expand.png62 */63 private static Image getExpandImage()64 {65 if (expandImage == null)66 {67 try68 {69 expandImage = ImageIO.read(images.Images.getImage("Expand.png"));70 }71 catch (IOException ex)72 {73 Logger.getLogger(IncidentNumberPanel.class.getName()).log(Level.SEVERE, null, ex);74 }75 }76 77 return expandImage;78 }79 33 80 34 /** … … 84 38 private class IncidentNumberMouseListener extends MouseInputAdapter 85 39 { 86 87 private final Shape collapseExpandButtonShape88 = new Rectangle(ScriptBuilderGuiConstants.COLLEX_BUTTON_X,89 ScriptBuilderGuiConstants.COLLEX_BUTTON_Y,90 ScriptBuilderGuiConstants.COLLEX_BUTTON_WIDTH,91 ScriptBuilderGuiConstants.COLLEX_BUTTON_HEIGHT);92 40 93 41 /** … … 100 48 public void mouseClicked(MouseEvent e) 101 49 { 102 if (collapseExpandButtonShape.contains(e.getX(), e.getY())) 103 { 104 incident.setCollapsed(!collapsed); 105 } 50 106 51 } 107 52 } … … 110 55 * Constructor. Sets up the mouse listener. 111 56 */ 112 public IncidentNumberPanel()57 public ScriptBuilderNumberPanel() 113 58 { 114 59 super(); … … 131 76 this.visible = incident != null; 132 77 133 if (incident != null)134 {135 this.collapsed = incident.collapsed;136 }137 138 78 Dimension newSize; 139 79 if (visible) 140 80 { 141 if (collapsed)142 {143 newSize = new Dimension(144 ScriptBuilderGuiConstants.INCIDENT_NUMBER_WIDTH,145 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT);146 }147 else148 {149 int mostEvents = 0;150 for (TimeSlice slice : incident.getSlices())151 {152 if (slice.events.size() > mostEvents)153 {154 mostEvents = slice.events.size();155 }156 }157 81 158 newSize = new Dimension(ScriptBuilderGuiConstants.INCIDENT_NUMBER_WIDTH,159 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT160 + ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP * (mostEvents + 1));161 } 82 newSize = new Dimension(ScriptBuilderGuiConstants.INCIDENT_NUMBER_WIDTH, 83 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT 84 + ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP * 2); 85 162 86 } 163 87 else … … 198 122 ScriptBuilderGuiConstants.INCIDENT_NUMBER_TOP_MARGIN); 199 123 200 g2d.drawImage((collapsed ? getExpandImage() : getCollapseImage()), 201 ScriptBuilderGuiConstants.COLLEX_BUTTON_X, 202 ScriptBuilderGuiConstants.COLLEX_BUTTON_Y, null); 124 int y = ScriptBuilderGuiConstants.INCIDENT_NUMBER_TOP_MARGIN * 2 - 14; 125 g2d.setFont(ScriptBuilderGuiConstants.INCIDENT_NAME_FONT); 126 for (String line : incident.name.split(" ")) 127 { 128 g2d.drawString(line, 20, y); 129 y += 12; 130 } 203 131 204 if (!collapsed)205 {206 int y = ScriptBuilderGuiConstants.INCIDENT_NUMBER_TOP_MARGIN * 2 - 14;207 g2d.setFont(ScriptBuilderGuiConstants.INCIDENT_NAME_FONT);208 for (String line : incident.name.split(" "))209 {210 g2d.drawString(line, 20, y);211 y += 12;212 }213 }214 132 } 215 133 } -
trunk/src/scriptbuilder/gui/panels/ScriptBuilderTimelinePanel.java
r49 r53 29 29 * @version 2017/06/30 30 30 */ 31 public class IncidentTimelinePanel extends JPanel31 public class ScriptBuilderTimelinePanel extends JPanel 32 32 { 33 33 … … 39 39 * If true, this panel is in its minimized state. 40 40 */ 41 boolean collapsed;41 //boolean collapsed; 42 42 /** 43 43 * If false, this panel won't be drawn. … … 198 198 lastSlice = newSlice; 199 199 String newToolTip; 200 if (collapsed) 201 { 202 newToolTip = incident.slices.get(newSlice).toString(); 203 } 204 else 205 { 206 newToolTip = incident.slices.get(newSlice).getToolTipText(y); 207 } 200 201 newToolTip = incident.slices.get(newSlice).toString(); 202 208 203 setToolTipText((newToolTip == null || newToolTip.equals("")) 209 204 ? null : newToolTip); … … 218 213 * Constructor. Generates a HashMap of all possible event types. 219 214 */ 220 public IncidentTimelinePanel()215 public ScriptBuilderTimelinePanel() 221 216 { 222 217 super(); … … 258 253 { 259 254 this.incident = incident; 260 if (incident != null)261 {262 this.collapsed = incident.collapsed;263 }264 255 this.visible = incident != null; 265 256 … … 267 258 if (visible) 268 259 { 269 if (collapsed) 270 { 271 newSize = new Dimension((incident.length + incident.offset) 272 / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 273 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK, 274 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT); 275 } 276 else 277 { 278 int mostEvents = 0; 279 for (TimeSlice slice : incident.getSlices()) 280 { 281 if (slice.events.size() > mostEvents) 282 { 283 mostEvents = slice.events.size(); 284 } 285 } 286 287 newSize = new Dimension((ScriptBuilderGuiConstants.MAX_SIMULATION_LENGTH) 288 / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 289 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK, 290 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT 291 + ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP * (mostEvents + 1)); 292 } 260 261 newSize = new Dimension(((incident.length + incident.offset) 262 / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 263 * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK) 264 + ScriptBuilderGuiConstants.EVENT_ICON_WIDTH, 265 ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT 266 + ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP * 2); 267 293 268 } 294 269 else … … 319 294 320 295 Graphics2D g2d = (Graphics2D) g; 321 IncidentTimelineDrawer.Draw IncidentTimeline(g2d, incident, collapsed);296 IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 322 297 323 298 if (focused)
Note: See TracChangeset
for help on using the changeset viewer.
