Search in sources :

Example 1 with Transform

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform in project EnrichmentMapApp by BaderLab.

the class HeatMapMainPanel method createToolbarPanel.

private JPanel createToolbarPanel() {
    gradientLegendPanel = new GradientLegendPanel(table);
    showValuesCheck = new JCheckBox("Show Values");
    JLabel operatorLabel = new JLabel("Genes:");
    operatorCombo = new JComboBox<>();
    JLabel normLabel = new JLabel("Expressions:");
    normCombo = new JComboBox<>();
    SwingUtil.makeSmall(operatorLabel, operatorCombo, normLabel, normCombo, showValuesCheck);
    operatorCombo.addItem(new ComboItem<>(Operator.UNION, "Union"));
    operatorCombo.addItem(new ComboItem<>(Operator.INTERSECTION, "Intersection"));
    operatorCombo.setSelectedItem(ComboItem.of(Operator.UNION));
    normCombo.addItem(new ComboItem<>(Transform.AS_IS, "Expression Values"));
    normCombo.addItem(new ComboItem<>(Transform.ROW_NORMALIZE, "Row Normalize"));
    normCombo.addItem(new ComboItem<>(Transform.LOG_TRANSFORM, "Log Transform"));
    normCombo.addItem(new ComboItem<>(Transform.COMPRESS_MEDIAN, "Compress (Median)"));
    normCombo.addItem(new ComboItem<>(Transform.COMPRESS_MIN, "Compress (Min)"));
    normCombo.addItem(new ComboItem<>(Transform.COMPRESS_MAX, "Compress (Max)"));
    normCombo.setSelectedItem(ComboItem.of(Transform.COMPRESS_MEDIAN));
    operatorCombo.addActionListener(operatorActionListener = e -> updateSetting_Operator(getOperator()));
    normCombo.addActionListener(normActionListener = e -> updateSetting_Transform(getTransform()));
    showValuesCheck.addActionListener(showValueActionListener = e -> updateSetting_ShowValues(isShowValues()));
    JButton plusButton = SwingUtil.createIconButton(iconManager, IconManager.ICON_PLUS, "Add Rankings...");
    JButton gearButton = SwingUtil.createIconButton(iconManager, IconManager.ICON_GEAR, "Settings");
    JButton menuButton = SwingUtil.createIconButton(iconManager, IconManager.ICON_EXTERNAL_LINK, "Export");
    LookAndFeelUtil.equalizeSize(gearButton, menuButton);
    plusButton.addActionListener(e -> addRankings());
    gearButton.addActionListener(e -> settingsPanel.popup(gearButton));
    menuButton.addActionListener(this::showExportMenu);
    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(false);
    layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
    layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(gradientLegendPanel, 180, 180, 180).addGap(0, 0, Short.MAX_VALUE).addComponent(operatorLabel).addComponent(operatorCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGap(5).addComponent(normLabel).addComponent(normCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGap(5).addComponent(showValuesCheck).addGap(5).addComponent(plusButton).addComponent(gearButton).addComponent(menuButton));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(gradientLegendPanel).addComponent(operatorLabel).addComponent(operatorCombo).addComponent(normLabel).addComponent(normCombo).addComponent(showValuesCheck).addComponent(plusButton).addComponent(gearButton).addComponent(menuButton));
    panel.setOpaque(false);
    return panel;
}
Also used : JCheckBox(javax.swing.JCheckBox) Arrays(java.util.Arrays) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) Operator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Operator) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) IconManager(org.cytoscape.util.swing.IconManager) Assisted(com.google.inject.assistedinject.Assisted) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) Map(java.util.Map) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) DEFAULT_SIZE(javax.swing.GroupLayout.DEFAULT_SIZE) Set(java.util.Set) ColorAndValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorAndValueRenderer) Distance(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Distance) Component(java.awt.Component) Collectors(java.util.stream.Collectors) TableRowSorter(javax.swing.table.TableRowSorter) Sets(com.google.common.collect.Sets) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) ColumnHeaderRankOptionRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderRankOptionRenderer) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) ActionListener(java.awt.event.ActionListener) TableColumnModel(javax.swing.table.TableColumnModel) SortKey(javax.swing.RowSorter.SortKey) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CompletableFuture(java.util.concurrent.CompletableFuture) GradientLegendPanel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.GradientLegendPanel) ArrayList(java.util.ArrayList) SwingUtilities(javax.swing.SwingUtilities) EMStyleBuilder(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder) JButton(javax.swing.JButton) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) ActionEvent(java.awt.event.ActionEvent) RankOptionErrorHeader(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader) RankValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValueRenderer) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ColorRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorRenderer) Comparator(java.util.Comparator) JPanel(javax.swing.JPanel) GradientLegendPanel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.GradientLegendPanel) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel)

Example 2 with Transform

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform in project EnrichmentMapApp by BaderLab.

the class ColorRenderer method getTableCellRendererComponent.

public JLabel getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    JLabel label = new JLabel();
    //MUST do this for background to show up.
    label.setOpaque(true);
    HeatMapTableModel model = (HeatMapTableModel) table.getModel();
    EMDataSet dataset = model.getDataSet(col);
    Transform transform = model.getTransform();
    DataSetColorRange range = getRange(dataset, transform);
    if (value instanceof Double) {
        Color color = getColor(range.getTheme(), range.getRange(), (Double) value);
        label.setBackground(color);
        Border border = BorderFactory.createMatteBorder(1, 1, 1, 1, isSelected ? table.getSelectionForeground() : color);
        label.setBorder(border);
        if (Double.isFinite((Double) value))
            label.setToolTipText(value.toString());
    }
    return label;
}
Also used : Color(java.awt.Color) JLabel(javax.swing.JLabel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) Border(javax.swing.border.Border)

Aggregations

JLabel (javax.swing.JLabel)2 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)2 Transform (org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform)2 Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 Assisted (com.google.inject.assistedinject.Assisted)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Component (java.awt.Component)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1