Search in sources :

Example 1 with SplineEditor

use of org.gephi.ui.components.splineeditor.SplineEditor in project gephi by gephi.

the class AppearanceTopComponent method initControls.

private void initControls() {
    //Add ranking controls
    //        toolbar.addRankingControl(localScaleButton);
    toolbar.addRankingControl(splineButton);
    //Add partition controls
    //        toolbar.addPartitionControl(localScaleButton);
    //Actions
    localScaleButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.getAppearanceController().setUseLocalScale(localScaleButton.isSelected());
        }
    });
    splineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            RankingFunction function = (RankingFunction) model.getSelectedFunction();
            if (splineEditor == null) {
                splineEditor = new SplineEditor(NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.splineEditor.title"));
            }
            Interpolator interpolator = function.getInterpolator();
            if (interpolator instanceof Interpolator.BezierInterpolator) {
                Interpolator.BezierInterpolator bezierInterpolator = (Interpolator.BezierInterpolator) interpolator;
                splineEditor.setControl1(bezierInterpolator.getControl1());
                splineEditor.setControl2(bezierInterpolator.getControl2());
            } else {
                splineEditor.setControl1(new Point2D.Float(0, 0));
                splineEditor.setControl2(new Point2D.Float(1, 1));
            }
            splineEditor.setVisible(true);
            function.setInterpolator(new Interpolator.BezierInterpolator((float) splineEditor.getControl1().getX(), (float) splineEditor.getControl1().getY(), (float) splineEditor.getControl2().getX(), (float) splineEditor.getControl2().getY()));
        }
    });
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.appearanceController.transform(model.getSelectedFunction());
        }
    });
    autoApplyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.startAutoApply();
        }
    });
    stopAutoApplyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.stopAutoApply();
        }
    });
    enableAutoButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.setAutoApply(model.getAutoAppyTransformer() == null);
        }
    });
    stopAutoApplyButton.setVisible(false);
    autoApplyButton.setVisible(false);
//        listButton = new JToggleButton();
//        listButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/ranking/resources/list.png"))); // NOI18N
//        listButton.setToolTipText(NbBundle.getMessage(RankingTopComponent.class, "RankingTopComponent.listButton.text"));
//        listButton.setEnabled(false);
//        listButton.setFocusable(false);
//        southToolbar.add(listButton);
/*
         * barChartButton = new JToggleButton(); barChartButton.setIcon(new
         * javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/ranking/resources/barchart.png")));
         * // NOI18N NbBundle.getMessage(RankingTopComponent.class,
         * "RankingTopComponent.barchartButton.text");
         * barChartButton.setEnabled(false); barChartButton.setFocusable(false);
         * southToolbar.add(barChartButton);
         */
//        localScaleButton = new JToggleButton();
//        localScaleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/desktop/ranking/resources/funnel.png"))); // NOI18N
//        localScaleButton.setToolTipText(NbBundle.getMessage(RankingTopComponent.class, "RankingTopComponent.localScaleButton.text"));
//        localScaleButton.setEnabled(false);
//        localScaleButton.setFocusable(false);
//        southToolbar.add(localScaleButton);
//
//        //Local scale enabled
//        localScaleButton.setEnabled(model != null ? model.isLocalScaleEnabled() : false);
//
//        //BarChartPanel & ListPanel
//        listResultPanel.setVisible(false);
//
//        listButton.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                model.setListVisible(listButton.isSelected());
//            }
//        });
//
//        localScaleButton.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                model.setLocalScale(localScaleButton.isSelected());
//            }
//        });
/*
         * barChartButton.addActionListener(new ActionListener() {
         *
         * public void actionPerformed(ActionEvent e) {
         * model.setBarChartVisible(barChartButton.isSelected()); } });
         */
}
Also used : RankingFunction(org.gephi.appearance.api.RankingFunction) ActionListener(java.awt.event.ActionListener) SplineEditor(org.gephi.ui.components.splineeditor.SplineEditor) ActionEvent(java.awt.event.ActionEvent) Interpolator(org.gephi.appearance.api.Interpolator)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Interpolator (org.gephi.appearance.api.Interpolator)1 RankingFunction (org.gephi.appearance.api.RankingFunction)1 SplineEditor (org.gephi.ui.components.splineeditor.SplineEditor)1