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


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).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • 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} 
Note: See TracChangeset for help on using the changeset viewer.