B4J Question Cannot recreate B4XRect after put it inside a List [SOLVED]

max123

Well-Known Member
Licensed User
Longtime User
Hi all,

I've this piece of code where there is a Select Case.

I pass to the sub a List of arguments as objects, the first argument Args.Get(0) is a B4XRect.
The problem here is that I cannot recreate a B4XRect passed as Object and the error occours
on the line Dim left As Float = rect.Left
B4X:
 Case "DrawRoundRectRotated"   ' DrawRoundRectRotated(Rect As B4XRect, Color As Int, Filled As Boolean, StrokeWidth As Float, CornerRadius As Float, Degrees As Float)
            Dim path As B4XPath
            Dim rect As B4XRect = Args.Get(0).As(B4XRect)
            Dim left As Float = rect.Left
            Dim top As Float = rect.Top
            Dim right As Float = rect.Right
            Dim bottom As Float = rect.Bottom
            rect.Initialize(left, top, right, bottom)
            path.InitializeRoundedRect(rect, Args.Get(4))
            cvs.DrawPathRotated(path, Args.Get(1), Args.Get(2), Args.Get(3), Args.Get(5), rect.CenterX, rect.CenterY) ' 0 degrees

On this line in Debug mode I can see the passed rectangle dimensions, but may it is transformed to string when iI put in the list ?
B4X:
Dim rect As B4XRect = Args.Get(0).As(B4XRect)

I construct the list this way, CM is a command and arguments separator, I cannot use just a single character like a comma
because need to be a pattern because I use some commands that accept strings and the split command confuse it.
Note that separator is not a problem, I've used it in other commands and in other projects and it works.
B4X:
Private Sub Class_Globals
    Private fx As JFX
    Private xui As XUI

    Private Const CM As String = "-,-" ' Separator
    Private DrawList As List    ' List of all drawings
    Private ArgList As List  ' List of all arguments

    Private mAutoInvalidate As Boolean = False
End Sub

'Similar to DrawRoundRect. Draw a rectangle with round corners and rotated by Degrees angle.
Sub DrawRoundRectRotated(Rect As B4XRect, Color As Int, Filled As Boolean, StrokeWidth As Float, CornerRadius As Float, Degrees As Float)
    ArgList.Initialize2(Array(Rect, Color, Filled, StrokeWidth, CornerRadius, Degrees))
    InvalidateCommand("DrawRoundRectRotated", ArgList)
End Sub

Private Sub InvalidateCommand(cmd As String, Args As List)
'    Try
        If mAutoInvalidate Then
            ParseCommand(cmd, Args)
        Else
            Dim oCmd As Object = cmd
            For Each o As Object In Args
                oCmd = oCmd & CM & o
            Next
            DrawList.Add(oCmd)
        End If
'    Catch
'        Log("ERROR: " & LastException)
'    End Try
End Sub

Here is how B4XRect looks inside the Args list:
(200.0, 200.0, 350.0, 350.0)

Attached the error log.

Thanks

Waiting for debugger to connect...
Program started.
600
600
STARTED
Resize
Error occurred on line: 208 (AsyncCanvas)
java.lang.RuntimeException: Method: getLeft not found in: java.lang.String
at anywheresoftware.b4a.shell.Shell$MethodCache.getMethod(Shell.java:891)
at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:539)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:628)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
 
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
Hi @Daestrum,

I finished to write a class, then tried to pack as b4xlib but I've some strange issues.

B4J IDE see the b4xlib in the library tab, but there is no version, it is always 0.00.
I created a manifest.txt and put inside the zip, this is the content:
Version=1.02
B4J.DependsOn=jXUI, JavaObject
I even tried to add other platforms, but no luck...

I don't know where I'm wrong, I already packaged some b4xlib for B4R some time ago, but not had this problem.

The IDE always see the library for all 3 platforms, it should be only B4J.

But the big problem is that it does not see completely my class and a new type AsyncCanvas.

Please, did you know where I'm wrong ?

Many Thanks
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I can't really help, my experience of B4XLibs is like zero, I don't use them.
I'm sure others on here can help with the B4XLib problem.
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Ok thanks, I will post a thread if it continue to not work.
 
Upvote 0
Top