X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureSettings.java;h=18d17f4329c0ca65a6c55eb271243a677d97c26d;hb=bfa1ec36b19342ccdced621509f78dc527c3ad18;hp=7bf291de3d8bd9e5968e8ec6cb4328e7db127c0c;hpb=0e5bdbba50619f3c626b14c7f1cd2261e0552440;p=jalview.git diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 7bf291d..18d17f4 100755 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) - * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * - * 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 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * 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 . */ package jalview.gui; @@ -135,7 +134,7 @@ public class FeatureSettings extends JPanel scrollPane.setViewportView(table); - dassourceBrowser = new DasSourceBrowser(); + dassourceBrowser = new DasSourceBrowser(this); dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER); if (af.getViewport().featuresDisplayed == null @@ -164,16 +163,24 @@ 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, "Sequence Feature Settings", 475, 480); + } + else + { + 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); + dassourceBrowser.fs = null; + }; + }); frame.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -273,8 +280,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); } } } @@ -305,15 +313,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() + 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; @@ -398,8 +406,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) { @@ -434,10 +442,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) { @@ -513,8 +521,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); } @@ -588,10 +596,10 @@ 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"); @@ -608,29 +616,28 @@ public class FeatureSettings extends JPanel file), "UTF-8"); jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours(); - jucs = (jalview.schemabinding.version2.JalviewUserColours) jucs.unmarshal(in); - + jucs = (jalview.schemabinding.version2.JalviewUserColours) jucs + .unmarshal(in); + for (int i = jucs.getColourCount() - 1; i >= 0; i--) { String name; jalview.schemabinding.version2.Colour newcol = jucs.getColour(i); if (newcol.hasMax()) { - Color mincol=null,maxcol=null; - float thrsh=Float.NaN; - try { - mincol = new Color( - Integer.parseInt(newcol.getMinRGB(), 16)); - maxcol = new Color( - Integer.parseInt(newcol.getRGB(), 16)); - + Color mincol = null, maxcol = null; + try + { + mincol = new Color(Integer.parseInt(newcol.getMinRGB(), 16)); + maxcol = new Color(Integer.parseInt(newcol.getRGB(), 16)); + } catch (Exception e) { - Cache.log.warn("Couldn't parse out graduated feature color.",e); + 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()); @@ -644,24 +651,28 @@ public class FeatureSettings extends JPanel gcol.setThresh(newcol.getThreshold()); gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD); // default } - if (newcol.getThreshType().length()>0) + if (newcol.getThreshType().length() > 0) { String ttyp = newcol.getThreshType(); - if (ttyp.equalsIgnoreCase("NONE")) { + if (ttyp.equalsIgnoreCase("NONE")) + { gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD); } if (ttyp.equalsIgnoreCase("ABOVE")) { gcol.setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD); } - if (ttyp.equalsIgnoreCase("BELOW")){ + if (ttyp.equalsIgnoreCase("BELOW")) + { gcol.setThreshType(AnnotationColourGradient.BELOW_THRESHOLD); - } + } } fr.setColour(name = newcol.getName(), gcol); - } else { + } + else + { fr.setColour(name = jucs.getColour(i).getName(), new Color( - Integer.parseInt(jucs.getColour(i).getRGB(), 16))); + Integer.parseInt(jucs.getColour(i).getRGB(), 16))); } fr.setOrder(name, (i == 0) ? 0 : i / jucs.getColourCount()); } @@ -683,10 +694,10 @@ 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"); @@ -893,7 +904,7 @@ 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.setFont(JvSwingUtils.getLabelFont()); invert.setText("Invert Selection"); invert.addActionListener(new ActionListener() { @@ -902,7 +913,7 @@ public class FeatureSettings extends JPanel invertSelection(); } }); - optimizeOrder.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + optimizeOrder.setFont(JvSwingUtils.getLabelFont()); optimizeOrder.setText("Optimise Order"); optimizeOrder.addActionListener(new ActionListener() { @@ -911,7 +922,7 @@ public class FeatureSettings extends JPanel orderByAvWidth(); } }); - sortByScore.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + sortByScore.setFont(JvSwingUtils.getLabelFont()); sortByScore.setText("Seq sort by Score"); sortByScore.addActionListener(new ActionListener() { @@ -920,7 +931,7 @@ public class FeatureSettings extends JPanel sortByScore(null); } }); - sortByDens.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + sortByDens.setFont(JvSwingUtils.getLabelFont()); sortByDens.setText("Seq Sort by density"); sortByDens.addActionListener(new ActionListener() { @@ -929,7 +940,7 @@ public class FeatureSettings extends JPanel sortByDens(null); } }); - cancel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + cancel.setFont(JvSwingUtils.getLabelFont()); cancel.setText("Cancel"); cancel.addActionListener(new ActionListener() { @@ -939,7 +950,7 @@ public class FeatureSettings extends JPanel close(); } }); - ok.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + ok.setFont(JvSwingUtils.getLabelFont()); ok.setText("OK"); ok.addActionListener(new ActionListener() { @@ -948,7 +959,7 @@ public class FeatureSettings extends JPanel close(); } }); - loadColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + loadColours.setFont(JvSwingUtils.getLabelFont()); loadColours.setText("Load Colours"); loadColours.addActionListener(new ActionListener() { @@ -957,7 +968,7 @@ public class FeatureSettings extends JPanel load(); } }); - saveColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + saveColours.setFont(JvSwingUtils.getLabelFont()); saveColours.setText("Save Colours"); saveColours.addActionListener(new ActionListener() { @@ -1041,18 +1052,30 @@ public class FeatureSettings extends JPanel gps = getDisplayedFeatureGroups(); if (typ != null) { + ArrayList types = new ArrayList(); for (int i = 0; i < typ.length; i++) { - System.err.println("Sorting on Types:" + typ[i]); + if (typ[i] != null) + { + types.add(typ[i]); + } + typ = new String[types.size()]; + types.toArray(typ); } } if (gps != null) { + ArrayList grps = new ArrayList(); for (int i = 0; i < gps.length; i++) { - System.err.println("Sorting on groups:" + gps[i]); + if (gps[i] != null) + { + grps.add(gps[i]); + } } + gps = new String[grps.size()]; + grps.toArray(gps); } AlignmentPanel alignPanel = af.alignPanel; AlignmentI al = alignPanel.av.getAlignment(); @@ -1142,6 +1165,7 @@ public class FeatureSettings extends JPanel { fetchDAS.setEnabled(false); cancelDAS.setEnabled(true); + dassourceBrowser.setGuiEnabled(false); Vector selectedSources = dassourceBrowser.getSelectedSources(); doDasFeatureFetch(selectedSources, true, true); } @@ -1269,6 +1293,8 @@ public class FeatureSettings extends JPanel { fetchDAS.setEnabled(true); cancelDAS.setEnabled(false); + dassourceBrowser.setGuiEnabled(true); + } public void cancelDAS_actionPerformed(ActionEvent e) @@ -1277,8 +1303,7 @@ public class FeatureSettings extends JPanel { dasFeatureFetcher.cancel(); } - fetchDAS.setEnabled(true); - cancelDAS.setEnabled(false); + complete(); } public void noDasSourceActive() @@ -1371,6 +1396,8 @@ public class FeatureSettings extends JPanel public ColorRenderer() { setOpaque(true); // MUST do this for background to show up. + setHorizontalTextPosition(SwingConstants.CENTER); + setVerticalTextPosition(SwingConstants.CENTER); } public Component getTableCellRendererComponent(JTable table, @@ -1452,22 +1479,28 @@ public class FeatureSettings extends JPanel public static void renderGraduatedColor(JLabel comp, GraduatedColor gcol, int w, int h) { - + boolean thr = false; String tt = ""; String tx = ""; if (gcol.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD) { - tx += "> "; + thr = true; + tx += ">"; tt += "Thresholded (Above " + gcol.getThresh() + ") "; } if (gcol.getThreshType() == AnnotationColourGradient.BELOW_THRESHOLD) { - tx += "< "; + thr = true; + tx += "<"; tt += "Thresholded (Below " + gcol.getThresh() + ") "; } if (gcol.isColourByLabel()) { tt = "Coloured by label text. " + tt; + if (thr) + { + tx += " "; + } tx += "Label"; comp.setIcon(null); } @@ -1475,14 +1508,15 @@ public class FeatureSettings extends JPanel { Color newColor = gcol.getMaxColor(); comp.setBackground(newColor); - System.err.println("Width is " + w / 2); - Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w / 2, h); + // System.err.println("Width is " + w / 2); + Icon ficon = new FeatureIcon(gcol, comp.getBackground(), w, h, thr); comp.setIcon(ficon); // tt+="RGB value: Max (" + newColor.getRed() + ", " // + newColor.getGreen() + ", " + newColor.getBlue() // + ")\nMin (" + minCol.getRed() + ", " + minCol.getGreen() // + ", " + minCol.getBlue() + ")"); } + comp.setHorizontalAlignment(SwingConstants.CENTER); comp.setText(tx); if (tt.length() > 0) { @@ -1504,14 +1538,31 @@ class FeatureIcon implements Icon Color backg; + boolean midspace = false; + int width = 50, height = 20; - FeatureIcon(GraduatedColor gfc, Color bg, int w, int h) + int s1, e1; // start and end of midpoint band for thresholded symbol + + Color mpcolour = Color.white; + + FeatureIcon(GraduatedColor gfc, Color bg, int w, int h, boolean mspace) { gcol = gfc; backg = bg; width = w; height = h; + midspace = mspace; + if (midspace) + { + s1 = width / 3; + e1 = s1 * 2; + } + else + { + s1 = width / 2; + e1 = s1; + } } public int getIconWidth() @@ -1548,7 +1599,14 @@ class FeatureIcon implements Icon { Color minCol = gcol.getMinColor(); g.setColor(minCol); - g.fillRect(0, 0, width, height); + g.fillRect(0, 0, s1, height); + if (midspace) + { + g.setColor(Color.white); + g.fillRect(s1, 0, e1 - s1, height); + } + g.setColor(gcol.getMaxColor()); + g.fillRect(0, e1, width - e1, height); } } }