/*
- * 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.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, 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 <http://www.gnu.org/licenses/>.
*/
package jalview.gui;
import javax.swing.table.*;
import jalview.analysis.AlignmentSorter;
+import jalview.bin.Cache;
import jalview.commands.OrderCommand;
import jalview.datamodel.*;
import jalview.io.*;
scrollPane.setViewportView(table);
- dassourceBrowser = new DasSourceBrowser();
+ dassourceBrowser = new DasSourceBrowser(this);
dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER);
if (af.getViewport().featuresDisplayed == null
frame = new JInternalFrame();
frame.setContentPane(this);
- Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 450);
+ 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()
{
javax.swing.event.InternalFrameEvent evt)
{
fr.removePropertyChangeListener(change);
+ dassourceBrowser.fs = null;
};
});
frame.setLayer(JLayeredPane.PALETTE_LAYER);
InputStreamReader in = new InputStreamReader(new FileInputStream(
file), "UTF-8");
- jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours();
- jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in);
+ jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours();
+ jucs = (jalview.schemabinding.version2.JalviewUserColours) jucs
+ .unmarshal(in);
for (int i = jucs.getColourCount() - 1; i >= 0; i--)
{
String name;
- // TODO: update Colour XML
- fr.setColour(name = jucs.getColour(i).getName(), new Color(
- Integer.parseInt(jucs.getColour(i).getRGB(), 16)));
+ jalview.schemabinding.version2.Colour newcol = jucs.getColour(i);
+ if (newcol.hasMax())
+ {
+ 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);
+ }
+ GraduatedColor gcol = new GraduatedColor(mincol, maxcol, newcol
+ .getMin(), newcol.getMax());
+ if (newcol.hasAutoScale())
+ {
+ gcol.setAutoScaled(newcol.getAutoScale());
+ }
+ if (newcol.hasColourByLabel())
+ {
+ gcol.setColourByLabel(newcol.getColourByLabel());
+ }
+ if (newcol.hasThreshold())
+ {
+ gcol.setThresh(newcol.getThreshold());
+ gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD); // default
+ }
+ if (newcol.getThreshType().length() > 0)
+ {
+ String ttyp = newcol.getThreshType();
+ if (ttyp.equalsIgnoreCase("NONE"))
+ {
+ gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD);
+ }
+ if (ttyp.equalsIgnoreCase("ABOVE"))
+ {
+ gcol
+ .setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
+ }
+ if (ttyp.equalsIgnoreCase("BELOW"))
+ {
+ gcol
+ .setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
+ }
+ }
+ fr.setColour(name = newcol.getName(), gcol);
+ }
+ else
+ {
+ fr.setColour(name = jucs.getColour(i).getName(), new Color(
+ Integer.parseInt(jucs.getColour(i).getRGB(), 16)));
+ }
fr.setOrder(name, (i == 0) ? 0 : i / jucs.getColourCount());
}
if (table != null)
if (value == JalviewFileChooser.APPROVE_OPTION)
{
String choice = chooser.getSelectedFile().getPath();
- jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours();
+ jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours();
ucs.setSchemeName("Sequence Features");
try
{
}
jalview.util.QuickSort.sort(sortOrder, sortTypes);
sortOrder = null;
+ Object fcol;
+ GraduatedColor gcol;
for (i = 0; i < sortTypes.length; i++)
{
- jalview.binding.Colour col = new jalview.binding.Colour();
+ jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
col.setName(sortTypes[i]);
col.setRGB(jalview.util.Format.getHexString(fr.getColour(col
.getName())));
+ fcol = fr.getFeatureStyle(sortTypes[i]);
+ if (fcol instanceof GraduatedColor)
+ {
+ gcol = (GraduatedColor) fcol;
+ col.setMin(gcol.getMin());
+ col.setMax(gcol.getMax());
+ col.setMinRGB(jalview.util.Format.getHexString(gcol
+ .getMinColor()));
+ col.setAutoScale(gcol.isAutoScale());
+ col.setThreshold(gcol.getThresh());
+ col.setColourByLabel(gcol.isColourByLabel());
+ switch (gcol.getThreshType())
+ {
+ case AnnotationColourGradient.NO_THRESHOLD:
+ col.setThreshType("NONE");
+ break;
+ case AnnotationColourGradient.ABOVE_THRESHOLD:
+ col.setThreshType("ABOVE");
+ break;
+ case AnnotationColourGradient.BELOW_THRESHOLD:
+ col.setThreshType("BELOW");
+ break;
+ }
+ }
ucs.addColour(col);
}
ucs.marshal(out);
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();
{
fetchDAS.setEnabled(false);
cancelDAS.setEnabled(true);
+ dassourceBrowser.setGuiEnabled(false);
Vector selectedSources = dassourceBrowser.getSelectedSources();
doDasFeatureFetch(selectedSources, true, true);
}
{
fetchDAS.setEnabled(true);
cancelDAS.setEnabled(false);
+ dassourceBrowser.setGuiEnabled(true);
+
}
public void cancelDAS_actionPerformed(ActionEvent e)
{
dasFeatureFetcher.cancel();
}
- fetchDAS.setEnabled(true);
- cancelDAS.setEnabled(false);
+ complete();
}
public void noDasSourceActive()
public ColorRenderer()
{
setOpaque(true); // MUST do this for background to show up.
+ setHorizontalTextPosition(SwingConstants.CENTER);
+ setVerticalTextPosition(SwingConstants.CENTER);
}
public Component getTableCellRendererComponent(JTable table,
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);
}
{
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)
{
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()
{
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);
}
}
}