B4J Question How to draw an arc with the jGraphicLib library ?

CHAUVET

Member
Licensed User
Longtime User
Hello,

How to draw an arc with the jGraphicLib library ?

With JavaFX scene Builder, I created an Arc shape and when I run the application I get an error.


B4X:
#Region  Project Attributes
    #MainFormWidth: 500
    #MainFormHeight: 500
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
  
    Public circle_stats_1 As GLArc
  
  
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("dashboard.fxml") 'Load the layout file.
    MainForm.Show
  
    circle_stats_1.SetLength(90.0)
    circle_stats_1.SetFill(fx.Colors.Magenta)

  
End Sub

Sub circle_stats_1_MouseClicked (EventData As MouseEvent)
    circle_stats_1.SetLength(circle_stats_1.GetLength+10)
End Sub

Program started.
Error occurred on line: 18 (Main)
java.lang.ClassCastException: com.stevel05.rtest.glarc cannot be cast to anywheresoftware.b4a.ObjectWrapper
at anywheresoftware.b4j.objects.FXMLBuilder.setNodeField(FXMLBuilder.java:140)
at anywheresoftware.b4j.objects.FXMLBuilder.LoadLayout(FXMLBuilder.java:124)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:71)
at b4j.example.main._appstart(main.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:593)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/317949656.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/1775282465.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1764213640.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/2040495657.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1558600329.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)

Thanks for your help.
 

Attachments

  • GLArc.zip
    5.2 KB · Views: 363

CHAUVET

Member
Licensed User
Longtime User
Hi,

This is my solution (without jGraphicLib and only with JavaObject) :

B4X:
#Region  Project Attributes
    #MainFormWidth: 1000
    #MainFormHeight: 800
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private JOarc1 As JavaObject
    Private JOarc2 As JavaObject

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED") ' UTILITY
    MainForm.Title = "Arc by JO"

    MainForm.Resizable = False
    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
  
    ' JOarc1 and JOarc2 are created in JavaFX Scene Builder
    SetArc(JOarc1, 0, 0, 100.0, 100.0, 90.0, 55)
    SetArc(JOarc2, 25, 0, 100.0, 100.0, 270.0, 45)

End Sub

Public Sub SetArc(ArcName As JavaObject, CenterX As Double, CenterY As Double, RadiusX As Double, RadiusY As Double, StartAngle As Double, Length As Double)
    ArcName.RunMethod("setCenterX",Array As Object(CenterX))
    ArcName.RunMethod("setCenterY",Array As Object(CenterY))
    ArcName.RunMethod("setRadiusX",Array As Object(RadiusX))
    ArcName.RunMethod("setRadiusY",Array As Object(RadiusY))
    ArcName.RunMethod("setStartAngle",Array As Object(StartAngle))
    ArcName.RunMethod("setLength",Array As Object(Length))
End Sub
 
Upvote 0
Top