summaryrefslogtreecommitdiff
path: root/systems/android/hktex/HKtex2/src/worker4math/hktex2/Parseequation.java
blob: b81daea42d28e7eb746fb0fdaa13739ca2948495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Latex Project Public Licence (lppl1.3) applies
// Originally written by Kwanleung Tse
// First Release : 1st July, 2014
// Last Update : 25th September, 2014
//
//

package worker4math.hktex2;

import java.util.ArrayList;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.SparseBooleanArray;

public class Parseequation {
	
	public static volatile SparseArray<Float> thisypos = new SparseArray<Float>();
	public static volatile SparseBooleanArray error = new SparseBooleanArray();
	public static volatile SparseArray<String> errormessage = new SparseArray<String>();
    
    public void parseequation(Canvas canvas, Block block, Integer tid,  Integer containerwidth, Integer containerheight, Integer superblocknumber, SuperBlock superblock ,SparseArray<ArrayList<String>> superblockline,SparseIntArray superblocknumline,SparseIntArray superblockstartline, SparseIntArray superblockendline, ArrayList<Typeface> tf ,String columnspec, Float ypos, String attribute) {
 
    	int ii;
	    
	    float linegap = Header.linegap;    
		float adjusty=ypos;
		float shiftx=0;
		float columnwidth=0;
		
		String blockline = new String();	
		String rawblockline = new String();
		String thisattribute=attribute;
		
		    ArrayList<Float> lineheight = new ArrayList<Float>();
		    ArrayList<Float> linedepth = new ArrayList<Float>();
		    
		    error.put(tid,false);
		    errormessage.put(tid,"");
		    
            float blockwidth = 0.0f;
            float blockheight = 0.0f;
            float blockdepth = 0.0f;
            
    	  lineheight.clear();linedepth.clear();
         
            		  lineheight.add(0.0f);
            		  linedepth.add(0.0f);
            		  synchronized(this){superblock.create(tid);}
            		                       
                 String currentsuperblockline=superblockline.get(superblocknumber).get(0);
               
            			  rawblockline=currentsuperblockline;
            			  if (rawblockline.equals("")){rawblockline=" ";};
            			 
            		  Parsepreparation prepareblockline = new Parsepreparation();
    	              blockline=prepareblockline.parsepreparation(rawblockline,Symbol.symboltype,Symbol.matchsymbol);	  	                      
            		  Parseblock parseblockline = new Parseblock();
	            	  parseblockline.parseblock(tid,canvas,block, blockline,tf,thisattribute);	                  

                      if (Block.error.get(tid)==true){error.put(tid, true); errormessage.put(tid, Block.errormessage.get(tid)); }
                      columnwidth=Block.blockwidth2.get(tid);
                      blockwidth=Block.blockwidth2.get(tid);
                      blockheight=Block.blockheight2.get(tid)+linegap;
                      blockdepth=Block.blockdepth2.get(tid)+linegap;
                      
            	  
            	  adjusty=adjusty+blockheight-blockdepth;
            	  thisypos.put(tid, adjusty+blockdepth+linegap);
            	  for (ii=0;ii<=Block.subblock2.get(tid).size()-1;ii++){            			  
            		  Block.subblockypos2.get(tid).set(ii, Block.subblockypos2.get(tid).get(ii)+adjusty);           		  
                      }
            	             	  
            	  int viewportwidth=containerwidth-Header.leftsidemargin-Header.rightsidemargin;
            	  
            	  if (viewportwidth>columnwidth){shiftx=(viewportwidth-columnwidth)/2;}
            	  else {shiftx=0;};
            	              	  
            	  for (ii=0;ii<=Block.subblock2.get(tid).size()-1;ii++){           		           		            		  
            		  Block.subblockxpos2.get(tid).set(ii, Block.subblockxpos2.get(tid).get(ii)+shiftx+Header.leftsidemargin);           		             		  
            	  }
            	  synchronized(this){
                  superblock.add(tid,Block.subblock2,Block.subblockxpos2, Block.subblockypos2, Block.subblockattribute2, blockwidth, blockheight, blockdepth,'e',0);             
            	  }
}}