Skip to content

Commit acbfc73

Browse files
committed
Theme and Java 1.8 support
1 parent e25aac7 commit acbfc73

File tree

4 files changed

+75
-28
lines changed

4 files changed

+75
-28
lines changed

install4j/fc-spacemap-installer.install4j

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ return console.askYesNo(message, true);
476476
<unixInstaller name="Unix Installer" id="36" />
477477
<linuxDeb name="Linux Deb Archive" id="37" />
478478
<windowsArchive name="Windows Archive" id="38" />
479-
<windows name="Windows 32bit" id="39" jreBitType="32" />
479+
<windows name="Windows 32bit" id="39" jreBitType="32">
480+
<jreBundle jdkProviderId="Zulu" release="8/8u442" overrideJdkRelease="true" />
481+
</windows>
480482
<linuxRPM name="Linux RPM" id="41" />
481483
</mediaSets>
482484
</install4j>

pom.xml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<properties>
3333
<maven.compiler.source>21</maven.compiler.source>
34-
<maven.compiler.target>21</maven.compiler.target>
34+
<maven.compiler.target>1.8</maven.compiler.target>
3535
<java.home>C:\Program Files\Zulu\zulu-21</java.home>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3737
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -59,12 +59,47 @@
5959
<version>3.11.0</version>
6060
<configuration>
6161
<source>21</source>
62-
<target>21</target>
62+
<target>1.8</target>
6363
<fork>true</fork>
6464
<encoding>UTF-8</encoding>
65-
<executable>C:\Program Files\Zulu\zulu-21\bin\javac.exe</executable>
65+
<executable>${java.home}/bin/javac.exe</executable>
66+
<release>8</release>
6667
</configuration>
6768
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-jar-plugin</artifactId>
72+
<version>3.3.0</version>
73+
<configuration>
74+
<archive>
75+
<manifest>
76+
<addClasspath>true</addClasspath>
77+
<classpathPrefix>lib/</classpathPrefix>
78+
<mainClass>au.com.intermine.spacemap.SpaceMap</mainClass>
79+
</manifest>
80+
</archive>
81+
</configuration>
82+
</plugin>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-dependency-plugin</artifactId>
86+
<version>3.6.1</version>
87+
<executions>
88+
<execution>
89+
<id>copy-dependencies</id>
90+
<phase>prepare-package</phase>
91+
<goals>
92+
<goal>copy-dependencies</goal>
93+
</goals>
94+
<configuration>
95+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
96+
<overWriteReleases>false</overWriteReleases>
97+
<overWriteSnapshots>false</overWriteSnapshots>
98+
<overWriteIfNewer>true</overWriteIfNewer>
99+
</configuration>
100+
</execution>
101+
</executions>
102+
</plugin>
68103
<plugin>
69104
<artifactId>maven-assembly-plugin</artifactId>
70105
<version>2.4</version>
@@ -134,13 +169,13 @@
134169
<dependency>
135170
<groupId>com.formdev</groupId>
136171
<artifactId>flatlaf</artifactId>
137-
<version>3.3</version>
172+
<version>1.6.5</version>
138173
</dependency>
139174

140175
<dependency>
141176
<groupId>com.formdev</groupId>
142177
<artifactId>flatlaf-intellij-themes</artifactId>
143-
<version>3.3</version>
178+
<version>1.6.5</version>
144179
</dependency>
145180

146181
<dependency>
@@ -152,7 +187,7 @@
152187
<dependency>
153188
<groupId>org.mozilla</groupId>
154189
<artifactId>rhino</artifactId>
155-
<version>1.8.0</version>
190+
<version>1.7.14</version>
156191
</dependency>
157192

158193
</dependencies>

src/main/java/au/com/intermine/spacemap/SpaceMap.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
import javax.swing.UnsupportedLookAndFeelException;
4848
import com.formdev.flatlaf.FlatLaf;
4949
import com.formdev.flatlaf.FlatLightLaf;
50-
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
51-
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme;
52-
import com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme;
50+
import com.formdev.flatlaf.FlatDarkLaf;
51+
import com.formdev.flatlaf.FlatIntelliJLaf;
52+
import com.formdev.flatlaf.FlatDarculaLaf;
5353

5454
import au.com.intermine.spacemap.action.HideNodeAction;
5555
import au.com.intermine.spacemap.model.TreeNode;
@@ -104,23 +104,17 @@ public static void main(String[] args) {
104104
boolean isDarkTheme = isSystemDarkTheme();
105105
if (isDarkTheme) {
106106
try {
107-
if (!FlatDraculaIJTheme.setup()) {
108-
// Fallback to basic dark theme if Dracula fails
109-
FlatMacDarkLaf.setup();
110-
}
107+
FlatDarculaLaf.install();
111108
} catch (Exception e) {
112-
// Final fallback if both dark themes fail
113-
FlatLaf.setup(new FlatMacDarkLaf());
109+
// Fallback to basic dark theme
110+
FlatDarkLaf.install();
114111
}
115112
} else {
116113
try {
117-
if (!FlatLightFlatIJTheme.setup()) {
118-
// Fallback to basic light theme if JetBrains theme fails
119-
FlatLightLaf.setup();
120-
}
114+
FlatLightLaf.install();
121115
} catch (Exception e) {
122-
// Final fallback if both light themes fail
123-
FlatLaf.setup(new FlatLightLaf());
116+
// Final fallback to system look and feel
117+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
124118
}
125119
}
126120

src/main/java/au/com/intermine/spacemap/util/ResourceManager.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
package au.com.intermine.spacemap.util;
2323

2424
import java.awt.*;
25-
import java.awt.image.BaseMultiResolutionImage;
2625
import java.awt.image.BufferedImage;
2726
import java.net.URL;
2827
import java.util.Arrays;
@@ -36,6 +35,7 @@
3635
public class ResourceManager {
3736

3837
private static HashMap<String, ImageIcon> _IconCache;
38+
private static final int[] ICON_SIZES = { 14, 16, 18, 20, 24, 32, 64, 128 };
3939

4040
static {
4141
_IconCache = new HashMap<String, ImageIcon>();
@@ -52,16 +52,32 @@ public static synchronized ImageIcon getIcon(String name) {
5252
System.err.println("Warning: Resource not found: " + path);
5353
return null;
5454
}
55-
Image image = ImageIO.read(url);
55+
BufferedImage image = ImageIO.read(url);
5656
if (image == null) {
5757
System.err.println("Warning: Failed to read image: " + path);
5858
return null;
5959
}
60-
Image[] scaledImages = Arrays.stream(new int[] { 14, 16, 18, 20, 24, 32, 64, 128 }).mapToObj((int size) -> {
61-
return image.getScaledInstance(size, size, Image.SCALE_SMOOTH);
62-
}).toArray(Image[]::new);
6360

64-
ImageIcon result = new ImageIcon(new BaseMultiResolutionImage(scaledImages));
61+
// Get the system scale factor (1.0 for standard displays, 2.0 for HiDPI/Retina)
62+
double scaleFactor = Toolkit.getDefaultToolkit().getScreenResolution() / 96.0;
63+
64+
// Choose the appropriate size based on scale factor
65+
int baseSize = 16; // Default icon size
66+
int targetSize = (int) Math.round(baseSize * scaleFactor);
67+
68+
// Find the best matching size from our predefined sizes
69+
int bestSize = ICON_SIZES[0];
70+
for (int size : ICON_SIZES) {
71+
if (size >= targetSize) {
72+
bestSize = size;
73+
break;
74+
}
75+
}
76+
77+
// Create a scaled version of the image
78+
Image scaledImage = image.getScaledInstance(bestSize, bestSize, Image.SCALE_SMOOTH);
79+
80+
ImageIcon result = new ImageIcon(scaledImage);
6581
_IconCache.put(path, result);
6682
return result;
6783
} catch (Exception ex) {

0 commit comments

Comments
 (0)