use of org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItemModel in project cytoscape-impl by cytoscape.
the class GenerateDiscreteValuesAction method actionPerformed.
// ==[ PUBLIC METHODS ]=============================================================================================
@Override
public void actionPerformed(final ActionEvent e) {
final VisualPropertySheet selVpSheet = getVizMapperMainPanel().getSelectedVisualPropertySheet();
if (selVpSheet == null)
return;
final Set<VisualPropertySheetItem<?>> vpSheetItems = selVpSheet.getSelectedItems();
new Thread() {
@Override
public void run() {
final Map<DiscreteMapping<?, ?>, Map<Object, Object>> previousMappingValues = new HashMap<DiscreteMapping<?, ?>, Map<Object, Object>>();
final Map<DiscreteMapping<?, ?>, Map<Object, ?>> newMappingValues = new HashMap<DiscreteMapping<?, ?>, Map<Object, ?>>();
for (final VisualPropertySheetItem<?> vpsItem : vpSheetItems) {
final VisualPropertySheetItemModel<?> model = vpsItem.getModel();
final VisualProperty<?> vp = (VisualProperty<?>) model.getVisualProperty();
final Class<?> vpValueType = vp.getRange().getType();
final Class<?> generatorType = generator.getDataType();
final PropertySheetPanel propSheetPnl = vpsItem.getPropSheetPnl();
final Item value = (Item) propSheetPnl.getTable().getValueAt(0, 0);
if (value.isProperty()) {
final VizMapperProperty<?, ?, ?> prop = (VizMapperProperty<?, ?, ?>) value.getProperty();
if (vpValueType.isAssignableFrom(generatorType) || ((generator instanceof NumberSeriesMappingGenerator || generator instanceof RandomNumberMappingGenerator) && Number.class.isAssignableFrom(vpValueType)))
generateValues(vpsItem, prop.getValue().toString(), vp, previousMappingValues, newMappingValues);
}
}
// Undo support
if (!previousMappingValues.isEmpty()) {
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new GenerateValuesEdit(previousMappingValues, newMappingValues));
}
}
}.start();
}
Aggregations