Frame range selection and speed improvements.

This commit is contained in:
John M. Penn 2024-12-02 12:17:46 -06:00
parent c311abce8a
commit efe90ae230
8 changed files with 352 additions and 134 deletions

View File

@ -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<JobExecutionEvent> jobEvents;
public double start;
public double stop;
/**
* Constructor
*/
public FrameRecord() {
start = 0.0;
stop = 0.0;
jobEvents = new ArrayList<JobExecutionEvent>()
;
}
/**
* @return the stop time minus the start time.
*/
public double getDuration() {
return stop - start;
}
}

View File

@ -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);
}
}

View File

@ -6,9 +6,15 @@ import java.util.*;
import javax.swing.*; import javax.swing.*;
/** /**
* Class JobPerf is an application that renders time line data from a Trick based * Capabilites That Need To Be Added
simulation and generates run-time statistics reports for the simulation jobs. * - a way to filter the data to be within a user specified sub time period
It can be run with or without a GUI. * 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 { public class JobPerf extends JFrame {
ArrayList<JobExecutionEvent> jobExecEvtList; ArrayList<JobExecutionEvent> jobExecEvtList;

View File

@ -11,44 +11,61 @@ import javax.swing.event.*;
/** /**
* Class TraceViewCanvas renders the simulation timeline data stored in * Class TraceViewCanvas renders the simulation timeline data stored in
* an ArrayList of JobExecutionEvent's [jobExecEvtList]. Information regarding mouse clicks * an ArrayList of JobExecutionEvent's [jobExecEvtList]. Information regarding
* are sent to the TraceViewOutputToolBar [outputToolBar.] * mouse clicks are sent to the TraceViewOutputToolBar [outputToolBar.]
* @author John M. Penn
*/ */
public class TraceViewCanvas extends JPanel { public class TraceViewCanvas extends JPanel {
public static final int MIN_TRACE_WIDTH = 4; 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 MAX_TRACE_WIDTH = 30;
public static final int LEFT_MARGIN = 100; public static final int LEFT_MARGIN = 100;
public static final int RIGHT_MARGIN = 100; public static final int RIGHT_MARGIN = 100;
public static final int TOP_MARGIN = 20; public static final int TOP_MARGIN = 20;
public static final int BOTTOM_MARGIN = 20; public static final int BOTTOM_MARGIN = 20;
public static final int DEFAULT_FRAMES_TO_RENDER = 100;
private int traceWidth; private int traceWidth;
private double frameDuration; private double frameSize;
private List<JobExecutionEvent> jobExecList; private double totalDuration;
private FrameRecord[] frameArray;
private FrameRange frameRenderRange;
private KeyedColorMap idToColorMap; private KeyedColorMap idToColorMap;
private BufferedImage image; private BufferedImage image;
private TraceViewOutputToolBar sToolBar; private TraceViewOutputToolBar sToolBar;
private Cursor crossHairCursor; private Cursor crossHairCursor;
private Cursor defaultCursor; 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 * Constructor
* @param jobExecEvtList the job time line data. * @param jobExecEvtList the job time line data.
* @param outputToolBar the toolbar to which data is to be sent for display. * @param outputToolBar the toolbar to which data is to be sent for display.
*/ */
public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList, TraceViewOutputToolBar outputToolBar ) { public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList,
TraceViewOutputToolBar outputToolBar ) {
traceWidth = DEFAULT_TRACE_WIDTH; traceWidth = DEFAULT_TRACE_WIDTH;
frameDuration = 1.0; frameSize = 1.0;
image = null; image = null;
sToolBar = outputToolBar; sToolBar = outputToolBar;
jobExecList = jobExecEvtList;
crossHairCursor = new Cursor( Cursor.CROSSHAIR_CURSOR ); crossHairCursor = new Cursor( Cursor.CROSSHAIR_CURSOR );
defaultCursor = new Cursor( Cursor.DEFAULT_CURSOR ); defaultCursor = new Cursor( Cursor.DEFAULT_CURSOR );
double smallestStart = Double.MAX_VALUE;
double largestStop = -Double.MAX_VALUE;
try { try {
idToColorMap = new KeyedColorMap(); idToColorMap = new KeyedColorMap();
@ -56,34 +73,44 @@ public class TraceViewCanvas extends JPanel {
if (colorfile.exists()) { if (colorfile.exists()) {
idToColorMap.readFile("IdToColors.txt"); idToColorMap.readFile("IdToColors.txt");
} }
boolean wasTOF = false; 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 ) { List<FrameRecord> frameList = new ArrayList<FrameRecord>();
if (jobExec.start < smallestStart) smallestStart = jobExec.start; FrameRecord frameRecord = new FrameRecord();
if (jobExec.stop > largestStop) largestStop = jobExec.stop; for (JobExecutionEvent jobExec : jobExecEvtList ) {
// Calculate the average frame size.
if (!wasTOF && jobExec.isTOF) { if (!wasTOF && jobExec.isTOF) {
startOfFrame = jobExec.start; // Wrap up the previous frame record.
if (frameNumber > 0) { frameRecord.stop = jobExec.start;
double frameSize = (startOfFrame - lastStartOfFrame); frameList.add(frameRecord);
frameSizeSum += frameSize;
frameSizeCount ++; // Start a new frame record.
} frameRecord = new FrameRecord();
lastStartOfFrame = startOfFrame; frameRecord.start = jobExec.start;
frameNumber++; }
} frameRecord.jobEvents.add(jobExec);
wasTOF = jobExec.isTOF;
idToColorMap.addKey(jobExec.id); 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. // Set the range of frames to be rendered.
frameDuration = frameSizeSum / frameSizeCount; 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"); idToColorMap.writeFile("IdToColors.txt");
System.out.println("File loaded.\n"); System.out.println("File loaded.\n");
@ -95,28 +122,60 @@ public class TraceViewCanvas extends JPanel {
System.exit(0); System.exit(0);
} }
int preferredHeight = traceWidth * (int)((largestStop - smallestStart) / frameDuration) + TOP_MARGIN; setPreferredSize(new Dimension(500, neededPanelHeight()));
setPreferredSize(new Dimension(500, preferredHeight));
ViewListener viewListener = new ViewListener(); ViewListener viewListener = new ViewListener();
addMouseListener(viewListener); addMouseListener(viewListener);
addMouseMotionListener(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 * @return the current working frame size (seconds) used for rendering.
* is estimated from the timeline data, but it can be set to the actual * Initially this is estimated from the timeline data, but it can be set to
* realtime frame size of the user's sim. * the actual realtime frame size of the user's sim.
*/ */
public double getFrameDuration() { public double getFrameSize() {
return frameDuration; 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. * @param duration the frame size.
*/ */
public void setFrameDuration(double duration) { public void setFrameSize(double time) {
frameDuration = duration; frameSize = time;
repaint(); repaint();
} }
@ -124,7 +183,7 @@ public class TraceViewCanvas extends JPanel {
* Increment the width to be used to render the job traces if the current * Increment the width to be used to render the job traces if the current
* trace width is less than MAX_TRACE_WIDTH. * trace width is less than MAX_TRACE_WIDTH.
*/ */
public void increaseTraceWidth() { public void incrementTraceWidth() {
if (traceWidth < MAX_TRACE_WIDTH) { if (traceWidth < MAX_TRACE_WIDTH) {
traceWidth ++; traceWidth ++;
repaint(); repaint();
@ -135,7 +194,7 @@ public class TraceViewCanvas extends JPanel {
* Decrement the width to be used to render the job traces if the current * Decrement the width to be used to render the job traces if the current
* trace width is greater than MIN_TRACE_WIDTH. * trace width is greater than MIN_TRACE_WIDTH.
*/ */
public void decreaseTraceWidth() { public void decrementTraceWidth() {
if (traceWidth > MIN_TRACE_WIDTH) { if (traceWidth > MIN_TRACE_WIDTH) {
traceWidth --; traceWidth --;
repaint(); repaint();
@ -150,19 +209,7 @@ public class TraceViewCanvas extends JPanel {
int traceRectXMax = getWidth() - RIGHT_MARGIN; int traceRectXMax = getWidth() - RIGHT_MARGIN;
if ( x < (LEFT_MARGIN)) return false; if ( x < (LEFT_MARGIN)) return false;
if ( x > (traceRectXMax)) return false; if ( x > (traceRectXMax)) return false;
if ( y < TOP_MARGIN) return false; if (( y < TOP_MARGIN) || (y > (TOP_MARGIN + traceRectHeight()))) return false;
return true;
}
/**
* @return true if the time rectangle contains the point <x,y>, 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;
return true; return true;
} }
@ -177,20 +224,47 @@ public class TraceViewCanvas extends JPanel {
int y = e.getY(); int y = e.getY();
Color color = new Color ( image.getRGB(x,y) ); 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 ); String id = idToColorMap.getKeyOfColor( color );
sToolBar.setJobID(id); 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) { if ( y > TOP_MARGIN) {
int frameNumber = (y - TOP_MARGIN) / traceWidth; frameNumber = (y - TOP_MARGIN) / traceWidth + frameRenderRange.first;
sToolBar.setFrameNumber(frameNumber); sToolBar.setFrameNumber(frameNumber);
} }
// Determine the subframe-time where we clicked from the x-coordinate
// of the click position.
if ( traceRectContains(x, y)) { if ( traceRectContains(x, y)) {
double pixelsPerSecond = (double)calcTraceRectWidth() / frameDuration; double pixelsPerSecond = (double)traceRectWidth() / frameSize;
double subFrameTime = (x - LEFT_MARGIN) / pixelsPerSecond; double subFrameTime = (x - LEFT_MARGIN) / pixelsPerSecond;
sToolBar.setSubFrameTime(subFrameTime); 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 @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
int x = e.getX(); int x = e.getX();
@ -206,17 +280,25 @@ public class TraceViewCanvas extends JPanel {
/** /**
* @return the height of the trace rectangle. * @return the height of the trace rectangle.
*/ */
private int calcTraceRectHeight() { private int traceRectHeight() {
return ( getHeight() - TOP_MARGIN - BOTTOM_MARGIN); return traceWidth * frameRenderRange.size();
} }
/** /**
* @return the width of the trace rectangle. * @return the width of the trace rectangle.
*/ */
private int calcTraceRectWidth() { private int traceRectWidth() {
return ( getWidth() - LEFT_MARGIN - RIGHT_MARGIN); 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. * Render the job execution traces in the jobExecEvtList.
*/ */
@ -230,9 +312,9 @@ public class TraceViewCanvas extends JPanel {
rh.put(RenderingHints.KEY_RENDERING, rh.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY); RenderingHints.VALUE_RENDER_QUALITY);
int traceRectHeight = calcTraceRectHeight(); int traceRectHeight = traceRectHeight();
int traceRectWidth = calcTraceRectWidth(); int traceRectWidth = traceRectWidth();
double pixelsPerSecond = (double)traceRectWidth / frameDuration; double pixelsPerSecond = (double)traceRectWidth / frameSize;
// Panel Background Color Fill // Panel Background Color Fill
g2d.setPaint(Color.WHITE); g2d.setPaint(Color.WHITE);
@ -240,35 +322,32 @@ public class TraceViewCanvas extends JPanel {
// Frame Trace Rectangle Fill // Frame Trace Rectangle Fill
g2d.setPaint(Color.BLACK); g2d.setPaint(Color.BLACK);
g2d.fillRect(LEFT_MARGIN, TOP_MARGIN, traceRectWidth, traceRectHeight); g2d.fillRect(LEFT_MARGIN, TOP_MARGIN, traceRectWidth, traceRectHeight());
boolean wasEOF = false; // Draw each frame in the selected range of frames to be rendered.
boolean wasTOF = false; for (int n = frameRenderRange.first;
double startOfFrame = 0.0; n <= frameRenderRange.last;
int frameNumber = 0; n++) {
for (JobExecutionEvent jobExec : jobExecList ) { FrameRecord frame = frameArray[n];
if (!wasTOF && jobExec.isTOF) { // Draw the frame
startOfFrame = jobExec.start; for (JobExecutionEvent jobExec : frame.jobEvents) {
frameNumber ++; 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 @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);

View File

@ -10,50 +10,109 @@ import java.net.URL;
* Class TraceViewInputToolBar initially displays an estimate of the frame size * Class TraceViewInputToolBar initially displays an estimate of the frame size
* for the JobPerf input timeline data. A user may also enter the intended frame * 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 * 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 TraceViewCanvas traceView;
private JTextField frameDurationField; private JTextField frameSizeField;
private JTextField firstRenderFrameField;
private JTextField lastRenderFrameField;
/** /**
* Constructor * Constructor
* @param tvc TraceViewCanvas to be controlled. * @param tvc TraceViewCanvas to be controlled.
*/ */
public TraceViewInputToolBar (TraceViewCanvas tvc) { public TraceViewInputToolBar (TraceViewCanvas tvc) {
traceView = 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"); add( new JLabel(" Frame Size: "));
setButton.addActionListener(this); frameSizeField = new JTextField(15);
setButton.setActionCommand("setFrameSize"); frameSizeField.setText( String.format("%8.4f", traceView.getFrameSize()) );
setButton.setToolTipText("Set frame size in seconds."); add(frameSizeField);
add(setButton); 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. // Add Trick LOGO here.
} }
@Override
public void actionPerformed(ActionEvent event) { private void setFirstRenderFrame() {
String s = event.getActionCommand(); int newStartFrame = 0;
switch (s) { try {
case "setFrameSize": newStartFrame = Integer.parseInt( firstRenderFrameField.getText() );
double newFrameSize = 0.0; traceView.setFirstRenderFrame( newStartFrame );
try { } catch ( NumberFormatException e) {
newFrameSize = Double.parseDouble( frameDurationField.getText() ); firstRenderFrameField.setText( String.format("%d", traceView.getFirstRenderFrame()));
} catch ( NumberFormatException e) { } catch ( InvalidFrameBoundsExpection e) {
frameDurationField.setText( String.format("%8.4f", traceView.getFrameDuration()) ); firstRenderFrameField.setText( String.format("%d", traceView.getFirstRenderFrame()));
} }
if ( newFrameSize > 0.0) { }
traceView.setFrameDuration( newFrameSize );
} private void setLastRenderFrame() {
break; int newFinalFrame = 0;
default: try {
System.out.println("Unknown Action Command:" + s); newFinalFrame = Integer.parseInt( lastRenderFrameField.getText() );
break; 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 );
} }
} }
} }

View File

@ -13,8 +13,8 @@ import javax.swing.*;
* JMenuItem [fileMenuExit], Action: Call System.exit(0); * JMenuItem [fileMenuExit], Action: Call System.exit(0);
* JMenu [optionsMenu] * JMenu [optionsMenu]
* JMenu [traceSizeMenu] * JMenu [traceSizeMenu]
* JMenuItem [traceSizeMenuIncrease], Action: Call traceView.increaseTraceWidth(). * JMenuItem [traceSizeMenuIncrease], Action: Call traceView.incrementTraceWidth().
* JMenuItem [traceSizeMenuDecrease], Action: Call traceView.decreaseTraceWidth() * JMenuItem [traceSizeMenuDecrease], Action: Call traceView.decrementTraceWidth()
*/ */
public class TraceViewMenuBar extends JMenuBar implements ActionListener { public class TraceViewMenuBar extends JMenuBar implements ActionListener {
@ -38,7 +38,7 @@ public class TraceViewMenuBar extends JMenuBar implements ActionListener {
JMenu traceSizeMenu = new JMenu("TraceSize"); JMenu traceSizeMenu = new JMenu("TraceSize");
JMenuItem traceSizeMenuIncrease = new JMenuItem("Increase Trace Width"); JMenuItem traceSizeMenuIncrease = new JMenuItem("Increase Trace Width");
traceSizeMenuIncrease.setActionCommand("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.setAccelerator(ctrlPlus);
traceSizeMenuIncrease.addActionListener(this); traceSizeMenuIncrease.addActionListener(this);
traceSizeMenu.add(traceSizeMenuIncrease); traceSizeMenu.add(traceSizeMenuIncrease);
@ -57,10 +57,10 @@ public class TraceViewMenuBar extends JMenuBar implements ActionListener {
String s = e.getActionCommand(); String s = e.getActionCommand();
switch (s) { switch (s) {
case "increase-trace_width": case "increase-trace_width":
traceView.increaseTraceWidth(); traceView.incrementTraceWidth();
break; break;
case "decrease-trace_width": case "decrease-trace_width":
traceView.decreaseTraceWidth(); traceView.decrementTraceWidth();
break; break;
case "exit": case "exit":
System.exit(0); System.exit(0);

View File

@ -9,6 +9,8 @@ import javax.swing.*;
*/ */
class TraceViewOutputToolBar extends JToolBar { class TraceViewOutputToolBar extends JToolBar {
private JTextField IDField; private JTextField IDField;
private JTextField startField;
private JTextField stopField;
private JTextField frameNumberField; private JTextField frameNumberField;
private JTextField subFrameTimeField; private JTextField subFrameTimeField;
@ -23,6 +25,18 @@ class TraceViewOutputToolBar extends JToolBar {
IDField.setText( ""); IDField.setText( "");
add(IDField); 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: ")); add( new JLabel(" Frame Number: "));
frameNumberField = new JTextField(15); frameNumberField = new JTextField(15);
frameNumberField.setEditable(false); frameNumberField.setEditable(false);
@ -41,6 +55,26 @@ class TraceViewOutputToolBar extends JToolBar {
public void setJobID(String id) { public void setJobID(String id) {
IDField.setText( 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. * @param fn frame number to display.
*/ */

View File

@ -13,7 +13,7 @@ import javax.swing.*;
* - JPanel [mainPanel] * - JPanel [mainPanel]
* - JPanel [tracePanel] * - JPanel [tracePanel]
* - JScrollPane [scrollPane] * - JScrollPane [scrollPane]
* - TraceViewCanvas [traceView] * - TraceViewCanvas [traceViewCanvas]
* - TraceViewOutputToolBar [outputToolBar] * - TraceViewOutputToolBar [outputToolBar]
*/ */
public class TraceViewWindow extends JFrame { public class TraceViewWindow extends JFrame {
@ -24,16 +24,17 @@ public class TraceViewWindow extends JFrame {
*/ */
public TraceViewWindow( ArrayList<JobExecutionEvent> jobExecList ) { public TraceViewWindow( ArrayList<JobExecutionEvent> jobExecList ) {
TraceViewOutputToolBar outputToolBar = new TraceViewOutputToolBar(); 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); setJMenuBar(menuBar);
TraceViewInputToolBar nToolBar = new TraceViewInputToolBar( traceView ); TraceViewInputToolBar nToolBar = new TraceViewInputToolBar( traceViewCanvas );
add(nToolBar, BorderLayout.NORTH); add(nToolBar, BorderLayout.NORTH);
JScrollPane scrollPane = new JScrollPane( traceView ); JScrollPane scrollPane = new JScrollPane( traceViewCanvas );
scrollPane.setPreferredSize(new Dimension(800, 400)); scrollPane.setPreferredSize(new Dimension(800, 400));
scrollPane.getVerticalScrollBar().setUnitIncrement( 20 );
JPanel tracePanel = new JPanel(); JPanel tracePanel = new JPanel();
tracePanel.setPreferredSize(new Dimension(800, 400)); tracePanel.setPreferredSize(new Dimension(800, 400));
@ -55,6 +56,6 @@ public class TraceViewWindow extends JFrame {
setFocusable(true); setFocusable(true);
setVisible(true); setVisible(true);
traceView.repaint(); traceViewCanvas.repaint();
} }
} }