Warning: Can't use blame annotator:
svn blame failed on trunk/src/scriptbuilder/gui/drawers/TimeSliceDrawer.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/trunk/src/scriptbuilder/gui/drawers/TimeSliceDrawer.java @ 7

Revision 7, 3.0 KB checked in by bmcguffin, 9 years ago (diff)

Renamed Interfaces in structures.events package from "*Interface" to "I_*"

RevLine 
1package scriptbuilder.gui.drawers;
2
3import java.awt.Graphics2D;
4import java.awt.Image;
5import java.awt.geom.AffineTransform;
6import java.io.File;
7import java.io.IOException;
8import java.util.logging.Level;
9import java.util.logging.Logger;
10import javax.imageio.ImageIO;
11import scriptbuilder.gui.ScriptBuilderGuiConstants;
12import scriptbuilder.structures.ScriptEvent;
13import scriptbuilder.structures.TimeSlice;
14import scriptbuilder.structures.events.I_ScriptEvent;
15
16/**
17 * Draws the icons present in one timeslice, in one incident.
18 *
19 * @author Greg Eddington <geddingt@calpoly.edu>
20 * @author Bryan McGuffin
21 */
22public class TimeSliceDrawer
23{
24
25    /**
26     * The icon which indicates that there are events present in this timeSlice.
27     */
28    private static Image sliceEventImage = null;
29
30    /**
31     * The default zoom level.
32     */
33    public static int zoom = 20;
34
35    /**
36     * Get the icon to use whenever events are present in the slice. If we don't
37     * already have a copy, harvest it from a file.
38     *
39     * @return The existing copy of Event.png
40     */
41    private static Image getSliceEventImage()
42    {
43        if (sliceEventImage == null)
44        {
45            try
46            {
47                sliceEventImage = ImageIO.read(images.Images.getImage("Event.png"));
48            }
49            catch (IOException ex)
50            {
51                Logger.getLogger(EventIconDrawer.class.getName()).log(Level.SEVERE, null, ex);
52            }
53        }
54
55        return sliceEventImage;
56    }
57
58    /**
59     * Draw the events in this timeslice. If any exist, draw the slice event
60     * image. If the incident isn't collapsed, draw the event icons as well.
61     *
62     * @param g2d the graphics component
63     * @param slice the timeSlice to draw
64     * @param collapsed if true, don't draw the event icons
65     */
66    public static void DrawTimeSlice(Graphics2D g2d, TimeSlice slice,
67            boolean collapsed)
68    {
69        // If this is an empty slice, return
70        if (slice.events.size() == 0)
71        {
72            return;
73        }
74
75        // Draw the slice event icon to show that there are events here
76        g2d.drawImage(getSliceEventImage(), slice.getX()
77                - ScriptBuilderGuiConstants.EVENT_ICON_WIDTH,
78                ScriptBuilderGuiConstants.TIMELINE_EVENT_ICON_MARGIN, null);
79
80        // If the incident isn't collapsed, draw the event icons
81        if (!collapsed)
82        {
83            for (int i = 0; i < slice.events.size(); i++)
84            {
85                if (i >= ScriptBuilderGuiConstants.MAX_NUMBER_OF_SCRIPT_EVENT_ICON)
86                {
87                    break;
88                }
89
90                I_ScriptEvent event = slice.events.get(i);
91                EventIconDrawer.DrawEventIcon(g2d, event, slice.getX()
92                        - ScriptBuilderGuiConstants.EVENT_ICON_WIDTH,
93                        ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_TOP_MARGIN
94                        + i * ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP);
95            }
96        }
97    }
98}
Note: See TracBrowser for help on using the repository browser.