Skip to content
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

IGV FlatLaf theme support and selector #1672

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dependencies {
[group: 'org.apache.xmlgraphics', name: 'batik-svggen', version: xmlGraphicsVersion],
[group: 'org.apache.xmlgraphics', name: 'batik-codec', version: xmlGraphicsVersion],
[group: 'org.netbeans.external', name: 'AbsoluteLayout', version: 'RELEASE110'],
[group: 'com.formdev', name: 'flatlaf', version: '3.5.4'],

// Amazon deps
[group: 'software.amazon.awssdk', name: 'cognitoidentity', version: amazonVersion],
Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
requires batik.svggen;
requires batik.dom;
requires AbsoluteLayout.RELEASE110;
requires com.formdev.flatlaf;

// AWS
requires software.amazon.awssdk.core;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/broad/igv/prefs/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private Constants() {
public static final String AUTOLOAD_LAST_AUTOSAVE = "AUTOLOAD_LAST_AUTOSAVE";
public static final String AUTOSAVE_FREQUENCY = "AUTOSAVE_FREQUENCY";
public static final String AUTOSAVES_TO_KEEP = "AUTOSAVES_TO_KEEP";
public static final String USER_THEME = "USER_THEME";

//
public static final String RECENT_SESSIONS = "IGV.Session.recent.sessions";
Expand Down
37 changes: 34 additions & 3 deletions src/main/java/org/broad/igv/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package org.broad.igv.ui;

import com.formdev.flatlaf.themes.FlatMacDarkLaf;
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.sanityinc.jargs.CmdLineParser;
import htsjdk.samtools.seekablestream.SeekableStreamFactory;
Expand All @@ -40,6 +42,7 @@
import org.broad.igv.util.RuntimeUtils;
import org.broad.igv.util.stream.IGVSeekableStreamFactory;
import org.broad.igv.util.stream.IGVUrlHelperFactory;
import com.formdev.flatlaf.*;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -302,8 +305,37 @@ public void windowGainedFocus(WindowEvent windowEvent) {
private static void initializeLookAndFeel() {

try {
String lnf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(lnf);
String lnfselect = PreferencesManager.getPreferences().get(USER_THEME);

switch(lnfselect){
case "SYSTEM":
if (!Globals.IS_LINUX)
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
else
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
break;
case "FLATLIGHT":
if(Globals.IS_MAC)
UIManager.setLookAndFeel(new FlatMacLightLaf());
else
UIManager.setLookAndFeel(new FlatLightLaf());
break;
case "FLATDARK":
if(Globals.IS_MAC)
UIManager.setLookAndFeel(new FlatMacDarkLaf());
else
UIManager.setLookAndFeel(new FlatDarkLaf());
break;
case "FLATINTELLIJ":
UIManager.setLookAndFeel(new FlatIntelliJLaf());
break;
case "FLATINTELLIJDARK":
UIManager.setLookAndFeel(new FlatDarculaLaf());
break;
default:
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
break;
}

} catch (Exception e) {
log.error("Error setting look and feel", e);
Expand All @@ -326,7 +358,6 @@ private static void initializeLookAndFeel() {

if (Globals.IS_LINUX) {
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
UIManager.put("JideSplitPane.dividerSize", 5);
UIManager.put("JideSplitPaneDivider.background", Color.darkGray);

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/org/broad/igv/prefs/preferences.tab
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ DEFAULT_FONT_SIZE Default font size integer 10
SCALE_FONTS Scale fonts. Useful for some high-resolution screens. ** REQUIRES RESTART ** boolean FALSE
FONT_SCALE_FACTOR Font scale factor float 1
ENABLE_ANTIALIASING Enable anti-aliasing boolean TRUE
USER_THEME Select Theme (Requires Restart) select SYSTEM|FLATLIGHT|FLATDARK|FLATINTELLIJ|FLATINTELLIJDARK SYSTEM

##Nucleotide Colors
COLOR.A A color 0,150,0
Expand Down