|
14 | 14 | import java.awt.Dimension; |
15 | 15 | import java.awt.Font; |
16 | 16 | import java.awt.GridLayout; |
17 | | -import java.awt.Paint; |
18 | | -import java.awt.Shape; |
19 | | -import java.awt.Stroke; |
20 | 17 | import java.awt.event.ActionEvent; |
21 | 18 | import java.awt.event.ActionListener; |
22 | 19 | import java.awt.event.MouseEvent; |
|
54 | 51 | */ |
55 | 52 | public class Main extends JFrame { |
56 | 53 |
|
| 54 | + private static final Logger LOGGER = LOGGER; |
57 | 55 | private static final Color DEFAULT_BG_COLOR = Color.BLACK; |
58 | 56 | private static final Color Vertex_COLOR = Color.WHITE; |
59 | 57 | private static int DELAY = 2048; |
@@ -449,11 +447,11 @@ public void stateChanged(ChangeEvent e) { |
449 | 447 | try { |
450 | 448 | addGraph(); |
451 | 449 | } catch (ParserConfigurationException ex) { |
452 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 450 | + LOGGER.log(Level.SEVERE, null, ex); |
453 | 451 | } catch (IOException ex) { |
454 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 452 | + LOGGER.log(Level.SEVERE, null, ex); |
455 | 453 | } catch (SAXException ex) { |
456 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 454 | + LOGGER.log(Level.SEVERE, null, ex); |
457 | 455 | } |
458 | 456 | } |
459 | 457 | } |
@@ -596,7 +594,6 @@ public void nextOrPrevGraph(String direction) throws Exception { |
596 | 594 | count++; |
597 | 595 | } |
598 | 596 |
|
599 | | - //System.out.println("number of line in the graph = "+count); |
600 | 597 | if (count > NUM_EDGES_IMP_GRAPH) { |
601 | 598 | success = true; |
602 | 599 | } |
@@ -624,7 +621,7 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce |
624 | 621 |
|
625 | 622 |
|
626 | 623 | } catch (Exception ex) { |
627 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 624 | + LOGGER.log(Level.SEVERE, null, ex); |
628 | 625 | } |
629 | 626 |
|
630 | 627 |
|
@@ -764,7 +761,7 @@ public String transform(String i) { |
764 | 761 |
|
765 | 762 | updateStatsPanel(); |
766 | 763 |
|
767 | | - System.out.println("added the graph"); |
| 764 | + LOGGER.fine("Graph added"); |
768 | 765 | } |
769 | 766 |
|
770 | 767 | /** |
@@ -2111,11 +2108,11 @@ public void stateChanged(ChangeEvent e) { |
2111 | 2108 | try { |
2112 | 2109 | addGraph(); |
2113 | 2110 | } catch (ParserConfigurationException ex) { |
2114 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2111 | + LOGGER.log(Level.SEVERE, null, ex); |
2115 | 2112 | } catch (IOException ex) { |
2116 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2113 | + LOGGER.log(Level.SEVERE, null, ex); |
2117 | 2114 | } catch (SAXException ex) { |
2118 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2115 | + LOGGER.log(Level.SEVERE, null, ex); |
2119 | 2116 | } |
2120 | 2117 | } |
2121 | 2118 |
|
@@ -2168,40 +2165,38 @@ public void mouseClicked(MouseEvent e) { |
2168 | 2165 | public void mousePressed(MouseEvent e) { |
2169 | 2166 | //throw new UnsupportedOperationException("Not supported yet."); |
2170 | 2167 | if (e.getComponent() == playButton) { |
2171 | | - System.out.println("Play pressed"); |
| 2168 | + LOGGER.fine("Play pressed"); |
2172 | 2169 | timer.start(); |
2173 | 2170 | } else if (e.getComponent() == pauseButton) { |
2174 | | - System.out.println("Stop pressed"); |
| 2171 | + LOGGER.fine("Pause pressed"); |
2175 | 2172 | timer.stop(); |
2176 | 2173 | } else if (e.getComponent() == stopButton) { |
2177 | | - System.out.println("Stop pressed"); |
| 2174 | + LOGGER.fine("Stop pressed"); |
2178 | 2175 | timeline.setValue(1); |
2179 | 2176 | timer.stop(); |
2180 | 2177 | } else if (e.getComponent() == slowButton) { |
2181 | | - System.out.println("Slow pressed"); |
2182 | 2178 | DELAY = DELAY * 2; |
2183 | 2179 | timer.setDelay(DELAY); |
2184 | | - System.out.println(timer.getDelay() + ""); |
| 2180 | + LOGGER.fine("Slow pressed, delay=" + timer.getDelay()); |
2185 | 2181 | } else if (e.getComponent() == fastButton) { |
2186 | | - System.out.println("Fast pressed"); |
2187 | 2182 | DELAY = DELAY / 2; |
2188 | 2183 | timer.setDelay(DELAY); |
2189 | | - System.out.println(timer.getDelay() + ""); |
| 2184 | + LOGGER.fine("Fast pressed, delay=" + timer.getDelay()); |
2190 | 2185 | } else if (e.getComponent() == nextButton) { |
2191 | 2186 | try { |
2192 | | - System.out.println("next pressed"); |
| 2187 | + LOGGER.fine("Next pressed"); |
2193 | 2188 | nextOrPrevGraph("next"); |
2194 | 2189 | timer.stop(); |
2195 | 2190 | } catch (Exception ex) { |
2196 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2191 | + LOGGER.log(Level.SEVERE, null, ex); |
2197 | 2192 | } |
2198 | 2193 | } else if (e.getComponent() == prevButton) { |
2199 | 2194 | try { |
2200 | | - System.out.println("Prev pressed"); |
| 2195 | + LOGGER.fine("Prev pressed"); |
2201 | 2196 | nextOrPrevGraph("prev"); |
2202 | 2197 | timer.stop(); |
2203 | 2198 | } catch (Exception ex) { |
2204 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2199 | + LOGGER.log(Level.SEVERE, null, ex); |
2205 | 2200 | } |
2206 | 2201 | } |
2207 | 2202 | } |
@@ -2417,7 +2412,7 @@ public void actionPerformed(ActionEvent e) { |
2417 | 2412 | try { |
2418 | 2413 | curFile.createNewFile(); |
2419 | 2414 | } catch (IOException ex) { |
2420 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2415 | + LOGGER.log(Level.SEVERE, null, ex); |
2421 | 2416 | } |
2422 | 2417 | PNGDump dumper = new PNGDump(); |
2423 | 2418 | try { |
@@ -2449,16 +2444,16 @@ public void actionPerformed(ActionEvent e) { |
2449 | 2444 | try { |
2450 | 2445 | fileChooser.getSelectedFile().createNewFile(); |
2451 | 2446 | } catch (IOException ex) { |
2452 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2447 | + LOGGER.log(Level.SEVERE, null, ex); |
2453 | 2448 | } |
2454 | 2449 | try { |
2455 | 2450 | // Use commons-io FileUtils (already a project dependency) |
2456 | 2451 | // instead of the hand-rolled byte-copy loop. |
2457 | 2452 | FileUtils.copyFile(new File("./graph.txt"), fileChooser.getSelectedFile()); |
2458 | 2453 | } catch (FileNotFoundException ex) { |
2459 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2454 | + LOGGER.log(Level.SEVERE, null, ex); |
2460 | 2455 | } catch (IOException ex) { |
2461 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
| 2456 | + LOGGER.log(Level.SEVERE, null, ex); |
2462 | 2457 | } |
2463 | 2458 | } |
2464 | 2459 | }); |
@@ -2508,7 +2503,7 @@ public void actionPerformed(ActionEvent e) { |
2508 | 2503 | + "File: " + outFile.getName(), |
2509 | 2504 | "Export Complete", JOptionPane.INFORMATION_MESSAGE); |
2510 | 2505 | } catch (IOException ex1) { |
2511 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1); |
| 2506 | + LOGGER.log(Level.SEVERE, null, ex1); |
2512 | 2507 | JOptionPane.showMessageDialog(null, |
2513 | 2508 | "Export failed: " + ex1.getMessage(), |
2514 | 2509 | "Error", JOptionPane.ERROR_MESSAGE); |
@@ -2548,7 +2543,7 @@ public void run() { |
2548 | 2543 | ex = new Main(); |
2549 | 2544 | ex.setVisible(true); |
2550 | 2545 | } catch (Exception ex1) { |
2551 | | - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1); |
| 2546 | + LOGGER.log(Level.SEVERE, null, ex1); |
2552 | 2547 | } |
2553 | 2548 | } |
2554 | 2549 | }); |
|
0 commit comments