*/
package jalview.appletgui;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.COLOUR_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.SHOW_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.TYPE_COLUMN;
-
import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsControllerI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import java.awt.BorderLayout;
import java.awt.Button;
implements ItemListener, MouseListener, MouseMotionListener,
ActionListener, AdjustmentListener, FeatureSettingsControllerI
{
+ private static final int TYPE_COLUMN = 0;
+
+ private static final int COLOUR_COLUMN = 1;
+
+ private static final int SHOW_COLUMN = 2;
+
FeatureRenderer fr;
AlignmentPanel ap;
Object[][] data = new Object[tmpSize][columnCount];
System.arraycopy(tmp, 0, data, 0, tmpSize);
- fr.setFeaturePriority(data);
+ fr.setFeaturePriority(getTableAsBeans(data));
ap.paintAlignment(updateOverview, updateOverview);
}
+ /**
+ * Converts table data into an array of data beans
+ */
+ private FeatureSettingsBean[] getTableAsBeans(Object[][] data)
+ {
+ FeatureSettingsBean[] rowData = new FeatureSettingsBean[data.length];
+ for (int i = 0; i < data.length; i++)
+ {
+ String type = (String) data[i][TYPE_COLUMN];
+ FeatureColourI colour = (FeatureColourI) data[i][COLOUR_COLUMN];
+ Boolean isShown = (Boolean) data[i][SHOW_COLUMN];
+ // feature filter set to null as not (yet) offered in applet
+ rowData[i] = new FeatureSettingsBean(type, colour, null, isShown);
+ }
+ return rowData;
+ }
MyCheckbox selectedCheck;
boolean dragging = false;
*/
package jalview.gui;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.COLOUR_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.FILTER_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.SHOW_COLUMN;
-import static jalview.viewmodel.seqfeatures.FeatureRendererModel.TYPE_COLUMN;
+import static jalview.gui.FeatureSettings.FeatureTableModel.COLOUR_COLUMN;
+import static jalview.gui.FeatureSettings.FeatureTableModel.FILTER_COLUMN;
+import static jalview.gui.FeatureSettings.FeatureTableModel.SHOW_COLUMN;
+import static jalview.gui.FeatureSettings.FeatureTableModel.TYPE_COLUMN;
import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsControllerI;
import jalview.util.matcher.KeyedMatcherSet;
import jalview.util.matcher.KeyedMatcherSetI;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import jalview.ws.DasSequenceFeatureFetcher;
import jalview.ws.dbsources.das.api.jalviewSourceI;
{
private static final int COLUMN_COUNT = 4;
- private static final String COLON = ":";
-
private static final int MIN_WIDTH = 400;
private static final int MIN_HEIGHT = 400;
- private static final int MAX_TOOLTIP_LENGTH = 50;
-
DasSourceBrowser dassourceBrowser;
DasSequenceFeatureFetcher dasFeatureFetcher;
*/
private void updateFeatureRenderer(Object[][] data, boolean visibleNew)
{
- if (fr.setFeaturePriority(data, visibleNew))
+ FeatureSettingsBean[] rowData = getTableAsBeans(data);
+
+ if (fr.setFeaturePriority(rowData, visibleNew))
{
af.alignPanel.paintAlignment(true, true);
}
}
+ /**
+ * Converts table data into an array of data beans
+ */
+ private FeatureSettingsBean[] getTableAsBeans(Object[][] data)
+ {
+ FeatureSettingsBean[] rowData = new FeatureSettingsBean[data.length];
+ for (int i = 0; i < data.length; i++)
+ {
+ String type = (String) data[i][TYPE_COLUMN];
+ FeatureColourI colour = (FeatureColourI) data[i][COLOUR_COLUMN];
+ KeyedMatcherSetI theFilter = (KeyedMatcherSetI) data[i][FILTER_COLUMN];
+ Boolean isShown = (Boolean) data[i][SHOW_COLUMN];
+ rowData[i] = new FeatureSettingsBean(type, colour, theFilter,
+ isShown);
+ }
+ return rowData;
+ }
+
private void jbInit() throws Exception
{
this.setLayout(new BorderLayout());
// ///////////////////////////////////////////////////////////////////////
class FeatureTableModel extends AbstractTableModel
{
+ /*
+ * column indices of fields in Feature Settings table
+ */
+ static final int TYPE_COLUMN = 0;
+
+ static final int COLOUR_COLUMN = 1;
+
+ static final int FILTER_COLUMN = 2;
+
+ static final int SHOW_COLUMN = 3;
private String[] columnNames = {
MessageManager.getString("label.feature_type"),
implements jalview.api.FeatureRenderer
{
/*
- * column indices of fields in Feature Settings table
- * todo: transfer valuers as data beans instead of Object[][]
+ * a data bean to hold one row of feature settings from the gui
*/
- public static final int TYPE_COLUMN = 0;
+ public static class FeatureSettingsBean
+ {
+ public final String featureType;
+
+ public final FeatureColourI featureColour;
- public static final int COLOUR_COLUMN = 1;
+ public final KeyedMatcherSetI filter;
- public static final int FILTER_COLUMN = 2;
+ public final Boolean show;
- public static final int SHOW_COLUMN = 3;
+ public FeatureSettingsBean(String type, FeatureColourI colour,
+ KeyedMatcherSetI theFilter, Boolean isShown)
+ {
+ featureType = type;
+ featureColour = colour;
+ filter = theFilter;
+ show = isShown;
+ }
+ }
/*
* global transparency for feature
* Replace current ordering with new ordering
*
* @param data
- * { String(Type), Colour(Type), Boolean(Displayed) }
+ * an array of { Type, Colour, Filter, Boolean }
* @return true if any visible features have been reordered, else false
*/
- public boolean setFeaturePriority(Object[][] data)
+ public boolean setFeaturePriority(FeatureSettingsBean[] data)
{
return setFeaturePriority(data, true);
}
/**
- * Sets the priority order for features, with the highest priority (displayed
- * on top) at the start of the data array
+ * Sets the priority order for features, with the highest priority (displayed on
+ * top) at the start of the data array
*
* @param data
- * { String(Type), Colour(Type), Boolean(Displayed) }
+ * an array of { Type, Colour, Filter, Boolean }
* @param visibleNew
* when true current featureDisplay list will be cleared
- * @return true if any visible features have been reordered or recoloured,
- * else false (i.e. no need to repaint)
+ * @return true if any visible features have been reordered or recoloured, else
+ * false (i.e. no need to repaint)
*/
- public boolean setFeaturePriority(Object[][] data, boolean visibleNew)
+ public boolean setFeaturePriority(FeatureSettingsBean[] data,
+ boolean visibleNew)
{
/*
* note visible feature ordering and colours before update
{
for (int i = 0; i < data.length; i++)
{
- String type = data[i][TYPE_COLUMN].toString();
- setColour(type, (FeatureColourI) data[i][COLOUR_COLUMN]);
- if (((Boolean) data[i][SHOW_COLUMN]).booleanValue())
+ String type = data[i].featureType;
+ setColour(type, data[i].featureColour);
+ if (data[i].show)
{
av_featuresdisplayed.setVisible(type);
}
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import jalview.schemes.FeatureColour;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import java.awt.Color;
import java.util.List;
* - currently no way other than mimicking reordering of
* table in Feature Settings
*/
- Object[][] data = new Object[2][];
- data[0] = new Object[] { "Metal", red, true };
- data[1] = new Object[] { "Domain", green, true };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[2];
+ data[0] = new FeatureSettingsBean("Metal", red, null, true);
+ data[1] = new FeatureSettingsBean("Domain", green, null, true);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.blue, seq, 10);
assertEquals(c, Color.red);
/*
* ..and turn off display of Metal
*/
- data[0][2] = false;
+ data[0] = new FeatureSettingsBean("Metal", red, null, false);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.blue, seq, 10);
assertEquals(c, Color.green);
/*
* turn off display of Metal - is this the easiest way to do it??
*/
- Object[][] data = new Object[1][];
- data[0] = new Object[] { "Metal", red, false };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[1];
+ data[0] = new FeatureSettingsBean("Metal", red, null, false);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.blue, seq, 10);
assertEquals(c, Color.blue);
/*
* turn display of Metal back on
*/
- data[0] = new Object[] { "Metal", red, true };
+ data[0] = new FeatureSettingsBean("Metal", red, null, true);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.blue, seq, 10);
assertEquals(c, Color.red);
* 1) 0.6 * green(0, 255, 0) + 0.4 * cyan(0, 255, 255) = (0, 255, 102)
* 2) 0.6* red(255, 0, 0) + 0.4 * (0, 255, 102) = (153, 102, 41) rounded
*/
- Object[][] data = new Object[2][];
- data[0] = new Object[] { "Metal", red, true };
- data[1] = new Object[] { "Domain", green, true };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[2];
+ data[0] = new FeatureSettingsBean("Metal", red, null, true);
+ data[1] = new FeatureSettingsBean("Domain", green, null, true);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.cyan, seq, 10);
assertEquals(c, new Color(153, 102, 41));
* Domain (green) above background (pink)
* 0.6 * green(0, 255, 0) + 0.4 * pink(255, 175, 175) = (102, 223, 70)
*/
- data[0][2] = false;
+ data[0] = new FeatureSettingsBean("Metal", red, null, false);
fr.setFeaturePriority(data);
c = finder.findFeatureColour(Color.pink, seq, 10);
assertEquals(c, new Color(102, 223, 70));
/*
* turn off display of Metal
*/
- Object[][] data = new Object[1][];
- data[0] = new Object[] { "Metal", red, false };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[1];
+ data[0] = new FeatureSettingsBean("Metal", red, null, false);
fr.setFeaturePriority(data);
assertTrue(finder.noFeaturesDisplayed());
/*
* render order is kd above Metal
*/
- Object[][] data = new Object[2][];
- data[0] = new Object[] { kdFeature, fc, true };
- data[1] = new Object[] { metalFeature, green, true };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[2];
+ data[0] = new FeatureSettingsBean(kdFeature, fc, null, true);
+ data[1] = new FeatureSettingsBean(metalFeature, green, null, true);
fr.setFeaturePriority(data);
av.setShowSequenceFeatures(true);
import jalview.util.matcher.KeyedMatcher;
import jalview.util.matcher.KeyedMatcherSet;
import jalview.util.matcher.KeyedMatcherSetI;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import java.awt.Color;
import java.util.ArrayList;
* change render order (todo: an easier way)
* nb here last comes first in the data array
*/
- Object[][] data = new Object[3][];
+ FeatureSettingsBean[] data = new FeatureSettingsBean[3];
FeatureColourI colour = new FeatureColour(Color.RED);
- data[0] = new Object[] { "Rfam", colour, true };
- data[1] = new Object[] { "Pfam", colour, false };
- data[2] = new Object[] { "Scop", colour, false };
+ data[0] = new FeatureSettingsBean("Rfam", colour, null, true);
+ data[1] = new FeatureSettingsBean("Pfam", colour, null, false);
+ data[2] = new FeatureSettingsBean("Scop", colour, null, false);
fr.setFeaturePriority(data);
assertEquals(fr.getRenderOrder(), Arrays.asList("Scop", "Pfam", "Rfam"));
assertEquals(fr.getDisplayedFeatureTypes(), Arrays.asList("Rfam"));
/*
* make "Type2" not displayed
*/
- Object[][] data = new Object[4][];
FeatureColourI colour = new FeatureColour(Color.RED);
- data[0] = new Object[] { "Type1", colour, true };
- data[1] = new Object[] { "Type2", colour, false };
- data[2] = new Object[] { "Type3", colour, true };
- data[3] = new Object[] { "Disulphide Bond", colour, true };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[4];
+ data[0] = new FeatureSettingsBean("Type1", colour, null, true);
+ data[1] = new FeatureSettingsBean("Type2", colour, null, false);
+ data[2] = new FeatureSettingsBean("Type3", colour, null, true);
+ data[3] = new FeatureSettingsBean("Disulphide Bond", colour, null,
+ true);
fr.setFeaturePriority(data);
features = fr.findFeaturesAtColumn(seq, 15);
/*
* hide feature type, then unhide
*/
- Object[][] data = new Object[1][];
- data[0] = new Object[] { "Cath", fc, false };
+ FeatureSettingsBean[] data = new FeatureSettingsBean[1];
+ data[0] = new FeatureSettingsBean("Cath", fc, null, false);
fr.setFeaturePriority(data);
assertNull(fr.getColour(sf1));
- data[0] = new Object[] { "Cath", fc, true };
+ data[0] = new FeatureSettingsBean("Cath", fc, null, true);
fr.setFeaturePriority(data);
assertEquals(fr.getColour(sf1), Color.red);