package old; //package scriptbuilder.gui.timeline; // //import java.awt.Color; //import java.awt.Font; //import java.awt.Graphics; //import java.awt.Graphics2D; //import java.awt.Polygon; //import java.util.ArrayList; //import java.util.List; //import javax.swing.JPanel; //import scriptbuilder.gui.ScriptBuilderFrame; //import scriptbuilder.structures.TimelineSlice; //import scriptbuilder.structures.ScriptIncident; //import scriptbuilder.structures.ScriptEvent; // ///** // * // * @author Greg Eddington // */ //public class TimelinePanel extends JPanel //{ // private static Polygon cursor; // // private int curX = -300, curY = -300; // private String cursorTimeString; // private float zoom = 1.0f; // private List incidents; // private boolean cursorActive = true; // public int incident = 0; // private ScriptBuilderFrame sbf; // // public float getZoom() // { // return zoom; // } // // public int getCursorY() // { // return curY; // } // // public int getCursorX() // { // return curX; // } // // public List getIncidents() // { // return incidents; // } // // public void setIncident(int incident) // { // this.incident = incident; // } // // public void setCursorActive(boolean active) // { // cursorActive = active; // } // // public void setCursorLocation(int x, int y) // { // curX = x; // curY = y; // } // // public void setTimeString(String time) // { // cursorTimeString = time; // } // // public void setZoom(float zoom) // { // this.zoom = zoom; // } // // public void addIcon(int y, TimelineSlice icon) // { // incidents.get(incident).slices.add(icon); // } // // public void addEvent(ScriptEvent event) // { // int x = curX-5, y = curY-10; // ScriptIncident inc = incidents.get(incident); // boolean foundIcon = false; // // for(int i = 0; i < inc.slices.size(); i++) // { // if (inc.slices.get(i).x == x) // { // inc.slices.get(i).events.add(event); // foundIcon = true; // break; // } // } // // if (!foundIcon) // { // TimelineSlice newIcon = new TimelineSlice(x, y, 10, 10); // newIcon.events.add(event); // inc.slices.add(newIcon); // } // } // // public void setScriptBuilderFrame(ScriptBuilderFrame sbf) // { // this.sbf = sbf; // } // // public TimelinePanel() // { // super(); // // // Create the object lists // incidents = new ArrayList(); // // // Create the cursor // cursor = new Polygon(); // cursor.addPoint(0, 0); // cursor.addPoint(-(TimelinePanel.TIMELINE_30_SECOND_STEP/2), // TimelinePanel.TIMELINE_30_SECOND_STEP); // cursor.addPoint(TimelinePanel.TIMELINE_30_SECOND_STEP/2, // TimelinePanel.TIMELINE_30_SECOND_STEP); // // // Create the media incident // incidents.add(new ScriptIncident(Color.BLACK, 100, "Media", // "The media incident.", 10800)); // // // Initialize the time string // cursorTimeString = ""; // } // // @Override // public void paint(Graphics g) // { // Graphics2D g2d = (Graphics2D)g; // // super.paint(g); // // // Scale the panel // g2d.scale(zoom, zoom); // // // Draw the timelines // drawTimelineGrid(g2d); // drawIncidentLines(g2d); // // // Draw the event icons // drawTimelineIcons(g2d); // // // Redraw the cursor // drawCursor(g2d); // // // // // Update the incident information // if (incident >= 0 && incident < incidents.size() && sbf != null // && incidents != null) // sbf.updateIncident(incidents.get(incident), curX-5); // } // // private void drawIncidentLines(Graphics2D g2d) // { // // Draw the incident lines // g2d.setFont(INCIDENT_FONT); // for (int i = 0; i < incidents.size(); i++) // { // // Set the colour for this timeline // g2d.setColor(incidents.get(i).color); // // // Draw the timeline's name // g2d.drawString(Integer.toString(incidents.get(i).number), // INCIDENT_NAME_LEFT_PADDING, // i * INCIDENT_NAME_VERTICAL_STEP + INCIDENT_NAME_TOP_PADDING); // // // Draw the timeline's line // g2d.fillRect(TIMELINE_LEFT_PADDING, // i * TIMELINE_VERTICAL_STEP + TIMELINE_TOP_PADDING, // TIMELINE_30_SECOND_STEP * incidents.get(i).length / 30, // TIMELINE_WIDTH); // } // } // // private void drawTimelineGrid(Graphics2D g2d) // { // int maxTime = 360; // int maxHeight = 1000; // // g2d.setFont(GRID_FONT); // // // Thirty second ticks // g2d.setColor(THIRTY_SECOND_TICK_COLOR); // for (int i = 0; i < maxTime; i++) // { // for (int j = 0; j < maxHeight; j += 2) // g2d.drawLine(i * TIMELINE_30_SECOND_STEP + TIMELINE_LEFT_PADDING, // (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING, // i * TIMELINE_30_SECOND_STEP + TIMELINE_LEFT_PADDING, // (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING + // THIRTY_SECOND_TICK_STEP); // } // // // Fifteen minute ticks // g2d.setColor(FIFTEEN_MINUTE_TICK_COLOR); // for (int i = 0; i <= maxTime / 30; i++) // { // int minutes = i * 15; // // // Draw the time // g2d.drawString // ( // (minutes / 60) + ":" + ((minutes % 60) == 0 ? "00" : (minutes % 60)) + ":00", // i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING - TIME_LABEL_OFFSET, // FIFTEEN_MINUTE_LABEL_TOP_PADDING // ); // // // Draw the line // g2d.drawLine(i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING, // FIFTEEN_MINUTE_TICK_TOP_PADDING, // i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING, // FIFTEEN_MINUTE_TICK_TOP_PADDING + THIRTY_SECOND_TICK_STEP); // for (int j = 0; j < maxHeight; j += 2) // g2d.drawLine(i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING, // (j * THIRTY_SECOND_TICK_STEP) + THIRTY_SECOND_TICK_TOP_PADDING, // i * TIMELINE_15_MINUTE_STEP + TIMELINE_LEFT_PADDING, // (j * THIRTY_SECOND_TICK_STEP + THIRTY_SECOND_TICK_STEP) // + THIRTY_SECOND_TICK_TOP_PADDING); // } // } // // private void drawTimelineIcons(Graphics2D g2d) // { // for (ScriptIncident incident : incidents) // { // g2d.setColor(incident.color); // for (TimelineSlice icon : incident.slices) // { // g2d.fill(icon.getShape()); // } // } // } // // private void drawCursor(Graphics2D g2d) // { // // Draw the cursor // g2d.setColor(CURSOR_COLOR); // cursor.translate(curX - cursor.xpoints[0], curY - cursor.ypoints[0]); // g2d.fill(cursor); // // // Draw a timestamp // g2d.setColor(CURSOR_TIME_BORDER_COLOR); // g2d.fillRect(curX-30, curY + 15, 60, 20); // g2d.setColor(cursorActive ? CURSOR_TIME_ACTIVE_BG_COLOR : // CURSOR_TIME_INACTIVE_BG_COLOR); // g2d.fillRect(curX-28, curY + 17, 56, 16); // g2d.setColor(CURSOR_TIME_FONT_COLOR); // g2d.setFont(CURSOR_TIME_FONT); // g2d.drawString(cursorTimeString, curX-20, curY+30); // } //}