Search in sources :

Example 1 with SelectionMode

use of artisynth.core.driver.Main.SelectionMode in project artisynth_core by artisynth.

the class SelectionToolbar method setSelectionButtons.

public void setSelectionButtons() {
    // create an array of all the selection buttons
    ArrayList<JButton> selectionButtons = new ArrayList<JButton>();
    selectionButtons.add(selectButton);
    selectionButtons.add(ellipticSelectButton);
    selectionButtons.add(scaleButton);
    selectionButtons.add(transrotateButton);
    selectionButtons.add(translateButton);
    selectionButtons.add(rotateButton);
    selectionButtons.add(constrainedTranslateButton);
    selectionButtons.add(pullButton);
    // selectionButtons.add (articulatedTransformButton);
    // selectionButtons.add(addMarkerButton);
    // get the button that is currently selected
    SelectionMode mode = main.getSelectionMode();
    JButton selectedButton = null;
    switch(mode) {
        case Select:
            {
                selectedButton = selectButton;
                break;
            }
        case EllipticSelect:
            {
                selectedButton = ellipticSelectButton;
                break;
            }
        case Scale:
            {
                selectedButton = scaleButton;
                break;
            }
        case Translate:
            {
                selectedButton = translateButton;
                break;
            }
        case Transrotate:
            {
                selectedButton = transrotateButton;
                break;
            }
        case Rotate:
            {
                selectedButton = rotateButton;
                break;
            }
        case ConstrainedTranslate:
            {
                selectedButton = constrainedTranslateButton;
                break;
            }
        case Pull:
            {
                selectedButton = pullButton;
                break;
            }
        default:
            {
                throw new InternalErrorException("unimplemented mode " + mode);
            }
    }
    // remove the button that is currently selected from the array list
    selectionButtons.remove(selectedButton);
    // set the decoration on the selected button
    selectedButton.setBorder(bevelBorder);
    selectedButton.setBackground(Color.LIGHT_GRAY);
    // set the decoration on the unselected buttons
    for (JButton b : selectionButtons) {
        b.setBorder(border);
        b.setBackground(background);
    }
}
Also used : JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) InternalErrorException(maspack.util.InternalErrorException) SelectionMode(artisynth.core.driver.Main.SelectionMode)

Aggregations

SelectionMode (artisynth.core.driver.Main.SelectionMode)1 ArrayList (java.util.ArrayList)1 JButton (javax.swing.JButton)1 InternalErrorException (maspack.util.InternalErrorException)1