Search in sources :

Example 1 with VisualPropertySheetItemModel

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();
}
Also used : PropertySheetPanel(com.l2fprod.common.propertysheet.PropertySheetPanel) VisualPropertySheet(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) UndoSupport(org.cytoscape.work.undo.UndoSupport) VizMapperProperty(org.cytoscape.view.vizmap.gui.internal.VizMapperProperty) VisualPropertySheetItemModel(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItemModel) Item(com.l2fprod.common.propertysheet.PropertySheetTableModel.Item) VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem) NumberSeriesMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.NumberSeriesMappingGenerator) VisualProperty(org.cytoscape.view.model.VisualProperty) RandomNumberMappingGenerator(org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomNumberMappingGenerator) HashMap(java.util.HashMap) Map(java.util.Map) VisualPropertySheetItem(org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem)

Aggregations

PropertySheetPanel (com.l2fprod.common.propertysheet.PropertySheetPanel)1 Item (com.l2fprod.common.propertysheet.PropertySheetTableModel.Item)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 VisualProperty (org.cytoscape.view.model.VisualProperty)1 VizMapperProperty (org.cytoscape.view.vizmap.gui.internal.VizMapperProperty)1 NumberSeriesMappingGenerator (org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.NumberSeriesMappingGenerator)1 RandomNumberMappingGenerator (org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomNumberMappingGenerator)1 VisualPropertySheet (org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheet)1 VisualPropertySheetItem (org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem)1 VisualPropertySheetItemModel (org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItemModel)1 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)1 UndoSupport (org.cytoscape.work.undo.UndoSupport)1