use of com.l2fprod.common.propertysheet.Property in project cytoscape-impl by cytoscape.
the class GenerateDiscreteValuesAction method generateValues.
// ==[ PRIVATE METHODS ]============================================================================================
@SuppressWarnings({ "rawtypes", "unchecked" })
private void generateValues(final VisualPropertySheetItem<?> vpsItem, final String attrName, final VisualProperty<?> vp, final Map<DiscreteMapping<?, ?>, Map<Object, Object>> previousMappingValues, final Map<DiscreteMapping<?, ?>, Map<Object, ?>> newMappingValues) {
final VisualStyle style = servicesUtil.get(VisualMappingManager.class).getCurrentVisualStyle();
final VisualMappingFunction<?, ?> mapping = style.getVisualMappingFunction(vp);
if (!(mapping instanceof DiscreteMapping))
return;
final DiscreteMapping<Object, Object> dm = (DiscreteMapping) mapping;
final PropertySheetPanel propSheetPnl = vpsItem.getPropSheetPnl();
final SortedSet<Object> keySet = new TreeSet<Object>();
final Map<Object, Object> previousValues = new HashMap<Object, Object>();
for (final Property p : propSheetPnl.getProperties()) {
final VizMapperProperty<?, ?, ?> vmp = (VizMapperProperty<?, ?, ?>) p;
if (vmp.getCellType().equals(CellType.DISCRETE)) {
keySet.add(vmp.getKey());
// Save the current value for undo
previousValues.put(vmp.getKey(), vmp.getValue());
}
}
if (!keySet.isEmpty()) {
// Generate values
final Map<Object, ?> newValues = generator.generateMap(keySet);
// Save the mapping->old_values for undo
previousMappingValues.put(dm, previousValues);
// Save the mapping->new_values for redo
newMappingValues.put(dm, newValues);
// Update the visual mapping
dm.putAll(newValues);
}
}
use of com.l2fprod.common.propertysheet.Property in project cytoscape-impl by cytoscape.
the class VizMapPropertyBuilder method removeMappingProperties.
protected void removeMappingProperties(final PropertySheetPanel propertySheetPanel) {
final Property[] properties = propertySheetPanel.getProperties();
if (properties != null) {
final PropertySheetTable table = propertySheetPanel.getTable();
final PropertyRendererRegistry rendReg = (PropertyRendererRegistry) table.getRendererFactory();
for (final Property p : properties) {
if (p instanceof VizMapperProperty) {
final CellType cellType = ((VizMapperProperty<?, ?, ?>) p).getCellType();
if (cellType == CellType.CONTINUOUS || cellType == CellType.DISCRETE) {
if (cellType == CellType.CONTINUOUS) {
// TODO: Update range trace?
rendReg.unregisterRenderer(p);
}
propertySheetPanel.removeProperty(p);
}
}
}
table.repaint();
propertySheetPanel.repaint();
}
}
Aggregations