Insubstantial / insubstantial

Swing look-and-feel library and assorted widgets
193 stars 58 forks source link

Doesn’t work under Java 9, 10 #154

Closed brunchboy closed 6 years ago

brunchboy commented 6 years ago

I realize there isn’t much hope of anyone being around to help fix this any more, but I am using the Substance Raven look and feel in my Beat Link Trigger application, and this is causing crashes when Swing tries to create components under Java 9 or Java 10, specifically a NullPointerException at line 759 of SubstanceColorUtilties.java. Here is more context in the stack trace:

SubstanceColorUtilities.java:  759  org.pushingpixels.substance.internal.utils.SubstanceColorUtilities/getDefaultBackgroundColor
SubstanceColorUtilities.java:  661  org.pushingpixels.substance.internal.utils.SubstanceColorUtilities/getBackgroundFillColor
     SubstancePanelUI.java:   74  org.pushingpixels.substance.internal.ui.SubstancePanelUI/__org__pushingpixels__substance__internal__ui__SubstancePanelUI__installDefaults
     SubstancePanelUI.java:   -1  org.pushingpixels.substance.internal.ui.SubstancePanelUI/installDefaults
         BasicPanelUI.java:   62  javax.swing.plaf.basic.BasicPanelUI/installUI
     SubstancePanelUI.java:   -1  org.pushingpixels.substance.internal.ui.SubstancePanelUI/__org__pushingpixels__substance__internal__ui__SubstancePanelUI__installUI
     SubstancePanelUI.java:   -1  org.pushingpixels.substance.internal.ui.SubstancePanelUI/installUI
           JComponent.java:  685  javax.swing.JComponent/setUI
               JPanel.java:  150  javax.swing.JPanel/setUI 
…

Since my free application is already a side project of a side project of another free, open-source project of mine, I would really rather not have to be the one who dives in to understand how to fix this, but on the other hand, my UI is designed completely around the dark backgrounds provided by this look and feel, so it will also be a bunch of work if I have to give it up. Is there anyone who can help?

enwired commented 6 years ago

Have you tried using the official Substance LAF? The original developer is maintaining it again. If you haven't customized the LAF, you can probably just drop-in the newer jar files. If you have customized the LAF, you may have additional issues.

I'm not sure that even the official Substance supports Java 9. It looks like he is starting a newer project called "Radiance" for that.

brunchboy commented 6 years ago

No, I wasn’t even aware there was an “official Substance LAF”; I found this artifact when using seesaw to add a Swing UI to my Clojure project. Where can I find it? Thanks!

brunchboy commented 6 years ago

Ah, I think I have found it. I guess the reason I didn’t use it is that it doesn’t seem to offer artifacts on Maven Central, which is a vastly easier way to embed dependencies into a Clojure project that you are trying to distribute as an executable überjar. Hmm… It looks like Radiance will offer Maven releases, so maybe I should just wait for that. Thanks!

It’s a bit frustrating to have something like this prevent my users from upgrading to a current Java release, but at least there is hope. Perhaps I will use this as motivation to switch from Swing to an embedded web server for my UI, which would also let people run Beat Link Trigger on small Raspberry Pi machines in the DJ booth, and still have control of it over the network from a laptop in the lighting booth. But that would be so much work…

brunchboy commented 6 years ago

All right, that looks very promising. I will migrate to Radiance as soon as they put out their Maven artifacts. I’ve commented on the appropriate issue over there, so I shall close this one. Thanks again, @enwired !

enwired commented 6 years ago

The author of the Substance libraries has long resisted putting his artifacts on Maven. I wish he would do so. Perhaps he has changed his mind for Radiance, but I would be very surprised.

Radiance is new. I saw it for the first time yesterday. I am assuming it will replace Substance, but I do not know that for a fact.

On Mon, Jun 18, 2018 at 4:29 PM, James Elliott notifications@github.com wrote:

All right, that looks very promising. I will migrate to Radiance as soon as they put out their Maven artifacts. I’ve commented on the appropriate issue over there, so I shall close this one. Thanks again, @enwired https://github.com/enwired !

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Insubstantial/insubstantial/issues/154#issuecomment-398226931, or mute the thread https://github.com/notifications/unsubscribe-auth/AB77Ag84XB1zWFW9G2aCsR-DXcmZ99cTks5t-Df1gaJpZM4Usk3G .

kirill-grouchnikov commented 6 years ago

Radiance will provide Maven artifacts for all the libraries with its first release (fall 2018)

enwired commented 6 years ago

Yay! Thanks Kirill!

Is Radiance replacing Substance?

On Tue, Jun 19, 2018 at 11:07 AM, Kirill Grouchnikov < notifications@github.com> wrote:

Radiance will provide Maven artifacts for all the libraries with its first release (fall 2018)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Insubstantial/insubstantial/issues/154#issuecomment-398492573, or mute the thread https://github.com/notifications/unsubscribe-auth/AB77Atj1C051L6MqoCnzXCuA79d3weaDks5t-T3GgaJpZM4Usk3G .

kirill-grouchnikov commented 6 years ago

http://www.pushing-pixels.org/2018/05/23/hello-radiance.html

enwired commented 6 years ago

Kirill,

Thanks for that link. I had only seen the git-hub page for Radiance and didn't find any project description there, so I was just making guesses about what it was about.

On Tue, Jun 19, 2018 at 11:09 AM, Kirill Grouchnikov < notifications@github.com> wrote:

http://www.pushing-pixels.org/2018/05/23/hello-radiance.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Insubstantial/insubstantial/issues/154#issuecomment-398493230, or mute the thread https://github.com/notifications/unsubscribe-auth/AB77Aq1Thh368sZldc7gEaXJ2uQlEaH8ks5t-T5HgaJpZM4Usk3G .

kirill-grouchnikov commented 6 years ago

I'm in the middle of moving all documentation from the old projects to be under Radiance. https://github.com/kirill-grouchnikov/radiance/issues/21 is the tracker.

brunchboy commented 6 years ago

Yes, Radiance looks very promising, thanks for weighing in @kirill-grouchnikov since I was apparently not clear enough in my happiness about the forthcoming Maven artifacts.

Do any of the Insubstantial folks in this discussion perhaps know the answer to this question? The Raven look-and-feel in Insubstantial has some very interesting textures that it draws in the background of panels which make them look nice (and darker than you would otherwise expect given the background color you set). For example, from my Triggers window (zoom in a few times to really see the texture), or look at the enlargement of one of my Trigger state indicators. The newer builds of Substance don’t seem to have these textures. Were they something that Insubstantial added? Or something Substance’s Raven used to have but went away?

The font is also very different, but again I don’t know if that is a Substance/Insubstantial change, or a Java 8/10 change… but hopefully that is something that is easy enough to configure for a Look and Feel.

kirill-grouchnikov commented 6 years ago

The texture came from https://github.com/Insubstantial/insubstantial/blob/master/substance/src/main/java/org/pushingpixels/substance/api/watermark/SubstanceCrosshatchWatermark.java which was set as the watermark on the Raven skin.

This decision perhaps belongs under Radiance, but the short story is that I have removed watermarks from all core Substance skins. Those can be done at the application level by creating a complete new skin or extending one of the Substance skins and adding a custom watermark there.

kirill-grouchnikov commented 6 years ago

As for the fonts, there have been a lot of changes to bring in platform-aware font selection and rendering in the last couple of releases of Substance. If you wish to use a custom font in your app, SubstanceCortex.GlobalScope.setFontPolicy is the API for that.

brunchboy commented 6 years ago

Excellent, thanks for the pointers! I will perhaps explore restoring that watermark, it definitely looked good in the context of a light show synchronization tool. And I will explore setFontPolicy to find a way to switch to a thicker font, perhaps just going back to the default system Look and Feel font.

brunchboy commented 6 years ago

Whoops, looks like you’ve removed that entire Java class, eh? So to turn the watermark back on, I’ll need to port it to Clojure. Hmm, that’ll probably only take me about an hour of playing with Java interop, worth a try. 🚧 But not tonight! Once I’ve done that, is all I need to do in the constructor of my RavenSkin subclass, replicate these two lines?

this.watermarkScheme = activeScheme.shade(0.4);
this.watermark = new SubstanceCrosshatchWatermark();

And then how would I assign my new skin a name for use by UIManager/setLookAndFeel?

kirill-grouchnikov commented 6 years ago

I'll add the watermarks back in https://github.com/kirill-grouchnikov/radiance/issues/26

For using a custom skin, all you need to do is call SubstanceCortex.GlobalScope.setSkin. If you want to wrap it in a LookAndFeel class, then just pass the skin instance to the look-and-feel constructor like https://github.com/kirill-grouchnikov/radiance/blob/master/substance/src/main/java/org/pushingpixels/substance/api/skin/SubstanceBusinessLookAndFeel.java, and you can pass that to UIManager if that's your preferred way.

brunchboy commented 6 years ago

Ah, neat, I didn’t realize that setSkin() would ensure that Substance was the look-and-feel the way it does, I just skimmed that bit of the source code now that you pointed me at it, and I’ll use that approach. Thanks!

As far as putting the texture back in to the extras, that might be nice, but I have been able to recreate it in Clojure. If you are curious what a Clojure port of that Java class looks like, the source is here. Java Interop doesn’t make for the prettiest Clojure code, but it is still fairly compact and readable. The first half or so is setting up an atom to track the rendered image, and some private functions used to render it. The Java object that implements the SubstanceWaterMark interface is instantiated starting at line 52, and exposed with the public name crosshatch.

One difference I am seeing from the old Substance, however, is that the watermark is being drawn twice as large (which I suspect is another artifact of high-DPI displays), any thoughts about that?

kirill-grouchnikov commented 6 years ago

https://github.com/kirill-grouchnikov/radiance/issues/27