B4J Library jGauges

CHAUVET

Member
Licensed User
Longtime User
Hi jmon,
Hi Erel,

Thank you for your explanation and example.

Thanks to you I understand the mechanism. But it is not very simple in the sense that we do not know what to look for.

What would be fantastic about the B4X tools is having a panel with all the properties of an object (as VB did).

I worked very long time on ATARI ST with GFA Basic, then even more time on Visual Basic. Currently I work in PHP.

When I discovered B4J I had an immense joy. This tool allowed me to continue using the BASIC language to create JAVA programs. An old language that allows to generate a modern code. In this, the idea of Erel is an extraordinary idea. Many small developers (like me) have stalled with VB.NET.

B4J is fantastic but if the syntax is easily understandable it is necessary to have solid knowledge in JAVA to be able to get out (search in java source code for use this in basic langugage). It is somehow nonsense. Indeed why continue in BASIC if I know the JAVA? Or if I have to learn the JAVA to do Basic? Strange not?

In my case (and I think I'm not the only one) I have a great pleasure and a facility to use the Basic language and I do not master in JAVA. Because of this I have a great frustration because I can use a simple tool but I can not go very far in my projects because it becomes limited if we do not control JAVA.

Erel, how to make B4J simpler for a "small devloper in BASIC"?

I think your project is a beautiful thing. But I think so too it lacks a link in your project.

You can propose and sell additional modules as was possible with VB (like .vbx in old VB) And open this to the community of B4J for a good JAVA encoder that knows B4J. These coders could free or not to offer new modules with all the properties available on a panel.

For each module (jGauge for example) there is a panel with all the properties to define the set : sizes, colors, position on form, etc...

What do you think ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
For each module (jGauge for example) there is a panel with all the properties to define the set : sizes, colors, position on form, etc...

What do you think ?
This is already the case with %99.9 of the libraries. You can use this tool to see the methods: https://www.b4x.com/android/forum/t...cumentation-b4x-object-browser.25682/#content
Also available online: https://www.b4x.com/b4j/documentation.html

In this library, there were so many native methods that I decided not to wrap them and therefore they require a bit more work.
 

jmon

Well-Known Member
Licensed User
Longtime User
How can I find the list of methods available in this library?
I found better:
https://github.com/HanSolo/Medusa/wiki

Also a wiki for the skins:
https://github.com/HanSolo/Medusa/wiki/Gauge Skins
 

CHAUVET

Member
Licensed User
Longtime User
Hi,
jmon you are the King !!!
big thanks

With your help here is the result :

B4X:
    Dim minValue, maxValue, Value, decimal As Double 'type is important
    Dim Title, Unit, Skin, subTitle As String
    Value = 75
    minValue = 0
    maxValue = 150
    Title = "Power"
    subTitle = "sub title"
    Unit = "Watt"
    Skin = "DASHBOARD"

    Dim jo As JavaObject = Gauge12


    jo.RunMethod("setSkinType", Array(Skin))
    jo.RunMethod("setMinValue", Array(minValue))
    jo.RunMethod("setMaxValue", Array(maxValue))
    jo.RunMethod("setValue", Array(Value))

    jo.RunMethod("setTitle", Array(Title))
    jo.RunMethod("setUnit", Array(Unit))
    jo.RunMethod("setSubTitle", Array(subTitle))
  
    jo.RunMethod("setForegroundBaseColor", Array(fx.Colors.RGB(82,82,82))) ' Color for title, subtitle, unit, value, tick label, zeroColor
    jo.RunMethod("setUnitColor", Array(fx.Colors.RGB(82,82,82)))
    jo.RunMethod("setTitleColor", Array(fx.Colors.RGB(82,82,82)))
    jo.RunMethod("setSubTitleColor", Array(fx.Colors.RGB(82,82,82)))


    jo.RunMethod("setValueColor", Array(fx.Colors.RGB(82,82,82)))
    jo.RunMethod("setBarBackgroundColor", Array(fx.Colors.RGB(255,64,64)))
    jo.RunMethod("setBarColor", Array(fx.Colors.RGB(125,125,125)))

    jo.RunMethod("setDecimals", Array(1))
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

receiving stackoverflow error when setting min/max value for Skin GAUGE.
A small test project attached with two gauges, one (gauge1) with skin DASHBOARD for which min/max value setting is working and the second (gauge2) with skin GAUGE.

The error log is rather big - here an extract:
B4X:
main._buttongauge2setminmax_action (java line: 104)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4j.example.main._buttongauge2setminmax_action(main.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA$2.run(BA.java:165)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.StackOverflowError
    at eu.hansolo.medusa.Gauge.getRange(Gauge.java:744)
    at eu.hansolo.medusa.Gauge.calcAutoScale(Gauge.java:4844)
    at eu.hansolo.medusa.skins.GaugeSkin.handleEvents(GaugeSkin.java:353)
...
 

Attachments

  • GaugesTest.zip
    2.7 KB · Views: 566

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks for the hint.
Found a next runtime error when the minValue > 99 (Note: when setting using the designer, then no issue with f.e. range 950 - 1100):
B4X:
main._buttongauge2setminmax_action (java line: 106)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at b4j.example.main._buttongauge2setminmax_action(main.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA$2.run(BA.java:165)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: Infinite or NaN
    at java.math.BigDecimal.<init>(Unknown Source)
    at java.math.BigDecimal.<init>(Unknown Source)
    at eu.hansolo.medusa.tools.Helper.drawRadialTickMarks(Helper.java:531)
    at eu.hansolo.medusa.skins.GaugeSkin.redraw(GaugeSkin.java:1055)
    at eu.hansolo.medusa.skins.GaugeSkin.handleEvents(GaugeSkin.java:369)
    at eu.hansolo.medusa.skins.GaugeSkin.lambda$4(GaugeSkin.java:301)
    at eu.hansolo.medusa.Gauge.fireUpdateEvent(Gauge.java:5177)
    at eu.hansolo.medusa.Gauge.setMinValue(Gauge.java:667)
    ... 19 more

when using
B4X:
jo.RunMethod("setAutoScale", Array(False))
jo.RunMethod("setMinValue", Array(minValue))
jo.RunMethod("setMaxValue", Array(maxValue))
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks again --- after various tryouts because the scale was either missing or only 3 ticks etc., this is working for values > 99:

In the designer set the min to 0 and the max to 100.
Then when app is running, change the scale like
B4X:
Dim minValue, maxValue As Double
minValue = 950
maxValue = 1100
'IMPORTANT = set autoscale to false, then max prior min value
jo.RunMethod("setAutoScale", Array(False))
jo.RunMethod("setMaxValue", Array(maxValue))
jo.RunMethod("setMinValue", Array(minValue))

BTW: this is the result:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
but receive errors.
You should post it.

1. The method name is "setTickMarkSections"

2. It expects a list of sections.

Untested code:
B4X:
Dim sections As List
sections.Initialize
sections.Add(CreateSection(1, 2))
jo.RunMethod("setTickMarkSections", Array(sections))


Sub CreateSection(Start As Double, Stop As Double) As Object
 Dim jo As JavaObject
 jo.InitializeNewInstance("eu.hansolo.medusa.Section", Array(Start, Stop))
Return jo
End Sub
 

maleche

Active Member
Licensed User
Longtime User
The inner scale worked!
however, the outer numbers still show 1,1,2,2,3,3. I'm looking for the method to change this as well.
see picture.
thank you for the insight!
Doyle
 

Attachments

  • DAQ picture.PNG
    131.3 KB · Views: 361
Cookies are required to use this site. You must accept them to continue using the site. Learn more…