use of com.l2fprod.common.propertysheet.PropertyRendererRegistry in project cytoscape-impl by cytoscape.
the class VizMapPropertyBuilder method setDiscreteProps.
/**
* Set value, title, and renderer for each property in the category. This
* list should be created against all available attribute values.
*/
private <K, V> void setDiscreteProps(VisualProperty<V> vp, VisualMappingFunction<K, V> mapping, SortedSet<Object> attrSet, VisualPropertyEditor<V> vpEditor, PropertySheetPanel propertySheetPanel) {
if (attrSet == null)
return;
final Map<K, V> discMapping = ((DiscreteMapping<K, V>) mapping).getAll();
V val = null;
VizMapperProperty<K, V, VisualMappingFunction<K, V>> valProp;
String strVal;
final PropertySheetTable table = propertySheetPanel.getTable();
final PropertyRendererRegistry cellRendererFactory = (PropertyRendererRegistry) table.getRendererFactory();
final PropertyEditorRegistry cellEditorFactory = (PropertyEditorRegistry) table.getEditorFactory();
for (final Object key : attrSet) {
valProp = new VizMapperProperty<K, V, VisualMappingFunction<K, V>>(CellType.DISCRETE, (K) key, mapping.getVisualProperty().getRange().getType());
strVal = key.toString();
valProp.setDisplayName(strVal);
// but we don't know the type of the list items.
if (mapping.getMappingColumnType() == String.class && !(key instanceof String))
val = discMapping.get(key.toString());
else
val = discMapping.get(key);
if (val != null)
valProp.setType(val.getClass());
propertySheetPanel.addProperty(valProp);
if (vpEditor != null) {
final TableCellRenderer renderer = vpEditor.getDiscreteTableCellRenderer();
if (renderer != null)
cellRendererFactory.registerRenderer(valProp, renderer);
PropertyEditor cellEditor = null;
if (vpEditor instanceof VisualPropertyEditor2) {
cellEditor = ((VisualPropertyEditor2) vpEditor).getPropertyEditor(vp);
} else {
cellEditor = vpEditor.getPropertyEditor();
}
if (cellEditor != null)
cellEditorFactory.registerEditor(valProp, cellEditor);
}
valProp.setValue(val);
valProp.setInternalValue(mapping);
}
}
Aggregations