Skip to content

Commit

Permalink
Indicate selected frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpenn committed Dec 4, 2024
1 parent efe90ae commit 590c3dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion trick_source/java/src/main/java/trick/jobperf/JobPerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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 {
ArrayList<JobExecutionEvent> jobExecEvtList;
JobStats jobStats;

Expand Down
14 changes: 10 additions & 4 deletions trick_source/java/src/main/java/trick/jobperf/TraceViewCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TraceViewCanvas extends JPanel {
private double frameSize;
private double totalDuration;
private FrameRecord[] frameArray;
private int selectedFrameNumber;
private FrameRange frameRenderRange;
private KeyedColorMap idToColorMap;
private BufferedImage image;
Expand Down Expand Up @@ -63,6 +64,7 @@ public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList,
traceWidth = DEFAULT_TRACE_WIDTH;
frameSize = 1.0;
image = null;
selectedFrameNumber = 0;
sToolBar = outputToolBar;
crossHairCursor = new Cursor( Cursor.CROSSHAIR_CURSOR );
defaultCursor = new Cursor( Cursor.DEFAULT_CURSOR );
Expand Down Expand Up @@ -230,10 +232,10 @@ public void mouseReleased(MouseEvent e) {

// Determine the frame number that we clicked on from the y-
// coordinate of the click position.
int frameNumber = 0;

if ( y > TOP_MARGIN) {
frameNumber = (y - TOP_MARGIN) / traceWidth + frameRenderRange.first;
sToolBar.setFrameNumber(frameNumber);
selectedFrameNumber = (y - TOP_MARGIN) / traceWidth + frameRenderRange.first;
sToolBar.setFrameNumber(selectedFrameNumber);
}

// Determine the subframe-time where we clicked from the x-coordinate
Expand All @@ -249,13 +251,14 @@ public void mouseReleased(MouseEvent e) {
* times of the job, otherwise clear the start and stop fields.
*/
if (id != null) {
FrameRecord frame = frameArray[frameNumber];
FrameRecord frame = frameArray[selectedFrameNumber];
for (JobExecutionEvent jobExec : frame.jobEvents) {
if (id.equals( jobExec.id)) {
sToolBar.setJobStartTime(jobExec.start);
sToolBar.setJobStopTime(jobExec.stop);
}
}
repaint();
} else {
sToolBar.clearJobStartStopTime();
}
Expand Down Expand Up @@ -338,6 +341,9 @@ private void doDrawing(Graphics g) {
int jobWidth = (int)( (jobExec.stop - jobExec.start) * pixelsPerSecond);

g2d.setPaint(Color.BLACK);
if (n == selectedFrameNumber) {
g2d.setPaint(Color.GREEN);
}
g2d.drawString ( String.format("%d", n), 50, jobY + traceWidth/2);
g2d.setPaint( idToColorMap.getColor( jobExec.id ) );
g2d.fillRect(jobStartX, jobY, jobWidth, traceWidth-2);
Expand Down

0 comments on commit 590c3dd

Please sign in to comment.