Search in sources :

Example 6 with CyColumnIdentifier

use of org.cytoscape.view.presentation.property.values.CyColumnIdentifier in project cytoscape-impl by cytoscape.

the class RowsSetViewUpdater method isStyleAffected.

/**
 * Check if the columnName is used by any property of the passed Visual Style.
 * @param vs
 * @param columnName
 * @return
 */
private static boolean isStyleAffected(final VisualStyle vs, final String columnName, RenderingEngine<CyNetwork> renderer, CyColumnIdentifierFactory columnIdentifierFactory) {
    boolean result = false;
    if (renderer != null) {
        final CyColumnIdentifier colId = columnIdentifierFactory.createColumnIdentifier(columnName);
        final Set<VisualProperty<?>> properties = renderer.getVisualLexicon().getAllVisualProperties();
        for (final VisualProperty<?> vp : properties) {
            final VisualMappingFunction<?, ?> f = vs.getVisualMappingFunction(vp);
            if (f != null && f.getMappingColumnName().equalsIgnoreCase(columnName)) {
                result = true;
                break;
            }
            final Object defValue = vs.getDefaultValue(vp);
            if (defValue instanceof MappableVisualPropertyValue) {
                final Set<CyColumnIdentifier> mappedColIds = ((MappableVisualPropertyValue) defValue).getMappedColumns();
                if (mappedColIds.contains(colId)) {
                    result = true;
                    break;
                }
            }
        }
    }
    return result;
}
Also used : MappableVisualPropertyValue(org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue) VisualProperty(org.cytoscape.view.model.VisualProperty) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier)

Example 7 with CyColumnIdentifier

use of org.cytoscape.view.presentation.property.values.CyColumnIdentifier in project cytoscape-impl by cytoscape.

the class AbstractChartEditor method getItemLabelsColumnCmb.

protected JComboBox<CyColumnIdentifier> getItemLabelsColumnCmb() {
    if (itemLabelsColumnCmb == null) {
        itemLabelsColumnCmb = new CyColumnComboBox(labelColumns.keySet(), true);
        selectColumnIdItem(itemLabelsColumnCmb, chart.get(ITEM_LABELS_COLUMN, CyColumnIdentifier.class));
        itemLabelsColumnCmb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                final CyColumnIdentifier colId = (CyColumnIdentifier) itemLabelsColumnCmb.getSelectedItem();
                chart.set(ITEM_LABELS_COLUMN, colId != null ? colId.getColumnName() : null);
            }
        });
    }
    return itemLabelsColumnCmb;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier)

Example 8 with CyColumnIdentifier

use of org.cytoscape.view.presentation.property.values.CyColumnIdentifier in project cytoscape-impl by cytoscape.

the class AbstractChartEditor method getDomainLabelsColumnCmb.

protected JComboBox<CyColumnIdentifier> getDomainLabelsColumnCmb() {
    if (domainLabelsColumnCmb == null) {
        domainLabelsColumnCmb = new CyColumnComboBox(labelColumns.keySet(), true);
        selectColumnIdItem(domainLabelsColumnCmb, chart.get(DOMAIN_LABELS_COLUMN, CyColumnIdentifier.class));
        domainLabelsColumnCmb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                final CyColumnIdentifier colId = (CyColumnIdentifier) domainLabelsColumnCmb.getSelectedItem();
                chart.set(DOMAIN_LABELS_COLUMN, colId != null ? colId.getColumnName() : null);
            }
        });
    }
    return domainLabelsColumnCmb;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier)

Example 9 with CyColumnIdentifier

use of org.cytoscape.view.presentation.property.values.CyColumnIdentifier in project cytoscape-impl by cytoscape.

the class PieChartTest method testChartProperties.

@Test
public void testChartProperties() {
    final PieChart chart = new PieChart(props1, serviceRegistrar);
    // The chart properties has to return exactly the same values,
    // except column names, which are converted to CyColumIdentifier when set as String
    Map<String, Object> props2 = chart.getProperties();
    assertEquals(props1.get(DATA_COLUMNS), props2.get(DATA_COLUMNS));
    assertEquals(props1.get(COLOR_SCHEME), props2.get(COLOR_SCHEME));
    assertEquals(props1.get(COLORS), props2.get(COLORS));
    assertEquals(props1.get(BORDER_COLOR), props2.get(BORDER_COLOR));
    assertEquals(props1.get(BORDER_WIDTH), props2.get(BORDER_WIDTH));
    assertEquals("labels1", ((CyColumnIdentifier) props2.get(ITEM_LABELS_COLUMN)).getColumnName());
    assertEquals(props1.get(ITEM_LABELS), props2.get(ITEM_LABELS));
    assertEquals(props1.get(SHOW_ITEM_LABELS), props2.get(SHOW_ITEM_LABELS));
    assertEquals(props1.get(START_ANGLE), props2.get(START_ANGLE));
    assertNull(props2.get(VALUES));
    // When calling the internal get methods, some property values are converted to internal types,
    // which are not exposed to the API client code
    assertEquals(props2.get(DATA_COLUMNS), chart.getList(DATA_COLUMNS, CyColumnIdentifier.class));
    assertEquals(ColorScheme.CUSTOM, chart.get(COLOR_SCHEME, ColorScheme.class));
    assertEquals(props1.get(COLORS), chart.getList(COLORS, Color.class));
    assertEquals(Color.WHITE, chart.get(BORDER_COLOR, Color.class));
    assertEquals(new Float(2.5f), chart.get(BORDER_WIDTH, Float.class));
    assertEquals("labels1", chart.get(ITEM_LABELS_COLUMN, CyColumnIdentifier.class).getColumnName());
    assertEquals(props1.get(ITEM_LABELS), chart.getList(ITEM_LABELS, String.class));
    assertEquals(Boolean.TRUE, chart.get(SHOW_ITEM_LABELS, Boolean.class));
    assertEquals(new Double(-700), chart.get(START_ANGLE, Double.class));
    // Must never be null!
    assertTrue(chart.getList(VALUES, Double.class).isEmpty());
}
Also used : PieChart(org.cytoscape.ding.internal.charts.pie.PieChart) Color(java.awt.Color) ColorScheme(org.cytoscape.ding.customgraphics.ColorScheme) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) AbstractCustomGraphics2Test(org.cytoscape.ding.customgraphics.AbstractCustomGraphics2Test) Test(org.junit.Test)

Example 10 with CyColumnIdentifier

use of org.cytoscape.view.presentation.property.values.CyColumnIdentifier in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method createChart.

public CyCustomGraphics2<?> createChart(EMStyleOptions options) {
    CyCustomGraphics2<?> chart = null;
    ChartOptions chartOptions = options.getChartOptions();
    ChartData data = chartOptions != null ? chartOptions.getData() : null;
    if (data != null && data != ChartData.NONE) {
        // Ignore Signature Data Sets in charts
        Set<EMDataSet> dataSets = filterDataSets(options.getDataSets());
        if (dataSets.size() > 1) {
            ColumnDescriptor<Double> columnDescriptor = data.getColumnDescriptor();
            List<CyColumnIdentifier> columns = ChartUtil.getSortedColumnIdentifiers(options.getAttributePrefix(), dataSets, columnDescriptor, columnIdFactory);
            ChartType type = chartOptions.getType();
            Map<String, Object> props = new HashMap<>(type.getProperties());
            props.put("cy_dataColumns", columns);
            List<Double> range = ChartUtil.calculateGlobalRange(options.getNetworkView().getModel(), columns);
            props.put("cy_range", range);
            props.put("cy_autoRange", false);
            props.put("cy_globalRange", true);
            props.put("cy_showItemLabels", chartOptions.isShowLabels());
            props.put("cy_colors", chartOptions.getColorScheme().getColors());
            try {
                CyCustomGraphics2Factory<?> factory = chartFactoryManager.getChartFactory(type.getId());
                if (factory != null)
                    chart = factory.getInstance(props);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return chart;
}
Also used : ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) HashMap(java.util.HashMap) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Aggregations

CyColumnIdentifier (org.cytoscape.view.presentation.property.values.CyColumnIdentifier)21 Color (java.awt.Color)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 CyColumn (org.cytoscape.model.CyColumn)6 CyRow (org.cytoscape.model.CyRow)6 AbstractCustomGraphics2Test (org.cytoscape.ding.customgraphics.AbstractCustomGraphics2Test)5 ColorScheme (org.cytoscape.ding.customgraphics.ColorScheme)5 CyTable (org.cytoscape.model.CyTable)4 Test (org.junit.Test)4 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 Orientation (org.cytoscape.ding.customgraphics.Orientation)3 MappableVisualPropertyValue (org.cytoscape.view.presentation.property.values.MappableVisualPropertyValue)3 Collator (java.text.Collator)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2