Klaus Rheinwald asked me for an artificial horizon component that he needed and so i started adding one to the library. Fortunately i created one last year on my trip to JFokus and got some insider information of Mikael Grev who is an active fighter pilot and a coder (you might know one of his projects called MiGLayout which is a really nice Java Layout Manager).
So the result of this work looks like this...
Horizon |
The Horizon component is located in the extras package of the SteelSeries and you could customize it by defining the color of the sky, the background and the indicator (setPointerColor()). You could define pitch and roll and the horizon will hopefully display the right view. There's only one little problem left which occurs if you have a pitch larger than 90°. A real artificial horizon will flip over by rotating around 180° but i was not able to implement it in a way that looks good enough. I will spend some time to this problem later on, so stay tuned...
Klaus Rheinwald also pointed me to the Compass component that's already in the SteelSeries library and he mentioned that on an airplane the compass looks different in the way that the "needle" is fixed and the scale is rotating...
Ok, that was a piece of cake because in principle this is the same behaviour as the RadialCounter just with another pointer. Long story short, here is the AirCompass component...
AirCompass |
The design was taken from a real aviation instrument and the whole creation time for this component was only around 2 hours. You could set the value in the range of 0 to 360 degrees and the scale will rotate around the airplane in the center. The color could be changed by the pointerColor property of the component.
In the last release i forgot to mention that there was also a new FrameDesign and BackgroundColor that one could choose for the gauges and because i added another FrameDesign i will present both of it in this post...
Left: FrameDesign.GOLD, BackgroundColor.BROWN, PointerType.TYPE7 Right: FrameDesign.CHROME, KnobType.BIG_CHROME_KNOB, PointerType.TYPE7 |
On the left gauge you see the FrameDesign.GOLD with the new BackgroundColor.BROWN and on the right gauge you see the new FrameDesign.CHROME. In addition to the new FrameDesign you could see also another new PointerType.TYPE7 in both gauges and a new KnobType.BIG_CHROME_KNOB (on the right gauge).
Another user of the SteelSeries library asked me if it would be possible to get a square frame on the Clock component too...and of course this is possible...here we go...
Left: FrameType.ROUND Right: FrameType.SQUARE |
Another modification was the reduction of the memory footprint of the components. I mentioned this in my last post already, so it's not needed to repeat myself here. Nearly all components now make use of this combined layer technique.
The test application is now also updated to the 3.8 release of the library and is still available here as a webstart app.
At least i fixed a memory leak that occurred when using the setValueAnimated() method. After i made some long term tests over the last days the problem seems to be fixed now.
Like i said before, just let me know if you need some special component and i'll try to implement it if i'll find the time...
That's it for today, enjoy the upcoming weekend and keep coding...
Good work, as always!
ReplyDeleteWill be nice to see your library on Android platform (maybe for iOS too). I mean, written on pure Java as a custom Views library. Although, you've been selected html5 for these purposes, sometimes it's not appropriate or awful to use html code in your Android app (drastically slow and believe this is a bad practice). I understand, you're doing this in your spare time, though, maybe someone will port your library to Android and iOS?! How are you filling about that? Is it Okay?
Whatever, great work!
Hi Alexander,
ReplyDeleteThanx for the comment. I started to port one of the gauges to Android last year but switched to html5 quickly because i think this will be the only real x-platform environment in the future. I can't say that the speed is a problem on mobile devices like Android phones or iPhones. This demo here: http://idisk.mac.com/han.solo-Public/Canvas/SteelSeries/Radial.html runs 6 gauges at the same time and it works on my HTC desire as well as on an iPhone 3GS...in the browser. But don't get me wrong, this are only my thoughts and i might be wrong, so feel free to fork it and port it to Android, i would love to see it there too... :-)
Cheers, Gerrit
I cannot see 3.8.0 in maven repos. Is there any problem?
ReplyDeleteHere is the link to the Maven repo: https://oss.sonatype.org/index.html#nexus-search;quick~steelseries
ReplyDeleteThanks, my mistake. I supposed 3.8.0 but it is 3.8.
ReplyDeleteHello,
ReplyDeleteI have read your previous article about memory optimization but now initialization of our components is four times slower than with previous version 3.7.2. (3.7.2 - ~2.3sec, 3.8 - ~9.9 sec). In our SW we used a lot of your components (60x LCD displays,12x Linear Bars). Is there any workaround/fix for this performance regression?
jakub
Hi, hmm...9 sec is a lot...I guess you use the same framedesign, backgroundcolor for all gauges right? So i will implement some caching which should help you here. I will post the update asap, so please stay tuned and thanx for the feedback...
ReplyDeleteYou are right, all components have the same background. Only when some alarms are generated we change background for appropriate components to red color.
ReplyDeletebtw is there a way how to change font color for LCD component?
Here we go...i've added caching to the frame, background and foreground image creation methods. The current version 3.8.1 could be downloaded via the link on this page or you could download the sources from the repo.
ReplyDeletePlease let me know (e-mail) if this was of help for you...
Cheers, Gerrit
I sent you email, did you receive it?
ReplyDeletenope...no mail right now...
ReplyDeleteHello! Sorry if I disturb, but I have a (small, I hope!) problem.
ReplyDeleteI created a new java project in Eclipse, to test the 'Horizon' component, but I obtain the following error:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: eu.hansolo.steelseries.extras.Horizon.create_Image(II)Ljava/awt/image/BufferedImage;
I never had any problems with older SteelSeries version. I simply downloaded the SteelSeries-3.8.1.jar file, am I missing anything? Have you got any hints about this problem?
Thank you very much in advance!
Marco
Hi Marco,
ReplyDeletehere is some code as an example...
public class HorizonTest extends javax.swing.JFrame
{
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new java.lang.Runnable()
{
@Override
public void run()
{
HorizonTest app = new HorizonTest();
app.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
app.setSize(200, 222);
app.add(new eu.hansolo.steelseries.extras.Horizon());
app.setLocationRelativeTo(null);
app.setVisible(true);
}
});
}
}
You just have to keep in mind that you add the steelseries and the trident jar file to your project...
Hope that was of help for you, otherwise drop me a mail.
Cheers,
Gerrit
hi Gerrit when i copy above code i got this error may i know why Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: eu.hansolo.steelseries.extras.Horizon.getInnerBounds()Ljava/awt/Rectangle;
Deleteat eu.hansolo.steelseries.extras.Horizon.(Horizon.java:41)
at HorizonTest$1.run(HorizonTest.java:13)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Hello again Gerrit!
ReplyDeleteFirst, thank you for the very quick reply!
Unfortunately, even trying your piece of code, I'm still getting exactly the same error (I'm already including both SteelSeries and Trident jar files).
I really have no clues about this problem :(
Tell me if something comes to your mind.
Thanks again!
Marco
Hello Han.Solo!
ReplyDeleteThank you for so useful, excellent components! They look so natural and work great!
However I need some additional functionality for my other project.
1. Logarithmic scales. all linear and radial gauges should have logarithmic scales, to be able show small and big values.
2. "Static" Clock. Clock does not go itself, rather allows to set the time value an shows it (just like other gauges).
I can do all myself, I've downloaded the code from svn. However if you think, you wish to do it I'll live it to you. But I need it fast, so I'll start.
Another question, if I do it, because the logarithmic scale should override methods of the abstract layer, I will have 2 choices:
1. - to create new classes extending AbstractLinear and others.
2. - to add new functionality/members to existing Abstract* classes, without changing existing members.
What would you recommend?
Hi MarkMal,
ReplyDeletebelieve it or not but logarithmic scaling is on my list already. Unfortunately i did not find the time to implement it right now, because i first had to edit the tickmark creation method which i did already. So i will add the functionality, that's for sure but i can't tell you when this will happen. The static
clock won't be a big deal and could be implemented in the upcoming 3.9 release of the lib. If you need a quick solution you should try it yourself, otherwise you'll have to wait until i'll find the time to implement it. You could also send me your modifications and i'll implement them if they won't break existing functionality.
Thanx for your request,
Cheers, Gerrit
You don't happen to have a barometer, do you ? :-)
ReplyDeleteHey Jan,
DeleteUnfortunately not...
Cheers, Gerrit
Gerrit
ReplyDeleteFirst, Thanks for an amazing set of libraries that really take the pain out of GUI work. The aviation gauges lean on old Timeline and Spline features and I think porting them to modern features is beyond me, at this time. Is there any chane you will port them to either the Enzo or Gauges libraries ?
If so, great and if not, thanks for all the other great work...
Regards DAvid
Hi David,
DeleteWell if you can send me your exact requirements I might add them to Medusa as new skins...