From 05d220bbea0e8ce667490219436b96ebdf9826df Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 8 Nov 2017 11:34:40 +0000 Subject: [PATCH] JAL-2069 updated spike to latest --- src/jalview/gui/CalculationChooser.java | 4 ++-- src/jalview/gui/FeatureColourChooser.java | 14 +++++++------- src/jalview/gui/FeatureSettings.java | 14 ++++++-------- src/jalview/gui/JvSwingUtils.java | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index e403dba..886762a 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -169,8 +169,8 @@ public class CalculationChooser extends JPanel JPanel treePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); treePanel.setOpaque(false); - treePanel.setBorder(BorderFactory - .createTitledBorder(MessageManager.getString("label.tree"))); + JvSwingUtils.createItalicTitledBorder(treePanel, + MessageManager.getString("label.tree"), true); // then copy the inset dimensions for the border-less PCA panel JPanel pcaBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT)); diff --git a/src/jalview/gui/FeatureColourChooser.java b/src/jalview/gui/FeatureColourChooser.java index ddfa162..6280a64 100644 --- a/src/jalview/gui/FeatureColourChooser.java +++ b/src/jalview/gui/FeatureColourChooser.java @@ -278,6 +278,9 @@ public class FeatureColourChooser extends JalviewDialog } } + threshline = new GraphLine((max - min) / 2f, "Threshold", Color.black); + threshline.value = cs.getThreshold(); + if (cs.hasThreshold()) { // initialise threshold slider and selector @@ -285,9 +288,6 @@ public class FeatureColourChooser extends JalviewDialog slider.setEnabled(true); slider.setValue((int) (cs.getThreshold() * scaleFactor)); thresholdValue.setEnabled(true); - threshline = new GraphLine((max - min) / 2f, "Threshold", - Color.black); - threshline.value = cs.getThreshold(); } adjusting = false; @@ -389,8 +389,8 @@ public class FeatureColourChooser extends JalviewDialog { JPanel byValuePanel = new JPanel(); byValuePanel.setLayout(new BoxLayout(byValuePanel, BoxLayout.Y_AXIS)); - byValuePanel.setBorder(BorderFactory.createTitledBorder(MessageManager - .getString("label.colour_by_value"))); + JvSwingUtils.createItalicTitledBorder(byValuePanel, + MessageManager.getString("label.colour_by_value"), true); byValuePanel.setBackground(Color.white); /* @@ -599,8 +599,8 @@ public class FeatureColourChooser extends JalviewDialog { JPanel byTextPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); byTextPanel.setBackground(Color.white); - byTextPanel.setBorder(BorderFactory.createTitledBorder(MessageManager - .getString("label.colour_by_text"))); + JvSwingUtils.createItalicTitledBorder(byTextPanel, + MessageManager.getString("label.colour_by_text"), true); byDescription.setText(MessageManager.getString("label.label")); byDescription.setToolTipText(MessageManager diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 3be597c..4e4d2cb 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1341,9 +1341,8 @@ public class FeatureSettings extends JPanel */ JPanel chooseTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); chooseTypePanel.setBackground(Color.white); - chooseTypePanel.setBorder(BorderFactory - .createTitledBorder(MessageManager - .getString("label.feature_type"))); + JvSwingUtils.createItalicTitledBorder(chooseTypePanel, + MessageManager.getString("label.feature_type"), true); filteredFeatureChoice = new JComboBox<>(); filteredFeatureChoice.addItemListener(new ItemListener() { @@ -1364,8 +1363,8 @@ public class FeatureSettings extends JPanel JPanel filtersPanel = new JPanel(); filtersPanel.setLayout(new BoxLayout(filtersPanel, BoxLayout.Y_AXIS)); filtersPanel.setBackground(Color.white); - filtersPanel.setBorder(BorderFactory - .createTitledBorder(MessageManager.getString("label.filters"))); + JvSwingUtils.createItalicTitledBorder(filtersPanel, + MessageManager.getString("label.filters"), true); /* * add AND or OR radio buttons @@ -1407,9 +1406,8 @@ public class FeatureSettings extends JPanel */ JPanel showFiltersPanel = new JPanel(new BorderLayout(5, 5)); showFiltersPanel.setBackground(Color.white); - showFiltersPanel.setBorder(BorderFactory - .createTitledBorder(MessageManager - .getString("label.match_condition"))); + JvSwingUtils.createItalicTitledBorder(showFiltersPanel, + MessageManager.getString("label.match_condition"), true); filtersAsText = new JTextArea(); filtersAsText.setLineWrap(true); filtersAsText.setWrapStyleWord(true); diff --git a/src/jalview/gui/JvSwingUtils.java b/src/jalview/gui/JvSwingUtils.java index ef96fa6..79e0cef 100644 --- a/src/jalview/gui/JvSwingUtils.java +++ b/src/jalview/gui/JvSwingUtils.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.Objects; import javax.swing.AbstractButton; +import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -44,6 +45,8 @@ import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.SwingConstants; +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; /** * useful functions for building Swing GUIs @@ -351,4 +354,26 @@ public final class JvSwingUtils return combo; } + /** + * Adds a titled border to the component in the default font and position (top + * left) + * + * @param comp + * @param title + */ + public static void createItalicTitledBorder(JComponent comp, + String title, boolean italic) + { + Font font = comp.getFont(); + if (italic) + { + font = new Font(font.getName(), Font.ITALIC, font.getSize()); + } + Border border = BorderFactory.createTitledBorder(""); + TitledBorder titledBorder = BorderFactory.createTitledBorder(border, + title, TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, + font); + comp.setBorder(titledBorder); + } + } -- 1.7.10.2