Search in sources :

Example 1 with Property

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);
    }
}
Also used : PropertySheetPanel(com.l2fprod.common.propertysheet.PropertySheetPanel) HashMap(java.util.HashMap) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty) TreeSet(java.util.TreeSet) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty) Property(com.l2fprod.common.propertysheet.Property) VisualProperty(org.cytoscape.view.model.VisualProperty)

Example 2 with Property

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();
    }
}
Also used : PropertyRendererRegistry(com.l2fprod.common.propertysheet.PropertyRendererRegistry) CellType(org.cytoscape.view.vizmap.gui.internal.event.CellType) PropertySheetTable(com.l2fprod.common.propertysheet.PropertySheetTable) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty) Property(com.l2fprod.common.propertysheet.Property) VisualProperty(org.cytoscape.view.model.VisualProperty) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)

Aggregations

Property (com.l2fprod.common.propertysheet.Property)2 VisualProperty (org.cytoscape.view.model.VisualProperty)2 VizMapperProperty (org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)2 PropertyRendererRegistry (com.l2fprod.common.propertysheet.PropertyRendererRegistry)1 PropertySheetPanel (com.l2fprod.common.propertysheet.PropertySheetPanel)1 PropertySheetTable (com.l2fprod.common.propertysheet.PropertySheetTable)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1 CellType (org.cytoscape.view.vizmap.gui.internal.event.CellType)1 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)1