From 9378254a3897d1f05eeb501616607430d744c1c0 Mon Sep 17 00:00:00 2001 From: Denny Sheirer Date: Sat, 12 Jan 2019 07:17:51 -0500 Subject: [PATCH] Updates codebase to use jIconFont icons. (#484) Removes Ikonli library. --- build.gradle | 8 +-- .../java/io/github/dsheirer/gui/SDRTrunk.java | 5 ++ .../gui/control/MultipleFrequencyEditor.java | 24 ++++--- .../gui/instrument/PlaybackController.java | 62 ++++++++++++------- 4 files changed, 66 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index eacb3e0b..537533ff 100644 --- a/build.gradle +++ b/build.gradle @@ -74,10 +74,10 @@ dependencies { compile 'org.apache.axis:axis-jaxrpc:1.4' compile 'org.apache.axis:axis:1.4' compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.3' - compile 'org.kordamp.ikonli:ikonli-javafx:2.1.1' - compile 'org.kordamp.ikonli:ikonli-swing:2.1.1' - compile 'org.kordamp.ikonli:ikonli-fontawesome-pack:2.1.1' - compile 'com.google.guava:guava:27.0-jre' + compile 'com.google.guava:guava:27.0-jre' + compile group: 'com.github.jiconfont', name: 'jiconfont-font_awesome', version: '4.7.0.1' + compile group: 'com.github.jiconfont', name: 'jiconfont-javafx', version: '1.0.0' + compile group: 'com.github.jiconfont', name: 'jiconfont-swing', version: '1.0.1' } task wrapper(type: Wrapper) { diff --git a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java index d9407bf3..bc02ca44 100644 --- a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java +++ b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java @@ -56,6 +56,8 @@ import io.github.dsheirer.spectrum.ShowTunerMenuItem; import io.github.dsheirer.spectrum.SpectralDisplayPanel; import io.github.dsheirer.util.ThreadPool; import io.github.dsheirer.util.TimeStamp; +import jiconfont.icons.font_awesome.FontAwesome; +import jiconfont.swing.IconFontSwing; import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,6 +134,9 @@ public class SDRTrunk implements Listener //Log current properties setting SystemProperties.getInstance().logCurrentSettings(); + //Register FontAwesome so we can use the fonts in Swing windows + IconFontSwing.register(FontAwesome.getIconFont()); + TunerConfigurationModel tunerConfigurationModel = new TunerConfigurationModel(); TunerModel tunerModel = new TunerModel(tunerConfigurationModel); diff --git a/src/main/java/io/github/dsheirer/gui/control/MultipleFrequencyEditor.java b/src/main/java/io/github/dsheirer/gui/control/MultipleFrequencyEditor.java index e91578b4..01772e3f 100644 --- a/src/main/java/io/github/dsheirer/gui/control/MultipleFrequencyEditor.java +++ b/src/main/java/io/github/dsheirer/gui/control/MultipleFrequencyEditor.java @@ -20,12 +20,15 @@ package io.github.dsheirer.gui.control; +import jiconfont.icons.font_awesome.FontAwesome; +import jiconfont.swing.IconFontSwing; import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.AbstractAction; import javax.swing.DefaultCellEditor; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JFormattedTextField; import javax.swing.JFrame; @@ -62,6 +65,10 @@ public class MultipleFrequencyEditor extends JPanel { private final static Logger mLog = LoggerFactory.getLogger(MultipleFrequencyEditor.class); private static final Long DEFAULT_FREQUENCY = 0l; + private static final Icon ICON_ADD = IconFontSwing.buildIcon(FontAwesome.PLUS, 10); + private static final Icon ICON_DOWN = IconFontSwing.buildIcon(FontAwesome.ARROW_DOWN, 10); + private static final Icon ICON_REMOVE = IconFontSwing.buildIcon(FontAwesome.MINUS, 10); + private static final Icon ICON_UP = IconFontSwing.buildIcon(FontAwesome.ARROW_UP, 10); private DecimalFormat mDecimalFormat = new DecimalFormat("0.000000"); private FrequencyModel mFrequencyModel = new FrequencyModel(); private JTable mFrequencyTable; @@ -79,8 +86,9 @@ public class MultipleFrequencyEditor extends JPanel { setLayout(new MigLayout("insets 0 0 0 0", "[]1[grow,fill]1[]", "[]1[]1[top,grow,fill]")); - mMoveUpButton = new JButton("^"); -// mMoveUpButton.setIcon(FontIcon.of(FontAwesome.ARROW_UP, 10)); + + mMoveUpButton = new JButton(); + mMoveUpButton.setIcon(ICON_UP); mMoveUpButton.setEnabled(false); mMoveUpButton.addActionListener(e -> { int selectedRow = mFrequencyTable.getSelectedRow(); @@ -105,8 +113,8 @@ public class MultipleFrequencyEditor extends JPanel JScrollPane listScrollPane = new JScrollPane(mFrequencyTable); add(listScrollPane, "span 1 3"); - mAddButton = new JButton("+"); -// mAddButton.setIcon(FontIcon.of(FontAwesome.PLUS, 10)); + mAddButton = new JButton(); + mAddButton.setIcon(ICON_ADD); mAddButton.addActionListener(e -> { int selectedRow = mFrequencyTable.getSelectedRow(); if(selectedRow >= 0) @@ -134,8 +142,8 @@ public class MultipleFrequencyEditor extends JPanel }); add(mAddButton, "wrap"); - mMoveDownButton = new JButton("v"); -// mMoveDownButton.setIcon(FontIcon.of(FontAwesome.ARROW_DOWN, 10)); + mMoveDownButton = new JButton(); + mMoveDownButton.setIcon(ICON_DOWN); mMoveDownButton.setEnabled(false); mMoveDownButton.addActionListener(e -> { int selectedRow = mFrequencyTable.getSelectedRow(); @@ -148,8 +156,8 @@ public class MultipleFrequencyEditor extends JPanel }); add(mMoveDownButton); - mRemoveButton = new JButton("-"); -// mRemoveButton.setIcon(FontIcon.of(FontAwesome.MINUS, 10)); + mRemoveButton = new JButton(); + mRemoveButton.setIcon(ICON_REMOVE); mRemoveButton.setEnabled(false); mRemoveButton.addActionListener(e -> { int selectedRow = mFrequencyTable.getSelectedRow(); diff --git a/src/main/java/io/github/dsheirer/gui/instrument/PlaybackController.java b/src/main/java/io/github/dsheirer/gui/instrument/PlaybackController.java index a12f75c7..fd0d3102 100644 --- a/src/main/java/io/github/dsheirer/gui/instrument/PlaybackController.java +++ b/src/main/java/io/github/dsheirer/gui/instrument/PlaybackController.java @@ -1,18 +1,22 @@ -/******************************************************************************* - * sdr-trunk - * Copyright (C) 2014-2018 Dennis Sheirer +/* + * ****************************************************************************** + * sdrtrunk + * Copyright (C) 2014-2019 Dennis Sheirer * - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any - * later version. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with this program. - * If not, see - * - ******************************************************************************/ + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + * ***************************************************************************** + */ package io.github.dsheirer.gui.instrument; import io.github.dsheirer.gui.instrument.decoder.AbstractDecoderPane; @@ -32,8 +36,9 @@ import javafx.scene.control.ButtonType; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; -import org.kordamp.ikonli.fontawesome.FontAwesome; -import org.kordamp.ikonli.javafx.FontIcon; +import jiconfont.icons.font_awesome.FontAwesome; +import jiconfont.javafx.IconFontFX; +import jiconfont.javafx.IconNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,6 +69,7 @@ public class PlaybackController extends HBox implements IFrameLocationListener public PlaybackController() { super(10); + IconFontFX.register(jiconfont.icons.font_awesome.FontAwesome.getIconFont()); getChildren().addAll(getControlsBox(), getFileLabel()); @@ -235,7 +241,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener if(mRewindButton == null) { mRewindButton = new Button(); - mRewindButton.setGraphic(new FontIcon(FontAwesome.FAST_BACKWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_BACKWARD); + iconNode.setIconSize(10); + mRewindButton.setGraphic(iconNode); } return mRewindButton; @@ -248,7 +256,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay1Button = new Button("1"); mPlay1Button.setUserData(1); mPlay1Button.setOnAction(getPlaybackEventHandler()); - mPlay1Button.setGraphic(new FontIcon(FontAwesome.PLAY)); + IconNode iconNode = new IconNode(FontAwesome.PLAY); + iconNode.setIconSize(10); + mPlay1Button.setGraphic(iconNode); } return mPlay1Button; @@ -261,7 +271,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay10Button = new Button("10"); mPlay10Button.setUserData(10); mPlay10Button.setOnAction(getPlaybackEventHandler()); - mPlay10Button.setGraphic(new FontIcon(FontAwesome.FAST_FORWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_FORWARD); + iconNode.setIconSize(10); + mPlay10Button.setGraphic(iconNode); } return mPlay10Button; @@ -274,7 +286,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay30Button = new Button("30"); mPlay30Button.setUserData(30); mPlay30Button.setOnAction(getPlaybackEventHandler()); - mPlay30Button.setGraphic(new FontIcon(FontAwesome.FAST_FORWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_FORWARD); + iconNode.setIconSize(10); + mPlay30Button.setGraphic(iconNode); } return mPlay30Button; @@ -287,7 +301,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay100Button = new Button("100"); mPlay100Button.setUserData(100); mPlay100Button.setOnAction(getPlaybackEventHandler()); - mPlay100Button.setGraphic(new FontIcon(FontAwesome.FAST_FORWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_FORWARD); + iconNode.setIconSize(10); + mPlay100Button.setGraphic(iconNode); } return mPlay100Button; @@ -300,7 +316,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay1000Button = new Button("1000"); mPlay1000Button.setUserData(1000); mPlay1000Button.setOnAction(getPlaybackEventHandler()); - mPlay1000Button.setGraphic(new FontIcon(FontAwesome.FAST_FORWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_FORWARD); + iconNode.setIconSize(10); + mPlay1000Button.setGraphic(iconNode); } return mPlay1000Button; @@ -313,7 +331,9 @@ public class PlaybackController extends HBox implements IFrameLocationListener mPlay2000Button = new Button("2000"); mPlay2000Button.setUserData(2000); mPlay2000Button.setOnAction(getPlaybackEventHandler()); - mPlay2000Button.setGraphic(new FontIcon(FontAwesome.FAST_FORWARD)); + IconNode iconNode = new IconNode(FontAwesome.FAST_FORWARD); + iconNode.setIconSize(10); + mPlay2000Button.setGraphic(iconNode); } return mPlay2000Button;