From: gmungoc Date: Wed, 8 Nov 2017 15:46:56 +0000 (+0000) Subject: JAL-2808 i18n, widget state settings X-Git-Tag: Release_2_11_0~139 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=5f5b92d6dad613497a7f8a9f47d217197e5e9230 JAL-2808 i18n, widget state settings --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 4626c39..75c002a 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1349,3 +1349,4 @@ label.attribute = Attribute label.colour_by_label = Colour by label label.variable_colour = Variable colour label.select_new_colour = Select new colour +label.no_feature_attributes = No feature attributes found diff --git a/src/jalview/gui/FeatureColourChooser.java b/src/jalview/gui/FeatureColourChooser.java index 6280a64..6c85e8c 100644 --- a/src/jalview/gui/FeatureColourChooser.java +++ b/src/jalview/gui/FeatureColourChooser.java @@ -59,6 +59,12 @@ public class FeatureColourChooser extends JalviewDialog { private static final int MAX_TOOLTIP_LENGTH = 50; + private static int NO_COLOUR_OPTION = 0; + + private static int MIN_COLOUR_OPTION = 1; + + private static int MAX_COLOUR_OPTION = 2; + private FeatureRenderer fr; private FeatureColourI cs; @@ -190,6 +196,7 @@ public class FeatureColourChooser extends JalviewDialog } }); + // todo move all threshold setup inside a method float mm[] = fr.getMinMax().get(theType)[0]; min = mm[0]; max = mm[1]; @@ -231,6 +238,8 @@ public class FeatureColourChooser extends JalviewDialog } minColour.setBackground(oldminColour = cs.getMinColour()); maxColour.setBackground(oldmaxColour = cs.getMaxColour()); + noColour = cs.getNoColour(); + adjusting = true; try @@ -245,8 +254,6 @@ public class FeatureColourChooser extends JalviewDialog /* * set the initial state of options on screen */ - thresholdIsMin.setSelected(!cs.isAutoScaled()); - if (cs.isColourByLabel()) { if (cs.isColourByAttribute()) @@ -278,6 +285,19 @@ public class FeatureColourChooser extends JalviewDialog } } + if (noColour == null) + { + noValueCombo.setSelectedIndex(NO_COLOUR_OPTION); + } + else if (noColour.equals(oldminColour)) + { + noValueCombo.setSelectedIndex(MIN_COLOUR_OPTION); + } + else if (noColour.equals(oldmaxColour)) + { + noValueCombo.setSelectedIndex(MAX_COLOUR_OPTION); + } + threshline = new GraphLine((max - min) / 2f, "Threshold", Color.black); threshline.value = cs.getThreshold(); @@ -555,21 +575,21 @@ public class FeatureColourChooser extends JalviewDialog } /** - * Action on user choice of no / min / max colour when there is no value to - * colour by + * Action on user choice of no / min / max colour to use when there is no + * value to colour by */ protected void setNoValueColour() { int i = noValueCombo.getSelectedIndex(); - if (i == 0) + if (i == NO_COLOUR_OPTION) { noColour = null; } - else if (i == 1) + else if (i == MIN_COLOUR_OPTION) { noColour = minColour.getBackground(); } - else if (i == 2) + else if (i == MAX_COLOUR_OPTION) { noColour = maxColour.getBackground(); } @@ -798,6 +818,7 @@ public class FeatureColourChooser extends JalviewDialog maxColour.setForeground(oldmaxColour); minColour.setBackground(oldminColour); minColour.setForeground(oldminColour); + noColour = oldNoColour; } /* diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 4e4d2cb..01c40d5 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -53,6 +53,7 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.GridLayout; +import java.awt.LayoutManager; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -199,6 +200,9 @@ public class FeatureSettings extends JPanel private JTextArea filtersAsText; + // set white normally, black to debug layout + private Color debugBorderColour = Color.white; + /** * Constructor * @@ -1371,6 +1375,7 @@ public class FeatureSettings extends JPanel */ JPanel andOrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); andOrPanel.setBackground(Color.white); + andOrPanel.setBorder(BorderFactory.createLineBorder(debugBorderColour)); andFilters = new JRadioButton("And"); orFilters = new JRadioButton("Or"); ActionListener actionListener = new ActionListener() @@ -1397,8 +1402,9 @@ public class FeatureSettings extends JPanel * panel with filters - populated by refreshFiltersDisplay */ chooseFiltersPanel = new JPanel(); - chooseFiltersPanel.setLayout(new BoxLayout(chooseFiltersPanel, - BoxLayout.Y_AXIS)); + LayoutManager box = new BoxLayout(chooseFiltersPanel, + BoxLayout.Y_AXIS); + chooseFiltersPanel.setLayout(box); filtersPanel.add(chooseFiltersPanel); /* @@ -1454,12 +1460,12 @@ public class FeatureSettings extends JPanel } if (!found) { - filteredFeatureChoice // todo i18n - .addItem("No filterable feature attributes known"); + filteredFeatureChoice.addItem(MessageManager + .getString("label.no_feature_attributes")); + filteredFeatureChoice.setEnabled(false); } filteredFeatureChoice.addItemListener(listener); - } /** @@ -1515,9 +1521,11 @@ public class FeatureSettings extends JPanel .getCondition(); String pattern = filter.getMatcher().getPattern(); JPanel row = addFilter(key, attNames, condition, pattern, filterIndex); + row.setBorder(BorderFactory.createLineBorder(debugBorderColour)); chooseFiltersPanel.add(row); filterIndex++; } + // chooseFiltersPanel.add(Box.createVerticalGlue()); filtersPane.validate(); filtersPane.repaint(); @@ -1549,9 +1557,6 @@ public class FeatureSettings extends JPanel filterRow.setBackground(Color.white); /* - * inputs for attribute, condition, pattern - */ - /* * drop-down choice of attribute, with description as a tooltip * if we can obtain it */ @@ -1634,7 +1639,7 @@ public class FeatureSettings extends JPanel */ if (pattern != null && pattern.trim().length() > 0) { - // todo: gif for - button + // todo: gif for button drawing '-' or 'x' JButton removeCondition = new BasicArrowButton(SwingConstants.WEST); removeCondition.setToolTipText(MessageManager .getString("label.delete_row"));