Changeset 196 for trunk/src/org/expeditee/items/Text.java
- Timestamp:
- 08/07/08 11:44:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Text.java
r190 r196 21 21 import java.awt.geom.Rectangle2D; 22 22 import java.text.AttributedString; 23 import java.util.Collection; 23 24 import java.util.LinkedList; 24 25 import java.util.List; … … 30 31 import org.expeditee.gui.FrameKeyboardActions; 31 32 import org.expeditee.gui.FrameMouseActions; 33 import org.expeditee.gui.FrameUtils; 32 34 import org.expeditee.math.ExpediteeJEP; 33 35 import org.nfunk.jep.Node; … … 569 571 // otherwise, we are inserting text 570 572 } else { 571 _processedText = null; 573 setProcessedText(null); 574 setFormula(null); 572 575 // determine what line is being pointed to 573 576 line = getLinePosition(mouseY); … … 1872 1875 return; 1873 1876 } 1874 1877 String lowercaseFormula = formula.toLowerCase(); 1875 1878 ExpediteeJEP myParser = new ExpediteeJEP(); 1876 1879 myParser.addVariables(this.getParentOrCurrentFrame()); 1877 1880 String linkedFrame = getAbsoluteLink(); 1881 //Add the relative frame variable if the item is linked 1878 1882 if (linkedFrame != null) { 1879 myParser.addVariables(FrameIO.LoadFrame(linkedFrame)); 1883 Frame frame = FrameIO.LoadFrame(linkedFrame); 1884 myParser.addVariables(frame); 1885 //If the frame is linked add vector variable for the frame 1886 if(lowercaseFormula.contains("$frame")){ 1887 myParser.addVectorVariable(frame.getNonAnnotationItems(true), "$frame"); 1888 } 1889 } 1890 //Add the relative box variable if this item is a line end 1891 if (this.isLineEnd()){ 1892 //if its a line end add the enclosed stuff as an @variable 1893 if(lowercaseFormula.contains("$box")){ 1894 Collection<Item> enclosed = FrameUtils.getItemsEnclosedBy( 1895 this.getParentOrCurrentFrame(), this.getEnclosedShape()); 1896 myParser.addVectorVariable(enclosed, "$box"); 1897 } 1880 1898 } 1881 1899 myParser.resetObserver(); 1882 1900 try { 1883 Node node = myParser.parse( formula.toLowerCase());1901 Node node = myParser.parse(lowercaseFormula); 1884 1902 String result = myParser.evaluate(node); 1885 1903 if (result != null) { 1886 1904 this.setText(result); 1887 } 1888 } catch (Exception e) { 1905 this.setFormula(formula); 1906 } 1907 } catch (Throwable e) { 1889 1908 this.setText(getFormula()); 1890 }1891 1909 //this.setFormula(null); 1910 } 1892 1911 } 1893 1912
Note:
See TracChangeset
for help on using the changeset viewer.