-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the use of Weblaf from the UI #789
Comments
Initial build without com.alee creates 4K error 😂 Strategy will be to convert specific UI windows one at a time before dropping Weblaf from the pom. |
Yes, that isn't unexpected, just searching the code gives out a similar large number of usages. :D Maybe you can start by concentrating all common boilerplate code into a common "Corporate Design" class, so that the dependencies on WebLAF are first concentrated there and we can eventually refactor this place. I remember seeing quite a lot of similar code around that just adds the WebLAF style to components. We could maybe replace this by introducting a "Mars-Sim style", which fills the role of WebLAF, but allows us to quickly change the look and feel part of the simulation later. |
We will start from the outside and work inwards, i.e. the less integrated windows moving towards the MainWindow last. |
I've converted the Crew Editor class as a trail. Pretty straight forward. This dialog had lots of controls so it was a good test. Other windows will be easier as they are read only. |
Changes: - Create IconManager to hold and load the various SVG icons replace alee version Part of #789
Changes: - Person window & Tabs - TabPanel provides an getIcon method to find icons. Part of #789
Thoughts on the target release for dropping weblaf and potentially moving to Java 17? I'm thinking 3.5.0. I'm slowly dropping weblaf from the UI components. |
I don't like thinking too much in releases there, if its actually maintenance work. we should put it into the next minor version for sure, by semantic versioning, but I wouldn't mind if it takes until 3.6 to be finished. Can you make a feature request for the icon set file? I think the idea makes sense, what about just making it a Java resource file, a plain key value format should be good enough there. Also, does it make sense to support both PNG and SVG? |
Yes I was thinking a Java resource file that is preloaded in the Icon manager. Part of the change would be to have a single one supporting SVG & PNG. Too much effort to change the existing SVG to PNG. Also needs to support default sizing, but I've an idea about that. |
Changes: - Create IconManager to hold and load the various SVG icons replace alee version Part of #789
Changes: - Person window & Tabs - TabPanel provides an getIcon method to find icons. Part of #789
01.06.2023 - fix: correct NPE in MapTask in MapPanel when calling map.drawMap() Initialize map instance as surf map in constructor - new: add QUARTER_RANGE, HALF_RANGE, and MAX_RANGE in Settlement - change: rework missionRange in Settlement Related to #788 (comment)
In addition convert time window and remove unused classes. Part of #789
MonitorWindow now selects 1st Settlement Correct empty lanel in Scientific Tool Part of #789
@mokun I have been slowly converting the UI code base and have completed about 75%. What I have noticed along the way is there is a lot of Font management going on with many Font instantiations going on. Also there seems to be a mixture of Fonts with some inconsistency. |
What I want to do is drop the use of explicit Fonts altogether and use HTML styling to "adjust" rendering where needed. For example on the Panel titles we would do "Panel Title". This means that we can use any font that is specified as part of the Look And Feel without overriding it. |
I like the idea. Could it be implemented maybe even in a way, that we give the same kind of elements the same kind of styling throughout the UI? |
Yes I think so because there is mixture of styles. My thoughts are to push everything back to defaults and then customised only what is needed |
My smartphone displayed the contents first as plain UTF-8, so yeah, I understood it. :D |
@mokun Converting the Commander Tool today and it seems to have a few problems and unimplemented Tabs already. I'm not going to try and fix the issues I find. |
01.14.2023 - fix: correct conversionFuel2DriveEnergy in Vehicle - fix: correct energyUsed calculation in calculateFuelUsed() in OperateVehicle - fix: correct instantaneous fuel consumption - style: use textfields in MainDetailPanel #795
Yes. It's been a while since I updated the Commander Dashboard. I may have done once or twice just to keep it from breaking. At first, I thought it was a great idea to implement many new and latest changes in the Dashboard's tabs in But the That's said, we need to redefine what we want to do with We have said that we come up with a tab for each division as a way of adding more interactivity to mars-sim by giving players more options to toggle in each division. |
Changes: - CommanderWindow no longer uses weblaf - CommanderWindow now uses FactoryMetaTask Part of #789
It's scalable, you know |
That applies to most vector fonts today, including OTF and TTF. Also, it makes the UI design pretty chaotic to use too many fonts. Its like an early 1990s homepage. |
We should be able to use standard fonts from the UIManager I think. |
Sorry. my mistake. I meant to say SVG icons, not fonts. |
Ah, that makes way more sense now. :) Well, we already use SVG images for the settlement map, can't we use this as starting point to create a custom button class which renders a SVG image? |
Yea. We may be able to come up with that with what's shown here Or try something like this. In case of weblaf, it uses SVG Salamander, as explained in here. May we can replicate what's done in weblaf using SVG Salamander since it looks like it's a more direct and faster approach. |
Batik uses a lot of separate libraries and is very bloated and is something like ~8 (or 3.2 compressed) MB in size. I bet Batik also uses a lot of other dependencies. In comparison, currently, our mars-sim binary jar stands at about ~45 MB (compressed). Can we switch to using SVG Salamander (< 400 KB uncompressed) for displaying the image of each building as well as svg fonts ? |
That sounds good but let's focus on dropping weblaf first. Then as part of #791 we can consolidate how we manage icons. Control that in our own iconmanager class to allow us to be specific for vehicles, settlements etc. Then icon and image loading will be one pla e and hence easier to replace. |
But we currently reply on weblaf's own icon manager for rendering svg-based icons. So, in order to drop weblaf, we may need to figure out a replacement for reading svg icons at the same time. |
I've already started changing the SVG loading |
Changes: - Remove Weblaf from the popupunitmenu class - Reworked PopupUnitMenu to only build items needed. - Removed basic weblaf compoennts from the ToolToolBar - Move openBrowser method to MainWidnow to provide resuse Part of #789
Changes: - Create a new SwingHelper class to hold comman reused logic - MarsCalendar popup & toolbar button changed to use a JDialog create byt SwingHelper - SwingHelper refactor the popup logic in PopUpUnitMenu to supprot any floating popup window. - OpenBrowser method moved from MainWindow to the SwingHelper class - Remove some unused classes Part of #789
Changes: - Remove weblaf from NavigationWindow - Use ActionCommand for options menu in NavigationWindow - Remove weblaf from SettlementTransparentPanel - Rework image icons in SettlementTransparentPanel Part of #789
The weblaf UIManager is interferring with the standard JToolbar by adding an extra Margin & different layout. This means the new toolbar is slightly heighter than the old one but will revisit it once weblaf is totally removed. Changes: - ToolToolBar is using the basic JToolbar class now - ToolToolBar uses a single action listener emthod and the ActionCommand pattern to execute the correct action. - Toolbar now control s the various date labels. - Date fields are now basic JLabels and not text fields. - Remvoed all the displaying of date/time logic from MainWindow Part of #789
@mokun I worked on this last night and the only bit of WebLaf left is the pause overlay in the MainWindow. I don't know how to replace this at the moment; I think a JLayer could be used but not sure. |
Yes we may as well drop it. We'll find another way to pause |
Ok. To be clear, the pause logic is working, I've replaced the WebSwitch class. The pause overlay I haven't managed to migrate yet, I think the answer is to use a JLayer but I don't understand |
So what do you replace with ? |
Shall we look for a more lightweight LAF library that's Java 17 compatible and provide more decent UI elements than what Swing provides ? |
Remove the weblaf components from the MainWindow status bar. Changes: - Create a new JMemoryMeter component based on JProgressBar - Replace Webmemorybar with the new JMemoryMeter component - Replace WebSwitch with a JToggleButton for the pause button - PauseButton uses a ItemListner to flip the image when it is activated - OverlayCheckBox is enabled all times to accomodate the new pause logic - Displaying of the overlay is covered by a new method displayOverlay - Remove use of weblaf IconManager from MSPIconManager - Remove unused static finals and methods Part of #789
Just pushed a commit |
I don't mind but the question is do we need anything beyond basic Swing? You wanted to look at doing a different UI client but I see JavaFX is no longer supported within the JavaSE. |
I've just done the least part to remove the weblaf including the look and feel raking it back to vanilla Swing. It works but look rough, also it highlights where they is specific customization in the code. It looks like we have some extra styling on the monitor tables. I think we should carry on with this approach and get back to basic Swing. Then use a look and feel class like FlatLAF. https://www.formdev.com/flatlaf/ Flatlaf can help us with fonts as well, https://www.formdev.com/flatlaf/typography/#set_font. |
And we may use Radiance for theming, adding better image, font and text rendering. It also supports SVG Transcoder. It supports Java 17. |
Ok, do we want to start using custom components again? But I think the idea of theming is the right direction. We need to strip out all the custom Font and Color assignments and rely on the UIManager stylingmaybe leave SettlementMapPanel alone. |
Yeah, it's finished. 🥳 |
We actually have been using one of the Radiance's component called
The steelseries gauges requires it internally, I think. We used to use the source code of the steelseries. Now we have already switched to its maven artifact. We may or may not need Trident explicitly anymore. Shall we start using Radiance ? |
Describe the bug
The use of Weblaf is providing problems in Java 17 and beyond, #788. The advantage of moving to Java 17 has been discussed in #437.
There is a potential workaround by changing the JVM arguments but it should be possible to run directly from the JAR file.
To Reproduce (Please provide steps)
Run the swing JAR file with no arguments on 3.4.1. The ui fails to render.
Expected and unexpected behavior
Replace the use of Weblaf classes with the vanilla Swing equivalent. This will be a change to a lot of ui files.
Specifications (please complete the following information):
The text was updated successfully, but these errors were encountered: