From: gmungoc Date: Thu, 23 Nov 2017 10:38:20 +0000 (+0000) Subject: JAL-2808 refactor conversion of table data to beans for controller X-Git-Tag: Release_2_11_0~108 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ebe19c4969f174303e5d98e7d6b09422d0aaf6e3;p=jalview.git JAL-2808 refactor conversion of table data to beans for controller --- diff --git a/src/jalview/appletgui/FeatureSettings.java b/src/jalview/appletgui/FeatureSettings.java index 7db1fbe..ad04171 100755 --- a/src/jalview/appletgui/FeatureSettings.java +++ b/src/jalview/appletgui/FeatureSettings.java @@ -68,12 +68,6 @@ public class FeatureSettings extends Panel 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; @@ -590,47 +584,23 @@ public class FeatureSettings extends Panel { Component[] comps = featurePanel.getComponents(); int cSize = comps.length; - - /* - * temporary! leave column[2] empty - used for Filter in - * gui.FeatureSettings - */ - int columnCount = 4; - Object[][] tmp = new Object[cSize][columnCount]; - int tmpSize = 0; - for (int i = 0; i < cSize; i++) + FeatureSettingsBean[] rowData = new FeatureSettingsBean[cSize]; + int i = 0; + for (Component comp : comps) { - MyCheckbox check = (MyCheckbox) comps[i]; - tmp[tmpSize][TYPE_COLUMN /* 0 */] = check.type; - tmp[tmpSize][COLOUR_COLUMN /* 1 */] = fr.getFeatureStyle(check.type); - tmp[tmpSize][SHOW_COLUMN /* 3 */] = new Boolean(check.getState()); - tmpSize++; + MyCheckbox check = (MyCheckbox) comp; + // feature filter set to null as not (yet) offered in applet + FeatureColourI colour = fr.getFeatureStyle(check.type); + rowData[i] = new FeatureSettingsBean(check.type, colour, null, + check.getState()); + i++; } - Object[][] data = new Object[tmpSize][columnCount]; - System.arraycopy(tmp, 0, data, 0, tmpSize); - - fr.setFeaturePriority(getTableAsBeans(data)); + fr.setFeaturePriority(rowData); 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;