Skip to content

Commit df02a7c

Browse files
rostamclaude
andcommitted
Fix first-run UX, surface silent failures, remove BeanShell
Two independent bodies of work; they touch 217 of the same files and could not be split into separate commits. UX fixes -------- First run was a dead end. The welcome page was fetched from an http:// URL that 301s to https (which JEditorPane will not follow), pointing at a page that 404s, rendered into a pane the layout pins to 75px. The page now ships in the jar and opens in its own window, with a painted empty state on the canvas and a status bar that says what to do. The splash no longer pipes System.err into a text area. Generators entered an unannounced region-drag mode after the parameter dialog, announced only in the status bar, so generating appeared to do nothing. They now draw straight onto the visible canvas; manual placement stays available. Paste had the identical bug. Failures were invisible: ExceptionHandler logged to console and analytics and told the user nothing. Adds UserNotifier, precondition checks on reports, visible handling of null results, and a progress dialog for long calculations. The result window is now built on the EDT, packed before being shown, and cascades instead of stacking at one fixed point. Save no longer throws on non-table results, no longer writes JList.toString(), and stops accumulating duplicate file filters. Two wrong answers, both found via the empty-graph case: - Chromatic number tests colourability with t+1 colours but started at t=1, so it could never return 1; every edgeless graph reported 2. Covered by the new ChromaticNumberTest. - MaxOfIndSets carried NumOfIndSets's name and description; it returns a set size, not a count. Discoverability: adds a Ctrl+K command palette over all ~319 menu items. Accelerators go from 8 to 18 - the parser could only read single printable characters, so DELETE was unbindable, and the extension menu branch ignored the XML accelerator attribute entirely, which had been silently dropping Ctrl+L/M/I since they were written. Chrome: right-click menus were dead everywhere (vertex/edge branches commented out, nothing registered anything); all three now have items. Sidebar labels drawn with Java2D instead of 8px rotated GIFs. Toolbar says "Undo", not "Undo Action". Status bar shows live vertex/edge and selection counts. Title drops the internal "newrooz" codename. Watch BlackBoard off the Help menu, Getting Started on. About is a real dialog rather than a browser launch. Labels: fixes Pheriperal x3, Eccetricity, Eccentirc, comparision, WinerPolarity, "Wiener Diagonal"; disambiguates the duplicate Heuristic Greedy Coloring and VeIndex pairs; deletes AHomomorphism, a byte-identical copy of product/Union placing a second "Union" in the same submenu. Telemetry now asks before reporting, and the blocking external-IP lookup moved off the startup path. BeanShell removal ----------------- Removes bsh-2.0b4.jar (2005, unmaintained, carries a known deserialization CVE) and everything that existed to serve it: the graphtea.plugins.commandline plugin (78 files, ~2900 LOC), 52 .bsh command scripts, the commandline.jar build target, the @CommandAttitude annotation and its 220 usage sites, ExtensionShellCommandProvider, createExtensionCommandsForCommandLine() and performExtensionInCommandLine(). This removes the Shell sidebar console, the BSH: hyperlink protocol, and .bsh extension loading. The UnknownExtensionLoader hook they used remains, so a replacement loader could be registered later. Also carries prior uncommitted refactoring already present in the working tree: abstract base-class extraction across the report packages, removal of redundant getDescription() overrides, and Javadoc additions. Build succeeds, 869 tests pass, checkstyle is clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VC2QiQFi5nJpo39Z9zB5mb
1 parent 035df1e commit df02a7c

512 files changed

Lines changed: 8584 additions & 16826 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,6 @@
269269
<include name="graphtea/plugins/algorithmanimator/**/*.*"/>
270270
</fileset>
271271
</jar>
272-
<jar destfile="${dist.dir}/plugins/commandline.jar">
273-
<manifest>
274-
<attribute name="Built-By" value="${user.name}"/>
275-
<attribute name="plugin-name" value="commandline"/>
276-
<attribute name="plugin-version" value="20060104"/>
277-
<attribute name="plugin-depends" value="main 20060104"/>
278-
</manifest>
279-
<fileset dir="${build.dir}">
280-
<include name="graphtea/plugins/commandline/**/*.*"/>
281-
</fileset>
282-
</jar>
283272
<!--<jar destfile="${dist.dir}/plugins/developplugin.jar">-->
284273
<!--<manifest>-->
285274
<!--<attribute name="Built-By" value="${user.name}"/>-->

config/checkstyle-suppressions.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
<suppress files="AEvent.java" checks=".*"/>
1616
<suppress files="AGIndex.java" checks=".*"/>
17-
<suppress files="AHomomorphism.java" checks=".*"/>
1817
<suppress files="AbstractAction.java" checks=".*"/>
1918
<suppress files="AbstractExtensionAction.java" checks=".*"/>
2019
<suppress files="AbstractGraphRenderer.java" checks=".*"/>
@@ -68,7 +67,6 @@
6867
<suppress files="AvgTransmission.java" checks=".*"/>
6968
<suppress files="BFS.java" checks=".*"/>
7069
<suppress files="BFSAnim.java" checks=".*"/>
71-
<suppress files="BSHExtensionLoader.java" checks=".*"/>
7270
<suppress files="BackwardTrees.java" checks=".*"/>
7371
<suppress files="BalabanIndex.java" checks=".*"/>
7472
<suppress files="BananaTreeGenerator.java" checks=".*"/>
@@ -110,12 +108,10 @@
110108
<suppress files="Cluster.java" checks=".*"/>
111109
<suppress files="CmnGenerator.java" checks=".*"/>
112110
<suppress files="CocktailPartyGraph.java" checks=".*"/>
113-
<suppress files="CodeCompletionUtils.java" checks=".*"/>
114111
<suppress files="Cograph.java" checks=".*"/>
115112
<suppress files="ColoringListener.java" checks=".*"/>
116113
<suppress files="ColoringReport.java" checks=".*"/>
117114
<suppress files="ColumnIntersectionGraph.java" checks=".*"/>
118-
<suppress files="CommandAttitude.java" checks=".*"/>
119115
<suppress files="CompCompare.java" checks=".*"/>
120116
<suppress files="ComparingE1E2.java" checks=".*"/>
121117
<suppress files="Complement.java" checks=".*"/>
@@ -129,8 +125,6 @@
129125
<suppress files="ConnectiveEccentricIndex.java" checks=".*"/>
130126
<suppress files="ConnectivityChecker.java" checks=".*"/>
131127
<suppress files="ConnectivityEccentricityIndex.java" checks=".*"/>
132-
<suppress files="Converter.java" checks=".*"/>
133-
<suppress files="Copier.java" checks=".*"/>
134128
<suppress files="Copy.java" checks=".*"/>
135129
<suppress files="CopyAsImage.java" checks=".*"/>
136130
<suppress files="CopyAsMatrix.java" checks=".*"/>
@@ -144,7 +138,6 @@
144138
<suppress files="Cycle.java" checks=".*"/>
145139
<suppress files="DAG.java" checks=".*"/>
146140
<suppress files="DeSelect.java" checks=".*"/>
147-
<suppress files="DefaultParser.java" checks=".*"/>
148141
<suppress files="DegreeDistance.java" checks=".*"/>
149142
<suppress files="DegreeKirchhoffIndex.java" checks=".*"/>
150143
<suppress files="DelayEvent.java" checks=".*"/>
@@ -184,7 +177,6 @@
184177
<suppress files="EccentricityMatrixOfGraph.java" checks=".*"/>
185178
<suppress files="Edge.java" checks=".*"/>
186179
<suppress files="EdgeAttrSet.java" checks=".*"/>
187-
<suppress files="EdgeCommands.java" checks=".*"/>
188180
<suppress files="EdgeDegree.java" checks=".*"/>
189181
<suppress files="EdgeEvent.java" checks=".*"/>
190182
<suppress files="EdgeHighlightAction.java" checks=".*"/>
@@ -221,7 +213,6 @@
221213
<suppress files="ExtensionConfigFrame.java" checks=".*"/>
222214
<suppress files="ExtensionHandler.java" checks=".*"/>
223215
<suppress files="ExtensionLoader.java" checks=".*"/>
224-
<suppress files="ExtensionShellCommandProvider.java" checks=".*"/>
225216
<suppress files="ExtractSubGraph.java" checks=".*"/>
226217
<suppress files="FastRenderer.java" checks=".*"/>
227218
<suppress files="Filters.java" checks=".*"/>
@@ -301,7 +292,6 @@
301292
<suppress files="GraphArtActionExtendTree.java" checks=".*"/>
302293
<suppress files="GraphAttrSet.java" checks=".*"/>
303294
<suppress files="GraphColoringRenderer.java" checks=".*"/>
304-
<suppress files="GraphCommands.java" checks=".*"/>
305295
<suppress files="GraphComplement.java" checks=".*"/>
306296
<suppress files="GraphComponentInitializer.java" checks=".*"/>
307297
<suppress files="GraphControl.java" checks=".*"/>
@@ -379,7 +369,6 @@
379369
<suppress files="InverseDegree.java" checks=".*"/>
380370
<suppress files="InverseSum.java" checks=".*"/>
381371
<suppress files="InvertSelection.java" checks=".*"/>
382-
<suppress files="InwardCommandParser.java" checks=".*"/>
383372
<suppress files="Irr_G.java" checks=".*"/>
384373
<suppress files="Irr_t_G.java" checks=".*"/>
385374
<suppress files="IsBipartite.java" checks=".*"/>
@@ -479,7 +468,6 @@
479468
<suppress files="MultiplicativeHarary.java" checks=".*"/>
480469
<suppress files="NDMetis.java" checks=".*"/>
481470
<suppress files="NNGenerator.java" checks=".*"/>
482-
<suppress files="NativeCommands.java" checks=".*"/>
483471
<suppress files="NetworkGenerateorAlgrithm.java" checks=".*"/>
484472
<suppress files="NewGraph.java" checks=".*"/>
485473
<suppress files="NewLowerBounds.java" checks=".*"/>
@@ -581,11 +569,6 @@
581569
<suppress files="SerializedAttrSet.java" checks=".*"/>
582570
<suppress files="SetValidator.java" checks=".*"/>
583571
<suppress files="Settings.java" checks=".*"/>
584-
<suppress files="Shell.java" checks=".*"/>
585-
<suppress files="ShellCodeCompletion.java" checks=".*"/>
586-
<suppress files="ShellConsole.java" checks=".*"/>
587-
<suppress files="ShellServer.java" checks=".*"/>
588-
<suppress files="ShellServerCommands.java" checks=".*"/>
589572
<suppress files="ShowAboutDialog.java" checks=".*"/>
590573
<suppress files="ShowG.java" checks=".*"/>
591574
<suppress files="ShowMessage.java" checks=".*"/>
@@ -652,7 +635,6 @@
652635
<suppress files="VeIndex.java" checks=".*"/>
653636
<suppress files="Vertex.java" checks=".*"/>
654637
<suppress files="VertexAttrSet.java" checks=".*"/>
655-
<suppress files="VertexCommands.java" checks=".*"/>
656638
<suppress files="VertexCorona.java" checks=".*"/>
657639
<suppress files="VertexCycleLengthComparator.java" checks=".*"/>
658640
<suppress files="VertexEdgeLabelAnimator.java" checks=".*"/>

src/graphtea/extensions/AlgorithmUtils.java

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
public class AlgorithmUtils {
2626
public final static int Max_Int = 2100000000;
2727

28-
2928
/**
3029
* sets all vertex colors to 0.
3130
*/
@@ -296,7 +295,6 @@ public static double getAngle(GPoint rootp, GPoint v1p, GPoint v2p) {
296295
double qx = v2p.x - rootp.x;
297296
double qy = v2p.y - rootp.y;
298297

299-
300298
double pDOTq = px * qx + py * qy;
301299
double plength = getLength(px, py);
302300
double qlength = getLength(qx, qy);
@@ -417,7 +415,6 @@ public static double round(double value, int decimalPlace) {
417415
/ power_of_ten;
418416
}
419417

420-
421418
public static double[] round (double[] array, int prec)
422419
{
423420
for(int i=0;i<array.length;i++)
@@ -446,48 +443,21 @@ public static String getEigenValues(GraphModel g) {
446443
return res.toString();
447444
}
448445

449-
/**
450-
* Computes the sum of the eigenvalues of A
451-
*
452-
* @param A the given matrix
453-
* @return the sum of the eigenvalues of A
454-
*/
455-
public static double sumOfExpOfEigenValues(Matrix A) {
456-
EigenvalueDecomposition ed = A.eig();
457-
double[] rv = ed.getRealEigenvalues();
446+
private static double sumOfTransformedEigenvalues(Matrix A, java.util.function.DoubleUnaryOperator transform) {
447+
double[] rv = A.eig().getRealEigenvalues();
458448
double sum = 0;
459-
460-
//positiv RV
461-
Double[] prv = new Double[rv.length];
462-
for (int i = 0; i < rv.length; i++) {
463-
prv[i] = Math.exp(rv[i]);
464-
prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d;
465-
sum += prv[i];
449+
for (double v : rv) {
450+
sum += round(transform.applyAsDouble(v), 5);
466451
}
467-
468452
return sum;
469453
}
470454

471-
/**
472-
* Computes the sum of the eigenvalues of A
473-
*
474-
* @param A the given matrix
475-
* @return the sum of the eigenvalues of A
476-
*/
477-
public static double sumOfEigenValues(Matrix A) {
478-
EigenvalueDecomposition ed = A.eig();
479-
double[] rv = ed.getRealEigenvalues();
480-
double sum = 0;
481-
482-
//positiv RV
483-
Double[] prv = new Double[rv.length];
484-
for (int i = 0; i < rv.length; i++) {
485-
prv[i] = Math.abs(rv[i]);
486-
prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d;
487-
sum += prv[i];
488-
}
455+
public static double sumOfExpOfEigenValues(Matrix A) {
456+
return sumOfTransformedEigenvalues(A, Math::exp);
457+
}
489458

490-
return sum;
459+
public static double sumOfEigenValues(Matrix A) {
460+
return sumOfTransformedEigenvalues(A, Math::abs);
491461
}
492462

493463
/**
@@ -552,6 +522,29 @@ public static String getEigenValues(Matrix A) {
552522
return res.toString();
553523
}
554524

525+
/**
526+
* Returns eigenvalues (formatted as "re + im·i" or plain real) and eigenvectors
527+
* of {@code a}, as a list of display strings, ready to append to a spectrum report.
528+
*/
529+
public static ArrayList<String> formatEigenDecomposition(Matrix a) {
530+
ArrayList<String> result = new ArrayList<>();
531+
EigenvalueDecomposition ed = a.eig();
532+
double[] rv = ed.getRealEigenvalues();
533+
double[] iv = ed.getImagEigenvalues();
534+
for (int i = 0; i < rv.length; i++) {
535+
if (iv[i] != 0) {
536+
result.add(round(rv[i], 5) + " + " + round(iv[i], 5) + "i");
537+
} else {
538+
result.add(String.valueOf(round(rv[i], 5)));
539+
}
540+
}
541+
result.add("Eigen Vectors:\n");
542+
for (double[] vec : ed.getV().getArray()) {
543+
result.add(Arrays.toString(round(vec, 5)));
544+
}
545+
return result;
546+
}
547+
555548
// get kth minimum degree
556549
public static double getMinNonPendentDegree(GraphModel g) {
557550
ArrayList<Integer> al = getDegreesList(g);
@@ -646,7 +639,6 @@ public static GraphModel createComplementGraph(GraphModel g1) {
646639
g2.addVertex(tmp);
647640
}
648641

649-
650642
for(Vertex v1 : g1.getVertexArray()) {
651643
for(Vertex v2 : g1.getVertexArray()) {
652644
if(v1.getId() != v2.getId()) {
@@ -728,7 +720,6 @@ public static Matrix getDistanceAdjacencyMatrix (GraphModel g) {
728720
return adj;
729721
}
730722

731-
732723
/**
733724
* Undirected Laplacian.
734725
*
@@ -801,7 +792,6 @@ public static Matrix getLaplacian(GraphModel g) {
801792
return D;
802793
}
803794

804-
805795
public static Matrix getSignlessLaplacian(Matrix A) {
806796
//double[][] res=new double[g.numOfVertices()][g.numOfVertices()];
807797
int n = A.getArray().length;
@@ -935,4 +925,29 @@ public static int[] getEccentricities(GraphModel g) {
935925
}
936926
return ecc;
937927
}
928+
929+
public static int eccentricityOf(GraphModel g, int v, int[][] dist) {
930+
int max = 0;
931+
for (int j = 0; j < g.getVerticesCount(); j++) {
932+
if (max < dist[v][j]) {
933+
max = dist[v][j];
934+
}
935+
}
936+
return max;
937+
}
938+
939+
public static Matrix eccentricityMatrix(GraphModel g, int[][] dist) {
940+
int n = g.getVerticesCount();
941+
Matrix m = new Matrix(n, n);
942+
for (int i = 0; i < n; i++) {
943+
for (int j = 0; j < n; j++) {
944+
int ei = eccentricityOf(g, i, dist);
945+
int ej = eccentricityOf(g, j, dist);
946+
if (dist[i][j] == Math.min(ei, ej)) {
947+
m.set(i, j, dist[i][j]);
948+
}
949+
}
950+
}
951+
return m;
952+
}
938953
}

src/graphtea/extensions/G6Format.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class G6Format {
2121
private static final int WORDSIZE = 32;
2222
private static String g6_graph;
2323

24-
2524
static int[] bit_ = {020000000000, 010000000000, 04000000000, 02000000000,
2625
01000000000, 0400000000, 0200000000, 0100000000, 040000000,
2726
020000000, 010000000, 04000000, 02000000, 01000000, 0400000,
@@ -40,7 +39,6 @@ int SETBT(int pos) {
4039
return ((pos) & 037);
4140
}
4241

43-
4442
public static HashMap<Integer, List<Integer>> stringToGraph(String g6) {
4543
int n = graphsize(g6);
4644
HashMap<Integer, List<Integer>> graph = new HashMap<>();
@@ -137,7 +135,6 @@ public static String createAdjMatrix (Matrix m){
137135
return result.toString();
138136
}
139137

140-
141138
public static String encodeGraph(int NoNodes, String adjmatrix) {
142139
int[] nn = encodeN(NoNodes);
143140
int[] adj = encodeR(adjmatrix);

src/graphtea/extensions/actions/BarycentricSubdivisionGraph.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import graphtea.plugins.main.GraphData;
1515
import graphtea.plugins.main.extension.GraphActionExtension;
1616

17-
1817
/**
1918
* Creates a line graph from the current graph and shows it in a new tab
2019
*
@@ -71,11 +70,6 @@ public String getName() {
7170
return "Barycentric Subdivision Graph";
7271
}
7372

74-
public String getDescription() {
75-
return "Barycentric Subdivision Graph";
76-
}
77-
78-
7973
@Override
8074
public String getCategory() {
8175
return "Transformations";

src/graphtea/extensions/actions/CircularVisualization.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,11 @@ public static void circularVisualize(int r, int x, int y, SubGraph g) {
4545
}
4646
}
4747

48-
4948
@Override
5049
public String getName() {
5150
return "Circular Visualize";
5251
}
5352

54-
@Override
55-
public String getDescription() {
56-
return "Circular Visualize";
57-
}
58-
5953
@Override
6054
public String getCategory() {
6155
return "Visualization";

src/graphtea/extensions/actions/ComplementGraph.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public void action(GraphData graphData) {
3030
g2.addVertex(tmp);
3131
}
3232

33-
3433
Vertex[] verts = g1.getVertexArray();
3534
for (int i = 0; i < verts.length; i++) {
3635
for (int j = i + 1; j < verts.length; j++) {

src/graphtea/extensions/actions/Composition.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ public String getName() {
2222
return "Composition";
2323
}
2424

25-
@Override
26-
public String getDescription() {
27-
return "Composition";
28-
}
29-
3025
@Override
3126
public void action(GraphData graphData) {
3227
GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME);
@@ -37,7 +32,6 @@ public void action(GraphData graphData) {
3732
graphData.core.showGraph(g);
3833
}
3934

40-
4135
@Override
4236
public String getCategory() {
4337
return "Products";

src/graphtea/extensions/actions/Disjunction.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ public String getName() {
2222
return "Graph Disjunction";
2323
}
2424

25-
@Override
26-
public String getDescription() {
27-
return "Graph Disjunction";
28-
}
29-
3025
@Override
3126
public void action(GraphData graphData) {
3227
GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME);
@@ -36,7 +31,6 @@ public void action(GraphData graphData) {
3631
graphData.core.showGraph(g);
3732
}
3833

39-
4034
@Override
4135
public String getCategory() {
4236
return "Products";

0 commit comments

Comments
 (0)