All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jhotdraw8.draw.action.SelectChildrenAction Maven / Gradle / Ivy

The newest version!
/*
 * @(#)SelectChildrenAction.java
 * Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
 */
package org.jhotdraw8.draw.action;

import javafx.event.ActionEvent;
import org.jhotdraw8.application.action.Action;
import org.jhotdraw8.application.resources.Resources;
import org.jhotdraw8.draw.DrawLabels;
import org.jhotdraw8.draw.DrawingEditor;
import org.jhotdraw8.draw.DrawingView;
import org.jhotdraw8.draw.figure.Figure;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * SelectChildrenAction.
 *
 * @author Werner Randelshofer
 */
public class SelectChildrenAction extends AbstractDrawingViewAction {

    public static final String ID = "edit.selectChildren";

    /**
     * Creates a new instance.
     *
     * @param editor the drawing editor
     */
    public SelectChildrenAction(DrawingEditor editor) {
        super(editor);
        Resources labels = DrawLabels.getResources();
        set(Action.ID_KEY, ID);
        labels.configureAction(this, ID);
    }

    @Override
    protected void onActionPerformed(ActionEvent e, DrawingView dview) {
        final List
figures = new ArrayList<>(dview.getSelectedFigures()); selectChildren(dview, figures); } public static void selectChildren(DrawingView view, Collection
figures) { List
selectedChildren = new ArrayList<>(); for (Figure f : figures) { selectedChildren.addAll(f.getChildren()); } view.getSelectedFigures().clear(); view.getSelectedFigures().addAll(selectedChildren); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy