complete demo \label{UC:user-guide}
authormmahringer <s1520454056@students.fh-hagenberg.at>
Tue, 21 Nov 2017 11:53:30 +0100
changeset 5223ba3233a38b4d
parent 5222 a088c015de67
child 5224 3de25c2fe154
child 5225 7c6026666b73
complete demo \label{UC:user-guide}
isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java
isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala
isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala
isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java
isac-java/src/java/isac/gui/mawen/editor/Settings.scala
     1.1 --- a/isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java	Tue Nov 21 08:46:34 2017 +0100
     1.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/MockCalcTree.java	Tue Nov 21 11:53:30 2017 +0100
     1.3 @@ -22,7 +22,8 @@
     1.4  	  // buildEvalTreeScen1();
     1.5  	  // buildEvalTreeScen4();
     1.6  	  // buildEvalTreeScen5();
     1.7 -	  buildEvalTreeEDITOR();
     1.8 +	  buildtestUC_userguide();
     1.9 +
    1.10      
    1.11  	}
    1.12  private void buildEvalTreeScen5() {
    1.13 @@ -142,34 +143,53 @@
    1.14    calc_tree_.add(new CalcFormula(pos, form));
    1.15    }
    1.16  
    1.17 -private void buildEvalTreeEDITOR() {
    1.18 -  Vector<Integer> p = new Vector<Integer>();
    1.19 +private void buildtestUC_userguide() {
    1.20 +
    1.21 +  Vector<Integer> p = new Vector<>();
    1.22    Position pos = new Position(p, "Pbl");
    1.23 -  Formula form = new Formula("xxx", TestsDATA.a_1() );
    1.24 +  Formula form = new Formula("xxx)", 
    1.25 +/*err*/    (isac.gui.mawen.TestDATA.ast_05()));
    1.26    calc_tree_.add(new CalcFormula(pos, form));
    1.27  
    1.28    // getFormulaeFromTo will need ([],Met):
    1.29    p = new Vector<Integer>();
    1.30    pos = new Position(p, "Met");
    1.31    form = new Formula("xxx", 
    1.32 -/*err*/TestsDATA.a_1());
    1.33 +/*err*/    (isac.gui.mawen.TestDATA.ast_05()));
    1.34    calc_tree_.add(new CalcFormula(pos, form));
    1.35 -  
    1.36  
    1.37 -  // getFormulaeFromTo will need ([],Met):
    1.38 -  p = new Vector<Integer>();
    1.39 -  p.add(1);
    1.40 +  //-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false;
    1.41 +  //<--ISA: "1 + (2 * x * (y + 3)) / (4 * z * (y + 3)) + 5"
    1.42 +  p = new Vector<Integer>(); p.add(1);
    1.43    pos = new Position(p, "Frm");
    1.44    form = new Formula("yyy", 
    1.45 -/*err*/TestsDATA.a_2());
    1.46 +/*err*/    (isac.gui.mawen.TestDATA.ast_06()));
    1.47    calc_tree_.add(new CalcFormula(pos, form));
    1.48 -  
    1.49 -  p = new Vector<Integer>();
    1.50 -  p.add(1);
    1.51 +
    1.52 +  //-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false;
    1.53 +  //<--ISA: "1 + (2 * x) / (4 * z) + 5"
    1.54 +  p = new Vector<Integer>(); p.add(1);
    1.55    pos = new Position(p, "Res");
    1.56    form = new Formula("zzz", 
    1.57 -/*err*/TestsDATA.a_3());
    1.58 +/*err*/    (isac.gui.mawen.TestDATA.ast_07()));
    1.59    calc_tree_.add(new CalcFormula(pos, form));
    1.60 +
    1.61 +  //-->ISA: getFormulaeFromTo 1 ([1],Res) ([2],Res) 0 false;
    1.62 +  //<--ISA: "1 + x / (2 * z) + 5"
    1.63 +  p = new Vector<Integer>(); p.add(2);
    1.64 +  pos = new Position(p, "Res");
    1.65 +  form = new Formula("zzz", 
    1.66 +/*err*/    (isac.gui.mawen.TestDATA.ast_07()));
    1.67 +  calc_tree_.add(new CalcFormula(pos, form));
    1.68 +
    1.69 +  //-->ISA: getFormulaeFromTo 1 ([2],Res) ([3],Res) 0 false;
    1.70 +  //<--ISA: "6 + x / (2 * z)"
    1.71 +  p = new Vector<Integer>(); p.add(3);
    1.72 +  pos = new Position(p, "Res");
    1.73 +  form = new Formula("zzz", 
    1.74 +/*err*/    (isac.gui.mawen.TestDATA.ast_07()));
    1.75 +  calc_tree_.add(new CalcFormula(pos, form));
    1.76 +
    1.77    
    1.78  
    1.79  }
     2.1 --- a/isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala	Tue Nov 21 08:46:34 2017 +0100
     2.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestDATA.scala	Tue Nov 21 11:53:30 2017 +0100
     2.3 @@ -128,5 +128,78 @@
     2.4                XML.Elem(("NUM", Nil), List(XML.Text ("2")))))))))))
     2.5    }
     2.6    // CONCLUSION: either d_d as mixfix (with fraction?), or introduce TERM as root, or ???????????????????
     2.7 +  
     2.8 +  // TestData from TestUseCases.testUC_userguide()
     2.9 +  def ast_05() : Ast =
    2.10 +      Appl(List(
    2.11 +        Constant("Groups.plus_class.plus"),
    2.12 +        Appl(List(
    2.13 +          Constant("Diff.d_d"),
    2.14 +          Variable("x"),
    2.15 +          Variable("x"))),
    2.16 +        Appl(List(
    2.17 +          Constant("Diff.d_d"),
    2.18 +          Variable("x"),
    2.19 +          Appl(List(                 //added to above
    2.20 +            Constant("BOX.1"),       //added to above
    2.21 +            Appl(List(
    2.22 +              Constant("Transcendental.sin"),
    2.23 +              Appl(List(             //added to above
    2.24 +                Constant("BOX.2"),   //added to above
    2.25 +                Appl(List(
    2.26 +                  Constant("Power.power_class.power"),
    2.27 +                  Variable("x"),
    2.28 +                  Variable("2")))))))))))))
    2.29 +                  
    2.30 +    def ast_06() : Ast =
    2.31 +      Appl(List(
    2.32 +        Constant("HOL.eq"),
    2.33 +        Appl(List(
    2.34 +          Constant("Diff.d_d"),
    2.35 +          Variable("bdv"),
    2.36 +          Appl(List(                 //added to above
    2.37 +            Constant("BOX.1"),       //added to above
    2.38 +            Appl(List(
    2.39 +              Constant("Transcendental.sin"),
    2.40 +              Appl(List(             //added to above
    2.41 +                Constant("BOX.2"),   //added to above
    2.42 +                Variable("u"))))))))),
    2.43 +        Appl(List(
    2.44 +          Constant("Groups.times_class.times"),
    2.45 +          Appl(List(                 //added to above
    2.46 +            Constant("BOX.3"),       //added to above
    2.47 +            Appl(List(
    2.48 +              Constant("Transcendental.cos"),
    2.49 +              Variable("u"))))),
    2.50 +          Appl(List(
    2.51 +            Constant("Diff.d_d"),
    2.52 +            Variable("bdv"),
    2.53 +            Appl(List(               //added to above
    2.54 +              Constant("BOX.4"),     //added to above
    2.55 +              Variable("u")))))))))
    2.56 +              
    2.57 +    def ast_07() : Ast =
    2.58 +      Appl(List(
    2.59 +        Constant("Groups.plus_class.plus"),
    2.60 +        Appl(List(
    2.61 +          Constant("Diff.d_d"),
    2.62 +          Variable("x"),
    2.63 +          Variable("x"))),
    2.64 +        Appl(List(
    2.65 +          Constant("Groups.times_class.times"),
    2.66 +          Appl(List(                 //added to above
    2.67 +            Constant("BOX.3"),       //added to above
    2.68 +            Appl(List(
    2.69 +              Constant("Transcendental.cos"),
    2.70 +              Appl(List(
    2.71 +                Constant("Power.power_class.power"),
    2.72 +                Variable("x"),
    2.73 +                Variable("2"))))))),
    2.74 +          Appl(List(
    2.75 +            Constant("Diff.d_d"),
    2.76 +            Variable("x"),
    2.77 +            Appl(List(               //added to above
    2.78 +              Constant("BOX.4"),     //added to above
    2.79 +              Variable("GAP")))))))))
    2.80  
    2.81  }
    2.82 \ No newline at end of file
     3.1 --- a/isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala	Tue Nov 21 08:46:34 2017 +0100
     3.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestUseCases.scala	Tue Nov 21 11:53:30 2017 +0100
     3.3 @@ -55,7 +55,7 @@
     3.4                Variable("2"))))))))))
     3.5      //println(Ast.math_string_of(ast))
     3.6      assertEquals(math_string_of(ast), term_str)
     3.7 -    val ast_05 =
     3.8 +    val ast_05 =  // copied to TestData.scala
     3.9        Appl(List(
    3.10          Constant("Groups.plus_class.plus"),
    3.11          Appl(List(
    3.12 @@ -101,7 +101,7 @@
    3.13              Variable("u"))))))))
    3.14      //println(Ast.math_string_of(ast))
    3.15      assertEquals(math_string_of(ast), term_str)
    3.16 -    val ast_06 =
    3.17 +    val ast_06 = // copied to TestData.scala
    3.18        Appl(List(
    3.19          Constant("HOL.eq"),
    3.20          Appl(List(
    3.21 @@ -154,7 +154,7 @@
    3.22              Variable("GAP")))))))) //NOT Constant("#"), because comes from Isabelle_Isac
    3.23      //println(Ast.math_string_of(ast))
    3.24      assertEquals(math_string_of(ast), term_str) //Isabelle requires (sin (x ^ 2)
    3.25 -    val ast_07 =
    3.26 +    val ast_07 = // copied to TestData.scala
    3.27        Appl(List(
    3.28          Constant("Groups.plus_class.plus"),
    3.29          Appl(List(
     4.1 --- a/isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java	Tue Nov 21 08:46:34 2017 +0100
     4.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/TestWorksheetForMawen.java	Tue Nov 21 11:53:30 2017 +0100
     4.3 @@ -59,6 +59,8 @@
     4.4   *         We don't want RMI in this TestCase and modify code of
     4.5   *         <code>WindowApplication#openNewWorksheet</code> such that RMI is
     4.6   *         excluded.
     4.7 + *         
     4.8 + *         For running this Test see comment in testWorksheetIsac().
     4.9   * 
    4.10   */
    4.11  public class TestWorksheetForMawen extends TestCase implements IToWorksheetUser 
    4.12 @@ -322,8 +324,18 @@
    4.13  		System.out.println("\\--END isac.gui.mawen.testModDialogIterator2");
    4.14  	}
    4.15  
    4.16 -	/* display example for reference in a Worksheet.
    4.17 -	 * THIS TEST WORKS ONLY IN DEBUG MODE, JUnit hangs here.
    4.18 +	/* display example for reference in a Worksheet, preperations:
    4.19 +	 * 
    4.20 +	 * 1. In MockCalcTree define the formulas to be displayed by
    4.21 +	 * 1.1. writing the formulas into a methode build*
    4.22 +	 * 1.2. call this method in the constructor.
    4.23 +	 * 1.3. uncomment lines in testWorksheetIsac according to no. of formulas
    4.24 +	 * 
    4.25 +	 * 2. Run the test in the debugger (because some bug in the Mock* makes the test hang)
    4.26 +	 * 2.1. Set Breakpoint at isac.gui.treetable.CalculationModel.calcChanged() in line 90
    4.27 +	 * 2.2. hit <step over> down to the end of calcChanged()
    4.28 +	 * 2.3. repeat hits accordng to no. of formulas.
    4.29 +	 * 
    4.30  	 */
    4.31  	public void testWorksheetIsac() {
    4.32  			System.out.println("/--BEGIN isac.gui.mawen.testWorksheetIsac");
    4.33 @@ -351,44 +363,44 @@
    4.34        e1.printStackTrace();
    4.35      }
    4.36  		wd.sendFormulaToWorksheet (from, to); // the root-node in CalcModelHierarchy
    4.37 -//		try {
    4.38 -//      Thread.sleep(10);
    4.39 -//    } catch (InterruptedException e1) {
    4.40 -//      // TODO Auto-generated catch block
    4.41 -//      e1.printStackTrace();
    4.42 -//    }
    4.43 -//		//-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false;
    4.44 -//		from = new Position(); from.setKind("Met");
    4.45 -//		to = new Position(); to.addInt("1"); to.setKind("Frm");
    4.46 -//		try {
    4.47 -//      Thread.sleep(100);
    4.48 -//    } catch (InterruptedException e1) {
    4.49 -//      // TODO Auto-generated catch block
    4.50 -//      e1.printStackTrace();
    4.51 -//    }
    4.52 -//		wd.sendFormulaToWorksheet (from, to);
    4.53 -//		try {
    4.54 -//      Thread.sleep(100);
    4.55 -//    } catch (InterruptedException e1) {
    4.56 -//      // TODO Auto-generated catch block
    4.57 -//      e1.printStackTrace();
    4.58 -//    }
    4.59 -//		//-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false;
    4.60 -//		from = new Position(); from.addInt("1"); from.setKind("Frm");
    4.61 -//		to = new Position(); to.addInt("1"); to.setKind("Res");
    4.62 -//		try {
    4.63 -//      Thread.sleep(10);
    4.64 -//    } catch (InterruptedException e1) {
    4.65 -//      // TODO Auto-generated catch block
    4.66 -//      e1.printStackTrace();
    4.67 -//    }
    4.68 -//		wd.sendFormulaToWorksheet (from, to);
    4.69 -//		try {
    4.70 -//      Thread.sleep(10);
    4.71 -//    } catch (InterruptedException e1) {
    4.72 -//      // TODO Auto-generated catch block
    4.73 -//      e1.printStackTrace();
    4.74 -//    }
    4.75 +		try {
    4.76 +      Thread.sleep(10);
    4.77 +    } catch (InterruptedException e1) {
    4.78 +      // TODO Auto-generated catch block
    4.79 +      e1.printStackTrace();
    4.80 +    }
    4.81 +		//-->ISA: getFormulaeFromTo 1 ([],Met) ([1],Frm) 0 false;
    4.82 +		from = new Position(); from.setKind("Met");
    4.83 +		to = new Position(); to.addInt("1"); to.setKind("Frm");
    4.84 +		try {
    4.85 +      Thread.sleep(100);
    4.86 +    } catch (InterruptedException e1) {
    4.87 +      // TODO Auto-generated catch block
    4.88 +      e1.printStackTrace();
    4.89 +    }
    4.90 +		wd.sendFormulaToWorksheet (from, to);
    4.91 +		try {
    4.92 +      Thread.sleep(100);
    4.93 +    } catch (InterruptedException e1) {
    4.94 +      // TODO Auto-generated catch block
    4.95 +      e1.printStackTrace();
    4.96 +    }
    4.97 +		//-->ISA: getFormulaeFromTo 1 ([1],Frm) ([1],Res) 0 false;
    4.98 +		from = new Position(); from.addInt("1"); from.setKind("Frm");
    4.99 +		to = new Position(); to.addInt("1"); to.setKind("Res");
   4.100 +		try {
   4.101 +      Thread.sleep(10);
   4.102 +    } catch (InterruptedException e1) {
   4.103 +      // TODO Auto-generated catch block
   4.104 +      e1.printStackTrace();
   4.105 +    }
   4.106 +		wd.sendFormulaToWorksheet (from, to);
   4.107 +		try {
   4.108 +      Thread.sleep(10);
   4.109 +    } catch (InterruptedException e1) {
   4.110 +      // TODO Auto-generated catch block
   4.111 +      e1.printStackTrace();
   4.112 +    }
   4.113  //		//-->ISA: getFormulaeFromTo 1 ([1],Res) ([2],Res) 0 false;
   4.114  //		from = new Position(); from.addInt("1"); from.setKind("Res");
   4.115  //		to = new Position(); to.addInt("2"); to.setKind("Res");
     5.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Settings.scala	Tue Nov 21 08:46:34 2017 +0100
     5.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Settings.scala	Tue Nov 21 11:53:30 2017 +0100
     5.3 @@ -56,6 +56,9 @@
     5.4    var ast_Stringbounds = Map.empty[String, (Rectangle, Rectangle, Rectangle)]
     5.5    
     5.6    def getStringBoundOf(key: String, level: Int) : Rectangle = {
     5.7 +    if (key == "" || key == "u"  || key == "bdv" ) {
     5.8 +      return new Rectangle(0,0,50,50);
     5.9 +    }
    5.10      ast_Stringbounds(key).productElement(Math.min(2, level)).asInstanceOf[Rectangle].clone().asInstanceOf[Rectangle]
    5.11    }
    5.12    def getStringBoundOf(key: String, level: Int, dx: Int, dy: Int) : Rectangle =  {
    5.13 @@ -127,19 +130,20 @@
    5.14      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)
    5.15      new Rectangle(norm_rect.x, norm_rect.y, norm_rect.width, norm_rect.height)
    5.16    }
    5.17 +  // brighter colors are not easily visible
    5.18    val CollorMapping: Map[Int, java.awt.Color] =  Map(
    5.19      0 -> java.awt.Color.BLACK, 
    5.20      1 -> java.awt.Color.BLACK, 
    5.21      2 -> java.awt.Color.BLUE,
    5.22 -    3 -> java.awt.Color.CYAN,
    5.23 -    4 -> java.awt.Color.DARK_GRAY,
    5.24 -    5 -> java.awt.Color.GRAY,
    5.25 +    3 -> java.awt.Color.MAGENTA,
    5.26 +    4 -> java.awt.Color.RED,
    5.27 +    5 -> java.awt.Color.DARK_GRAY,
    5.28      6 -> java.awt.Color.GREEN,
    5.29      7 -> java.awt.Color.LIGHT_GRAY,
    5.30 -    8 -> java.awt.Color.MAGENTA,
    5.31 +    8 -> java.awt.Color.CYAN,
    5.32      9 -> java.awt.Color.ORANGE,
    5.33      10 -> java.awt.Color.PINK,
    5.34 -    11 -> java.awt.Color.RED,
    5.35 +    11 -> java.awt.Color.GRAY,
    5.36      12 -> java.awt.Color.YELLOW,
    5.37      13 -> new java.awt.Color(128,64,0))
    5.38    val layout = Map (