]> matita.cs.unibo.it Git - logicplayer.git/blob - mainActivity/src/com/example/furt/myapplication/touchParserHandler.java
464cc09c9bfe8aedd11a9d539b6432596a99c720
[logicplayer.git] / mainActivity / src / com / example / furt / myapplication / touchParserHandler.java
1 package com.example.furt.myapplication;
2
3 import android.view.View;
4 import android.widget.TextView;
5
6 public class touchParserHandler implements View.OnClickListener
7 {
8     int type; //0=and 1=or 2=impl 3=not 4=literal
9     char l; //for literals
10     touchParserHandler(int t,char l)
11     {
12         type=t;
13         this.l=l;
14     }
15     public void onClick(View view)
16     {
17         parserDialog.undo.add(parserDialog.F.duplicate());
18         parserDialog.formulaLayout.removeAllViews();
19         if(type==0)
20         {
21             UndefinedFormula newCursor=new UndefinedFormula();
22             newCursor.currentF=true;
23             Formula newF=new FormulaAnd(newCursor,new UndefinedFormula());
24             if ((parserDialog.F).toString().equals("_"))
25             {
26                 parserDialog.F=newF;
27             }
28             else {
29                 parserDialog.F.Fill(newF);
30                 parserDialog.F.setCursor();
31             }
32         }
33         else if(type==1)
34         {
35             UndefinedFormula newCursor=new UndefinedFormula();
36             newCursor.currentF=true;
37             Formula newF=new FormulaOr(newCursor,new UndefinedFormula());
38             if ((parserDialog.F).toString().equals("_"))
39             {
40                 parserDialog.F=newF;
41             }
42             else
43                 parserDialog.F.Fill(newF);
44         }
45         else if(type==2)
46         {
47             UndefinedFormula newCursor=new UndefinedFormula();
48             newCursor.currentF=true;
49             Formula newF=new FormulaImpl(newCursor,new UndefinedFormula());
50             if ((parserDialog.F).toString().equals("_"))
51             {
52                 parserDialog.F=newF;
53             }
54             else {
55                 parserDialog.F.Fill(newF);
56                 parserDialog.F.setCursor();
57             }
58         }
59         else if(type==3)
60         {
61             UndefinedFormula newCursor=new UndefinedFormula();
62             newCursor.currentF=true;
63             Formula newF=new FormulaNot(newCursor);
64             if ((parserDialog.F).toString().equals("_"))
65             {
66                 parserDialog.F=newF;
67             }
68             else {
69                 parserDialog.F.Fill(newF);
70                 parserDialog.F.setCursor();
71             }
72         }
73         else if(type==4)
74         {
75             Formula newF;
76             if(l=='⊥')
77                 newF=new FormulaBOT();
78             else if(l=='T')
79                 newF=new FormulaTOP();
80             else
81                 newF=new Literal(l);
82             if ((parserDialog.F).toString().equals("_"))
83             {
84                 parserDialog.F=newF;
85             }
86             else {
87                 parserDialog.F.Fill(newF);
88                 parserDialog.F.setCursor();
89             }
90         }
91         TextView FView=new TextView(parserDialog.formulaLayout.getContext());
92         FView.setText(parserDialog.F.toString());
93         FView.setTextSize(DrawActivity.textSize);
94         parserDialog.formulaLayout.addView(FView);
95     }
96 }