Example usage for javax.swing.event ChangeEvent getSource

List of usage examples for javax.swing.event ChangeEvent getSource

Introduction

In this page you can find the example usage for javax.swing.event ChangeEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:org.forester.archaeopteryx.ControlPanel.java

private void buildJSlider(int width, int min, int max) {
    _color_branches_edpl_slider = new JSlider(min, max);
    Dimension d = _color_branches_edpl_slider.getSize();
    d.width = width;//from  ww  w .j  a  va  2 s .  co  m
    d.height = 100;
    _color_branches_edpl_slider.setPreferredSize(d);
    //       _color_branches_edpl_slider.setLayout(null);

    // slider popup with cutoff value
    _slider_popup = new JPopupMenu();
    JLabel text = new JLabel();
    text.setText(String.valueOf(_edpl_current_cutoff));
    _slider_popup.add(text);
    if (!_configuration.isUseNativeUI()) {
        _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color);
        _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color);
    }
    _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)");
    _color_branches_edpl_slider.setMinorTickSpacing(10);
    _color_branches_edpl_slider.setMajorTickSpacing(50);
    _color_branches_edpl_slider.setPaintTicks(true);
    _color_branches_edpl_slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // get Treepanel function
            final TreePanel tp = getMainPanel().getCurrentTreePanel();
            if (tp == null) {
                return;
            }
            Phylogeny phy = tp.getPhylogeny();
            _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0);
            tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff);
            _edpl_current_cutoff = _edpl_next_cutoff;
            //              System.out.println("Neuer Wert: "+
            //              ((JSlider)(e.getSource())).getValue());
        }
    });
    _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                _slider_popup.setVisible(false);
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                //               Point p = getMainPanel().getMainFrame().getLocation();
                Point p = _color_branches_edpl_slider.getLocationOnScreen();
                JLabel text = (JLabel) _slider_popup.getComponent(0);
                text.setText(String.valueOf(_edpl_current_cutoff));
                int x = (int) p.getX() + 18;
                int y = (int) p.getY() - 25;
                _slider_popup.setLocation(x, y);
                _slider_popup.setVisible(true);
            }

        }
    });
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIComponent.java

/***********************************************************************************************
 * Respond to changes in the DatasetDomain Sliders or a ControlKnobUIComponent.
 *
 * @param event/*ww  w  .  ja  v  a  2 s .c  om*/
 */

public void stateChanged(final ChangeEvent event) {
    final String SOURCE = "ChartUIComponent.stateChanged() ";
    final Object source;
    final boolean boolDebug;

    boolDebug = LOADER_PROPERTIES.isChartDebug();

    LOGGER.debug(boolDebug, "Chart State Changed " + Logger.CONSOLE_SEPARATOR_MAJOR);

    source = event.getSource();

    if (source instanceof MThumbSlider) {
        final MThumbSlider slider;

        slider = (MThumbSlider) source;

        // Try to update the moving crosshair, but only if there is a Chart
        if ((slider.getModelAt(MThumbSliderAdditionalUI.INDEX_LEFT) != null)
                && (slider.getModelAt(MThumbSliderAdditionalUI.INDEX_RIGHT) != null)) {
            LOGGER.debug(boolDebug, SOURCE + "[value.current.left="
                    + slider.getValueAt(MThumbSliderAdditionalUI.INDEX_LEFT) + "] [value.current.right="
                    + slider.getValueAt(MThumbSliderAdditionalUI.INDEX_RIGHT) + "] [value.previous.left="
                    + getDatasetDomainStartPoint() + "] [value.previous.right=" + getDatasetDomainEndPoint()
                    + "] [slider.isadjusting=" + slider.getValueIsAdjusting() + "] [model.isadjusting.left="
                    + slider.getModelAt(MThumbSliderAdditionalUI.INDEX_LEFT).getValueIsAdjusting()
                    + "] [model.isadjusting.right="
                    + slider.getModelAt(MThumbSliderAdditionalUI.INDEX_RIGHT).getValueIsAdjusting() + "]");

            if (slider.getModelAt(MThumbSliderAdditionalUI.INDEX_LEFT).getValueIsAdjusting()) {
                ChartUIHelper.updateDomainCrosshairForDomainSlider(this, INDEX_LEFT,
                        getDatasetDomainStartPoint(), getDatasetDomainEndPoint(), slider.getValueAt(INDEX_LEFT),
                        DOMAIN_SLIDER_MINIMUM, DOMAIN_SLIDER_MAXIMUM, boolDebug);
            } else if (slider.getModelAt(MThumbSliderAdditionalUI.INDEX_RIGHT).getValueIsAdjusting()) {
                ChartUIHelper.updateDomainCrosshairForDomainSlider(this, INDEX_RIGHT,
                        getDatasetDomainStartPoint(), getDatasetDomainEndPoint(),
                        slider.getValueAt(INDEX_RIGHT), DOMAIN_SLIDER_MINIMUM, DOMAIN_SLIDER_MAXIMUM,
                        boolDebug);
            } else {
                // This should never occur!
                setDomainCrosshair(0.0);
            }

            LOGGER.debug(boolDebug,
                    SOURCE + "Domain Slider Crosshair updated [crosshair.domain=" + getDomainCrosshair() + "]");
        } else {
            LOGGER.debug(boolDebug, SOURCE + "There is no Slider, so cannot update Domain Crosshair");
        }
    } else if (source instanceof ControlKnobInterface) {
        final ControlKnobInterface knob;

        knob = (ControlKnobInterface) source;

        LOGGER.debug(boolDebug, SOURCE + "ControlKnobUIComponent [value.knob=" + knob.getValue() + "]");

        //            ChartHelper.updateDomainCrosshairForOffsetControl(this,
        //                                                              OFFSET_CONTROL_COARSE_MINIMUM,
        //                                                              OFFSET_CONTROL_COARSE_MAXIMUM,
        //                                                              knob.getValue(),
        //                                                              boolDebug);
    } else {
        LOGGER.error(SOURCE + "Unexpected Source of ChangeEvent");
    }
}

From source file:CSSDFarm.UserInterface.java

private void sliderViewStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderViewStateChanged
    // TODO add your handling code here:
    JSlider source = (JSlider) evt.getSource();
    if (!source.getValueIsAdjusting()) {
        if (source.getValue() == 0) {
            panelReportTable.setVisible(false);
            panelHeatmap.setVisible(true);
            displayHeatmap();//from w w  w .j a v a  2  s . com
        } else {
            panelReportTable.setVisible(true);
            panelHeatmap.setVisible(false);
        }

    }
}

From source file:GUI.MainWindow.java

private void ViewModeTabPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_ViewModeTabPaneStateChanged
    JTabbedPane sourceTabbedPane = (JTabbedPane) evt.getSource();
    int index = sourceTabbedPane.getSelectedIndex();
    String title = sourceTabbedPane.getTitleAt(index);
    System.out.println("Tab changed to: " + sourceTabbedPane.getTitleAt(index));

    Object layout = RightPanelCardLayout.getLayout();
    if (layout instanceof java.awt.CardLayout) {
        java.awt.CardLayout cl = (java.awt.CardLayout) layout;
        if (title.equalsIgnoreCase("Vuln View")) {
            // Show the vuln view card
            cl.show(RightPanelCardLayout, "vulnView");

        } else if (title.equalsIgnoreCase("Host View")) {
            DefaultMutableTreeNode hostRoot = new TreeUtils()
                    .convertVulnViewToHostView((DefaultMutableTreeNode) this.VulnTree.getModel().getRoot());
            DefaultTreeModel dtm = ((DefaultTreeModel) this.HostTree.getModel());
            dtm.setRoot(hostRoot);/* w  ww.ja v a  2  s . c om*/
            dtm.reload(hostRoot);
            // Expand all nodes to make everything visible
            new TreeUtils().expandAll(this.HostTree);
            // Show the host view card
            cl.show(RightPanelCardLayout, "hostView");
        }
    }

    //cardLayout.show(cardPanel, "CardToShow");
    //java.awt.CardLayout cl = (java.awt.CardLayout)(RightPanelCardLayout.getLayout()) ;
    //        

}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

@Override
public void stateChanged(ChangeEvent ev) {
    JSpinner currSpinner = null;/*from   w w  w. ja v a  2  s  .  c o  m*/
    int currValue;
    if (ignoreAction)
        return;
    // //////////////////////////////////////////////////////////////////////
    // war es ein spinner?
    if (ev.getSource() instanceof JSpinner) {
        currSpinner = (JSpinner) ev.getSource();
        // //////////////////////////////////////////////////////////////////////
        // Deco gradient Hith
        if (currSpinner.equals(configPanel.getDecoGradientenHighSpinner())) {
            // wert fr High ndern
            currValue = (Integer) currSpinner.getValue();
            lg.debug(String.format("change decoGradientHighSpinner <%d/%x>...", currValue, currValue));
            currentConfig.setDecoGfHigh(currValue);
            setDecoComboAfterSpinnerChange();
        }
        // //////////////////////////////////////////////////////////////////////
        // Deco gradient Low
        else if (currSpinner.equals(configPanel.getDecoGradientenLowSpinner())) {
            // Wert fr LOW ndern
            currValue = (Integer) currSpinner.getValue();
            lg.debug(String.format("change decoGradientLowSpinner <%d/%x>...", currValue, currValue));
            currentConfig.setDecoGfLow(currValue);
            setDecoComboAfterSpinnerChange();
        } else {
            lg.warn("unknown spinner recived!");
        }
    }
    // //////////////////////////////////////////////////////////////////////
    // war es ein tabbedPane
    // //////////////////////////////////////////////////////////////////////
    else if (ev.getSource() instanceof JTabbedPane) {
        if (tabbedPane.equals(ev.getSource())) {
            int tabIdx = tabbedPane.getSelectedIndex();
            lg.debug(String.format("tabbedPane changed to %02d!", tabIdx));
            //
            // ist es das Grafikpanel?
            //
            if (tabIdx == programTabs.TAB_LOGGRAPH.ordinal()) {
                lg.debug("graph tab select, init grapic...");
                String connDev = null;
                if (btComm != null) {
                    connDev = btComm.getConnectedDevice();
                }
                // Grafiksachen initialisieren
                try {
                    logGraphPanel.initGraph(connDev);
                } catch (Exception ex) {
                    lg.error("initGraph Exception: <" + ex.getLocalizedMessage() + ">");
                    showErrorDialog(LangStrings.getString("MainCommGUI.errorDialog.openGraphWindow"));
                    return;
                }
            } else {
                // grafiksachen freigeben
                logGraphPanel.releaseGraph();
            }
            //
            // ist es das Exportpanel zum exportieren der Daten (importieren fr Service)
            //
            if (tabIdx == programTabs.TAB_FILEMANAGER.ordinal()) {
                lg.debug("export/import tab select, init db...");
                String connDev = null;
                if (btComm != null) {
                    connDev = btComm.getConnectedDevice();
                }
                // Panel initialisieren
                try {
                    fileManagerPanel.initData(connDev);
                } catch (Exception ex) {
                    lg.error("initData Exception: <" + ex.getLocalizedMessage() + ">");
                    showErrorDialog(LangStrings.getString("MainCommGUI.errorDialog.openExportWindow"));
                    return;
                }
            }
            //
            // ist es das Config Panel?
            //
            if (tabIdx == programTabs.TAB_CONFIG.ordinal()) {
                lg.debug("config tab select, init gui...");
                configPanel.prepareConfigPanel(currentConfig);
            } else {
                // Daten freigeben
                configPanel.releaseConfig();
            }
            //
            // ist es das Loglistpanel
            //
            if (tabIdx == programTabs.TAB_LOGREAD.ordinal()) {
                // Panel initialisieren
                lg.debug("logreader tab select, init gui...");
                String connDev = null;
                if (btComm != null) {
                    connDev = btComm.getConnectedDevice();
                }
                logListPanel.prepareLogListPanel(connDev);
            } else {
                logListPanel.releasePanel();
            }
            //
            // ist es das Gaspanel?
            //
            if (tabIdx == programTabs.TAB_GASLIST.ordinal()) {
                // Panel initialisieren
                lg.debug("gaslist tab select, init gui...");
                gasConfigPanel.prepareGasslistPanel();
            } else {
                // Panel Daten freigeben
                gasConfigPanel.releasePanel();
            }
        }
    } else {
        lg.warn("unknown source type recived!");
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void sunZSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_sunZSliderStateChanged
{//GEN-HEADEREND:event_sunZSliderStateChanged

    final JSlider source = (JSlider) evt.getSource();

    if (!source.getValueIsAdjusting()) {
        int value = (int) source.getValue();

        this.parent.getParameters().getRenderParameters().getSunPosition().setZ(value);
    }//from  w w  w  . jav a  2s.c  o  m
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void sunYSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_sunYSliderStateChanged
{//GEN-HEADEREND:event_sunYSliderStateChanged

    final JSlider source = (JSlider) evt.getSource();

    if (!source.getValueIsAdjusting()) {
        int value = (int) source.getValue();

        this.parent.getParameters().getRenderParameters().getSunPosition().setY(value);
    }//from  ww w.  j a  va  2  s  .c om
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void sunXSliderStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_sunXSliderStateChanged
{//GEN-HEADEREND:event_sunXSliderStateChanged

    final JSlider source = (JSlider) evt.getSource();

    if (!source.getValueIsAdjusting()) {
        int value = (int) source.getValue();

        this.parent.getParameters().getRenderParameters().getSunPosition().setX(value);
    }//from   www  .  j a  v  a 2 s  .  co  m
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void riverSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_riverSpinnerStateChanged
{//GEN-HEADEREND:event_riverSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();
    final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

    params.setRivers((Integer) source.getValue());
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void ambientSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_ambientSpinnerStateChanged
{//GEN-HEADEREND:event_ambientSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();

    Double value = (Double) ambientSpinner.getValue();

    this.parent.getParameters().getRenderParameters().setAmbient(value.floatValue());
}