I am trying to translate KitCarlson's chart recorder to B4J. Many objects have the same name as in B4A. But some not:
B4X:
'B4A
Dim btnStart As Button
Dim pnlChart As Panel
Dim cvsGraph As Canvas
Dim rectGrid As Rect
Dim SrcRec, DestRec, PltRec As Rect
....
rectGrid.Initialize(GridX0, GridY0, GridX1, GridY1) ' initialize rectangle
Substituting Panel by Pane might be obvious (have to see the final result...) but what to do for Rect?
Also,
how to translate rectGrid.Initialize(...)?
Thanks for help. If finally successful, I will post the B4J code
Thanks BPak, that works, but translating that chart recorder (B4A) to B4J turns out to be beyond my capabilities. The laguages though similar differ in too many details. I gave up and programmed the chart recorder from scratch using the basics. It's gone little slow since I redraw all the points in the chart each time a new value arrives. So I will try to convert the more elegant scrolling method used in the KitCarlson's example:
B4X:
cvsGraph.DrawBitmap(cvsGraph.Bitmap,SrcRec,DestRec) 'B4A: copy scroll grid and plots
Unfortunately, in B4J this won't work. Is there any suggestion how to convert?
Thanks Erel,
Yes, that works, but once one problem is solved others are coming up....
In B4A, transparent color can be used to erase a colored point.
In B4J, I got the impression that it really means transparency. Right or wrong?
Sub grid
For i=-1000 To 1000 Step 200
y1 = Round(i * c1 + c2)
cvs.DrawLine(0,y1,cvs.Width,y1, fx.Colors.red,1)
Next
image1=cvs.Snapshot
cvs.DrawImage2(image1,0,0,cvs.Width,cvs.Height,0,0,cvs.Width,cvs.Height)
End Sub
This code works without error. However, using the line cvs.Drawimage2(...) in another sub I get the error "object should first be initialized (image)". But Initialize then wants to load an image from file what might not be needed.
I had used Dim, Public, Private as image1, but no difference.
Why can't I use image1=cvs.Snapshot in a different sub?
anywhere in the program without getting that error. The error mentioned above was not a compiler error but happend when the program was started -in debug and release modes.
Thank you for your help.