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


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

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

Legend:

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

    r53 r54  
    1111import javax.swing.JPanel; 
    1212import javax.swing.event.MouseInputAdapter; 
     13import scriptbuilder.gui.IncidentEditorFrame; 
    1314import scriptbuilder.gui.ScriptBuilderFrame; 
    1415import scriptbuilder.gui.ScriptBuilderGuiConstants; 
     
    100101        { 
    101102            Editor ed = new Editor(); 
    102             ScriptBuilderFrame f = (ScriptBuilderFrame) getTopLevelAncestor(); 
     103            ScriptBuilderFrame f = null; 
     104            IncidentEditorFrame g = null; 
     105            if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     106            { 
     107                f = (ScriptBuilderFrame) getTopLevelAncestor(); 
     108            } 
     109            else if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     110            { 
     111                g = (IncidentEditorFrame) getTopLevelAncestor(); 
     112            } 
    103113 
    104114            x = cursorTime = e.getX(); 
     
    142152            if (e.getButton() == MouseEvent.BUTTON1) 
    143153            { 
    144                 if (f.currentEventType != null) 
    145                 { 
    146                     I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 
    147                     ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 
    148                     if (incident.slices.get(newSlice) == null) 
     154                if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     155                { 
     156                    if (f.currentEventType != null) 
    149157                    { 
    150                         incident.addNewEvent(s, newSlice); 
     158                        I_ScriptEvent s = ScriptEvent.factoryByType(f.currentEventType); 
     159                        ed.addProperty(eventTypeToPropertyMap.get(f.currentEventType), s); 
     160                        if (incident.slices.get(newSlice) == null) 
     161                        { 
     162                            incident.addNewEvent(s, newSlice); 
     163                        } 
     164                        else 
     165                        { 
     166                            incident.slices.get(newSlice).addEvent(s); 
     167                        } 
     168                        f.update(f.getScript(), f.getScript()); 
    151169                    } 
    152                     else 
     170                } 
     171                if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     172                { 
     173                    if (g.currentEventType != null) 
    153174                    { 
    154                         incident.slices.get(newSlice).addEvent(s); 
     175                        I_ScriptEvent s = ScriptEvent.factoryByType(g.currentEventType); 
     176                        ed.addProperty(eventTypeToPropertyMap.get(g.currentEventType), s); 
     177                        if (incident.slices.get(newSlice) == null) 
     178                        { 
     179                            incident.addNewEvent(s, newSlice); 
     180                        } 
     181                        else 
     182                        { 
     183                            incident.slices.get(newSlice).addEvent(s); 
     184                        } 
     185                        g.update(null, g.getIncident()); 
    155186                    } 
    156                     f.update(f.getScript(), f.getScript()); 
    157187                } 
    158188            } 
     
    294324 
    295325        Graphics2D g2d = (Graphics2D) g; 
    296         IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 
     326        if (getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     327        { 
     328            IncidentTimelineDrawer.DrawScriptBuilderTimeline(g2d, incident); 
     329        } 
     330        if (getTopLevelAncestor() instanceof IncidentEditorFrame) 
     331        { 
     332            IncidentTimelineDrawer.DrawIncidentTimeline(g2d, incident, false); 
     333        } 
    297334 
    298335        if (focused) 
    299336        { 
    300337            CursorDrawer.DrawCursor(g2d, cursorTime, false); 
    301             if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 
    302             { 
    303                 EventIconDrawer.DrawEventIcon(g2d, 
    304                         ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 
    305                         x + 5, y + 10); 
     338            if (this.getTopLevelAncestor() instanceof ScriptBuilderFrame) 
     339            { 
     340                if (((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType != null) 
     341                { 
     342                    EventIconDrawer.DrawEventIcon(g2d, 
     343                            ((ScriptBuilderFrame) this.getTopLevelAncestor()).currentEventType, 
     344                            x + 5, y + 10); 
     345                } 
     346            } 
     347            if (this.getTopLevelAncestor() instanceof IncidentEditorFrame) 
     348            { 
     349                if (((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType != null) 
     350                { 
     351                    EventIconDrawer.DrawEventIcon(g2d, 
     352                            ((IncidentEditorFrame) this.getTopLevelAncestor()).currentEventType, 
     353                            x + 5, y + 10); 
     354                } 
    306355            } 
    307356        } 
  • trunk/src/scriptbuilder/gui/panels/TimeStampPanel.java

    r1 r54  
    8989 
    9090    /** 
     91     * Update the length interval and the dimensions of the panel. NOTE: This 
     92     * method implementation is an exact duplication of the update method in 
     93     * panels.TimelineTickPanel. I'm not sure if it actually accomplishes 
     94     * anything here. 
     95     * 
     96     * @param script The simulation script model 
     97     */ 
     98    public void update(ScriptIncident incident) 
     99    { 
     100        longestLength = ScriptBuilderGuiConstants.TICK_TIMELINE_SMALLEST_LENGTH; 
     101 
     102        // Get the stats on the incidents 
     103        int height = ScriptBuilderGuiConstants.TICK_TOP_MARGIN * 4; 
     104        if (incident != null) 
     105        { 
     106            height += incident.collapsed 
     107                    ? ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT 
     108                    : ScriptBuilderGuiConstants.TIMELINE_OPENED_HEIGHT; 
     109            if ((incident.length + incident.offset) > longestLength) 
     110            { 
     111                longestLength = incident.length + incident.offset; 
     112            } 
     113        } 
     114 
     115        if (incident != null && incident.number == 100) 
     116        { 
     117            incident.length = longestLength; 
     118            incident.offset = 0; 
     119        } 
     120 
     121        Dimension newSize = new Dimension(longestLength 
     122                / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION 
     123                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK 
     124                + ScriptBuilderGuiConstants.TICK_TIMELINE_LEFT_MARGIN + 50, 
     125                height); 
     126        this.setPreferredSize(newSize); 
     127        this.setSize(newSize); 
     128 
     129        this.invalidate(); 
     130    } 
     131 
     132    /** 
    91133     * Refresh the panel. Draw the timestamps for the appropriate intervals 
    92134     * based on zoom level. 
  • 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.