B4J Question Chart JavaFx (javaobject) remove point

ivanomonti

Well-Known Member
Licensed User
how can I remove the point (0) by a line graph of the chart javafx!!

{I have to create an effect like oscilloscope}


B4X:
Sub Class_Globals
    Private fx As JFX
    Private OscilloscopeForm As Form
    Private PaneMainForm As Pane
    Private l1,l2,l3,l4 As List
    Private b1,b2 As Button
    Private XAxis,YAxis,LineChart,Series1,Series2,Series3,Series4,GetData1,GetData2,GetData3,GetData4,LCGetData As JavaObject
    Private tm As Timer
End Sub

Public Sub Initialize
   
    l1.Initialize
    l2.Initialize
    l3.Initialize
    l4.Initialize

    OscilloscopeForm.Initialize("OscilloscopeForm",800,400)
    OscilloscopeForm.Show
   
    PaneMainForm.Initialize("PaneMainForm")
    OscilloscopeForm.RootPane.AddNode(PaneMainForm,0,0,OscilloscopeForm.Width,OscilloscopeForm.Height-42)
   
    Private l,t,w,h As Int
   
    l = 10
    t = OscilloscopeForm.Height - 42
    w = (OscilloscopeForm.Width/2)-20
    h = 32
   
    b1.Initialize("b1")
    b1.Text = "Start"
    OscilloscopeForm.RootPane.AddNode(b1,l,t,w,h)
   
    l = OscilloscopeForm.Width/2
   
    b2.Initialize("b2")
    b2.Text = "Close"
    OscilloscopeForm.RootPane.AddNode(b2,l,t,w,h)
   
    chartInitialize
   
    tm.Initialize("tm",100)
    tm.Enabled = True
   
End Sub

Sub tm_tick
    l1.Add(Rnd(1,2048))
    l2.Add(Rnd(1,2048))
    l3.Add(Rnd(1,2048))
    l4.Add(Rnd(1,2048))
    serie(1,l1.Size-1)
    serie(2,l2.Size-1)
    serie(3,l3.Size-1)
    serie(4,l4.Size-1)
End Sub

Sub chartInitialize As Boolean
   
   
    XAxis.InitializeNewInstance("javafx.scene.chart.CategoryAxis",Null)
    YAxis.InitializeNewInstance("javafx.scene.chart.NumberAxis",Null)
    LineChart.InitializeNewInstance("javafx.scene.chart.LineChart",Array As Object(XAxis,YAxis))
    LineChart.RunMethod("setTitle",Array As Object("Simulator Oscilloscope"))
   
    XAxis.RunMethod("setLabel",Array As Object("Value"))

    Series1.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
    Series1.RunMethod("setName",Array As Object("Canale" & 1))
    GetData1=Series1.RunMethod("getData",Null)
   
    Series2.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
    Series2.RunMethod("setName",Array As Object("Canale" & 2))
    GetData2=Series2.RunMethod("getData",Null)

    Series3.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
    Series3.RunMethod("setName",Array As Object("Canale" & 3))
    GetData3=Series3.RunMethod("getData",Null)
   
    Series4.InitializeNewInstance("javafx.scene.chart.XYChart.Series",Null)
    Series4.RunMethod("setName",Array As Object("Canale" & 4))
    GetData4=Series4.RunMethod("getData",Null)
   
    PaneMainForm.RemoveAllNodes
    PaneMainForm.AddNode(LineChart,0,40,OscilloscopeForm.Width,OscilloscopeForm.Height-100)
   
    LCGetData=LineChart.RunMethod("getData",Null)
    LCGetData.RunMethod("addAll",Array As Object(Array As Object(Series1,Series2,Series3,Series4)))

    Return True
   
End Sub

Sub serie(i As Int,index As Int)
   
    Dim s As String = index
    Dim ss As Int
   
    Select i
   
    Case 1
        ss = l1.Get(index)
        AddData(GetData1,s,ss)
        GetData1=Series1.RunMethod("getData",Null)
    Case 2
        ss = l2.Get(index)
        AddData(GetData2,s,ss)
        GetData2=Series2.RunMethod("getData",Null)
    Case 3
        ss = l3.Get(index)
        AddData(GetData3,s,ss)
        GetData3=Series3.RunMethod("getData",Null)
    Case 4
        ss = l4.Get(index)
        AddData(GetData4,s,ss)
        GetData4=Series4.RunMethod("getData",Null)
    End Select
   
End Sub

Sub AddData(xGetData As JavaObject,index As String,Value As Int)
    Dim Data As JavaObject
    Data.InitializeNewInstance("javafx.scene.chart.XYChart.Data",Array As Object(index,Value))
    xGetData.RunMethod("add",Array As Object(Data))
End Sub
 
Top