Changeset 332


Ignore:
Timestamp:
Apr 4, 2012, 1:20:55 PM (5 years ago)
Author:
tim.te.beek@…
Message:

Add a checkbox to toggle whether only expression attributes are displayed

Location:
trunk/expression-data-viewer/src/main/java/nl/nbic/brs/expview
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/expression-data-viewer/src/main/java/nl/nbic/brs/expview/model/AttributeListModel.java

    r329 r332  
    1818        private List<String>    selectableAttributes    = Arrays.asList("");
    1919
     20        /**
     21         * Receive ChangeEvent from PlottingParams to update the selectable attributes based on settings in PlottingParams.
     22         *
     23         * @param event
     24         *            spawned from PlottingParams
     25         */
     26        @Override
     27        public void stateChanged(final ChangeEvent event) {
     28                // Cache the new attributes from plotting params
     29                PlottingParams plottingParams = (PlottingParams) event.getSource();
     30                cacheSelectableAttributes(plottingParams);
     31        }
     32
    2033        private void cacheSelectableAttributes(final PlottingParams plottingParams) {
    2134                // Retrieve selected nodes for selected network
     
    3245
    3346                        // Expression values get an exp suffix in Cytoscape
    34                         if (plottingParams.isOnlyExpressionAttributes() && !attributeName.endsWith("exp"))
     47                        if (plottingParams.getOnlyExpressionAttributes().isSelected() && !attributeName.endsWith("exp"))
    3548                                continue;
    3649
     
    5669
    5770        @Override
    58         public void stateChanged(final ChangeEvent event) {
    59                 // Cache the new attributes from plotting params
    60                 PlottingParams plottingParams = (PlottingParams) event.getSource();
    61                 cacheSelectableAttributes(plottingParams);
    62         }
    63 
    64         @Override
    6571        public int getSize() {
    6672                return selectableAttributes.size();
  • trunk/expression-data-viewer/src/main/java/nl/nbic/brs/expview/model/PlottingParams.java

    r331 r332  
    33import giny.model.GraphObject;
    44
     5import java.awt.event.ItemEvent;
     6import java.awt.event.ItemListener;
    57import java.util.ArrayList;
    68import java.util.List;
     
    911import java.util.TreeSet;
    1012
     13import javax.swing.ButtonModel;
     14import javax.swing.JToggleButton.ToggleButtonModel;
    1115import javax.swing.event.ChangeEvent;
    1216import javax.swing.event.ChangeListener;
     
    2327
    2428@Getter
    25 public class PlottingParams implements ListSelectionListener {
    26         NetworkComboBoxModel            networkModel;
    27         AttributeListModel                      attributeModel;
    28         AttributeListSelectionModel     attributeSelectionModel;
    29         boolean                                         onlyExpressionAttributes;
     29public class PlottingParams implements ItemListener, ListSelectionListener {
     30        NetworkComboBoxModel            networkModel                            = new NetworkComboBoxModel();
     31        ButtonModel                                     onlyExpressionAttributes        = new ToggleButtonModel();
     32        AttributeListModel                      attributeModel                          = new AttributeListModel();
     33        AttributeListSelectionModel     attributeSelectionModel         = new AttributeListSelectionModel();
    3034
    31         DefaultCategoryDataset          dataset = new DefaultCategoryDataset();
     35        DefaultCategoryDataset          dataset                                         = new DefaultCategoryDataset();
    3236
    3337        public PlottingParams() {
    3438                // Maintain network selection
    35                 networkModel = new NetworkComboBoxModel();
    3639                networkModel.addListSelectionListener(this);
    3740
     41                //
     42                onlyExpressionAttributes.addItemListener(this);
     43
    3844                // Maintain list of selectable attributes that can be plotted
    39                 attributeModel = new AttributeListModel();
    4045                addChangeListener(attributeModel);
    41                 // XXX This changeEvent only works the first time: we need to listen to changes in node selection
     46                // XXX This changeEvent only works the first time: we also need to listen to changes in node selection
    4247                attributeModel.stateChanged(new ChangeEvent(this));
    4348                // Cytoscape.SELECT_NODES_ONLY;
    4449
    4550                // Maintain list of selected attributes to plot
    46                 attributeSelectionModel = new AttributeListSelectionModel();
     51                // TODO When attributeModel changes, so must the selected columns, preferably without losing selections
    4752                attributeSelectionModel.addListSelectionListener(this);
    48 
    49                 // Flags to filter selectable attributes
    50                 onlyExpressionAttributes = true;
    5153        }
    5254
     
    6870
    6971        @Override
     72        public void itemStateChanged(final ItemEvent e) {
     73                anyUpdate();
     74        }
     75
     76        @Override
    7077        public void valueChanged(final ListSelectionEvent event) {
    7178                if (event.getValueIsAdjusting())
    7279                        return;
     80                anyUpdate();
     81        }
    7382
     83        /**
     84         * When any of the elements we are listening to through various Listening interfaces, this method should be called.
     85         */
     86        private void anyUpdate() {
    7487                // FIXME Calling this here means it all runs on the EventDispatchThread. Might not perform well with large data
    7588                // Update values in dataset
     
    8093        }
    8194
     95        /**
     96         * Clear the previous values in the JFreeChart dataset, and write the new values into the dataset.
     97         * The dataset itself takes care to notify the ChartPanel to update the chart in response to changes.
     98         */
    8299        private void updateDataset() {
    83100                // Clear dataset to remove previously plotted data
  • trunk/expression-data-viewer/src/main/java/nl/nbic/brs/expview/view/PlotDialog.java

    r330 r332  
    66import javax.swing.GroupLayout.ParallelGroup;
    77import javax.swing.GroupLayout.SequentialGroup;
     8import javax.swing.JCheckBox;
    89import javax.swing.JComboBox;
    910import javax.swing.JDialog;
     
    2122        private PlottingParams  plottingParams  = new PlottingParams();
    2223
    23         private ChartPanel              chartPanel;
    2424        private JComboBox               networkCombobox;
     25
     26        private JCheckBox               expressionOnlyCheckbox;
    2527
    2628        private JList                   attributesList;
    2729        private JScrollPane             attributesListPane;
     30
     31        private ChartPanel              chartPanel;
    2832
    2933        public PlotDialog(final Frame owner) {
     
    3741                // TODO Add better guesses for these labels
    3842                // TODO Improve the plot graphics, subtitle, hide advertisement, etc
    39                 // TODO Make the plot interactive to for instance toggle specific plot lines
     43                // TODO Make the plot itself interactive to for instance toggle specific plot lines by clicking on them
    4044                String title = "title";
    4145                String categoryAxisLabel = "attributes";
     
    5256                attributesList.setVisibleRowCount(5);
    5357                attributesListPane = new JScrollPane(attributesList);
     58
     59                // Toggle whether only expression attributes are show in attribute selection, or all numerical attributes
     60                expressionOnlyCheckbox = new JCheckBox("Only show expression attributes");
     61                expressionOnlyCheckbox.setModel(plottingParams.getOnlyExpressionAttributes());
    5462        }
    5563
     
    6270                ParallelGroup horizontalControlsGroup = layout.createParallelGroup();
    6371                horizontalControlsGroup.addComponent(networkCombobox);
     72                horizontalControlsGroup.addComponent(expressionOnlyCheckbox);
    6473                horizontalControlsGroup.addComponent(attributesListPane);
    6574
     
    7483                SequentialGroup verticalControlsGroup = layout.createSequentialGroup();
    7584                verticalControlsGroup.addComponent(networkCombobox);
     85                verticalControlsGroup.addComponent(expressionOnlyCheckbox);
    7686                verticalControlsGroup.addComponent(attributesListPane);
    7787
Note: See TracChangeset for help on using the changeset viewer.