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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations