Greetings, I have an error trying to implement a new B4A library, if I could help create the initialization part and correct this error that I place in the image, thanks
B4X:
package com.floor;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.DependsOn;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Array;
//import com.floor.SaveASCII;;
@BA.Version(1.0F)
@BA.ShortName("Floor")
//@DependsOn(values={"draw"})
public class DrawGrid
extends View
{
private static final boolean D = false;
private static final String TAG = "WizPlanCore.DrawGrid";
static int canvasSpace = 0;
static int countLine = 0;
static int countPoint = 0;
static int countText = 0;
static int countUndo = 0;
static int countUndoDelete = 0;
static int countUndoSelect = 0;
static int countUndoSelectText = 0;
static int cx = 0;
static int cy = 0;
static int gridColor = 0;
static int gridPixel = 30;
static int[][] lineArray;
static int lineColor = 0;
static int lineSize = 0;
static final int maxLine = 10000;
static final int maxPoint = 100;
static final int maxText = 100;
static final int maxUndo = 100;
static int moveX = 0;
static int moveY = 0;
static int[][] pointArray;
static final int recordLenght = 9;
static int startX = 0;
static int startY = 0;
public static int[][] textArray;
static final int textRecordLenght = 9;
static int textSize;
static String[] textStringArray;
static int[] undoHistory;
static int[] undoTrimPoint;
static boolean visibleDimensionLayer;
static boolean visibleMeasuredDimension;
static boolean visibleTextLayer = true;
static boolean visibleUnmeasuredDimension;
static int zoomLevel;
int height = 0;
public int width = 0;
static
{
canvasSpace = 10;
countLine = 0;
countPoint = 0;
countText = 0;
countUndo = 0;
countUndoDelete = -1;
countUndoSelect = 1;
countUndoSelectText = 1;
undoTrimPoint = new int[4];
startX = 0;
startY = 0;
moveX = 0;
moveY = 0;
zoomLevel = 1;
gridColor = -11776948;
lineColor = -1;
lineSize = 0;
textSize = 14;
int[] arrayOfInt1 = { 10000, 9 };
lineArray = (int[][])Array.newInstance(Integer.TYPE, arrayOfInt1);
int[] arrayOfInt2 = { 100, 3 };
pointArray = (int[][])Array.newInstance(Integer.TYPE, arrayOfInt2);
int[] arrayOfInt3 = { 100, 9 };
textArray = (int[][])Array.newInstance(Integer.TYPE, arrayOfInt3);
textStringArray = new String[100];
undoHistory = new int[100];
cx = 0;
cy = 0;
visibleDimensionLayer = false;
visibleMeasuredDimension = false;
visibleUnmeasuredDimension = false;
}
public DrawGrid(Context paramContext)
{
super(paramContext);
}
//public void Initialize(String Name)
//{
//new DrawGrid(null);
//}
//
//
//public void Initialize1(BA pBA, DrawGrid aMapView)
//public void Initialize1(BA pBA)
//{
//new DrawGrid(pBA.context);
//}
...
**** some classes
....
public void onDraw(Canvas paramCanvas)
{
super.onDraw(paramCanvas);
Paint localPaint1 = new Paint();
localPaint1.setColor(-1);
localPaint1.setTextSize(zoomLevel * textSize);
Paint localPaint2 = new Paint();
localPaint2.setStyle(Paint.Style.STROKE);
localPaint2.setColor(0);
paramCanvas.drawPaint(localPaint2);
this.width = (getWidth() - 2 * canvasSpace);
this.width = (this.width / gridPixel * gridPixel);
this.height = (getHeight() - 2 * canvasSpace);
this.height = (this.height / gridPixel * gridPixel);
localPaint2.setColor(gridColor);
for (int i = 0;; i++)
{
int j = this.width / gridPixel;
if (i > j) {
for (int k = 0;; k++)
{
int m = this.height / gridPixel;
if (k > m)
{
localPaint1.setColor(-65536);
for (int n = 0;; n++)
{
int i1 = countLine;
if (n >= i1)
{
int i4;
if (visibleTextLayer)
{
// new String [15]; original ***************************************
i4 = 0;
int i5 = countText;
if (i4 >= i5) {
localPaint1.setTextSize(zoomLevel * textSize);
}
}
else
{
invalidate();
return;
}
if (textArray[i4][4] > 0) {
localPaint1.setColor(65280);
} else {
localPaint1.setColor(textArray[i4][6]);
}
localPaint1.setTextSize(zoomLevel * textArray[i4][7]);
String[] arrayOfString1 = null; // se agrego *************************************
int i6 = 0; // se agrego *************************************
if (textArray[i4][4] >= 0)
{
if ((textArray[i4][0] == textArray[i4][2]) && (textArray[i4][1] == textArray[i4][3]))
{
String[] arrayOfString2 = textStringArray[i4].split("\n");
int i9;
if (textArray[i4][3] < textArray[i4][1]) {
i9 = -5 - (int)((arrayOfString2.length - 1) * (2.0F + localPaint1.getTextSize()));
} else {
i9 = 5 + (int)localPaint1.getTextSize();
}
for (int i10 = 0;; i10++)
{
int i11 = arrayOfString2.length;
if (i10 >= i11)
{
paramCanvas.drawCircle(startX + zoomLevel * (textArray[i4][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (textArray[i4][1] - canvasSpace) + canvasSpace, 3.0F, localPaint1);
break;
}
paramCanvas.drawText(arrayOfString2[i10], startX + zoomLevel * (textArray[i4][2] - canvasSpace) + canvasSpace, i9 + (startY + zoomLevel * (textArray[i4][3] - canvasSpace) + canvasSpace) + (int)(i10 * (2.0F + localPaint1.getTextSize())) - 5, localPaint1);
}
}
arrayOfString1 = textStringArray[i4].split("\n");
if (textArray[i4][3] < textArray[i4][1]) {
i6 = -5 - (int)((arrayOfString1.length - 1) * (2.0F + localPaint1.getTextSize()));
} else {
i6 = 5 + (int)localPaint1.getTextSize();
}
}
for (int i7 = 0;; i7++)
{
int i8 = arrayOfString1.length;
if (i7 >= i8)
{
paramCanvas.drawLine(startX + zoomLevel * (textArray[i4][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (textArray[i4][1] - canvasSpace) + canvasSpace, startX + zoomLevel * (textArray[i4][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (textArray[i4][3] - canvasSpace) + canvasSpace, localPaint1);
paramCanvas.drawCircle(startX + zoomLevel * (textArray[i4][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (textArray[i4][1] - canvasSpace) + canvasSpace, 3.0F, localPaint1);
i4++;
break;
}
paramCanvas.drawText(arrayOfString1[i7], startX + zoomLevel * (textArray[i4][2] - canvasSpace) + canvasSpace, i6 + (startY + zoomLevel * (textArray[i4][3] - canvasSpace) + canvasSpace) + (int)(i7 * (2.0F + localPaint1.getTextSize())), localPaint1);
}
}
if (lineArray[n][4] > 0) {
localPaint2.setColor(65280);
} else {
localPaint2.setColor(lineArray[n][6]);
}
if (lineArray[n][7] == -2)
{
localPaint2.setPathEffect(new DashPathEffect(new float[] { 10.0F, 5.0F }, 0.0F));
localPaint2.setStrokeWidth(-lineArray[n][7]);
}
else if (lineArray[n][7] == -1)
{
localPaint2.setPathEffect(new DashPathEffect(new float[] { 10.0F, 5.0F, 1.0F, 5.0F }, 0.0F));
localPaint2.setStrokeWidth(-lineArray[n][7]);
}
else
{
localPaint2.setPathEffect(null);
localPaint2.setStrokeWidth(lineArray[n][7]);
}
if (lineArray[n][4] >= 0)
{
int i2;
if (lineArray[n][5] == 0) {
i2 = 1;
} else {
i2 = 0;
}
int i3;
if (lineArray[n][5] == 1) {
i3 = 1;
} else {
i3 = 0;
}
if ((i2 | i3) != 0)
{
paramCanvas.drawLine(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace, localPaint2);
if ((visibleMeasuredDimension) && (lineArray[n][8] != 0))
{
if (lineArray[n][5] == 0)
{
localPaint1.setColor(-16776961);
paramCanvas.drawText(String.valueOf(lineArray[n][8] / 1000.0D) + "m", 2 + ((startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace + startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace) / 2 + lineArray[n][7] / 2), (startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace + startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace) / 2 - (2 + lineArray[n][7] / 2), localPaint1);
}
}
else if ((visibleUnmeasuredDimension) && (lineArray[n][8] == 0) && (lineArray[n][5] == 0))
{
localPaint1.setColor(-65536);
paramCanvas.drawText(String.valueOf(lineArray[n][8] / 1000.0D) + "m", (startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace + startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace) / 2, (startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace + startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace) / 2, localPaint1);
}
}
else if (lineArray[n][5] == 2)
{
Path localPath = new Path();
Point localPoint1 = new Point(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace);
Point localPoint2 = new Point(startX + zoomLevel * (pointArray[getFirstPointOfSelectedLine(n)][1] - canvasSpace) + canvasSpace, startY + zoomLevel * (pointArray[getFirstPointOfSelectedLine(n)][2] - canvasSpace) + canvasSpace);
Point localPoint3 = new Point(startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace);
localPath.moveTo(localPoint1.x, localPoint1.y);
localPath.cubicTo(localPoint2.x, localPoint2.y, localPoint2.x, localPoint2.y, localPoint3.x, localPoint3.y);
paramCanvas.drawPath(localPath, localPaint2);
}
else if (lineArray[n][5] == 3)
{
paramCanvas.drawCircle(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, (float)calculatePointToPointDistance(zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace), localPaint2);
if ((visibleMeasuredDimension) && (lineArray[n][8] != 0))
{
localPaint1.setColor(-16776961);
paramCanvas.drawText(String.valueOf(lineArray[n][8] / 1000.0D) + "m", (startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace + startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace) / 2, (startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace + startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace) / 2, localPaint1);
localPaint1.setPathEffect(new DashPathEffect(new float[] { 10.0F, 5.0F }, 0.0F));
paramCanvas.drawLine(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace, localPaint1);
localPaint1.setPathEffect(null);
}
else if ((visibleUnmeasuredDimension) && (lineArray[n][8] == 0))
{
localPaint1.setColor(-65536);
paramCanvas.drawText(String.valueOf(lineArray[n][8] / 1000.0D) + "m", (startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace + startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace) / 2, (startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace + startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace) / 2, localPaint1);
localPaint1.setPathEffect(new DashPathEffect(new float[] { 10.0F, 5.0F }, 0.0F));
paramCanvas.drawLine(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace, localPaint1);
localPaint1.setPathEffect(null);
}
}
else if (lineArray[n][5] == 4)
{
float f = (float)calculatePointToPointDistance(zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace);
RectF localRectF = new RectF();
localRectF.set(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace - f, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace - f, f + (startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace), f + (startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace));
paramCanvas.drawArc(localRectF, pointArray[getFirstPointOfSelectedLine(n)][1], pointArray[getFirstPointOfSelectedLine(n)][2], false, localPaint2);
}
else
{
paramCanvas.drawLine(startX + zoomLevel * (lineArray[n][0] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][1] - canvasSpace) + canvasSpace, startX + zoomLevel * (lineArray[n][2] - canvasSpace) + canvasSpace, startY + zoomLevel * (lineArray[n][3] - canvasSpace) + canvasSpace, localPaint2);
}
}
}
}
paramCanvas.drawLine(canvasSpace, canvasSpace + k * gridPixel, this.width + canvasSpace, canvasSpace + k * gridPixel, localPaint2);
}
}
paramCanvas.drawLine(canvasSpace + i * gridPixel, canvasSpace, canvasSpace + i * gridPixel, this.height + canvasSpace, localPaint2);
}
}