X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=mainActivity%2Fapp%2Fsrc%2Fmain%2Fjava%2Fcom%2Fexample%2Ffurt%2Fmyapplication%2FtouchParserHandler.java;fp=mainActivity%2Fapp%2Fsrc%2Fmain%2Fjava%2Fcom%2Fexample%2Ffurt%2Fmyapplication%2FtouchParserHandler.java;h=655901f4da3cfbdbb16d679196188b4313946a6b;hb=23a3fa7a8181ef21d272a90dd1ff2ba353268813;hp=0000000000000000000000000000000000000000;hpb=e477ff2be762ba333c5c77c14bfdea574c700259;p=logicplayer.git diff --git a/mainActivity/app/src/main/java/com/example/furt/myapplication/touchParserHandler.java b/mainActivity/app/src/main/java/com/example/furt/myapplication/touchParserHandler.java new file mode 100644 index 0000000..655901f --- /dev/null +++ b/mainActivity/app/src/main/java/com/example/furt/myapplication/touchParserHandler.java @@ -0,0 +1,102 @@ +package com.example.furt.myapplication; + +import android.view.View; +import android.widget.TextView; +import android.widget.Toast; + +public class touchParserHandler implements View.OnClickListener +{ + int type; //0=and 1=or 2=impl 3=not 4=literal + char l; //for literals + touchParserHandler(int t,char l) + { + type=t; + this.l=l; + } + public void onClick(View view) + { + if(!parserDialog.F.toString().contains("_")) + { + Toast.makeText(DrawActivity.rootNode.view.getContext(),"Formula completa! Premere \"Undo\" per modificare", Toast.LENGTH_SHORT).show(); + return; + } + parserDialog.undo.add(parserDialog.F.duplicate()); + parserDialog.formulaLayout.removeAllViews(); + if(type==0) + { + UndefinedFormula newCursor=new UndefinedFormula(); + newCursor.currentF=true; + Formula newF=new FormulaAnd(newCursor,new UndefinedFormula()); + if ((parserDialog.F).toString().equals("_")) + { + parserDialog.F=newF; + } + else { + parserDialog.F.Fill(newF); + parserDialog.F.setCursor(); + } + } + else if(type==1) + { + UndefinedFormula newCursor=new UndefinedFormula(); + newCursor.currentF=true; + Formula newF=new FormulaOr(newCursor,new UndefinedFormula()); + if ((parserDialog.F).toString().equals("_")) + { + parserDialog.F=newF; + } + else + parserDialog.F.Fill(newF); + } + else if(type==2) + { + UndefinedFormula newCursor=new UndefinedFormula(); + newCursor.currentF=true; + Formula newF=new FormulaImpl(newCursor,new UndefinedFormula()); + if ((parserDialog.F).toString().equals("_")) + { + parserDialog.F=newF; + } + else { + parserDialog.F.Fill(newF); + parserDialog.F.setCursor(); + } + } + else if(type==3) + { + UndefinedFormula newCursor=new UndefinedFormula(); + newCursor.currentF=true; + Formula newF=new FormulaNot(newCursor); + if ((parserDialog.F).toString().equals("_")) + { + parserDialog.F=newF; + } + else { + parserDialog.F.Fill(newF); + parserDialog.F.setCursor(); + } + } + else if(type==4) + { + Formula newF; + if(l=='⊥') + newF=new FormulaBOT(); + else if(l=='T') + newF=new FormulaTOP(); + else + newF=new Literal(l); + if ((parserDialog.F).toString().equals("_")) + { + parserDialog.F=newF; + } + else { + parserDialog.F.Fill(newF); + parserDialog.F.setCursor(); + } + } + TextView FView=new TextView(parserDialog.formulaLayout.getContext()); + FView.setText(parserDialog.F.toString()); + FView.setTextSize(DrawActivity.textSize); + parserDialog.formulaLayout.addView(FView); + } +}