/* //javac -classpath "C:\Program Files\Wolfram Research\Mathematica\4.1\AddOns\Applications\JLink\JLink.jar;C:\j2sdk1.4.2\bin" Slippery.java //java -classpath "C:\Program Files\Wolfram Research\Mathematica\4.1\AddOns\Applications\JLink\JLink.jar;C:\j2sdk1.4.2\bin" Slippery //javac -classpath "C:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\JLink\JLink.jar;C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin" Slippery.java //java -classpath "C:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\JLink\JLink.jar;C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin" Slippery //file: Slippery.java */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import com.wolfram.jlink.*; import java.util.*; import java.io.*; import java.applet.Applet; import java.nio.channels.*; public class Slippery extends JFrame { double FPS_MIN = 0; double FPS_MAX = 50; //This label uses ImageIcon to show the doggy pictures. JLabel picture; JPanel sliderPanel; JPanel animationPanel; Container content; JPanel main; JButton button; JButton saveButton; JButton loadButton; int globalCounter = 0; //Add a formatted text field to supplement the slider. KernelLink ml = null; public Vector allPowersCalculated = new Vector(); public Vector energyChanges = new Vector(); public Vector allConfigurations = new Vector(); DrawingArea drawingArea; StringBuffer fileStringBuffer = new StringBuffer(""); String releaseTimes[] = new String[8]; JSlider slider; boolean sliderWasChanged = true; TextField lowerLimitTextField; TextField textField; TextField alphaTF; TextField binarySearchTF; TextField optimalPointSearchTF; TextField JobRelease1; TextField JobRelease2; TextField JobRelease3; TextField JobRelease4; TextField JobRelease5; TextField JobRelease6; TextField JobRelease7; TextField JobRelease8; TextField fileNameTF; public Slippery( ) { super("Ready to start."); //Create a Kernel link setSize(920, 850); setLocation(200, 200); content = getContentPane( ); main = new JPanel(new GridLayout(0,1)); sliderPanel = new JPanel(new GridLayout(0,2)); slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 0); slider.setMajorTickSpacing(48); slider.setMinorTickSpacing(16); slider.setPaintTicks(true); // sliderPanel.add(slider); main.add(sliderPanel); lowerLimitTextField = new TextField("0.0", 10); //textField.setHorizontalAlignment(TextField.RIGHT); textField = new TextField("3", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease1 = new TextField("0.0", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease2 = new TextField("1", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease3 = new TextField("3", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease4 = new TextField("", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease5 = new TextField("", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease6 = new TextField("", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease7 = new TextField("", 10); //textField.setHorizontalAlignment(TextField.RIGHT); JobRelease8 = new TextField("", 10); //textField.setHorizontalAlignment(TextField.RIGHT); final JLabel lowerLimitTextFieldLabel =new JLabel("Lower limit for the power of the last job:"); final JLabel textFieldLabel =new JLabel("Upper limit for the power of the last job:"); final JLabel JobReleaseLabel1 =new JLabel("Release time of Job 1:"); final JLabel JobReleaseLabel2 =new JLabel("Release time of Job 2:"); final JLabel JobReleaseLabel3 =new JLabel("Release time of Job 3:"); final JLabel JobReleaseLabel4 =new JLabel("Release time of Job 4:"); final JLabel JobReleaseLabel5 =new JLabel("Release time of Job 5:"); final JLabel JobReleaseLabel6 =new JLabel("Release time of Job 6:"); final JLabel JobReleaseLabel7 =new JLabel("Release time of Job 7:"); final JLabel JobReleaseLabel8 =new JLabel("Release time of Job 8:"); sliderPanel.add(lowerLimitTextFieldLabel); sliderPanel.add(lowerLimitTextField); sliderPanel.add(textFieldLabel); sliderPanel.add(textField); sliderPanel.add(JobReleaseLabel1); sliderPanel.add(JobRelease1); sliderPanel.add(JobReleaseLabel2); sliderPanel.add(JobRelease2); sliderPanel.add(JobReleaseLabel3); sliderPanel.add(JobRelease3); sliderPanel.add(JobReleaseLabel4); sliderPanel.add(JobRelease4); sliderPanel.add(JobReleaseLabel5); sliderPanel.add(JobRelease5); sliderPanel.add(JobReleaseLabel6); sliderPanel.add(JobRelease6); sliderPanel.add(JobReleaseLabel7); sliderPanel.add(JobRelease7); sliderPanel.add(JobReleaseLabel8); sliderPanel.add(JobRelease8); alphaTF = new TextField("3", 10); final JLabel alphaTFLabel =new JLabel("Alpha:"); sliderPanel.add(alphaTFLabel); sliderPanel.add(alphaTF); binarySearchTF = new TextField("0.0001", 10); final JLabel binarySearchTFLabel =new JLabel("Binary Search Precision:"); sliderPanel.add(binarySearchTFLabel); sliderPanel.add(binarySearchTF); optimalPointSearchTF = new TextField("0.01", 10); final JLabel optimalPointSearchTFLabel =new JLabel("Optimal Point Search Precision:"); sliderPanel.add(optimalPointSearchTFLabel); sliderPanel.add(optimalPointSearchTF); fileNameTF = new TextField("", 10); //sliderPanel.add(fileNameLabel); loadButton = new JButton("Click here to load computation from a file."); loadButton.setPreferredSize(new Dimension(200, 80)); sliderPanel.add(loadButton); sliderPanel.add(fileNameTF); button = new JButton("Click here to start computation."); button.setPreferredSize(new Dimension(200, 80)); sliderPanel.add(button); saveButton = new JButton("Click here to save computation in a file."); saveButton.setPreferredSize(new Dimension(200, 80)); sliderPanel.add(saveButton); sliderPanel.add(slider); //Create the label that displays the animation. picture = new JLabel(); picture.setHorizontalAlignment(JLabel.CENTER); picture.setAlignmentX(Component.CENTER_ALIGNMENT); picture.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(10,10,10,10))); //picture.setIcon(new ImageIcon("C:\\graphFromJava.jpeg")); main.add(picture); drawingArea = new DrawingArea(); main.add(drawingArea); content.add(main, BorderLayout.CENTER); final JLabel statusLabel = new JLabel("Ready to start computation."); content.add(statusLabel, BorderLayout.SOUTH); // wire up the event handlers slider.addChangeListener(new ChangeListener( ) { public void stateChanged(ChangeEvent e) { String searchString = fileStringBuffer.toString(); StringTokenizer st= new StringTokenizer(searchString,"\n"); int fileLineCounter = 0; boolean found = false; String slidervalue=""; String enAll=""; String currentConfig=""; String inTermsOfPlast=""; String completionTimes=""; String runningX=""; String jobSpeeds=""; String jobEnergies=""; //main.remove(drawingArea); while(st.hasMoreTokens()){ //if first line in the file it means it is energy, then compare it String str = st.nextToken().trim(); if(!",".equals(str.substring(str.length()-1)) && !"}".equals(str.substring(str.length()-1))){ //Check if we are inside of given precision if((slider.getValue()/100.0 +Double.parseDouble(optimalPointSearchTF.getText()))>=Double.parseDouble(str)){ //System.out.println("slidervalue="+(slidervalue=""+(slider.getValue()/100.0))); //System.out.println("enAll="+str); //read the rest of the data, we know there is some for sure, and then breakout of the loop currentConfig=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(currentConfig.substring(currentConfig.length()-1))) currentConfig += st.nextToken().substring(1); //System.out.println("currentConfig="+currentConfig);//currentConfig>>>C:\output.txt; inTermsOfPlast=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(inTermsOfPlast.substring(inTermsOfPlast.length()-1))) inTermsOfPlast += st.nextToken().substring(1); //System.out.println("inTermsOfPlast="+inTermsOfPlast);//inTermsOfPlast>>>C:\output.txt; completionTimes=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(completionTimes.substring(completionTimes.length()-1))) completionTimes += st.nextToken().substring(1); //System.out.println("completionTimes="+completionTimes);//completionTimes>>>outputFileName; runningX=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(runningX.substring(runningX.length()-1))) runningX += st.nextToken().substring(1); // System.out.println("runningX="+runningX);//runningX>>>C:\output.txt; jobSpeeds=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(jobSpeeds.substring(jobSpeeds.length()-1))) jobSpeeds += st.nextToken().substring(1); // System.out.println("jobSpeeds="+jobSpeeds);//jobSpeeds>>>C:\output.txt; jobEnergies=st.nextToken(); //If Mathematica split the output line in next file, then read it from there if(!"}".equals(jobEnergies.substring(jobEnergies.length()-1))) jobEnergies += st.nextToken().substring(1); // System.out.println("jobEnergies="+jobEnergies);//jobEnergies>>>C:\output.txt; found = true; break; } } fileLineCounter++; } if(!found) {System.out.println("NotFound, should use default"); //main.add(drawingArea); //drawingArea.paintComponent(); //repaint(); }else{ main.remove(drawingArea); runningX = runningX.substring(1,runningX.length()-1); completionTimes = completionTimes.substring(1,completionTimes.length()-1); currentConfig = currentConfig.substring(1,currentConfig.length()-1); inTermsOfPlast = inTermsOfPlast.substring(1,inTermsOfPlast.length()-1); jobSpeeds = jobSpeeds.substring(1,jobSpeeds.length()-1); jobEnergies = jobEnergies.substring(1,jobEnergies.length()-1); StringTokenizer stt = new StringTokenizer(runningX,","); Vector runT = new Vector(); while(stt.hasMoreTokens()){ runT.add(stt.nextToken()); } stt = new StringTokenizer(completionTimes,","); Vector completionT = new Vector(); while(stt.hasMoreTokens()){ completionT.add(stt.nextToken()); } Vector releaseT = new Vector(); for(int i=0;i>C:\\globalListFile.txt"); ml.discardAnswer(); //Save input parameters too ml.evaluate("alpha>>>C:\\globalListFile.txt"); ml.discardAnswer(); ml.evaluate("lowerEnergy>>>C:\\globalListFile.txt"); ml.discardAnswer(); ml.evaluate("errorForBinarySearch>>>C:\\globalListFile.txt"); ml.discardAnswer(); ml.evaluate("howClose>>>C:\\globalListFile.txt"); ml.discardAnswer(); ml.evaluate("JobReleases>>>C:\\globalListFile.txt"); ml.discardAnswer(); ml.evaluate("optPoint>>>C:\\globalListFile.txt"); ml.discardAnswer(); //allOptimalConfigurations /*ml.evaluate("LowerEnvelope[];")); ml.discardAnswer();*/ statusLabel.setText("Executing LowerEnvelope[]...please wait."); ml.evaluate("LowerEnvelope[];"); ml.waitForAnswer(); String result = ml.getString(); statusLabel.setText("Finished executing: LowerEnvelope[], drawing a new graph...."); ml.evaluate("a = Show[globalListOfPlots, DisplayFunction -> $DisplayFunction];"); ml.waitForAnswer(); result = ml.getString(); //System.out.println("result2= " + result); ml.evaluate("Export[\"C:\\graphFromJava"+globalCounter+".jpeg\", a, \"JPEG\"];"); ml.waitForAnswer(); result = ml.getString(); String intervalsOfOptimalConfigurations = ml.evaluateToOutputForm("intervalsOfOptimalConfigurations",0) ; ml.evaluate("intervalsOfOptimalConfigurations>>>C:\\globalListFile.txt"); ml.discardAnswer(); String allOptimalConfigurations = ml.evaluateToOutputForm("allOptimalConfigurations",0) ; ml.evaluate("allOptimalConfigurations>>>C:\\globalListFile.txt"); ml.discardAnswer(); String allEnergiesForOptimalConfigurations = ml.evaluateToOutputForm("allEnergiesForOptimalConfigurations",0) ; ml.evaluate("allEnergiesForOptimalConfigurations>>>C:\\globalListFile.txt"); ml.discardAnswer(); String allEnergiesUsed = ml.evaluateToOutputForm("allEnergiesUsed",0) ; ml.evaluate("allEnergiesUsed>>>C:\\globalListFile.txt"); ml.discardAnswer(); allOptimalConfigurations = allOptimalConfigurations.substring(1,allOptimalConfigurations.length()-1); System.out.println("allOptimalConfigurations="+allOptimalConfigurations); statusLabel.setText("Optimal configuration points of changes: "+intervalsOfOptimalConfigurations+"\nAll Optimal Configurations:"+allOptimalConfigurations); allEnergiesForOptimalConfigurations = allEnergiesForOptimalConfigurations.substring(1,allEnergiesForOptimalConfigurations.length()-1); allEnergiesUsed = allEnergiesUsed.substring(1,allEnergiesUsed.length()-1); System.out.println("allEnergiesUsed="+allEnergiesUsed); try{ StringTokenizer st = new StringTokenizer(allEnergiesUsed,","); energyChanges = new Vector(); while(st.hasMoreTokens()){ String nextEnergyUsed = st.nextToken(); energyChanges.add(nextEnergyUsed); } System.out.println("energyChanges="+energyChanges); st = new StringTokenizer(allOptimalConfigurations,"}"); boolean first = true; while(st.hasMoreTokens()){ String nextConfig = st.nextToken(); if(first){ nextConfig = nextConfig.substring(1); first = false; }else{ nextConfig = nextConfig.substring(3); } allConfigurations.add(nextConfig); } System.out.println("allConfigurations="+allConfigurations); if(!sliderWasChanged){ slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 0); sliderWasChanged = false; } slider.setMajorTickSpacing(48); slider.setMinorTickSpacing(16); slider.setPaintTicks(true); slider.setMaximum((int)java.lang.Math.round(Double.parseDouble(allEnergiesUsed.substring(0,allEnergiesUsed.indexOf(",")))*100)); slider.setMinimum((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.setValue((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.createStandardLabels(1); //slider.setPaintLabels(true); //System.out.println("Value of the slider="+ (int)java.lang.Math.round(Double.parseDouble(allEnergiesUsed.substring(0,allEnergiesUsed.indexOf(",")))*100)); }catch(java.lang.NullPointerException npe){ System.out.println("RETRY Inside!"); StringTokenizer st = new StringTokenizer(allEnergiesUsed,","); energyChanges = new Vector(); while(st.hasMoreTokens()){ String nextEnergyUsed = st.nextToken(); energyChanges.add(nextEnergyUsed); } System.out.println("energyChanges="+energyChanges); st = new StringTokenizer(allOptimalConfigurations,"}"); boolean first = true; while(st.hasMoreTokens()){ String nextConfig = st.nextToken(); if(first){ nextConfig = nextConfig.substring(1); first = false; }else{ nextConfig = nextConfig.substring(3); } allConfigurations.add(nextConfig); } System.out.println("allConfigurations="+allConfigurations); if(!sliderWasChanged){ slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 0); sliderWasChanged = false; } slider.setMajorTickSpacing(48); slider.setMinorTickSpacing(16); slider.setPaintTicks(true); slider.setMaximum((int)java.lang.Math.round(Double.parseDouble(allEnergiesUsed.substring(0,allEnergiesUsed.indexOf(",")))*100)); slider.setMinimum((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.setValue((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.createStandardLabels(1); } try { /*assuming that result is in form: enAll>>>C:\output.txt; currentConfig>>>C:\output.txt; inTermsOfPlast>>>C:\output.txt; completionTimes>>>C:\output.txt; runningX>>>C:\output.txt; jobSpeeds>>>C:\output.txt; jobEnergies>>>C:\output.txt; */ BufferedReader in = new BufferedReader(new FileReader("C:\\output.txt")); String str; fileStringBuffer = new StringBuffer(""); //first line is just a header, ignore it in.readLine(); while ((str = in.readLine()) != null) { fileStringBuffer.append(str+"\n"); } in.close(); } catch (IOException eio) { System.out.println(eio); } return allEnergiesForOptimalConfigurations; } catch (MathLinkException e) { System.out.println("MathLinkException occurred: " + e.getMessage()); } finally { ml.close(); } }//end of if else{//Now read everything from a file instead of invoking Mathematica String intervalsOfOptimalConfigurations = ""; String allOptimalConfigurations = ""; String allEnergiesForOptimalConfigurations = ""; String allEnergiesUsed = ""; try { /*assuming that result is in form: enAll>>>C:\output.txt; currentConfig>>>C:\output.txt; inTermsOfPlast>>>C:\output.txt; completionTimes>>>C:\output.txt; runningX>>>C:\output.txt; jobSpeeds>>>C:\output.txt; jobEnergies>>>C:\output.txt; */ //Read all the global variables BufferedReader in = new BufferedReader(new FileReader("input"+fileNameTF.getText()+".txt")); String str; String temp; //fileStringBuffer = new StringBuffer(""); //first line is just a header, ignore it in.readLine(); str = in.readLine().trim(); alphaTF.setText(str); str = in.readLine().trim(); lowerLimitTextField.setText(str); str = in.readLine().trim(); binarySearchTF.setText(str); str = in.readLine().trim(); optimalPointSearchTF.setText(str); //temp = ""; /*while(",".equals(str.substring(str.length()-1))){ temp+=str; str = in.readLine().trim(); }*/ str = in.readLine().trim(); StringTokenizer stjr = new StringTokenizer(str.substring(1,str.length()-1),","); if(stjr.hasMoreTokens()){ JobRelease1.setText(stjr.nextToken().trim()); } if(stjr.hasMoreTokens()){ JobRelease2.setText(stjr.nextToken().trim()); }else{ JobRelease2.setText(""); } if(stjr.hasMoreTokens()){ JobRelease3.setText(stjr.nextToken().trim()); }else{ JobRelease3.setText(""); } if(stjr.hasMoreTokens()){ JobRelease4.setText(stjr.nextToken().trim()); }else{ JobRelease4.setText(""); } if(stjr.hasMoreTokens()){ JobRelease5.setText(stjr.nextToken().trim()); }else{ JobRelease5.setText(""); } if(stjr.hasMoreTokens()){ JobRelease6.setText(stjr.nextToken().trim()); }else{ JobRelease6.setText(""); } if(stjr.hasMoreTokens()){ JobRelease7.setText(stjr.nextToken().trim()); }else{ JobRelease7.setText(""); } if(stjr.hasMoreTokens()){ JobRelease8.setText(stjr.nextToken().trim()); }else{ JobRelease8.setText(""); } //releaseTimes = new String[8]; releaseTimes[0] = JobRelease1.getText(); releaseTimes[1] = JobRelease2.getText(); releaseTimes[2] = JobRelease3.getText(); releaseTimes[3] = JobRelease4.getText(); releaseTimes[4] = JobRelease5.getText(); releaseTimes[5] = JobRelease6.getText(); releaseTimes[6] = JobRelease7.getText(); releaseTimes[7] = JobRelease8.getText(); str = in.readLine().trim(); textField.setText(str); str = in.readLine().trim(); temp = ""; while(",".equals(str.substring(str.length()-1))){ temp+=str; str = in.readLine().trim(); } intervalsOfOptimalConfigurations = temp + str; str = in.readLine().trim(); temp = ""; //System.out.println("Read:"+str); while(",".equals(str.substring(str.length()-1))){ temp+=str; str = in.readLine().trim(); //System.out.println("Read:"+str); } allOptimalConfigurations = temp + str; str = in.readLine().trim(); temp = ""; while(",".equals(str.substring(str.length()-1))){ temp+=str; str = in.readLine().trim(); } allEnergiesForOptimalConfigurations = temp + str; str = in.readLine().trim(); temp = ""; while(",".equals(str.substring(str.length()-1))){ temp+=str; str = in.readLine().trim(); } allEnergiesUsed = temp + str; allOptimalConfigurations = allOptimalConfigurations.substring(1,allOptimalConfigurations.length()-1); System.out.println("allOptimalConfigurations="+allOptimalConfigurations); statusLabel.setText("Optimal configuration points of changes: "+intervalsOfOptimalConfigurations+"\nAll Optimal Configurations:"+allOptimalConfigurations); allEnergiesForOptimalConfigurations = allEnergiesForOptimalConfigurations.substring(1,allEnergiesForOptimalConfigurations.length()-1); allEnergiesUsed = allEnergiesUsed.substring(1,allEnergiesUsed.length()-1); System.out.println("allEnergiesUsed="+allEnergiesUsed); in.close(); } catch (IOException eio) { System.out.println(eio); } try{ StringTokenizer st = new StringTokenizer(allEnergiesUsed,","); energyChanges = new Vector(); while(st.hasMoreTokens()){ String nextEnergyUsed = st.nextToken(); energyChanges.add(nextEnergyUsed); } System.out.println("energyChanges="+energyChanges); st = new StringTokenizer(allOptimalConfigurations,"}"); boolean first = true; while(st.hasMoreTokens()){ String nextConfig = st.nextToken(); if(first){ nextConfig = nextConfig.substring(1); first = false; }else{ nextConfig = nextConfig.substring(3); } allConfigurations.add(nextConfig); } System.out.println("allConfigurations="+allConfigurations); if(!sliderWasChanged){ slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 0); sliderWasChanged = false; } //slider.setMajorTickSpacing(48); //slider.setMinorTickSpacing(16); //slider.setPaintTicks(true); slider.setMaximum((int)java.lang.Math.round(Double.parseDouble(allEnergiesUsed.substring(0,allEnergiesUsed.indexOf(",")))*100)); slider.setMinimum((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.setValue((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.createStandardLabels(1); //slider.setPaintLabels(true); }catch(java.lang.NullPointerException npe){ StringTokenizer st = new StringTokenizer(allEnergiesUsed,","); energyChanges = new Vector(); while(st.hasMoreTokens()){ String nextEnergyUsed = st.nextToken(); energyChanges.add(nextEnergyUsed); } System.out.println("energyChanges="+energyChanges); st = new StringTokenizer(allOptimalConfigurations,"}"); boolean first = true; while(st.hasMoreTokens()){ String nextConfig = st.nextToken(); if(first){ nextConfig = nextConfig.substring(1); first = false; }else{ nextConfig = nextConfig.substring(3); } allConfigurations.add(nextConfig); } System.out.println("allConfigurations="+allConfigurations); if(!sliderWasChanged){ slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 0); sliderWasChanged = false; } //slider.setMajorTickSpacing(48); //slider.setMinorTickSpacing(16); //slider.setPaintTicks(true); slider.setMaximum((int)java.lang.Math.round(Double.parseDouble(allEnergiesUsed.substring(0,allEnergiesUsed.indexOf(",")))*100)); slider.setMinimum((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.setValue((int)java.lang.Math.round(Double.parseDouble(lowerEnergy)*100)); slider.createStandardLabels(1); } try { /*assuming that result is in form: enAll>>>C:\output.txt; currentConfig>>>C:\output.txt; inTermsOfPlast>>>C:\output.txt; completionTimes>>>C:\output.txt; runningX>>>C:\output.txt; jobSpeeds>>>C:\output.txt; jobEnergies>>>C:\output.txt; */ BufferedReader in = new BufferedReader(new FileReader("output"+fileNameTF.getText()+".txt")); System.out.println("Reading from outputfile"); //force image associated with batch file to be named: graphFromJava0.jpeg globalCounter = 0; String str; fileStringBuffer = new StringBuffer(""); //first line is just a header, ignore it in.readLine(); while ((str = in.readLine()) != null) { fileStringBuffer.append(str+"\n"); } in.close(); //System.out.println(fileStringBuffer); } catch (IOException eio) { System.out.println(eio); } //System.out.println("allEnergiesForOptimalConfigurations="+allEnergiesForOptimalConfigurations); return allEnergiesForOptimalConfigurations; } return ""; //main.revalidate(); //main.repaint(); } public static void main(String[] args) { JFrame f = new Slippery( ); f.addWindowListener(new WindowAdapter( ) { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); } } class DrawingArea extends JPanel { Vector runTimes=null; Vector cTimes=null; Vector rTimes=null; Vector currentConfigV=null; Vector inTermsOfPlastV=null; Vector jobSpeedsV=null; Vector jobEnergiesV=null; double totalEnergy = 0.0; public DrawingArea(){}; // //public DrawingArea(Vector runningTimes, Vector completionTimes, Vector releaseTimes){ //drawingArea = new DrawingArea(runT,completionT,releaseT,currentConfigVector,inTermsOfPlastVector,jobSpeedsVector,jobEnergiesVector); public DrawingArea(double totalEnergy,Vector runningTimes, Vector completionTimes, Vector releaseTimes, Vector currentConfigVector, Vector inTermsOfPlastVector, Vector jobSpeedsVector, Vector jobEnergiesVector){ runTimes=runningTimes; cTimes=completionTimes; rTimes=releaseTimes; currentConfigV=currentConfigVector; jobSpeedsV=jobSpeedsVector; inTermsOfPlastV=inTermsOfPlastVector; jobEnergiesV=jobEnergiesVector; this.totalEnergy = totalEnergy; } public String chopToSixDigits(String st){ if(st.length()<6) return st; else return st.substring(0,6); } public void paintComponent(Graphics g) { // System.out.println("cTimes="+cTimes); // System.out.println("rTimes="+rTimes); // System.out.println("runTimes="+runTimes); super.paintComponent(g); //fillRect(int x, int y, int width, int height) if(runTimes==null){ }else{ g.setColor(Color.black); g.drawString("ENERGY LEVEL="+totalEnergy,0,10); double totalCompTime = 0.0; String currConfg = ""; for(int j=0; j=nextCompl-nextRun) xSize = (int)Math.round(nextRelease*100); else xSize = (int)Math.round((nextCompl-nextRun)*100); g.fillRect(xSize, 40, (int)Math.round(nextRun*100), 80); g.drawString("Job "+(j+1),xSize,100); g.drawString("Start time = "+(xSize/100.00),xSize,110); g.drawString("X"+(j+1)+"="+chopToSixDigits((String)runTimes.elementAt(j)),xSize,120); g.drawString("C"+(j+1)+"="+chopToSixDigits((String)cTimes.elementAt(j)),xSize,130); g.drawString("E"+(j+1)+"="+chopToSixDigits((String)jobEnergiesV.elementAt(j)),xSize,140); g.drawString("P"+(j+1)+"="+chopToSixDigits((String)inTermsOfPlastV.elementAt(j)),xSize,150); g.drawString("S"+(j+1)+"="+chopToSixDigits((String)jobSpeedsV.elementAt(j)),xSize,160); g.drawString("Configuration"+(j+1)+"="+(String)currentConfigV.elementAt(j),xSize,170); } }catch(Exception e223){ System.out.println(e223); } } } }