diff --git a/trick_source/java/src/main/java/trick/jobperf/FrameRecord.java b/trick_source/java/src/main/java/trick/jobperf/FrameRecord.java new file mode 100644 index 00000000..2f4ce8f7 --- /dev/null +++ b/trick_source/java/src/main/java/trick/jobperf/FrameRecord.java @@ -0,0 +1,27 @@ +package trick.jobperf; +import java.util.*; +/** +* Class FrameRecord represents the set of jobs that have been executed during a +* frame. +*/ +public class FrameRecord { + public ArrayList jobEvents; + public double start; + public double stop; + /** + * Constructor + */ + public FrameRecord() { + start = 0.0; + stop = 0.0; + jobEvents = new ArrayList() + + ; + } + /** + * @return the stop time minus the start time. + */ + public double getDuration() { + return stop - start; + } +} diff --git a/trick_source/java/src/main/java/trick/jobperf/InvalidFrameBoundsExpection.java b/trick_source/java/src/main/java/trick/jobperf/InvalidFrameBoundsExpection.java new file mode 100644 index 00000000..faded8ec --- /dev/null +++ b/trick_source/java/src/main/java/trick/jobperf/InvalidFrameBoundsExpection.java @@ -0,0 +1,12 @@ +package trick.jobperf; + +/** +* Class InvalidFrameBoundsExpection is an exception indicating +* that the user has specified an illegal range for the frames +* to be rendered. +*/ +class InvalidFrameBoundsExpection extends Exception { + public InvalidFrameBoundsExpection(String message) { + super(message); + } +} diff --git a/trick_source/java/src/main/java/trick/jobperf/JobPerf.java b/trick_source/java/src/main/java/trick/jobperf/JobPerf.java index b1169f9b..3992c3b8 100644 --- a/trick_source/java/src/main/java/trick/jobperf/JobPerf.java +++ b/trick_source/java/src/main/java/trick/jobperf/JobPerf.java @@ -6,9 +6,15 @@ import java.util.*; import javax.swing.*; /** -* Class JobPerf is an application that renders time line data from a Trick based - simulation and generates run-time statistics reports for the simulation jobs. - It can be run with or without a GUI. + * Capabilites That Need To Be Added + * - a way to filter the data to be within a user specified sub time period + * within the data set. + */ + +/** +* Class JobPerf is an application that renders time-line data from a Trick based + simulation. It also generates run-time statistics reports for the simulation + jobs. It can be run with or without a GUI. */ public class JobPerf extends JFrame { ArrayList jobExecEvtList; diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java index 169e2e24..c6f28128 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java @@ -11,44 +11,61 @@ import javax.swing.event.*; /** * Class TraceViewCanvas renders the simulation timeline data stored in -* an ArrayList of JobExecutionEvent's [jobExecEvtList]. Information regarding mouse clicks -* are sent to the TraceViewOutputToolBar [outputToolBar.] +* an ArrayList of JobExecutionEvent's [jobExecEvtList]. Information regarding +* mouse clicks are sent to the TraceViewOutputToolBar [outputToolBar.] +* @author John M. Penn */ public class TraceViewCanvas extends JPanel { public static final int MIN_TRACE_WIDTH = 4; - public static final int DEFAULT_TRACE_WIDTH = 10; + public static final int DEFAULT_TRACE_WIDTH = 15; public static final int MAX_TRACE_WIDTH = 30; public static final int LEFT_MARGIN = 100; public static final int RIGHT_MARGIN = 100; public static final int TOP_MARGIN = 20; public static final int BOTTOM_MARGIN = 20; + public static final int DEFAULT_FRAMES_TO_RENDER = 100; private int traceWidth; - private double frameDuration; - private List jobExecList; + private double frameSize; + private double totalDuration; + private FrameRecord[] frameArray; + private FrameRange frameRenderRange; private KeyedColorMap idToColorMap; private BufferedImage image; private TraceViewOutputToolBar sToolBar; private Cursor crossHairCursor; private Cursor defaultCursor; + public class FrameRange { + public int first; + public int last; + FrameRange (int first, int last) { + this.first = first; + this.last = last; + } + public boolean contains(int n) { + return ((first <= n) && (n <= last)); + } + public int size() { + return last - first + 1; + } + } + /** * Constructor * @param jobExecEvtList the job time line data. * @param outputToolBar the toolbar to which data is to be sent for display. */ - public TraceViewCanvas( ArrayList jobExecEvtList, TraceViewOutputToolBar outputToolBar ) { + public TraceViewCanvas( ArrayList jobExecEvtList, + TraceViewOutputToolBar outputToolBar ) { traceWidth = DEFAULT_TRACE_WIDTH; - frameDuration = 1.0; + frameSize = 1.0; image = null; sToolBar = outputToolBar; - jobExecList = jobExecEvtList; crossHairCursor = new Cursor( Cursor.CROSSHAIR_CURSOR ); defaultCursor = new Cursor( Cursor.DEFAULT_CURSOR ); - double smallestStart = Double.MAX_VALUE; - double largestStop = -Double.MAX_VALUE; try { idToColorMap = new KeyedColorMap(); @@ -56,34 +73,44 @@ public class TraceViewCanvas extends JPanel { if (colorfile.exists()) { idToColorMap.readFile("IdToColors.txt"); } - boolean wasTOF = false; - double startOfFrame = 0.0; - double lastStartOfFrame = 0.0; - double frameSizeSum = 0.0; - int frameNumber = 0; - int frameSizeCount = 0; - for (JobExecutionEvent jobExec : jobExecList ) { - if (jobExec.start < smallestStart) smallestStart = jobExec.start; - if (jobExec.stop > largestStop) largestStop = jobExec.stop; - // Calculate the average frame size. - if (!wasTOF && jobExec.isTOF) { - startOfFrame = jobExec.start; - if (frameNumber > 0) { - double frameSize = (startOfFrame - lastStartOfFrame); - frameSizeSum += frameSize; - frameSizeCount ++; - } - lastStartOfFrame = startOfFrame; - frameNumber++; - } - wasTOF = jobExec.isTOF; - idToColorMap.addKey(jobExec.id); + List frameList = new ArrayList(); + FrameRecord frameRecord = new FrameRecord(); + for (JobExecutionEvent jobExec : jobExecEvtList ) { + + if (!wasTOF && jobExec.isTOF) { + // Wrap up the previous frame record. + frameRecord.stop = jobExec.start; + frameList.add(frameRecord); + + // Start a new frame record. + frameRecord = new FrameRecord(); + frameRecord.start = jobExec.start; + } + frameRecord.jobEvents.add(jobExec); + + wasTOF = jobExec.isTOF; + idToColorMap.addKey(jobExec.id); + } + frameArray = frameList.toArray( new FrameRecord[ frameList.size() ]); + + // Estimate the total duration and the average frame size. Notice + // that we skip the first frame. + totalDuration = 0.0; + for (int n=1; n < frameArray.length; n++) { + totalDuration += frameArray[n].getDuration(); } + frameSize = totalDuration/(frameArray.length-1); - // Calculate the average frame size. - frameDuration = frameSizeSum / frameSizeCount; + // Set the range of frames to be rendered. + int last_frame_to_render = frameArray.length-1; + if ( frameArray.length > DEFAULT_FRAMES_TO_RENDER) { + last_frame_to_render = DEFAULT_FRAMES_TO_RENDER-1; + } + frameRenderRange = new FrameRange(0, last_frame_to_render); + + // Write the color file. idToColorMap.writeFile("IdToColors.txt"); System.out.println("File loaded.\n"); @@ -95,28 +122,60 @@ public class TraceViewCanvas extends JPanel { System.exit(0); } - int preferredHeight = traceWidth * (int)((largestStop - smallestStart) / frameDuration) + TOP_MARGIN; - setPreferredSize(new Dimension(500, preferredHeight)); + setPreferredSize(new Dimension(500, neededPanelHeight())); ViewListener viewListener = new ViewListener(); addMouseListener(viewListener); addMouseMotionListener(viewListener); } + public int getFrameTotal() { + return frameArray.length; + } + + public int getFirstRenderFrame() { + return frameRenderRange.first; + } + + public void setFirstRenderFrame(int first) throws InvalidFrameBoundsExpection { + if ((first >= 0) && (first <= frameRenderRange.last)) { + frameRenderRange = new FrameRange(first, frameRenderRange.last); + setPreferredSize(new Dimension(500, neededPanelHeight())); + repaint(); + } else { + throw new InvalidFrameBoundsExpection(""); + } + } + + public int getLastRenderFrame() { + return frameRenderRange.last; + } + + public void setLastRenderFrame(int last) throws InvalidFrameBoundsExpection { + if ((last >= frameRenderRange.first) && (last < frameArray.length)) { + frameRenderRange = new FrameRange(frameRenderRange.first, last); + // Re-render this TraceViewCanvas. + setPreferredSize(new Dimension(500, neededPanelHeight())); + repaint(); + } else { + throw new InvalidFrameBoundsExpection(""); + } + } + /** - * @return the current working frame size used for rendering. Initially this - * is estimated from the timeline data, but it can be set to the actual - * realtime frame size of the user's sim. + * @return the current working frame size (seconds) used for rendering. + * Initially this is estimated from the timeline data, but it can be set to + * the actual realtime frame size of the user's sim. */ - public double getFrameDuration() { - return frameDuration; + public double getFrameSize() { + return frameSize; } /** - * Set the frame size to be used for rendering the timeline data. + * Set the frame size (seconds) to be used for rendering the timeline data. * @param duration the frame size. */ - public void setFrameDuration(double duration) { - frameDuration = duration; + public void setFrameSize(double time) { + frameSize = time; repaint(); } @@ -124,7 +183,7 @@ public class TraceViewCanvas extends JPanel { * Increment the width to be used to render the job traces if the current * trace width is less than MAX_TRACE_WIDTH. */ - public void increaseTraceWidth() { + public void incrementTraceWidth() { if (traceWidth < MAX_TRACE_WIDTH) { traceWidth ++; repaint(); @@ -135,7 +194,7 @@ public class TraceViewCanvas extends JPanel { * Decrement the width to be used to render the job traces if the current * trace width is greater than MIN_TRACE_WIDTH. */ - public void decreaseTraceWidth() { + public void decrementTraceWidth() { if (traceWidth > MIN_TRACE_WIDTH) { traceWidth --; repaint(); @@ -150,19 +209,7 @@ public class TraceViewCanvas extends JPanel { int traceRectXMax = getWidth() - RIGHT_MARGIN; if ( x < (LEFT_MARGIN)) return false; if ( x > (traceRectXMax)) return false; - if ( y < TOP_MARGIN) return false; - return true; - } - /** - * @return true if the time rectangle contains the point , otherwise - * false. - */ - private boolean timeRectContains(int x, int y) { - int timeRectXMin = 30; - int timeRectXMax = LEFT_MARGIN; - if ( x < 30 ) return false; - if ( x > LEFT_MARGIN) return false; - if ( y < TOP_MARGIN) return false; + if (( y < TOP_MARGIN) || (y > (TOP_MARGIN + traceRectHeight()))) return false; return true; } @@ -177,20 +224,47 @@ public class TraceViewCanvas extends JPanel { int y = e.getY(); Color color = new Color ( image.getRGB(x,y) ); + // Get and display the ID of the job associated with the color. String id = idToColorMap.getKeyOfColor( color ); sToolBar.setJobID(id); + // Determine the frame number that we clicked on from the y- + // coordinate of the click position. + int frameNumber = 0; if ( y > TOP_MARGIN) { - int frameNumber = (y - TOP_MARGIN) / traceWidth; + frameNumber = (y - TOP_MARGIN) / traceWidth + frameRenderRange.first; sToolBar.setFrameNumber(frameNumber); } + + // Determine the subframe-time where we clicked from the x-coordinate + // of the click position. if ( traceRectContains(x, y)) { - double pixelsPerSecond = (double)calcTraceRectWidth() / frameDuration; + double pixelsPerSecond = (double)traceRectWidth() / frameSize; double subFrameTime = (x - LEFT_MARGIN) / pixelsPerSecond; sToolBar.setSubFrameTime(subFrameTime); } + + /** + * If we clicked on a job trace (above), show the start and stop + * times of the job, otherwise clear the start and stop fields. + */ + if (id != null) { + FrameRecord frame = frameArray[frameNumber]; + for (JobExecutionEvent jobExec : frame.jobEvents) { + if (id.equals( jobExec.id)) { + sToolBar.setJobStartTime(jobExec.start); + sToolBar.setJobStopTime(jobExec.stop); + } + } + } else { + sToolBar.clearJobStartStopTime(); + } } + /** + * Set the cursor to a crossHairCursor if it's over the frame traces, + * otherwise, set it to the defaultCursor. + */ @Override public void mouseMoved(MouseEvent e) { int x = e.getX(); @@ -206,17 +280,25 @@ public class TraceViewCanvas extends JPanel { /** * @return the height of the trace rectangle. */ - private int calcTraceRectHeight() { - return ( getHeight() - TOP_MARGIN - BOTTOM_MARGIN); + private int traceRectHeight() { + return traceWidth * frameRenderRange.size(); } /** * @return the width of the trace rectangle. */ - private int calcTraceRectWidth() { + private int traceRectWidth() { return ( getWidth() - LEFT_MARGIN - RIGHT_MARGIN); } + /** + * Calculate the height of the TraceViewCanvas (JPanel) needed to render the + * selected range of frames. + */ + private int neededPanelHeight() { + return traceWidth * frameRenderRange.size() + TOP_MARGIN + BOTTOM_MARGIN; + } + /** * Render the job execution traces in the jobExecEvtList. */ @@ -230,9 +312,9 @@ public class TraceViewCanvas extends JPanel { rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - int traceRectHeight = calcTraceRectHeight(); - int traceRectWidth = calcTraceRectWidth(); - double pixelsPerSecond = (double)traceRectWidth / frameDuration; + int traceRectHeight = traceRectHeight(); + int traceRectWidth = traceRectWidth(); + double pixelsPerSecond = (double)traceRectWidth / frameSize; // Panel Background Color Fill g2d.setPaint(Color.WHITE); @@ -240,35 +322,32 @@ public class TraceViewCanvas extends JPanel { // Frame Trace Rectangle Fill g2d.setPaint(Color.BLACK); - g2d.fillRect(LEFT_MARGIN, TOP_MARGIN, traceRectWidth, traceRectHeight); + g2d.fillRect(LEFT_MARGIN, TOP_MARGIN, traceRectWidth, traceRectHeight()); - boolean wasEOF = false; - boolean wasTOF = false; - double startOfFrame = 0.0; - int frameNumber = 0; + // Draw each frame in the selected range of frames to be rendered. + for (int n = frameRenderRange.first; + n <= frameRenderRange.last; + n++) { - for (JobExecutionEvent jobExec : jobExecList ) { + FrameRecord frame = frameArray[n]; - if (!wasTOF && jobExec.isTOF) { - startOfFrame = jobExec.start; - frameNumber ++; + // Draw the frame + for (JobExecutionEvent jobExec : frame.jobEvents) { + int jobY = TOP_MARGIN + (n - frameRenderRange.first) * traceWidth; + int jobStartX = LEFT_MARGIN + (int)((jobExec.start - frame.start) * pixelsPerSecond); + int jobWidth = (int)( (jobExec.stop - jobExec.start) * pixelsPerSecond); + + g2d.setPaint(Color.BLACK); + g2d.drawString ( String.format("%d", n), 50, jobY + traceWidth/2); + g2d.setPaint( idToColorMap.getColor( jobExec.id ) ); + g2d.fillRect(jobStartX, jobY, jobWidth, traceWidth-2); } - - wasTOF = jobExec.isTOF; - wasEOF = jobExec.isEOF; - - int jobY = TOP_MARGIN + frameNumber * traceWidth; - int jobStartX = LEFT_MARGIN + (int)((jobExec.start - startOfFrame) * pixelsPerSecond); - int jobWidth = (int)( (jobExec.stop - jobExec.start) * pixelsPerSecond); - - g2d.setPaint(Color.BLACK); - g2d.drawString ( String.format("%8.3f", startOfFrame), 30, jobY + traceWidth/2); - g2d.setPaint( idToColorMap.getColor( jobExec.id ) ); - g2d.fillRect(jobStartX, jobY, jobWidth, traceWidth-2); - } } + /** + * This function paints the TraceViewCanvas (i.e, JPanel) when required. + */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewInputToolBar.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewInputToolBar.java index c5a690ca..c441b1f7 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewInputToolBar.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewInputToolBar.java @@ -10,50 +10,109 @@ import java.net.URL; * Class TraceViewInputToolBar initially displays an estimate of the frame size * for the JobPerf input timeline data. A user may also enter the intended frame * size into the JTextField, and pressing the "Set" button, which calls -* traceView.setFrameDuration( newFrameSize ); +* traceView.setFrameSize( newFrameSize ); +* +* Class TraceViewInputToolBar aggregates the following GUI components: +* TraceViewInputToolBar (isa JToolBar) +* JLabel () +* JTextField [frameSizeField] +* JLabel +* JLabel +* JTextField [firstRenderFrameField] +* JLabel +* JTextField [lastRenderFrameField] */ -public class TraceViewInputToolBar extends JToolBar implements ActionListener { +public class TraceViewInputToolBar extends JToolBar { private TraceViewCanvas traceView; - private JTextField frameDurationField; + private JTextField frameSizeField; + private JTextField firstRenderFrameField; + private JTextField lastRenderFrameField; /** * Constructor * @param tvc TraceViewCanvas to be controlled. */ public TraceViewInputToolBar (TraceViewCanvas tvc) { traceView = tvc; - add( new JLabel(" Frame Size: ")); - frameDurationField = new JTextField(15); - frameDurationField.setText( String.format("%8.4f", traceView.getFrameDuration()) ); - add(frameDurationField); - JButton setButton = new JButton("Set"); - setButton.addActionListener(this); - setButton.setActionCommand("setFrameSize"); - setButton.setToolTipText("Set frame size in seconds."); - add(setButton); + add( new JLabel(" Frame Size: ")); + frameSizeField = new JTextField(15); + frameSizeField.setText( String.format("%8.4f", traceView.getFrameSize()) ); + add(frameSizeField); + frameSizeField.addKeyListener( new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + setFrameSize(); + } + } + }); + + add( new JLabel( String.format(" Total Frame Range: %d ... %d", 0, traceView.getFrameTotal()-1 ))); + + add( new JLabel(" Selected Frame Range: ")); + + firstRenderFrameField = new JTextField(15); + firstRenderFrameField.setText( String.format("%d", traceView.getFirstRenderFrame()) ); + add(firstRenderFrameField); + firstRenderFrameField.addKeyListener( new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + setFirstRenderFrame(); + } + } + }); + + add( new JLabel("...")); + lastRenderFrameField = new JTextField(15); + lastRenderFrameField.setText( String.format("%d", traceView.getLastRenderFrame()) ); + add(lastRenderFrameField); + lastRenderFrameField.addKeyListener( new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + setLastRenderFrame(); + } + } + }); // Add Trick LOGO here. - } - @Override - public void actionPerformed(ActionEvent event) { - String s = event.getActionCommand(); - switch (s) { - case "setFrameSize": - double newFrameSize = 0.0; - try { - newFrameSize = Double.parseDouble( frameDurationField.getText() ); - } catch ( NumberFormatException e) { - frameDurationField.setText( String.format("%8.4f", traceView.getFrameDuration()) ); - } - if ( newFrameSize > 0.0) { - traceView.setFrameDuration( newFrameSize ); - } - break; - default: - System.out.println("Unknown Action Command:" + s); - break; + + private void setFirstRenderFrame() { + int newStartFrame = 0; + try { + newStartFrame = Integer.parseInt( firstRenderFrameField.getText() ); + traceView.setFirstRenderFrame( newStartFrame ); + } catch ( NumberFormatException e) { + firstRenderFrameField.setText( String.format("%d", traceView.getFirstRenderFrame())); + } catch ( InvalidFrameBoundsExpection e) { + firstRenderFrameField.setText( String.format("%d", traceView.getFirstRenderFrame())); + } + } + + private void setLastRenderFrame() { + int newFinalFrame = 0; + try { + newFinalFrame = Integer.parseInt( lastRenderFrameField.getText() ); + traceView.setLastRenderFrame( newFinalFrame ); + } catch ( NumberFormatException e) { + lastRenderFrameField.setText( String.format("%d", traceView.getLastRenderFrame())); + } catch (InvalidFrameBoundsExpection e) { + lastRenderFrameField.setText( String.format("%d", traceView.getLastRenderFrame())); + } + } + + private void setFrameSize() { + double newFrameSize = 0.0; + try { + newFrameSize = Double.parseDouble( frameSizeField.getText() ); + } catch ( NumberFormatException e) { + frameSizeField.setText( String.format("%8.4f", traceView.getFrameSize()) ); + } + if ( newFrameSize > 0.0) { + traceView.setFrameSize( newFrameSize ); } } } diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewMenuBar.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewMenuBar.java index 1ee5353e..cae9d40b 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewMenuBar.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewMenuBar.java @@ -13,8 +13,8 @@ import javax.swing.*; * JMenuItem [fileMenuExit], Action: Call System.exit(0); * JMenu [optionsMenu] * JMenu [traceSizeMenu] -* JMenuItem [traceSizeMenuIncrease], Action: Call traceView.increaseTraceWidth(). -* JMenuItem [traceSizeMenuDecrease], Action: Call traceView.decreaseTraceWidth() +* JMenuItem [traceSizeMenuIncrease], Action: Call traceView.incrementTraceWidth(). +* JMenuItem [traceSizeMenuDecrease], Action: Call traceView.decrementTraceWidth() */ public class TraceViewMenuBar extends JMenuBar implements ActionListener { @@ -38,7 +38,7 @@ public class TraceViewMenuBar extends JMenuBar implements ActionListener { JMenu traceSizeMenu = new JMenu("TraceSize"); JMenuItem traceSizeMenuIncrease = new JMenuItem("Increase Trace Width"); traceSizeMenuIncrease.setActionCommand("increase-trace_width"); - KeyStroke ctrlPlus = KeyStroke.getKeyStroke('P', InputEvent.CTRL_MASK ); + KeyStroke ctrlPlus = KeyStroke.getKeyStroke('=', InputEvent.CTRL_MASK ); traceSizeMenuIncrease.setAccelerator(ctrlPlus); traceSizeMenuIncrease.addActionListener(this); traceSizeMenu.add(traceSizeMenuIncrease); @@ -57,10 +57,10 @@ public class TraceViewMenuBar extends JMenuBar implements ActionListener { String s = e.getActionCommand(); switch (s) { case "increase-trace_width": - traceView.increaseTraceWidth(); + traceView.incrementTraceWidth(); break; case "decrease-trace_width": - traceView.decreaseTraceWidth(); + traceView.decrementTraceWidth(); break; case "exit": System.exit(0); diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewOutputToolBar.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewOutputToolBar.java index c31e0e38..d0ea6a38 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewOutputToolBar.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewOutputToolBar.java @@ -9,6 +9,8 @@ import javax.swing.*; */ class TraceViewOutputToolBar extends JToolBar { private JTextField IDField; + private JTextField startField; + private JTextField stopField; private JTextField frameNumberField; private JTextField subFrameTimeField; @@ -23,6 +25,18 @@ class TraceViewOutputToolBar extends JToolBar { IDField.setText( ""); add(IDField); + add( new JLabel(" Job Start: ")); + startField = new JTextField(15); + startField.setEditable(false); + startField.setText( ""); + add(startField); + + add( new JLabel(" Job Stop: ")); + stopField = new JTextField(15); + stopField.setEditable(false); + stopField.setText( ""); + add(stopField); + add( new JLabel(" Frame Number: ")); frameNumberField = new JTextField(15); frameNumberField.setEditable(false); @@ -41,6 +55,26 @@ class TraceViewOutputToolBar extends JToolBar { public void setJobID(String id) { IDField.setText( id ); } + /** + * @param time to be displayed in the job start field. + */ + public void setJobStartTime(Double time) { + startField.setText( String.format("%8.4f", time) ); + } + /** + * @param time to be displayed in the job stop field. + */ + public void setJobStopTime(Double time) { + stopField.setText( String.format("%8.4f", time) ); + } + /** + * Clear the startField and stopField. + */ + public void clearJobStartStopTime() { + startField.setText(""); + stopField.setText(""); + IDField.setText(""); + } /** * @param fn frame number to display. */ diff --git a/trick_source/java/src/main/java/trick/jobperf/TraceViewWindow.java b/trick_source/java/src/main/java/trick/jobperf/TraceViewWindow.java index 23741a07..b9ba346e 100644 --- a/trick_source/java/src/main/java/trick/jobperf/TraceViewWindow.java +++ b/trick_source/java/src/main/java/trick/jobperf/TraceViewWindow.java @@ -13,7 +13,7 @@ import javax.swing.*; * - JPanel [mainPanel] * - JPanel [tracePanel] * - JScrollPane [scrollPane] -* - TraceViewCanvas [traceView] +* - TraceViewCanvas [traceViewCanvas] * - TraceViewOutputToolBar [outputToolBar] */ public class TraceViewWindow extends JFrame { @@ -24,16 +24,17 @@ public class TraceViewWindow extends JFrame { */ public TraceViewWindow( ArrayList jobExecList ) { TraceViewOutputToolBar outputToolBar = new TraceViewOutputToolBar(); - TraceViewCanvas traceView = new TraceViewCanvas( jobExecList, outputToolBar); + TraceViewCanvas traceViewCanvas = new TraceViewCanvas( jobExecList, outputToolBar); - TraceViewMenuBar menuBar = new TraceViewMenuBar(traceView); + TraceViewMenuBar menuBar = new TraceViewMenuBar( traceViewCanvas); setJMenuBar(menuBar); - TraceViewInputToolBar nToolBar = new TraceViewInputToolBar( traceView ); + TraceViewInputToolBar nToolBar = new TraceViewInputToolBar( traceViewCanvas ); add(nToolBar, BorderLayout.NORTH); - JScrollPane scrollPane = new JScrollPane( traceView ); + JScrollPane scrollPane = new JScrollPane( traceViewCanvas ); scrollPane.setPreferredSize(new Dimension(800, 400)); + scrollPane.getVerticalScrollBar().setUnitIncrement( 20 ); JPanel tracePanel = new JPanel(); tracePanel.setPreferredSize(new Dimension(800, 400)); @@ -55,6 +56,6 @@ public class TraceViewWindow extends JFrame { setFocusable(true); setVisible(true); - traceView.repaint(); + traceViewCanvas.repaint(); } }