Refactor JobPerf.java to clean up names and organization.

This commit is contained in:
John M. Penn 2024-10-01 12:19:48 -05:00
parent f287155f8c
commit 7e60ca864e

View File

@ -116,7 +116,7 @@ class KeyedColorMap {
} }
} // KeyedColorMap } // KeyedColorMap
class TraceViewPanel extends JPanel { 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 = 10;
@ -131,21 +131,21 @@ class TraceViewPanel extends JPanel {
private List<JobExecutionEvent> jobExecList; private List<JobExecutionEvent> jobExecList;
private KeyedColorMap idToColorMap; private KeyedColorMap idToColorMap;
private BufferedImage image; private BufferedImage image;
private SouthToolBar sToolBar; private TraceViewOutputToolBar sToolBar;
private Cursor crossHairCursor; private Cursor crossHairCursor;
private Cursor defaultCursor; private Cursor defaultCursor;
public TraceViewPanel( ArrayList<JobExecutionEvent> jobExecEvtList, SouthToolBar southToolBar ) { public TraceViewCanvas( ArrayList<JobExecutionEvent> jobExecEvtList, TraceViewOutputToolBar outputToolBar ) {
traceWidth = DEFAULT_TRACE_WIDTH; traceWidth = DEFAULT_TRACE_WIDTH;
frameDuration = 1.0; frameDuration = 1.0;
image = null; image = null;
sToolBar = southToolBar; sToolBar = outputToolBar;
jobExecList = jobExecEvtList; 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 smallestStart = Double.MAX_VALUE;
double largestStop = -Double.MAX_VALUE; double largestStop = -Double.MAX_VALUE;
try { try {
idToColorMap = new KeyedColorMap(); idToColorMap = new KeyedColorMap();
@ -334,14 +334,14 @@ class TraceViewPanel extends JPanel {
g.drawImage(image, 0, 0, this); g.drawImage(image, 0, 0, this);
g2.dispose(); g2.dispose();
} }
} // class TraceViewPanel } // class TraceViewCanvas
class NorthToolBar extends JToolBar implements ActionListener { class TraceViewInputToolBar extends JToolBar implements ActionListener {
private TraceViewPanel traceView; private TraceViewCanvas traceView;
private JTextField frameDurationField; private JTextField frameDurationField;
public NorthToolBar (TraceViewPanel tv) { public TraceViewInputToolBar (TraceViewCanvas tv) {
traceView = tv; traceView = tv;
add( new JLabel(" Frame Size: ")); add( new JLabel(" Frame Size: "));
frameDurationField = new JTextField(15); frameDurationField = new JTextField(15);
@ -373,14 +373,14 @@ class NorthToolBar extends JToolBar implements ActionListener {
break; break;
} }
} }
} // class NorthToolBar } // class TraceViewInputToolBar
class SouthToolBar extends JToolBar { class TraceViewOutputToolBar extends JToolBar {
private JTextField IDField; private JTextField IDField;
private JTextField frameNumberField; private JTextField frameNumberField;
private JTextField subFrameTimeField; private JTextField subFrameTimeField;
public SouthToolBar () { public TraceViewOutputToolBar () {
add( new JLabel(" Job ID: ")); add( new JLabel(" Job ID: "));
IDField = new JTextField(15); IDField = new JTextField(15);
@ -409,13 +409,13 @@ class SouthToolBar extends JToolBar {
public void setSubFrameTime(double time) { public void setSubFrameTime(double time) {
subFrameTimeField.setText( String.format("%8.4f", time)); subFrameTimeField.setText( String.format("%8.4f", time));
} }
} // class SouthToolBar } // class TraceViewOutputToolBar
class PerfMenuBar extends JMenuBar implements ActionListener { class TraceViewMenuBar extends JMenuBar implements ActionListener {
private TraceViewPanel traceView; private TraceViewCanvas traceView;
public PerfMenuBar(TraceViewPanel tv) { public TraceViewMenuBar(TraceViewCanvas tv) {
traceView = tv; traceView = tv;
JMenu fileMenu = new JMenu("File"); JMenu fileMenu = new JMenu("File");
@ -459,19 +459,18 @@ class PerfMenuBar extends JMenuBar implements ActionListener {
break; break;
} }
} }
} // class PerfMenuBar } // class TraceViewMenuBar
public class JobPerf extends JFrame { class TraceViewWindow extends JFrame {
public JobPerf( String fileName ) { public TraceViewWindow( ArrayList<JobExecutionEvent> jobExecList ) {
TraceViewOutputToolBar outputToolBar = new TraceViewOutputToolBar();
TraceViewCanvas traceView = new TraceViewCanvas( jobExecList, outputToolBar);
SouthToolBar southToolBar = new SouthToolBar(); TraceViewMenuBar menuBar = new TraceViewMenuBar(traceView);
TraceViewPanel traceView = new TraceViewPanel( JobExecutionEventList(fileName), southToolBar);
PerfMenuBar menuBar = new PerfMenuBar(traceView);
setJMenuBar(menuBar); setJMenuBar(menuBar);
NorthToolBar nToolBar = new NorthToolBar( traceView ); TraceViewInputToolBar nToolBar = new TraceViewInputToolBar( traceView );
add(nToolBar, BorderLayout.NORTH); add(nToolBar, BorderLayout.NORTH);
JScrollPane scrollPane = new JScrollPane( traceView ); JScrollPane scrollPane = new JScrollPane( traceView );
@ -486,7 +485,7 @@ public class JobPerf extends JFrame {
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(tracePanel); mainPanel.add(tracePanel);
add(southToolBar, BorderLayout.SOUTH); add(outputToolBar, BorderLayout.SOUTH);
setTitle("JobPerf"); setTitle("JobPerf");
setSize(800, 500); setSize(800, 500);
@ -499,6 +498,15 @@ public class JobPerf extends JFrame {
traceView.repaint(); traceView.repaint();
} }
} // class TraceViewWindow
public class JobPerf extends JFrame {
ArrayList<JobExecutionEvent> jobExecEvtList;
public JobPerf( String fileName ) {
jobExecEvtList = JobExecutionEventList(fileName);
TraceViewWindow traceViewWindow = new TraceViewWindow( jobExecEvtList );
}
private static void printHelpText() { private static void printHelpText() {
System.out.println( System.out.println(
@ -561,6 +569,7 @@ public class JobPerf extends JFrame {
++ii; ++ii;
} // while } // while
JobPerf jobPerf = new JobPerf(fileName); JobPerf jobPerf = new JobPerf( fileName );
} // main } // main
} // class JobPerf } // class JobPerf