/* 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 { AlgAnimFrame.COMPANEL_LINES = 5; } static { ciips.animation.UIFrame.allowUI( false ); } Graph graph = null; public DijkstraAlgThread( AlgAnimFrame frame ) { this.frame = frame; int first = 0; 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 graph_panel = new GraphPanel( frame.getCurrentPanel() ); } } 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); /* URL sourceURL = new URL(frame.getApplet().getCodeBase(), frame.filename); */ 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(); 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() { } }