B4J Library [B4X] [XUI] xGauges and xGaugesRect Classes and Libraries

klaus

Expert
Licensed User
Longtime User
Here is version 0.9 of a new class xGaugesRect.
Instead of adding the rectangular gauges to the current circular ones I made a new class.
It is easier for users because of the new specific properties which would overcrowd the current class.
For the moment, it works only with B4J and B4A, I have problems with B4i and BitmapCreator.

B4J B4A

I would be pleased to have some beta testers.

Attached the class module and a demo project.
 

Attachments

  • xGaugesRectV0_9.zip
    13.2 KB · Views: 438
  • xGaugesRect.bas
    36.5 KB · Views: 450

Diceman

Active Member
Licensed User
Klaus, the gauges look really good. The silver gradient makes it look real.
Suggestions: It would be nice to be able to have NeedleShadowColor & CursorShadowColor (or at least some sort of outline) so it gives some depth to these 2 important indicators. This will give the needle and cursor some relief from the background so they appear to be separate from the background as if floating above the background.

Problem. I haven't found anything wrong with your code, but the sample B4J form is acting kind of weird (release mode and debug mode). I loaded xGuagesRect.B4j into B4J v8.50 and ran it. A blank form appeared with no controls on it. No errors were reported. I ran the designer and saw the 3 xGaugesRect views. I resaved the form and reran it. Same thing; blank form appears. I went back into Designer and moved the gauges around and resaved it, thinking it would update the form. When I reran the sample app it still displayed a blank form. I solved the problem by going back into the Designer and dropping a label somewhere on the form. Recompiling it and running it showed the gauges working just fine. It appears to me that a regular view has to be on the form otherwise B4J won't display the gauges at all. I went back into Designer and deleted the Label view and when I ran the app the form was blank again. Adding the Label back on the form got the form to display the gauges again. I told you it was weird.

In B4A you have Layout.bal in the Files manager and its not needed. B4A complains when the app is loaded that Layout.bal is missing. I removed Layout.bal in the Files Manager and the app ran just fine. No problem like I had with B4J. Looks good in Android.

That's it from me, at least for now. The gauges look really professional and will save a lot of screen space.
Rect gauges are slim and trim (conserves space). If you have more than 1 round gauge they are fat and need a lot of screen space to display properly.
Once you've gone Rect, you'll never go back (to Round).
 

klaus

Expert
Licensed User
Longtime User
Your blank screen sounds very strange.
I develop with B4J version 8.50 like you.
I added shadows, but not yet convinced.
Can you please check the attached version, I post only the B4J demo program.
 

Attachments

  • xGaugesRect0_91.zip
    10.3 KB · Views: 420
Last edited:

Diceman

Active Member
Licensed User
Your blank screen sounds very strange.
I develop with B4J version 8.50 like you.
I added shadows, but not yet convinced.
Can you please check the attached version, I post only the B4J demo program.

Klaus,

I tried your example and the shadows do appear, but like you implied they look flat without any dimension to them.
I looked around for a solution and found JordiCP's suggestion #13 for creating shadows at this link Neumorphism UI - how would you do this

Would this work?
 

rodmcm

Active Member
Licensed User
Is it possible to redraw a guage with a change of Max and Min value in code
I would like to use guage.click to change the range.. An option is of course to have a another hidden quage appear I suppose
 

MikeCLX

Member
Licensed User
Longtime User
Great work
is it possible to have a second mid range color? Like ScaleMidLimitColor2 etc?
I have a value that should be in the middle, if it goes low or high then it should be in an orange warning zone either way, if it goes further then it should be red either way.
i.e.
0 to 20 =red
20 to 40 = orange
40 to 60 = normal no color
60 to 80 = orange
80 to 100 = red

another idea although not so important for me is a gradient color so in the above case the further from the set point it is outside the normal zone the redder the colour becomes I.e. 60 = orange 100 = red, gradient in between 60 and 100 .
this could be done with startcolor and endcolor properties on the limits

thanks for sharing these great guages
 

MikeCLX

Member
Licensed User
Longtime User
Thanks Klaus, I ended up implementing the second ScaleMidLimit before i saw your message, I also made a few other changes to the Lib to allow it to take decimal numbers in the Min and Max and added a value, although i have not tested it on the other variants.
I can share my changes if you think they are worth adding to the base Lib

 

klaus

Expert
Licensed User
Longtime User
another idea although not so important for me is a gradient color
Is this what you expect to see ?



The four limit zones can be set with mono or gradient colors.
There are three colors in the left gauge: green > yellow > red.
These can be set with one of the four limit zones: LowLimit, HighLimit, MidLimit or MidLimit2.
In the right gauge the four limit zones are set:
LowLimit: 0 - 30 green mono
MidLimit: 30 - 60 green > yellow gradient
MidLimit2: 140 - 170 yellow > red gradient
HighLimit: 170 - 200 red mono

The gradient colors must be set in the code:
B4X:
xGauge4.ScaleMidLimitColors2 = Array As Int(xui.Color_Green, xui.Color_Yellow, xui.Color_Red)
This allows to set more than 2 colors.

Attached the class for testing.
It is still a work in progress.
 

Attachments

  • xGauges.bas
    39.4 KB · Views: 295
Cookies are required to use this site. You must accept them to continue using the site. Learn more…