Dear Group,
I am interested to know if there is a way to be able to display a line by reading the coordinate points from a file? i am not dealing with any image stacks here, all i want is to be able to display a line, coz for some reason i am not able to do. here is what i did: public void actionPerformed(ActionEvent e) { String label = e.getActionCommand(); if (label==null) return; img = WindowManager.getCurrentImage(); if (img==null) { IJ.beep(); IJ.showStatus("No image"); return; } //the open method is supposed to read a coordinate points from a file and display the line on the img. if(label=="Open"){ IJ.showStatus("entered Open"); String line[] = new String[4]; JFileChooser chooser = new JFileChooser(morphoFile); if ( morphoFile.isFile() ) { chooser.setSelectedFile(morphoFile); } int result = chooser.showOpenDialog(frame); if (result == JFileChooser.CANCEL_OPTION) return; morphoFile = chooser.getSelectedFile(); try { FileReader readIn = new FileReader(morphoFile); BufferedReader in = new BufferedReader(readIn); String inLine; String fLine=""; int linectr=0; int ctr=0; // I am trying to read 2 lines at a time so that will provide the two endpoints of the line while ((inLine = in.readLine()) != null & linectr <= 1) { fLine = fLine + " " + inLine; ++linectr; if(linectr > 1){ StringTokenizer st = new StringTokenizer(fLine); while(st.hasMoreTokens()){ line[ctr++] = st.nextToken(); } canvas.setImageUpdated(); //s2ints funtion doesn't work at all! so i have used my own method called transfer to convert string to int[], but neither does this work :( //int[] xy = cp.s2ints(fLine); int[] xy = transfer(line); //i cannot get these messages printed! IJ.showStatus("len:"+xy.length); //IJ.showMessage(xy[0]+" "+xy[1]+" "+xy[2]+" "+xy[3]); //IJ.showMessage("pnt:"+x_1+" "+y_1); //imp.setRoi(ln); //my understanding is that these two methods are sufficient to draw a line, then why am i not able to? img.getProcessor().moveTo(canvas.offScreenX(xy[0]), canvas.offScreenY(xy[1])); img.getProcessor().lineTo(canvas.offScreenX(xy[2]), canvas.offScreenY(xy[3])); //imp.drawLine(x_1,y_1,x_2,y_2); //img.setProcessor("Draw A Line",imp); img.updateAndRepaintWindow(); linectr=0; ctr=0; } } }catch(Exception ex){IJ.showStatus(ex.getMessage());} } ..... Please tell me what am i doing wrong here! -Thanks in advance Sri |
Free forum by Nabble | Edit this page |