/* DijkstraAlgThread.java */ import java.awt.*; import java.io.*; import java.net.*; import ciips.animation.*; import ciips.animation.graph.*; public class DijkstraAlgThread extends AlgThread { static int max_data = 10; static String[] dataSets = {"Graph 1", "Graph 2"}; private static String base_data_file_name = "dij"; static String[] options = { "" }; AlgAnimFrame frame; static GraphPanel graph_panel; int delay = 2000; static int N_HISTORY_PANELS = 2; static { AlgAnimFrame.COMPANEL_LINES = 5; } static { ciips.animation.UIFrame.allowUI( false ); } Graph graph = null; public DijkstraAlgThread( AlgAnimFrame frame ) { super(); setParms( frame, base_data_file_name, N_HISTORY_PANELS ); this.frame = frame; int first = 0; System.out.println("DijkstraAlgThread: super called"); System.out.flush(); if (frame != null && graph_panel != null) { // graph_panel already created -> this constructor called from // clicking the run button -> use the generated data set } else { // Ensures that graph is created // init( frame.algfile+first ); // this constructor called from Frame constructor } System.out.println("DijkstraAlgThread: cons complete"); System.out.flush(); } public boolean loadData( int choice ) { System.out.println("DijkstraAlgThread: loadData not imp"); String fn = base_data_file_name+choice; init( fn ); return false; } public void init( String fn ) { DataInputStream inStream = null; try { URL dataURL = new URL(frame.getApplet().getCodeBase(), fn); inStream = new DataInputStream( dataURL.openConnection().getInputStream()); graph_panel.repaint(); } catch (IOException e) { System.out.println("DijkstraAlgThread:init - file [" + fn + "] not found"); } catch (NullPointerException e) {} graph = new Graph( inStream ); graph_panel.setGraph( graph ); } public void run() { // int choice = frame.getDataChoice(); if ( graph_panel == null ) { System.out.println("DijkstraAlgThread:run -> GraphPanel"); graph_panel = new GraphPanel( frame.getCurrentPanel() ); } generateData(); /* if (frame.filename.compareTo("GraphDij.java")==0) */ new GraphDij( this, graph, graph_panel ); /* else if (frame.filename.compareTo("GraphMST.java")==0) { new GraphMST(this); } */ frame.finishAlg(); graph_panel.repaint(); } public void restoreDrawingPanelColor() { } }