Changeset 54 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels/TimelineTickPanel.java


Ignore:
Timestamp:
08/09/2017 04:12:39 PM (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 edited

Legend:

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

    r31 r54  
    77import javax.swing.JPanel; 
    88import javax.swing.event.MouseInputAdapter; 
     9import scriptbuilder.gui.IncidentEditorFrame; 
    910import scriptbuilder.gui.ScriptBuilderFrame; 
    1011import scriptbuilder.gui.ScriptBuilderGuiConstants; 
     
    130131 
    131132    /** 
     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    /** 
    132169     * Refresh the panel. Redraw the ticks based on zoom level, panel 
    133170     * dimensions, and offset. If the user is trying to add an event, draw that 
     
    182219        paintChildren(g); 
    183220 
    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            } 
    190240        } 
    191241    } 
Note: See TracChangeset for help on using the changeset viewer.