package scriptbuilder.gui.drawers; import java.awt.Graphics2D; import java.awt.Image; import java.awt.geom.AffineTransform; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import scriptbuilder.gui.ScriptBuilderGuiConstants; import scriptbuilder.structures.ScriptEvent; import scriptbuilder.structures.TimeSlice; /** * * @author Greg Eddington */ public class TimeSliceDrawer { private static Image sliceEventImage = null; public static int zoom = 20; private static Image getSliceEventImage() { if (sliceEventImage == null) { try { sliceEventImage = ImageIO.read(images.Images.getImage("Event.png")); } catch (IOException ex) { Logger.getLogger(EventIconDrawer.class.getName()).log(Level.SEVERE, null, ex); } } return sliceEventImage; } public static void DrawTimeSlice(Graphics2D g2d, TimeSlice slice, boolean collapsed) { // If this is an empty slice, return if (slice.events.size() == 0) return; // Draw the slice event icon to show that there are events here g2d.drawImage(getSliceEventImage(), slice.getX() - ScriptBuilderGuiConstants.EVENT_ICON_WIDTH, ScriptBuilderGuiConstants.TIMELINE_EVENT_ICON_MARGIN, null); // If the incident isn't collapsed, draw the event icons if (!collapsed) { for (int i = 0; i < slice.events.size(); i++) { if (i >= ScriptBuilderGuiConstants.MAX_NUMBER_OF_SCRIPT_EVENT_ICON) break; ScriptEvent event = slice.events.get(i); EventIconDrawer.DrawEventIcon(g2d, event, slice.getX() - ScriptBuilderGuiConstants.EVENT_ICON_WIDTH, ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_TOP_MARGIN + i * ScriptBuilderGuiConstants.SCRIPT_EVENT_ICON_STEP); } } } }