# HG changeset patch # User mmahringer # Date 1511261610 -3600 # Node ID ba3233a38b4d17cd8eedadea4b7750a55daad7dd # Parent a088c015de67279de3f1cd0943edeb239c75eb92 complete demo \label{UC:user-guide} diff -r a088c015de67 -r ba3233a38b4d isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java --- a/isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java Tue Nov 21 08:46:34 2017 +0100 +++ b/isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java Tue Nov 21 11:53:30 2017 +0100 @@ -22,7 +22,8 @@ // buildEvalTreeScen1(); // buildEvalTreeScen4(); // buildEvalTreeScen5(); - buildEvalTreeEDITOR(); + buildtestUC_userguide(); + } private void buildEvalTreeScen5() { @@ -142,34 +143,53 @@ calc_tree_.add(new CalcFormula(pos, form)); } -private void buildEvalTreeEDITOR() { - Vector p = new Vector(); +private void buildtestUC_userguide() { + + Vector p = new Vector<>(); Position pos = new Position(p, "Pbl"); - Formula form = new Formula("xxx", TestsDATA.a_1() ); + Formula form = new Formula("xxx)", +/*err*/ (isac.gui.mawen.TestDATA.ast_05())); calc_tree_.add(new CalcFormula(pos, form)); // getFormulaeFromTo will need ([],Met): p = new Vector(); pos = new Position(p, "Met"); form = new Formula("xxx", -/*err*/TestsDATA.a_1()); +/*err*/ (isac.gui.mawen.TestDATA.ast_05())); calc_tree_.add(new CalcFormula(pos, form)); - - // getFormulaeFromTo will need ([],Met): - p = new Vector(); - p.add(1); + //-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false; + //<--ISA: "1 + (2 * x * (y + 3)) / (4 * z * (y + 3)) + 5" + p = new Vector(); p.add(1); pos = new Position(p, "Frm"); form = new Formula("yyy", -/*err*/TestsDATA.a_2()); +/*err*/ (isac.gui.mawen.TestDATA.ast_06())); calc_tree_.add(new CalcFormula(pos, form)); - - p = new Vector(); - p.add(1); + + //-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false; + //<--ISA: "1 + (2 * x) / (4 * z) + 5" + p = new Vector(); p.add(1); pos = new Position(p, "Res"); form = new Formula("zzz", -/*err*/TestsDATA.a_3()); +/*err*/ (isac.gui.mawen.TestDATA.ast_07())); calc_tree_.add(new CalcFormula(pos, form)); + + //-->ISA: getFormulaeFromTo 1 ([1],Res) ([2],Res) 0 false; + //<--ISA: "1 + x / (2 * z) + 5" + p = new Vector(); p.add(2); + pos = new Position(p, "Res"); + form = new Formula("zzz", +/*err*/ (isac.gui.mawen.TestDATA.ast_07())); + calc_tree_.add(new CalcFormula(pos, form)); + + //-->ISA: getFormulaeFromTo 1 ([2],Res) ([3],Res) 0 false; + //<--ISA: "6 + x / (2 * z)" + p = new Vector(); p.add(3); + pos = new Position(p, "Res"); + form = new Formula("zzz", +/*err*/ (isac.gui.mawen.TestDATA.ast_07())); + calc_tree_.add(new CalcFormula(pos, form)); + } diff -r a088c015de67 -r ba3233a38b4d isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala --- a/isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala Tue Nov 21 08:46:34 2017 +0100 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala Tue Nov 21 11:53:30 2017 +0100 @@ -128,5 +128,78 @@ XML.Elem(("NUM", Nil), List(XML.Text ("2"))))))))))) } // CONCLUSION: either d_d as mixfix (with fraction?), or introduce TERM as root, or ??????????????????? + + // TestData from TestUseCases.testUC_userguide() + def ast_05() : Ast = + Appl(List( + Constant("Groups.plus_class.plus"), + Appl(List( + Constant("Diff.d_d"), + Variable("x"), + Variable("x"))), + Appl(List( + Constant("Diff.d_d"), + Variable("x"), + Appl(List( //added to above + Constant("BOX.1"), //added to above + Appl(List( + Constant("Transcendental.sin"), + Appl(List( //added to above + Constant("BOX.2"), //added to above + Appl(List( + Constant("Power.power_class.power"), + Variable("x"), + Variable("2"))))))))))))) + + def ast_06() : Ast = + Appl(List( + Constant("HOL.eq"), + Appl(List( + Constant("Diff.d_d"), + Variable("bdv"), + Appl(List( //added to above + Constant("BOX.1"), //added to above + Appl(List( + Constant("Transcendental.sin"), + Appl(List( //added to above + Constant("BOX.2"), //added to above + Variable("u"))))))))), + Appl(List( + Constant("Groups.times_class.times"), + Appl(List( //added to above + Constant("BOX.3"), //added to above + Appl(List( + Constant("Transcendental.cos"), + Variable("u"))))), + Appl(List( + Constant("Diff.d_d"), + Variable("bdv"), + Appl(List( //added to above + Constant("BOX.4"), //added to above + Variable("u"))))))))) + + def ast_07() : Ast = + Appl(List( + Constant("Groups.plus_class.plus"), + Appl(List( + Constant("Diff.d_d"), + Variable("x"), + Variable("x"))), + Appl(List( + Constant("Groups.times_class.times"), + Appl(List( //added to above + Constant("BOX.3"), //added to above + Appl(List( + Constant("Transcendental.cos"), + Appl(List( + Constant("Power.power_class.power"), + Variable("x"), + Variable("2"))))))), + Appl(List( + Constant("Diff.d_d"), + Variable("x"), + Appl(List( //added to above + Constant("BOX.4"), //added to above + Variable("GAP"))))))))) } \ No newline at end of file diff -r a088c015de67 -r ba3233a38b4d isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala --- a/isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala Tue Nov 21 08:46:34 2017 +0100 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala Tue Nov 21 11:53:30 2017 +0100 @@ -55,7 +55,7 @@ Variable("2")))))))))) //println(Ast.math_string_of(ast)) assertEquals(math_string_of(ast), term_str) - val ast_05 = + val ast_05 = // copied to TestData.scala Appl(List( Constant("Groups.plus_class.plus"), Appl(List( @@ -101,7 +101,7 @@ Variable("u")))))))) //println(Ast.math_string_of(ast)) assertEquals(math_string_of(ast), term_str) - val ast_06 = + val ast_06 = // copied to TestData.scala Appl(List( Constant("HOL.eq"), Appl(List( @@ -154,7 +154,7 @@ Variable("GAP")))))))) //NOT Constant("#"), because comes from Isabelle_Isac //println(Ast.math_string_of(ast)) assertEquals(math_string_of(ast), term_str) //Isabelle requires (sin (x ^ 2) - val ast_07 = + val ast_07 = // copied to TestData.scala Appl(List( Constant("Groups.plus_class.plus"), Appl(List( diff -r a088c015de67 -r ba3233a38b4d isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java --- a/isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java Tue Nov 21 08:46:34 2017 +0100 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java Tue Nov 21 11:53:30 2017 +0100 @@ -59,6 +59,8 @@ * We don't want RMI in this TestCase and modify code of * WindowApplication#openNewWorksheet such that RMI is * excluded. + * + * For running this Test see comment in testWorksheetIsac(). * */ public class TestWorksheetForMawen extends TestCase implements IToWorksheetUser @@ -322,8 +324,18 @@ System.out.println("\\--END isac.gui.mawen.testModDialogIterator2"); } - /* display example for reference in a Worksheet. - * THIS TEST WORKS ONLY IN DEBUG MODE, JUnit hangs here. + /* display example for reference in a Worksheet, preperations: + * + * 1. In MockCalcTree define the formulas to be displayed by + * 1.1. writing the formulas into a methode build* + * 1.2. call this method in the constructor. + * 1.3. uncomment lines in testWorksheetIsac according to no. of formulas + * + * 2. Run the test in the debugger (because some bug in the Mock* makes the test hang) + * 2.1. Set Breakpoint at isac.gui.treetable.CalculationModel.calcChanged() in line 90 + * 2.2. hit down to the end of calcChanged() + * 2.3. repeat hits accordng to no. of formulas. + * */ public void testWorksheetIsac() { System.out.println("/--BEGIN isac.gui.mawen.testWorksheetIsac"); @@ -351,44 +363,44 @@ e1.printStackTrace(); } wd.sendFormulaToWorksheet (from, to); // the root-node in CalcModelHierarchy -// try { -// Thread.sleep(10); -// } catch (InterruptedException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// //-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false; -// from = new Position(); from.setKind("Met"); -// to = new Position(); to.addInt("1"); to.setKind("Frm"); -// try { -// Thread.sleep(100); -// } catch (InterruptedException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// wd.sendFormulaToWorksheet (from, to); -// try { -// Thread.sleep(100); -// } catch (InterruptedException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// //-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false; -// from = new Position(); from.addInt("1"); from.setKind("Frm"); -// to = new Position(); to.addInt("1"); to.setKind("Res"); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// wd.sendFormulaToWorksheet (from, to); -// try { -// Thread.sleep(10); -// } catch (InterruptedException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false; + from = new Position(); from.setKind("Met"); + to = new Position(); to.addInt("1"); to.setKind("Frm"); + try { + Thread.sleep(100); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + wd.sendFormulaToWorksheet (from, to); + try { + Thread.sleep(100); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false; + from = new Position(); from.addInt("1"); from.setKind("Frm"); + to = new Position(); to.addInt("1"); to.setKind("Res"); + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + wd.sendFormulaToWorksheet (from, to); + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } // //-->ISA: getFormulaeFromTo 1 ([1],Res) ([2],Res) 0 false; // from = new Position(); from.addInt("1"); from.setKind("Res"); // to = new Position(); to.addInt("2"); to.setKind("Res"); diff -r a088c015de67 -r ba3233a38b4d isac-java/src/java/isac/gui/mawen/editor/Settings.scala --- a/isac-java/src/java/isac/gui/mawen/editor/Settings.scala Tue Nov 21 08:46:34 2017 +0100 +++ b/isac-java/src/java/isac/gui/mawen/editor/Settings.scala Tue Nov 21 11:53:30 2017 +0100 @@ -56,6 +56,9 @@ var ast_Stringbounds = Map.empty[String, (Rectangle, Rectangle, Rectangle)] def getStringBoundOf(key: String, level: Int) : Rectangle = { + if (key == "" || key == "u" || key == "bdv" ) { + return new Rectangle(0,0,50,50); + } ast_Stringbounds(key).productElement(Math.min(2, level)).asInstanceOf[Rectangle].clone().asInstanceOf[Rectangle] } def getStringBoundOf(key: String, level: Int, dx: Int, dy: Int) : Rectangle = { @@ -127,19 +130,20 @@ val norm_rect = new Rectangle((rect.x / Settings.zoom).round, (rect.y / Settings.zoom).round, (rect.width / Settings.zoom).round, (rect.height / Settings.zoom).round) new Rectangle(norm_rect.x, norm_rect.y, norm_rect.width, norm_rect.height) } + // brighter colors are not easily visible val CollorMapping: Map[Int, java.awt.Color] = Map( 0 -> java.awt.Color.BLACK, 1 -> java.awt.Color.BLACK, 2 -> java.awt.Color.BLUE, - 3 -> java.awt.Color.CYAN, - 4 -> java.awt.Color.DARK_GRAY, - 5 -> java.awt.Color.GRAY, + 3 -> java.awt.Color.MAGENTA, + 4 -> java.awt.Color.RED, + 5 -> java.awt.Color.DARK_GRAY, 6 -> java.awt.Color.GREEN, 7 -> java.awt.Color.LIGHT_GRAY, - 8 -> java.awt.Color.MAGENTA, + 8 -> java.awt.Color.CYAN, 9 -> java.awt.Color.ORANGE, 10 -> java.awt.Color.PINK, - 11 -> java.awt.Color.RED, + 11 -> java.awt.Color.GRAY, 12 -> java.awt.Color.YELLOW, 13 -> new java.awt.Color(128,64,0)) val layout = Map (