use of org.cytoscape.view.vizmap.gui.internal.view.editor.valueeditor.DiscreteValueEditor in project cytoscape-impl by cytoscape.
the class EditorManagerImpl method buildDiscreteEditors.
@SuppressWarnings({ "unchecked", "rawtypes" })
private <V> void buildDiscreteEditors(final VisualLexicon lexicon) {
final Set<VisualProperty> vps = (Set) lexicon.getAllVisualProperties();
for (final VisualProperty<V> vp : vps) {
final Range<?> range = vp.getRange();
// If data type is basic (String, Boolean, etc.), custom editor is not necessary.
final Class<?> targetDataType = range.getType();
synchronized (mutex) {
if (REGISTRY.getEditor(targetDataType) != null)
continue;
if (this.getVisualPropertyEditor(vp) != null)
continue;
if (range instanceof DiscreteRange<?>) {
DiscreteValueEditor<?> valEditor = (DiscreteValueEditor) getVisualPropertyValueEditor(vp);
if (valEditor == null) {
valEditor = new DiscreteValueEditor(range.getType(), ((DiscreteRange) range).values(), servicesUtil);
this.addVisualPropertyValueEditor(valEditor, null);
}
final CyDiscreteValuePropertyEditor<?> discretePropEditor = new CyDiscreteValuePropertyEditor(valEditor);
final Set values = ((DiscreteRange) range).values();
// FIXME how can we manage the custom icon size based on value type?
Integer width = ICON_WIDTH_MAP.get(range.getType());
if (width == null)
width = ICON_W;
final ContinuousMappingCellRendererFactory cellRendererFactory = servicesUtil.get(ContinuousMappingCellRendererFactory.class);
final VisualPropertyEditor<?> vpEditor = new DiscreteValueVisualPropertyEditor(range.getType(), discretePropEditor, cellRendererFactory, values, width, ICON_H);
this.addVisualPropertyEditor(vpEditor, null);
servicesUtil.registerService(vpEditor, SetCurrentRenderingEngineListener.class, new Properties());
}
}
}
}
Aggregations