source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/gui/drawers/IncidentTimelineDrawer.java @ 1

Revision 1, 1.4 KB checked in by bmcguffin, 9 years ago (diff)

2017/07/18: Uploaded entire prototype to SVN repo.

Line 
1package scriptbuilder.gui.drawers;
2
3import java.awt.Graphics2D;
4import scriptbuilder.gui.ScriptBuilderGuiConstants;
5import scriptbuilder.structures.ScriptIncident;
6import scriptbuilder.structures.TimeSlice;
7
8/**
9 * Draws the graphics for one entire incident.
10 *
11 * @author Greg Eddington <geddingt@calpoly.edu>
12 * @author Bryan McGuffin
13 */
14public class IncidentTimelineDrawer
15{
16
17    /**
18     * Draw the incident line. Then, utilize TimeSliceDrawer to draw the
19     * timeslices.
20     *
21     * @param g2d the graphics component
22     * @param incident the incident to be drawn
23     * @param collapsed if true, time slice events won't be drawn
24     */
25    public static void DrawIncidentTimeline(Graphics2D g2d,
26            ScriptIncident incident, boolean collapsed)
27    {
28        // Draw the timeline
29        g2d.setColor(incident.color);
30        g2d.fillRect(incident.offset / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION
31                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK,
32                ScriptBuilderGuiConstants.TIMELINE_TOP_MARGIN,
33                incident.length / ScriptBuilderGuiConstants.HORIZONTAL_TICK_RESOLUTION
34                * ScriptBuilderGuiConstants.PIXEL_WIDTH_PER_HORIZONTAL_TICK,
35                ScriptBuilderGuiConstants.TIMELINE_HEIGHT);
36
37        // Draw each time slice
38        for (TimeSlice slice : incident.getSlices())
39        {
40            TimeSliceDrawer.DrawTimeSlice(g2d, slice, collapsed);
41        }
42    }
43}
Note: See TracBrowser for help on using the repository browser.