X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureSettings.java;h=3dae4e5fca4f4409bb5c2f7053a394c19a2ba107;hb=d5e858c7a3a5cc821651a94433f35003921c9edd;hp=1dc577eeab597fe5c68697cf76e18ea74fa66bcd;hpb=d423f22792e47dbc800ae220a58677f988971d06;p=jalview.git diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java old mode 100755 new mode 100644 index 1dc577e..3dae4e5 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1,29 +1,30 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview 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. - * + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * * Jalview 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 Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; import java.io.*; import java.util.*; - +import java.util.List; import java.awt.*; import java.awt.event.*; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -38,6 +39,8 @@ import jalview.datamodel.*; import jalview.io.*; import jalview.schemes.AnnotationColourGradient; import jalview.schemes.GraduatedColor; +import jalview.util.MessageManager; +import jalview.ws.dbsources.das.api.jalviewSourceI; public class FeatureSettings extends JPanel { @@ -98,12 +101,19 @@ public class FeatureSettings extends JPanel public void mousePressed(MouseEvent evt) { selectedRow = table.rowAtPoint(evt.getPoint()); - if (javax.swing.SwingUtilities.isRightMouseButton(evt)) + if (evt.isPopupTrigger()) { popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0), table.getValueAt(selectedRow, 1), fr.minmax, evt.getX(), evt.getY()); } + else if (evt.getClickCount() == 2) + { + fr.ap.alignFrame.avc.markColumnsContainingFeatures( + evt.isAltDown(), evt.isShiftDown() || evt.isMetaDown(), + evt.isMetaDown(), + (String) table.getValueAt(selectedRow, 0)); + } } }); @@ -131,10 +141,13 @@ public class FeatureSettings extends JPanel } } }); - + table.setToolTipText("" + + JvSwingUtils + .wrapTooltip("Click/drag feature types up or down to change render order.
Double click to select columns containing feature in alignment/current selection
Pressing Alt will select columns outside features rather than inside
Pressing Shift to modify current selection (rather than clear current selection)
Press CTRL or Command/Meta to toggle columns in/outside features
") + + ""); scrollPane.setViewportView(table); - dassourceBrowser = new DasSourceBrowser(); + dassourceBrowser = new DasSourceBrowser(this); dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER); if (af.getViewport().featuresDisplayed == null @@ -163,24 +176,39 @@ public class FeatureSettings extends JPanel frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 450); - frame - .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent evt) - { - fr.removePropertyChangeListener(change); - }; - }); + if (new jalview.util.Platform().isAMac()) + { + Desktop.addInternalFrame(frame, + MessageManager.getString("label.sequence_feature_settings"), + 475, 480); + } + else + { + Desktop.addInternalFrame(frame, + MessageManager.getString("label.sequence_feature_settings"), + 400, 450); + } + + frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + fr.removePropertyChangeListener(change); + dassourceBrowser.fs = null; + }; + }); frame.setLayer(JLayeredPane.PALETTE_LAYER); } protected void popupSort(final int selectedRow, final String type, final Object typeCol, final Hashtable minmax, int x, int y) { - JPopupMenu men = new JPopupMenu("Settings for " + type); - JMenuItem scr = new JMenuItem("Sort by Score"); + JPopupMenu men = new JPopupMenu(MessageManager.formatMessage( + "label.settings_for_param", new String[] + { type })); + JMenuItem scr = new JMenuItem( + MessageManager.getString("label.sort_by_score")); men.add(scr); final FeatureSettings me = this; scr.addActionListener(new ActionListener() @@ -193,7 +221,8 @@ public class FeatureSettings extends JPanel } }); - JMenuItem dens = new JMenuItem("Sort by Density"); + JMenuItem dens = new JMenuItem( + MessageManager.getString("label.sort_by_density")); dens.addActionListener(new ActionListener() { @@ -272,8 +301,9 @@ public class FeatureSettings extends JPanel // probably the color chooser! table.setValueAt(colorChooser.getColor(), selectedRow, 1); table.validate(); - me.updateFeatureRenderer(((FeatureTableModel) table - .getModel()).getData(), false); + me.updateFeatureRenderer( + ((FeatureTableModel) table.getModel()).getData(), + false); } } } @@ -281,6 +311,32 @@ public class FeatureSettings extends JPanel }); } } + JMenuItem selCols = new JMenuItem( + MessageManager.getString("label.select_columns_containing")); + selCols.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent arg0) + { + fr.ap.alignFrame.avc.markColumnsContainingFeatures(false, false, + false, type); + } + }); + JMenuItem clearCols = new JMenuItem( + MessageManager.getString("label.select_columns_not_containing")); + clearCols.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent arg0) + { + fr.ap.alignFrame.avc.markColumnsContainingFeatures(true, false, + false, type); + } + }); + men.add(selCols); + men.add(clearCols); men.show(table, x, y); } @@ -304,15 +360,15 @@ public class FeatureSettings extends JPanel Vector allGroups = new Vector(); SequenceFeature[] tmpfeatures; String group; - for (int i = 0; i < af.getViewport().alignment.getHeight(); i++) + for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++) { - if (af.getViewport().alignment.getSequenceAt(i).getDatasetSequence() - .getSequenceFeatures() == null) + if (af.getViewport().getAlignment().getSequenceAt(i) + .getDatasetSequence().getSequenceFeatures() == null) { continue; } - tmpfeatures = af.getViewport().alignment.getSequenceAt(i) + tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i) .getDatasetSequence().getSequenceFeatures(); int index = 0; @@ -397,8 +453,8 @@ public class FeatureSettings extends JPanel { public void itemStateChanged(ItemEvent evt) { - fr.featureGroups.put(check.getText(), new Boolean(check - .isSelected())); + fr.featureGroups.put(check.getText(), + new Boolean(check.isSelected())); af.alignPanel.seqPanel.seqCanvas.repaint(); if (af.alignPanel.overviewPanel != null) { @@ -433,10 +489,10 @@ public class FeatureSettings extends JPanel // Find out which features should be visible depending on which groups // are selected / deselected // and recompute average width ordering - for (int i = 0; i < af.getViewport().alignment.getHeight(); i++) + for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++) { - tmpfeatures = af.getViewport().alignment.getSequenceAt(i) + tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i) .getDatasetSequence().getSequenceFeatures(); if (tmpfeatures == null) { @@ -512,8 +568,8 @@ public class FeatureSettings extends JPanel data[dataIndex][0] = type; data[dataIndex][1] = fr.getFeatureStyle(type); - data[dataIndex][2] = new Boolean(af.getViewport().featuresDisplayed - .containsKey(type)); + data[dataIndex][2] = new Boolean( + af.getViewport().featuresDisplayed.containsKey(type)); dataIndex++; visibleChecks.removeElement(type); } @@ -587,13 +643,13 @@ public class FeatureSettings extends JPanel void load() { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "fc" }, new String[] - { "Sequence Feature Colours" }, "Sequence Feature Colours"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "fc" }, new String[] + { "Sequence Feature Colours" }, "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Load Feature Colours"); - chooser.setToolTipText("Load"); + chooser.setToolTipText(MessageManager.getString("action.load")); int value = chooser.showOpenDialog(this); @@ -627,8 +683,8 @@ public class FeatureSettings extends JPanel Cache.log.warn("Couldn't parse out graduated feature color.", e); } - GraduatedColor gcol = new GraduatedColor(mincol, maxcol, newcol - .getMin(), newcol.getMax()); + GraduatedColor gcol = new GraduatedColor(mincol, maxcol, + newcol.getMin(), newcol.getMax()); if (newcol.hasAutoScale()) { gcol.setAutoScaled(newcol.getAutoScale()); @@ -651,13 +707,11 @@ public class FeatureSettings extends JPanel } if (ttyp.equalsIgnoreCase("ABOVE")) { - gcol - .setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD); + gcol.setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD); } if (ttyp.equalsIgnoreCase("BELOW")) { - gcol - .setThreshType(AnnotationColourGradient.BELOW_THRESHOLD); + gcol.setThreshType(AnnotationColourGradient.BELOW_THRESHOLD); } } fr.setColour(name = newcol.getName(), gcol); @@ -687,13 +741,13 @@ public class FeatureSettings extends JPanel void save() { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "fc" }, new String[] - { "Sequence Feature Colours" }, "Sequence Feature Colours"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "fc" }, new String[] + { "Sequence Feature Colours" }, "Sequence Feature Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Save Feature Colour Scheme"); - chooser.setToolTipText("Save"); + chooser.setToolTipText(MessageManager.getString("action.save")); int value = chooser.showSaveDialog(this); @@ -707,13 +761,13 @@ public class FeatureSettings extends JPanel PrintWriter out = new PrintWriter(new OutputStreamWriter( new FileOutputStream(choice), "UTF-8")); - Enumeration e = fr.featureColours.keys(); + Iterator e = fr.featureColours.keySet().iterator(); float[] sortOrder = new float[fr.featureColours.size()]; String[] sortTypes = new String[fr.featureColours.size()]; int i = 0; - while (e.hasMoreElements()) + while (e.hasNext()) { - sortTypes[i] = e.nextElement().toString(); + sortTypes[i] = e.next().toString(); sortOrder[i] = fr.getOrder(sortTypes[i]); i++; } @@ -897,8 +951,8 @@ public class FeatureSettings extends JPanel settingsPane.setLayout(borderLayout2); dasSettingsPane.setLayout(borderLayout3); bigPanel.setLayout(borderLayout4); - invert.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - invert.setText("Invert Selection"); + invert.setFont(JvSwingUtils.getLabelFont()); + invert.setText(MessageManager.getString("label.invert_selection")); invert.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -906,8 +960,8 @@ public class FeatureSettings extends JPanel invertSelection(); } }); - optimizeOrder.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - optimizeOrder.setText("Optimise Order"); + optimizeOrder.setFont(JvSwingUtils.getLabelFont()); + optimizeOrder.setText(MessageManager.getString("label.optimise_order")); optimizeOrder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -915,8 +969,9 @@ public class FeatureSettings extends JPanel orderByAvWidth(); } }); - sortByScore.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - sortByScore.setText("Seq sort by Score"); + sortByScore.setFont(JvSwingUtils.getLabelFont()); + sortByScore + .setText(MessageManager.getString("label.seq_sort_by_score")); sortByScore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -924,8 +979,9 @@ public class FeatureSettings extends JPanel sortByScore(null); } }); - sortByDens.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - sortByDens.setText("Seq Sort by density"); + sortByDens.setFont(JvSwingUtils.getLabelFont()); + sortByDens.setText(MessageManager + .getString("label.sequence_sort_by_density")); sortByDens.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -933,8 +989,8 @@ public class FeatureSettings extends JPanel sortByDens(null); } }); - cancel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - cancel.setText("Cancel"); + cancel.setFont(JvSwingUtils.getLabelFont()); + cancel.setText(MessageManager.getString("action.cancel")); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -943,8 +999,8 @@ public class FeatureSettings extends JPanel close(); } }); - ok.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - ok.setText("OK"); + ok.setFont(JvSwingUtils.getLabelFont()); + ok.setText(MessageManager.getString("action.ok")); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -952,8 +1008,8 @@ public class FeatureSettings extends JPanel close(); } }); - loadColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - loadColours.setText("Load Colours"); + loadColours.setFont(JvSwingUtils.getLabelFont()); + loadColours.setText(MessageManager.getString("label.load_colours")); loadColours.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -961,8 +1017,8 @@ public class FeatureSettings extends JPanel load(); } }); - saveColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - saveColours.setText("Save Colours"); + saveColours.setFont(JvSwingUtils.getLabelFont()); + saveColours.setText(MessageManager.getString("label.save_colours")); saveColours.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -980,7 +1036,7 @@ public class FeatureSettings extends JPanel }); transparency.setMaximum(70); - fetchDAS.setText("Fetch DAS Features"); + fetchDAS.setText(MessageManager.getString("label.fetch_das_features")); fetchDAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -988,7 +1044,7 @@ public class FeatureSettings extends JPanel fetchDAS_actionPerformed(e); } }); - saveDAS.setText("Save as default"); + saveDAS.setText(MessageManager.getString("action.save_as_default")); saveDAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -999,7 +1055,7 @@ public class FeatureSettings extends JPanel dasButtonPanel.setBorder(BorderFactory.createEtchedBorder()); dasSettingsPane.setBorder(null); cancelDAS.setEnabled(false); - cancelDAS.setText("Cancel Fetch"); + cancelDAS.setText(MessageManager.getString("action.cancel_fetch")); cancelDAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -1122,33 +1178,34 @@ public class FeatureSettings extends JPanel private String[] getDisplayedFeatureGroups() { String[] gps = null; + ArrayList _gps = new ArrayList(); if (fr != null) { if (fr.featureGroups != null) { - Enumeration en = fr.featureGroups.keys(); - gps = new String[fr.featureColours.size()]; + Iterator en = fr.featureGroups.keySet().iterator(); int g = 0; boolean valid = false; - while (en.hasMoreElements()) + while (en.hasNext()) { - String gp = (String) en.nextElement(); + String gp = (String) en.next(); Boolean on = (Boolean) fr.featureGroups.get(gp); if (on != null && on.booleanValue()) { valid = true; - gps[g++] = gp; + _gps.add(gp); } } - while (g < gps.length) - { - gps[g++] = null; - } if (!valid) { return null; } + else + { + gps = new String[_gps.size()]; + _gps.toArray(gps); + } } } return gps; @@ -1158,6 +1215,7 @@ public class FeatureSettings extends JPanel { fetchDAS.setEnabled(false); cancelDAS.setEnabled(true); + dassourceBrowser.setGuiEnabled(false); Vector selectedSources = dassourceBrowser.getSelectedSources(); doDasFeatureFetch(selectedSources, true, true); } @@ -1169,7 +1227,7 @@ public class FeatureSettings extends JPanel * @param checkDbRefs * @param promptFetchDbRefs */ - private void doDasFeatureFetch(Vector selectedSources, + private void doDasFeatureFetch(List selectedSources, boolean checkDbRefs, boolean promptFetchDbRefs) { SequenceI[] dataset, seqs; @@ -1217,9 +1275,9 @@ public class FeatureSettings extends JPanel * Vector of Strings to resolve to DAS source nicknames. * @return sources that are present in source list. */ - public Vector resolveSourceNicknames(Vector sources) + public List resolveSourceNicknames(Vector sources) { - return dassourceBrowser.resolveSourceNicknames(sources); + return dassourceBrowser.sourceRegistry.resolveSourceNicknames(sources); } /** @@ -1245,14 +1303,15 @@ public class FeatureSettings extends JPanel public void fetchDasFeatures(Vector sources, boolean block) { initDasSources(); - Vector resolved = resolveSourceNicknames(sources); + List resolved = dassourceBrowser.sourceRegistry + .resolveSourceNicknames(sources); if (resolved.size() == 0) { resolved = dassourceBrowser.getSelectedSources(); } if (resolved.size() > 0) { - final Vector dassources = resolved; + final List dassources = resolved; fetchDAS.setEnabled(false); // cancelDAS.setEnabled(true); doDasFetch does this. Runnable fetcher = new Runnable() @@ -1285,6 +1344,8 @@ public class FeatureSettings extends JPanel { fetchDAS.setEnabled(true); cancelDAS.setEnabled(false); + dassourceBrowser.setGuiEnabled(true); + } public void cancelDAS_actionPerformed(ActionEvent e) @@ -1293,18 +1354,21 @@ public class FeatureSettings extends JPanel { dasFeatureFetcher.cancel(); } - fetchDAS.setEnabled(true); - cancelDAS.setEnabled(false); + complete(); } public void noDasSourceActive() { complete(); - JOptionPane.showInternalConfirmDialog(Desktop.desktop, - "No das sources were selected.\n" - + "Please select some sources and\n" + " try again.", - "No Sources Selected", JOptionPane.DEFAULT_OPTION, - JOptionPane.INFORMATION_MESSAGE); + JOptionPane + .showInternalConfirmDialog( + Desktop.desktop, + MessageManager + .getString("label.no_das_sources_selected_warn"), + MessageManager + .getString("label.no_das_sources_selected_title"), + JOptionPane.DEFAULT_OPTION, + JOptionPane.INFORMATION_MESSAGE); } // /////////////////////////////////////////////////////////////////////// @@ -1583,7 +1647,7 @@ class FeatureIcon implements Icon // width/g.getFontMetrics().stringWidth("Label"), // height/g.getFontMetrics().getHeight()))); - g.drawString("Label", 0, 0); + g.drawString(MessageManager.getString("label.label"), 0, 0); } else