Changeset 53 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels


Ignore:
Timestamp:
08/09/2017 10:03:37 AM (9 years ago)
Author:
bmcguffin
Message:

Duplicated main ScriptBuilder? window. The new window will become the Incident Editor window (see Storyboard 2a-B). The main ScriptBuilder? window will become the Incident Combiner window (see storyboard 1a-B).

Location:
trunk/src/scriptbuilder/gui/panels
Files:
1 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/panels/IncidentTimelineTickPanel.java

    r31 r53  
    2121 * @author Bryan McGuffin 
    2222 */ 
    23 public class TimelineTickPanel extends JPanel 
     23public class IncidentTimelineTickPanel extends JPanel 
    2424{ 
    2525 
     
    8282     * Constructor. Set up the mouse listener. 
    8383     */ 
    84     public TimelineTickPanel() 
     84    public IncidentTimelineTickPanel() 
    8585    { 
    8686        super(); 
  • trunk/src/scriptbuilder/gui/panels/IncidentsPanel.java

    r1 r53  
    2020    private SimulationScript script; 
    2121    private TimelineTickPanel timelineTickPanel; 
    22     private List<IncidentTimelinePanel> incidentPanels; 
    23     private List<IncidentNumberPanel> numberPanels; 
     22    private List<ScriptBuilderTimelinePanel> incidentPanels; 
     23    private List<ScriptBuilderNumberPanel> numberPanels; 
    2424 
    2525    /** 
  • trunk/src/scriptbuilder/gui/panels/ScriptBuilderNumberPanel.java

    r1 r53  
    2626 * @author Bryan McGuffin 
    2727 */ 
    28 public class IncidentNumberPanel extends JPanel 
     28public class ScriptBuilderNumberPanel extends JPanel 
    2929{ 
    3030 
    3131    ScriptIncident incident; 
    3232    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.png 
    40      */ 
    41     private static Image getCollapseImage() 
    42     { 
    43         if (collapseImage == null) 
    44         { 
    45             try 
    46             { 
    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.png 
    62      */ 
    63     private static Image getExpandImage() 
    64     { 
    65         if (expandImage == null) 
    66         { 
    67             try 
    68             { 
    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     } 
    7933 
    8034    /** 
     
    8438    private class IncidentNumberMouseListener extends MouseInputAdapter 
    8539    { 
    86  
    87         private final Shape collapseExpandButtonShape 
    88                 = new Rectangle(ScriptBuilderGuiConstants.COLLEX_BUTTON_X, 
    89                         ScriptBuilderGuiConstants.COLLEX_BUTTON_Y, 
    90                         ScriptBuilderGuiConstants.COLLEX_BUTTON_WIDTH, 
    91                         ScriptBuilderGuiConstants.COLLEX_BUTTON_HEIGHT); 
    9240 
    9341        /** 
     
    10048        public void mouseClicked(MouseEvent e) 
    10149        { 
    102             if (collapseExpandButtonShape.contains(e.getX(), e.getY())) 
    103             { 
    104                 incident.setCollapsed(!collapsed); 
    105             } 
     50 
    10651        } 
    10752    } 
     
    11055     * Constructor. Sets up the mouse listener. 
    11156     */ 
    112     public IncidentNumberPanel() 
     57    public ScriptBuilderNumberPanel() 
    11358    { 
    11459        super(); 
     
    13176        this.visible = incident != null; 
    13277 
    133         if (incident != null) 
    134         { 
    135             this.collapsed = incident.collapsed; 
    136         } 
    137  
    13878        Dimension newSize; 
    13979        if (visible) 
    14080        { 
    141             if (collapsed) 
    142             { 
    143                 newSize = new Dimension( 
    144                         ScriptBuilderGuiConstants.INCIDENT_NUMBER_WIDTH, 
    145                         ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT); 
    146             } 
    147             else 
    148             { 
    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                 } 
    15781 
    158                 newSize = new Dimension(ScriptBuilderGuiConstants.INCIDENT_NUMBER_WIDTH, 
    159                         ScriptBuilderGuiConstants.TIMELINE_COLLAPSED_HEIGHT 
    160                         + 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 
    16286        } 
    16387        else 
     
    198122                ScriptBuilderGuiConstants.INCIDENT_NUMBER_TOP_MARGIN); 
    199123 
    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        } 
    203131 
    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         } 
    214132    } 
    215133} 
  • trunk/src/scriptbuilder/gui/panels/ScriptBuilderTimelinePanel.java

    r49 r53  
    2929 * @version 2017/06/30 
    3030 */ 
    31 public class IncidentTimelinePanel extends JPanel 
     31public class ScriptBuilderTimelinePanel extends JPanel 
    3232{ 
    3333 
     
    3939     * If true, this panel is in its minimized state. 
    4040     */ 
    41     boolean collapsed; 
     41    //boolean collapsed; 
    4242    /** 
    4343     * If false, this panel won't be drawn. 
     
    198198                    lastSlice = newSlice; 
    199199                    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 
    208203                    setToolTipText((newToolTip == null || newToolTip.equals("")) 
    209204                            ? null : newToolTip); 
     
    218213     * Constructor. Generates a HashMap of all possible event types. 
    219214     */ 
    220     public IncidentTimelinePanel() 
     215    public ScriptBuilderTimelinePanel() 
    221216    { 
    222217        super(); 
     
    258253    { 
    259254        this.incident = incident; 
    260         if (incident != null) 
    261         { 
    262             this.collapsed = incident.collapsed; 
    263         } 
    264255        this.visible = incident != null; 
    265256 
     
    267258        if (visible) 
    268259        { 
    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 
    293268        } 
    294269        else 
     
    319294 
    320295        Graphics2D g2d = (Graphics2D) g; 
    321         IncidentTimelineDrawer.DrawIncidentTimeline(g2d, incident, collapsed); 
     296        IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 
    322297 
    323298        if (focused) 
Note: See TracChangeset for help on using the changeset viewer.