Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit bfb05d4

Browse files
chore: remove dead code, unused imports, and replace debug prints with Logger
Main.java: - Removed 3 unused imports (java.awt.Paint, Shape, Stroke) - Replaced 10 System.out.println debug statements with LOGGER.fine() (Play/Pause/Stop/Slow/Fast/Next/Prev button handlers + graph add) - Consolidated 9 repeated Logger.getLogger(Main.class.getName()) calls into a single static LOGGER field - Removed commented-out println - Fixed duplicate 'Stop pressed' message (was logged for both pause and stop buttons; pause now correctly logs 'Pause pressed') - Collapsed 2 separate println calls (action + delay) into single log messages for slow/fast handlers GraphGenerator.java: - Removed dead private method createWeightedEdge() — declared but never called anywhere in the codebase GraphResilienceAnalyzer.java: - Removed unused import java.util.stream.Collectors Net: -13 lines, 0 functional changes.
1 parent 7a3d690 commit bfb05d4

3 files changed

Lines changed: 24 additions & 37 deletions

File tree

Gvisual/src/gvisual/GraphGenerator.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,6 @@ private edge createEdge(String v1, String v2) {
151151
return e;
152152
}
153153

154-
private edge createWeightedEdge(String v1, String v2, float weight) {
155-
edge e = new edge("f", v1, v2);
156-
e.setLabel("gen_" + (edgeCounter++));
157-
e.setWeight(weight);
158-
return e;
159-
}
160-
161154
private void addNodes(Graph<String, edge> graph, int n) {
162155
for (int i = 0; i < n; i++) {
163156
graph.addVertex(nodeName(i));

Gvisual/src/gvisual/GraphResilienceAnalyzer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import edu.uci.ics.jung.graph.Graph;
44
import edu.uci.ics.jung.graph.UndirectedSparseGraph;
55
import java.util.*;
6-
import java.util.stream.Collectors;
76

87
/**
98
* Analyzes network resilience by simulating node removal attacks and measuring

Gvisual/src/gvisual/Main.java

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import java.awt.Dimension;
1515
import java.awt.Font;
1616
import java.awt.GridLayout;
17-
import java.awt.Paint;
18-
import java.awt.Shape;
19-
import java.awt.Stroke;
2017
import java.awt.event.ActionEvent;
2118
import java.awt.event.ActionListener;
2219
import java.awt.event.MouseEvent;
@@ -54,6 +51,7 @@
5451
*/
5552
public class Main extends JFrame {
5653

54+
private static final Logger LOGGER = LOGGER;
5755
private static final Color DEFAULT_BG_COLOR = Color.BLACK;
5856
private static final Color Vertex_COLOR = Color.WHITE;
5957
private static int DELAY = 2048;
@@ -449,11 +447,11 @@ public void stateChanged(ChangeEvent e) {
449447
try {
450448
addGraph();
451449
} catch (ParserConfigurationException ex) {
452-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
450+
LOGGER.log(Level.SEVERE, null, ex);
453451
} catch (IOException ex) {
454-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
452+
LOGGER.log(Level.SEVERE, null, ex);
455453
} catch (SAXException ex) {
456-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
454+
LOGGER.log(Level.SEVERE, null, ex);
457455
}
458456
}
459457
}
@@ -596,7 +594,6 @@ public void nextOrPrevGraph(String direction) throws Exception {
596594
count++;
597595
}
598596

599-
//System.out.println("number of line in the graph = "+count);
600597
if (count > NUM_EDGES_IMP_GRAPH) {
601598
success = true;
602599
}
@@ -624,7 +621,7 @@ public void addGraph() throws ParserConfigurationException, IOException, SAXExce
624621

625622

626623
} catch (Exception ex) {
627-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
624+
LOGGER.log(Level.SEVERE, null, ex);
628625
}
629626

630627

@@ -764,7 +761,7 @@ public String transform(String i) {
764761

765762
updateStatsPanel();
766763

767-
System.out.println("added the graph");
764+
LOGGER.fine("Graph added");
768765
}
769766

770767
/**
@@ -2111,11 +2108,11 @@ public void stateChanged(ChangeEvent e) {
21112108
try {
21122109
addGraph();
21132110
} catch (ParserConfigurationException ex) {
2114-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2111+
LOGGER.log(Level.SEVERE, null, ex);
21152112
} catch (IOException ex) {
2116-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2113+
LOGGER.log(Level.SEVERE, null, ex);
21172114
} catch (SAXException ex) {
2118-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2115+
LOGGER.log(Level.SEVERE, null, ex);
21192116
}
21202117
}
21212118

@@ -2168,40 +2165,38 @@ public void mouseClicked(MouseEvent e) {
21682165
public void mousePressed(MouseEvent e) {
21692166
//throw new UnsupportedOperationException("Not supported yet.");
21702167
if (e.getComponent() == playButton) {
2171-
System.out.println("Play pressed");
2168+
LOGGER.fine("Play pressed");
21722169
timer.start();
21732170
} else if (e.getComponent() == pauseButton) {
2174-
System.out.println("Stop pressed");
2171+
LOGGER.fine("Pause pressed");
21752172
timer.stop();
21762173
} else if (e.getComponent() == stopButton) {
2177-
System.out.println("Stop pressed");
2174+
LOGGER.fine("Stop pressed");
21782175
timeline.setValue(1);
21792176
timer.stop();
21802177
} else if (e.getComponent() == slowButton) {
2181-
System.out.println("Slow pressed");
21822178
DELAY = DELAY * 2;
21832179
timer.setDelay(DELAY);
2184-
System.out.println(timer.getDelay() + "");
2180+
LOGGER.fine("Slow pressed, delay=" + timer.getDelay());
21852181
} else if (e.getComponent() == fastButton) {
2186-
System.out.println("Fast pressed");
21872182
DELAY = DELAY / 2;
21882183
timer.setDelay(DELAY);
2189-
System.out.println(timer.getDelay() + "");
2184+
LOGGER.fine("Fast pressed, delay=" + timer.getDelay());
21902185
} else if (e.getComponent() == nextButton) {
21912186
try {
2192-
System.out.println("next pressed");
2187+
LOGGER.fine("Next pressed");
21932188
nextOrPrevGraph("next");
21942189
timer.stop();
21952190
} catch (Exception ex) {
2196-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2191+
LOGGER.log(Level.SEVERE, null, ex);
21972192
}
21982193
} else if (e.getComponent() == prevButton) {
21992194
try {
2200-
System.out.println("Prev pressed");
2195+
LOGGER.fine("Prev pressed");
22012196
nextOrPrevGraph("prev");
22022197
timer.stop();
22032198
} catch (Exception ex) {
2204-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2199+
LOGGER.log(Level.SEVERE, null, ex);
22052200
}
22062201
}
22072202
}
@@ -2417,7 +2412,7 @@ public void actionPerformed(ActionEvent e) {
24172412
try {
24182413
curFile.createNewFile();
24192414
} catch (IOException ex) {
2420-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2415+
LOGGER.log(Level.SEVERE, null, ex);
24212416
}
24222417
PNGDump dumper = new PNGDump();
24232418
try {
@@ -2449,16 +2444,16 @@ public void actionPerformed(ActionEvent e) {
24492444
try {
24502445
fileChooser.getSelectedFile().createNewFile();
24512446
} catch (IOException ex) {
2452-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2447+
LOGGER.log(Level.SEVERE, null, ex);
24532448
}
24542449
try {
24552450
// Use commons-io FileUtils (already a project dependency)
24562451
// instead of the hand-rolled byte-copy loop.
24572452
FileUtils.copyFile(new File("./graph.txt"), fileChooser.getSelectedFile());
24582453
} catch (FileNotFoundException ex) {
2459-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2454+
LOGGER.log(Level.SEVERE, null, ex);
24602455
} catch (IOException ex) {
2461-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
2456+
LOGGER.log(Level.SEVERE, null, ex);
24622457
}
24632458
}
24642459
});
@@ -2508,7 +2503,7 @@ public void actionPerformed(ActionEvent e) {
25082503
+ "File: " + outFile.getName(),
25092504
"Export Complete", JOptionPane.INFORMATION_MESSAGE);
25102505
} catch (IOException ex1) {
2511-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1);
2506+
LOGGER.log(Level.SEVERE, null, ex1);
25122507
JOptionPane.showMessageDialog(null,
25132508
"Export failed: " + ex1.getMessage(),
25142509
"Error", JOptionPane.ERROR_MESSAGE);
@@ -2548,7 +2543,7 @@ public void run() {
25482543
ex = new Main();
25492544
ex.setVisible(true);
25502545
} catch (Exception ex1) {
2551-
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1);
2546+
LOGGER.log(Level.SEVERE, null, ex1);
25522547
}
25532548
}
25542549
});

0 commit comments

Comments
 (0)