[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Relation.java, 1.3, 1.4 CoordinateSy
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-03-07 07:38:47
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6923/src/net/sourceforge/bprocessor/model Modified Files: Relation.java CoordinateSystem.java Log Message: More work on relations Index: CoordinateSystem.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/CoordinateSystem.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** CoordinateSystem.java 6 Mar 2007 14:53:48 -0000 1.37 --- CoordinateSystem.java 7 Mar 2007 07:38:41 -0000 1.38 *************** *** 687,691 **** public void update() { for (Relation relation : relations) { ! System.out.println("offset : " + relation.getOffset()); } } --- 687,692 ---- public void update() { for (Relation relation : relations) { ! double distance = relation.evaluate(); ! System.out.println("offset : " + distance); } } Index: Relation.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Relation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Relation.java 6 Mar 2007 14:53:48 -0000 1.3 --- Relation.java 7 Mar 2007 07:38:41 -0000 1.4 *************** *** 8,15 **** --- 8,23 ---- package net.sourceforge.bprocessor.model; + import java.io.Reader; + import java.io.StringReader; + import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; + import net.sourceforge.bprocessor.model.parser.ExpressionLexer; + import net.sourceforge.bprocessor.model.parser.ExpressionParser; + import antlr.RecognitionException; + import antlr.TokenStreamException; + /** * Relation *************** *** 44,47 **** --- 52,76 ---- return offset; } + + /** + * @return offset + */ + public double evaluate() { + Reader input = new StringReader(offset); + ExpressionLexer lexer = new ExpressionLexer(input); + ExpressionParser parser = new ExpressionParser(lexer); + HashMap env = Project.getInstance().getGlobals().environment(); + double value = 1.0; + try { + value = parser.expression(env); + } catch (RecognitionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TokenStreamException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return value; + } /** {@inheritDoc} */ |