Warning: Can't use blame annotator:
svn blame failed on branches/ScriptBuilder4/src/old/TimelinePanel.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator-scriptbuilder/branches/ScriptBuilder4/src/old/TimelinePanel.java @ 6

Revision 6, 7.8 KB checked in by jdalbey, 9 years ago (diff)

Add original prototype to branch

RevLine 
1package old;
2
3//package scriptbuilder.gui.timeline;
4//
5//import java.awt.Color;
6//import java.awt.Font;
7//import java.awt.Graphics;
8//import java.awt.Graphics2D;
9//import java.awt.Polygon;
10//import java.util.ArrayList;
11//import java.util.List;
12//import javax.swing.JPanel;
13//import scriptbuilder.gui.ScriptBuilderFrame;
14//import scriptbuilder.structures.TimelineSlice;
15//import scriptbuilder.structures.ScriptIncident;
16//import scriptbuilder.structures.ScriptEvent;
17//
18///**
19// *
20// * @author Greg Eddington
21// */
22//public class TimelinePanel extends JPanel
23//{
24//    private static Polygon cursor;
25//
26//    private int curX = -300, curY = -300;
27//    private String cursorTimeString;
28//    private float zoom = 1.0f;
29//    private List<ScriptIncident> incidents;
30//    private boolean cursorActive = true;
31//    public int incident = 0;
32//    private ScriptBuilderFrame sbf;
33//
34//    public float getZoom()
35//    {
36//        return zoom;
37//    }
38//
39//    public int getCursorY()
40//    {
41//        return curY;
42//    }
43//
44//    public int getCursorX()
45//    {
46//        return curX;
47//    }
48//
49//    public List<ScriptIncident> getIncidents()
50//    {
51//        return incidents;
52//    }
53//
54//    public void setIncident(int incident)
55//    {
56//        this.incident = incident;
57//    }
58//
59//    public void setCursorActive(boolean active)
60//    {
61//        cursorActive = active;
62//    }
63//
64//    public void setCursorLocation(int x, int y)
65//    {
66//        curX = x;
67//        curY = y;
68//    }
69//
70//    public void setTimeString(String time)
71//    {
72//        cursorTimeString = time;
73//    }
74//
75//    public void setZoom(float zoom)
76//    {
77//        this.zoom = zoom;
78//    }
79//
80//    public void addIcon(int y, TimelineSlice icon)
81//    {
82//        incidents.get(incident).slices.add(icon);
83//    }
84//
85//    public void addEvent(ScriptEvent event)
86//    {
87//        int x = curX-5, y = curY-10;
88//        ScriptIncident inc = incidents.get(incident);
89//        boolean foundIcon = false;
90//
91//        for(int i = 0; i < inc.slices.size(); i++)
92//        {
93//            if (inc.slices.get(i).x == x)
94//            {
95//                inc.slices.get(i).events.add(event);
96//                foundIcon = true;
97//                break;
98//            }
99//        }
100//
101//        if (!foundIcon)
102//        {
103//            TimelineSlice newIcon = new TimelineSlice(x, y, 10, 10);
104//            newIcon.events.add(event);
105//            inc.slices.add(newIcon);
106//        }
107//    }
108//
109//    public void setScriptBuilderFrame(ScriptBuilderFrame sbf)
110//    {
111//        this.sbf = sbf;
112//    }
113//
114//    public TimelinePanel()
115//    {
116//        super();
117//
118//        // Create the object lists
119//        incidents = new ArrayList<ScriptIncident>();
120//
121//        // Create the cursor
122//        cursor = new Polygon();
123//        cursor.addPoint(0, 0);
124//        cursor.addPoint(-(TimelinePanel.TIMELINE_30_SECOND_STEP/2),
125//                TimelinePanel.TIMELINE_30_SECOND_STEP);
126//        cursor.addPoint(TimelinePanel.TIMELINE_30_SECOND_STEP/2,
127//                TimelinePanel.TIMELINE_30_SECOND_STEP);
128//
129//        // Create the media incident
130//        incidents.add(new ScriptIncident(Color.BLACK, 100, "Media",
131//                "The media incident.", 10800));
132//
133//        // Initialize the time string
134//        cursorTimeString = "";
135//    }
136//
137//    @Override
138//    public void paint(Graphics g)
139//    {
140//        Graphics2D g2d = (Graphics2D)g;
141//
142//        super.paint(g);
143//
144//        // Scale the panel
145//        g2d.scale(zoom, zoom);
146//
147//        // Draw the timelines
148//        drawTimelineGrid(g2d);
149//        drawIncidentLines(g2d);
150//
151//        // Draw the event icons
152//        drawTimelineIcons(g2d);
153//
154//        // Redraw the cursor
155//        drawCursor(g2d);
156//
157//
158//
159//        // Update the incident information
160//        if (incident >= 0 && incident < incidents.size() && sbf != null
161//                && incidents != null)
162//            sbf.updateIncident(incidents.get(incident), curX-5);
163//    }
164//
165//    private void drawIncidentLines(Graphics2D g2d)
166//    {
167//        // Draw the incident lines
168//        g2d.setFont(INCIDENT_FONT);
169//        for (int i = 0; i < incidents.size(); i++)
170//        {
171//            // Set the colour for this timeline
172//            g2d.setColor(incidents.get(i).color);
173//
174//            // Draw the timeline's name
175//            g2d.drawString(Integer.toString(incidents.get(i).number),
176//                    INCIDENT_NAME_LEFT_PADDING,
177//                    i * INCIDENT_NAME_VERTICAL_STEP + INCIDENT_NAME_TOP_PADDING);
178//
179//            // Draw the timeline's line
180//            g2d.fillRect(TIMELINE_LEFT_PADDING,
181//                    i * TIMELINE_VERTICAL_STEP + TIMELINE_TOP_PADDING,
182//                    TIMELINE_30_SECOND_STEP * incidents.get(i).length / 30,
183//                    TIMELINE_WIDTH);
184//        }
185//    }
186//
187//    private void drawTimelineGrid(Graphics2D g2d)
188//    {
189//        int maxTime = 360;
190//        int maxHeight = 1000;
191//
192//        g2d.setFont(GRID_FONT);
193//
194//        // Thirty second ticks
195//        g2d.setColor(THIRTY_SECOND_TICK_COLOR);
196//        for (int i = 0; i < maxTime; i++)
197//        {
198//            for (int j = 0; j < maxHeight; j += 2)
199//                g2d.drawLine(i * TIMELINE_30_SECOND_STEP + TIMELINE_LEFT_PADDING,
200//                        (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING,
201//                        i * TIMELINE_30_SECOND_STEP + TIMELINE_LEFT_PADDING,
202//                        (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING +
203//                        THIRTY_SECOND_TICK_STEP);
204//        }
205//
206//        // Fifteen minute ticks
207//        g2d.setColor(FIFTEEN_MINUTE_TICK_COLOR);
208//        for (int i = 0; i <= maxTime / 30; i++)
209//        {
210//            int minutes = i * 15;
211//
212//            // Draw the time
213//            g2d.drawString
214//            (
215//                (minutes / 60) + ":" + ((minutes % 60) == 0 ? "00" : (minutes % 60)) + ":00",
216//                i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING - TIME_LABEL_OFFSET,
217//                FIFTEEN_MINUTE_LABEL_TOP_PADDING
218//            );
219//
220//            // Draw the line
221//            g2d.drawLine(i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING,
222//                    FIFTEEN_MINUTE_TICK_TOP_PADDING,
223//                    i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING,
224//                    FIFTEEN_MINUTE_TICK_TOP_PADDING + THIRTY_SECOND_TICK_STEP);
225//            for (int j = 0; j < maxHeight; j += 2)
226//                g2d.drawLine(i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING,
227//                        (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING,
228//                        i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING,
229//                        (j * THIRTY_SECOND_TICK_STEP + THIRTY_SECOND_TICK_STEP)
230//                        + THIRTY_SECOND_TICK_TOP_PADDING);
231//        }
232//    }
233//
234//    private void drawTimelineIcons(Graphics2D g2d)
235//    {
236//        for (ScriptIncident incident : incidents)
237//        {
238//            g2d.setColor(incident.color);
239//            for (TimelineSlice icon : incident.slices)
240//            {
241//                g2d.fill(icon.getShape());
242//            }
243//        }
244//    }
245//
246//    private void drawCursor(Graphics2D g2d)
247//    {
248//        // Draw the cursor
249//        g2d.setColor(CURSOR_COLOR);
250//        cursor.translate(curX - cursor.xpoints[0], curY - cursor.ypoints[0]);
251//        g2d.fill(cursor);
252//
253//        // Draw a timestamp
254//        g2d.setColor(CURSOR_TIME_BORDER_COLOR);
255//        g2d.fillRect(curX-30, curY + 15, 60, 20);
256//        g2d.setColor(cursorActive ? CURSOR_TIME_ACTIVE_BG_COLOR :
257//            CURSOR_TIME_INACTIVE_BG_COLOR);
258//        g2d.fillRect(curX-28, curY + 17, 56, 16);
259//        g2d.setColor(CURSOR_TIME_FONT_COLOR);
260//        g2d.setFont(CURSOR_TIME_FONT);
261//        g2d.drawString(cursorTimeString, curX-20, curY+30);
262//    }
263//}
Note: See TracBrowser for help on using the repository browser.