//***************************************************************************** // // Beenish Chaudry, Geetika Tewari, Elif Tosun and // Ileana Streinu // // Summer 1999, Fall 1999, Spring 2000 // //***************************************************************************** // // FrameInfo.java // Prints out the coordinates of the points drawn on the PointCanvas // and other information (later) // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.lang.*; import java.io.*; import java.util.*; class FrameInfo extends Frame implements PointSetObserver{ TextArea ta; FramePoint bf; int strall; //************************** // // Constructor // //************************** public FrameInfo(FramePoint bff, String title) { super(title); bf = bff; //setVisible(true); setVisible(Constants.infoFrameStart); ta = new TextArea(30, 20); add(ta); setBounds(Constants.xFI, Constants.yFI, Constants.wFI, Constants.hFI); bf.ps.registerAsObserver(this); } //************************************* // // Reset // Clears Info with some information // //************************************* public void Reset() { int c; String all; int sum = 0; all = "\nPoint Set: \n" + " ---------------------------------------------- \n" + "Origin = (" +bf.ps.or.x + ", " + bf.ps.or.y + ")\n" + bf.ps.unitL.ToString()+ "\nwOrient = " + bf.ps.wOrient + "\n"; //n = " + bf.ps.n + "\n"; c = all.length(); ta.replaceRange("", 0, strall); ta.replaceRange(all, sum, sum+c ); strall = 0; } //************************************************************ // // PointSetHasChanged // Info. on infoframe changes when changes are made to the PS // //************************************************************ public void PointSetHasChanged(PointSet ps) { int a, b, c; int i = ps.ptList.Length() -1; LList ptr; String abs, rel, both = "", unitL, all; int sum = 0; if (bf.mb.viopen.getState() == true) { all = "\nPoint Set: \n" + " ---------------------------------------------- \n" + "Origin = (" +bf.ps.or.x + ", " + bf.ps.or.y + ")\n" + "Unit Length = " + bf.ps.unitL.ToString() + "\n"; if (bf.ps.wOrient) all = all + "Orientation: Y up \n"; else all = all + "Orientation: Y down \n"; // + "wOrient = " + bf.ps.wOrient + "\n"; c = all.length(); ta.replaceRange(all, sum, sum+c ); //Prints the info on the textarea sum = sum +c; for (ptr = bf.ps.ptList; ptr != Constants.nullCell; ptr = ptr.next) { abs = ptr.data.ToStringAbsolute(); //String of old coordinates rel = ptr.data.ToStringRelative(); //String of new coordinates a = abs.length(); //length of old coordinates b = rel.length(); //length oif new coordniates both = abs.concat(rel); ta.replaceRange(both, sum, (sum+a+b)); sum = sum + a + b; //adds up all the strings of the old and new coordinates strall = sum +60; i--; //60 is added to get rid of the extra string at the end of the infoframe } ta.replaceRange("", sum, strall); } }// end PointSetHasChanged }//end class FrameInfo