Example usage for java.awt.event ActionEvent getSource

List of usage examples for java.awt.event ActionEvent getSource

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:client.gui.ButtonPanel.java

@Override
public void actionPerformed(final ActionEvent event) {
    if (GlobalVariables.connected) {

        if (event.getSource() == exchangeCards) {
            try {
                final JSONArray toSend = new JSONArray();

                toSend.put(new JSONObject().put("action", "exchange_cards"));

                for (int i = 0; i < GlobalVariables.hand.length; i++) {

                    if (!(GlobalVariables.chosen[i])) {
                        continue;
                    }//from  www  .jav a2 s .com

                    toSend.put(new JSONObject().put("suit", GlobalVariables.hand[i].getSuit()).put("rank",
                            GlobalVariables.hand[i].getRank()));

                }

                GlobalVariables.chosen = new boolean[] { false, false, false, false };

                GlobalVariables.out.println(toSend);

                System.out.println("[DEBUG] " + toSend);

            } catch (JSONException e) {
                e.printStackTrace();
            }

        } else if (event.getSource() == startGame) {

            try {
                final JSONArray toSend = new JSONArray();

                toSend.put(new JSONObject().put("action", "start_game"));

                GlobalVariables.out.println(toSend);

                System.out.println("[DEBUG] " + toSend);

            } catch (JSONException e) {
                e.printStackTrace();
            }

        } else if (event.getSource() == smallBlind) {

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "small_blind"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == bigBlind) {

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "big_blind"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == call) {

            final JSONArray toSend = new JSONArray();
            try {
                toSend.put(new JSONObject().put("action", "call"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == raise) {

            int raise;

            try {
                raise = Integer.parseInt(JOptionPane.showInputDialog(this, "Type your bet:"));
            } catch (NumberFormatException e) {
                new MyDialog("This isn't a number").setVisible(true);
                return;
            }

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "raise"));
                toSend.put(new JSONObject().put("bet", raise));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == bet) {

            int bet;

            try {
                bet = Integer.parseInt(JOptionPane.showInputDialog(this, "Type your bet:"));
            } catch (NumberFormatException e) {
                new MyDialog("This isn't a number").setVisible(true);
                return;
            }

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "bet"));
                toSend.put(new JSONObject().put("bet", bet));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == check) {

            final JSONArray toSend = new JSONArray();
            try {
                toSend.put(new JSONObject().put("action", "check"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == fold) {

            final JSONArray toSend = new JSONArray();
            try {
                toSend.put(new JSONObject().put("action", "fold"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == allIn) {

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "all-in"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        } else if (event.getSource() == liveBlind) {

            int raise;

            try {
                raise = Integer.parseInt(JOptionPane.showInputDialog(this, "Type your bet:"));
            } catch (NumberFormatException e) {
                new MyDialog("This isn't a number").setVisible(true);
                return;
            }

            final JSONArray toSend = new JSONArray();

            try {
                toSend.put(new JSONObject().put("action", "live_blind"));
                toSend.put(new JSONObject().put("bet", raise));
            } catch (JSONException e) {
                e.printStackTrace();
            }

            GlobalVariables.out.println(toSend);

        }

        hideAll();

        //   GlobalVariables.panel.repaint();
    }

}

From source file:com.kenai.redminenb.repository.RedmineRepositoryController.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == panel.connectButton) {
        onConnect();// w  w  w .  j  ava 2  s  .c  o m
    } else if (e.getSource() == panel.projectComboBox) {
        onProjectSelected();
    } else if (e.getSource() == panel.createNewProjectButton) {
        onCreateNewProject();
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                validate();
                fireChange();
            }
        });
    }
}

From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java

@Override
public void actionPerformed(final ActionEvent e) {
    try {//from w w  w .ja  v a  2 s.c  o  m
        Object src = e.getSource();

        if (src == btn_run) {
            simKernel.setNetPlan(mainWindow.getDesign());
            runSimulation(false);
        } else if (src == btn_step) {
            runSimulation(true);
        } else if (src == btn_pause) {
            simKernel.getSimCore().setSimulationState(
                    simKernel.getSimCore().getSimulationState() == SimState.PAUSED ? SimState.RUNNING
                            : SimState.PAUSED);
        } else if (src == btn_stop) {
            simKernel.getSimCore().setSimulationState(SimState.STOPPED);
        } else if (src == btn_reset) {
            simKernel.getSimCore().setSimulationState(SimState.STOPPED);
            simKernel.reset();
            simKernel.setNetPlan(simKernel.getInitialNetPlan());
            mainWindow.setCurrentNetPlanDoNotUpdateVisualization(simKernel.getInitialNetPlan());
            final VisualizationState vs = mainWindow.getVisualizationState();
            Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = vs
                    .suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(
                            new HashSet<>(mainWindow.getDesign().getNetworkLayers()));
            vs.setCanvasLayerVisibilityAndOrder(mainWindow.getDesign(), res.getFirst(), res.getSecond());
            mainWindow.updateVisualizationAfterNewTopology();
        } else if (src == btn_viewEventList) {
            viewFutureEventList();
        } else if (src == btn_updateReport) {
            updateSimReport();
        } else {
            throw new Net2PlanException("Bad");
        }
    } catch (Net2PlanException ex) {
        if (ErrorHandling.isDebugEnabled())
            ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
        ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation");
    } catch (Throwable ex) {
        ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
        ErrorHandling.showErrorDialog("An error happened");
    }
}

From source file:edu.ku.brc.af.ui.db.JAutoCompTextField.java

protected void keyReleasedInternal(KeyEvent ev) {
    //System.out.println(ev);
    if (dbAdapter != null) {
        if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY) {
            /*lookup(getText());
                    //  ww w  .  jav  a2  s.  c o  m
            if (!foundMatch)
            {
            setText("");
            }*/

            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JMenuItem mi = (JMenuItem) ae.getSource();
                    int inx = 0;
                    for (PickListItemIFace pli : dbAdapter.getList()) {
                        String title = pli.getTitle();
                        if (mi.getText().equals(title)) {
                            setSelectedIndex(inx);
                            break;
                        }
                        inx++;
                    }
                    popupMenu = null;
                }
            };

            String txt = getText();

            int cnt = 0;
            for (PickListItemIFace pli : dbAdapter.getList()) {
                String title = pli.getTitle();
                if (title.length() >= txt.length() && title.startsWith(txt)) {
                    cnt++;
                }
            }

            if (cnt > 0) {
                popupMenu = new JPopupMenu();
                for (PickListItemIFace pli : dbAdapter.getList()) {
                    String title = pli.getTitle();
                    if (title.length() >= txt.length() && title.startsWith(txt)) {
                        JMenuItem mi = new JMenuItem(title);
                        setControlSize(mi);
                        popupMenu.add(mi);
                        mi.addActionListener(al);
                    }
                }
                Point location = getLocation();
                Dimension size = getSize();
                popupMenu.show(this, location.x, location.y + size.height);
            }

        } else if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
            addNewItemFromTextField();

        } else if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT)
        {
            setSelectionStart(prevCaretPos);
            setSelectionEnd(getText().length());
        }

        /*else
        {
        char key = ev.getKeyChar();
        if (ev.getKeyCode() == KeyEvent.VK_BACK_SPACE)
        {
            String s = getText();
            if (foundMatch)
            {
                //System.out.println("len ["+s.length()+"]");
                //System.out.println(s+"["+s.substring(0, s.length()-1)+"]");
                
                setText(s.length() == 0 ? "" : s.substring(0, s.length()-1));
                        
            } else
            {
                hasChanged = true;
            }
            return;
                    
        } else if ((!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) && 
                     ev.getKeyCode() != KeyEvent.VK_DELETE)
        {
            if (ev.getKeyCode() == KeyEvent.VK_ENTER) 
            {
                addNewItemFromTextField();
            }
            //System.out.println("Key Code "+ev.getKeyCode()+"  Pos: "+getCaretPosition()+"  Del: "+KeyEvent.VK_DELETE);
                    
            if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT)
            {
                setSelectionStart(prevCaretPos);
                setSelectionEnd(getText().length());
            }
            return;
                    
        } else if(ev.getKeyCode() == KeyEvent.VK_DELETE)
        {
            foundMatch = false;
            hasChanged = true;
            return;
        }
        //System.out.println("["+ev.getKeyCode()+"]["+KeyEvent.VK_DELETE+"]");
                
        caretPos = getCaretPosition();
        String text = "";
        try
        {
            text = getText(0, caretPos);
                    
        } catch (Exception ex)
        {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(JAutoCompTextField.class, ex);
            ex.printStackTrace();
        }
                
        lookup(text);
        }*/
    }
}

From source file:org.jfree.chart.demo.XYTickLabelDemo.java

/**
 * When a checkbox is changed ...//from w w  w . j ava 2 s.c o m
 * 
 * @param event  the event.
 */
public void actionPerformed(final ActionEvent event) {
    final ValueAxis[] axes = new ValueAxis[4];
    final XYPlot plot = this.chart.getXYPlot();
    axes[0] = plot.getDomainAxis();
    axes[1] = plot.getRangeAxis();
    axes[2] = plot.getDomainAxis(1);
    axes[3] = plot.getRangeAxis(1);

    final Object source = event.getSource();

    if (source == this.symbolicAxesCheckBox) {

        final boolean val = this.symbolicAxesCheckBox.isSelected();

        for (int i = 0; i < axes.length; i++) {
            ValueAxis axis = axes[i];
            final String label = axis.getLabel();
            final int maxTick = (int) axis.getUpperBound();
            final String[] tickLabels = new String[maxTick];
            final Font ft = axis.getTickLabelFont();
            for (int itk = 0; itk < maxTick; itk++) {
                tickLabels[itk] = "Label " + itk;
            }
            axis = val ? new SymbolicAxis(label, tickLabels) : new NumberAxis(label);
            axis.setTickLabelFont(ft);
            axes[i] = axis;
        }
        plot.setDomainAxis(axes[0]);
        plot.setRangeAxis(axes[1]);
        plot.setDomainAxis(1, axes[2]);
        plot.setRangeAxis(1, axes[3]);

    }

    if (source == this.symbolicAxesCheckBox || source == this.verticalTickLabelsCheckBox) {
        final boolean val = this.verticalTickLabelsCheckBox.isSelected();

        for (int i = 0; i < axes.length; i++) {
            axes[i].setVerticalTickLabels(val);
        }

    } else if (source == this.symbolicAxesCheckBox || source == this.horizontalPlotCheckBox) {

        final PlotOrientation val = this.horizontalPlotCheckBox.isSelected() ? PlotOrientation.HORIZONTAL
                : PlotOrientation.VERTICAL;
        this.chart.getXYPlot().setOrientation(val);

    } else if (source == this.symbolicAxesCheckBox || source == this.fontSizeTextField) {
        final String s = this.fontSizeTextField.getText();
        if (s.length() > 0) {
            final float sz = Float.parseFloat(s);
            for (int i = 0; i < axes.length; i++) {
                final ValueAxis axis = axes[i];
                Font ft = axis.getTickLabelFont();
                ft = ft.deriveFont(sz);
                axis.setTickLabelFont(ft);
            }
        }
    }
}

From source file:com.github.bfour.fpliteraturecollector.gui.AtomicRequestBrowsePanel.java

/**
 * //from ww w.ja  v  a 2  s.  c  o m
 * @param servMan
 * @param query
 *            limit the AtomicRequests to this Query, ie. only
 *            AtomicRequests belonging to this Query will be shown
 */
public AtomicRequestBrowsePanel(final ServiceManager servMan, final Query query) {

    super(AtomicRequest.class, servMan.getAtomicRequestService(), false);

    // show default buttons for CRUD options
    setDeleteEntityEnabled(true);
    setEditEntityEnabled(true);
    setCreateEntityEnabled(true);

    // hide search bar
    setSearchPanel(null);

    // ==== columns ====
    FPJGUITableColumn<AtomicRequest> crawlerColumn = new FPJGUITableColumn<AtomicRequest>("Crawler",
            new FPJGUITableFieldGetter<AtomicRequest>() {
                @Override
                public String get(AtomicRequest item) {
                    return servMan.getCrawlerService().getIdentifierForCrawler(item.getCrawler());
                }
            }, true, 30, 30, "crawler", false);
    getListLikeContainer().addColumn(crawlerColumn);

    FPJGUITableColumn<AtomicRequest> requestStringColumn = new FPJGUITableColumn<AtomicRequest>(
            "Request String", new FPJGUITableFieldGetter<AtomicRequest>() {
                @Override
                public String get(AtomicRequest item) {
                    return item.getSearchString();
                }
            }, true, 30, 30, "requestStrings", false);
    getListLikeContainer().addColumn(requestStringColumn);

    FPJGUITableColumn<AtomicRequest> errorColumn = new FPJGUITableColumn<AtomicRequest>("Error",
            new FPJGUITableFieldGetter<AtomicRequest>() {
                @Override
                public String get(AtomicRequest item) {
                    return item.getProcessingError();
                }
            }, true, 30, 30, "error", false);
    getListLikeContainer().addColumn(errorColumn);

    getListLikeContainer().setPreferredColumnWidth(crawlerColumn, 100);
    getListLikeContainer().setPreferredColumnWidth(requestStringColumn, 400);
    getListLikeContainer().setPreferredColumnWidth(errorColumn, 100);

    getListLikeContainer().setMinimumColumnWidth(crawlerColumn, 100);
    getListLikeContainer().setMinimumColumnWidth(requestStringColumn, 200);
    getListLikeContainer().setMinimumColumnWidth(errorColumn, 50);

    // ==== loader ====
    setLoader(new EntityLoader<AtomicRequest>() {
        @Override
        public List<AtomicRequest> get() {
            if (query != null)
                return new ArrayList<>(query.getAtomicRequests());
            return new ArrayList<>(0);
        }
    });

    // hook up table with change event system
    setChangeEventSystemEnabled(false); // disable default handlers
    if (query == null) {
        // no query specified --> this browse panel is for a new query -->
        // do not register for any changes
    } else {
        // query is specified --> this browse panel is only for
        // AtomicRequests of this Query --> listen for changes to query
        ChangeListener<Query> changeListener = new ChangeListener<Query>() {
            @Override
            public void handle(BatchCreateEvent<Query> arg0) {
            }

            @Override
            public void handle(BatchDeleteEvent<Query> arg0) {
                if (arg0.getAffectedObjects().contains(query))
                    getListLikeContainer().deleteAllEntries();
            }

            @Override
            public void handle(BatchUpdateEvent<Query> arg0) {
                Iterator<UpdateEvent<Query>> iter = arg0.getChanges().iterator();
                while (iter.hasNext()) {
                    handle(arg0);
                }
            }

            @Override
            public void handle(CreateEvent<Query> arg0) {
            }

            @Override
            public void handle(DeleteEvent<Query> arg0) {
                if (arg0.getDeletedObject().equals(query))
                    getListLikeContainer().deleteAllEntries();
            }

            @Override
            public void handle(UpdateEvent<Query> arg0) {
                if (arg0.getOldObject().equals(query))
                    getListLikeContainer().setEntries(new ArrayList<>(arg0.getNewObject().getAtomicRequests()));
            }
        };
        ChangeHandler.getInstance(Query.class).addEventListener(changeListener);
    }

    // load initial data
    load();

    // set button actions
    ActionListener deleteListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            AtomicRequestService eServ = servMan.getAtomicRequestService();
            Component source;
            // TODO (high) clean up mess (maybe set back to delete button as
            // source only)
            if (e.getSource() != null && e.getSource() instanceof Component) {
                source = (Component) e.getSource();
                if (source instanceof JMenuItem) {
                    try {
                        source = (Component) BeanUtils.cloneBean(source);
                    } catch (IllegalAccessException | InstantiationException | InvocationTargetException
                            | NoSuchMethodException e1) {
                        source = getDeleteButton();
                    }
                }
            } else {
                source = getDeleteButton();
            }
            if (query == null) {
                getListLikeContainer().deleteEntry(getListLikeContainer().getSelectedItem());
            } else {
                DefaultActionInterfaceHandler.getInstance().requestDeleteFromList(source, getFeedbackProxy(),
                        getListLikeContainer().getSelectedItem(), eServ);
            }
        }
    };
    addDeleteAction(deleteListener);

}

From source file:de.dfki.owlsmx.gui.ResultVisualization.java

private void saveActionPerformed(java.awt.event.ActionEvent event) {//GEN-FIRST:event_saveActionPerformed
    try {/*  w  w  w  .java 2s  . co m*/
        if (event.getSource().equals(save)) {
            if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                if (fc.getFileFilter().getClass().equals((new PNGFilter()).getClass()))
                    if (fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".png"))
                        ChartUtilities.saveChartAsPNG(fc.getSelectedFile(), chart, graphPrintWidth,
                                graphPrintHeight);
                    else
                        ChartUtilities.saveChartAsPNG(new File(fc.getSelectedFile().getAbsolutePath() + ".png"),
                                chart, graphPrintWidth, graphPrintHeight);

                else if (fc.getFileFilter().getClass().equals((new JPGFilter()).getClass()))
                    if (fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".png"))
                        ChartUtilities.saveChartAsJPEG(fc.getSelectedFile(), chart, graphPrintWidth,
                                graphPrintHeight);
                    else
                        ChartUtilities.saveChartAsJPEG(
                                new File(fc.getSelectedFile().getAbsolutePath() + ".png"), chart,
                                graphPrintWidth, graphPrintHeight);

                else if (fc.getFileFilter().getClass().equals((new PDFFilter()).getClass()))
                    if (fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".pdf"))
                        Converter.convertToPdf(chart, graphPrintWidth, graphPrintHeight,
                                fc.getSelectedFile().getAbsolutePath());
                    else
                        Converter.convertToPdf(chart, graphPrintWidth, graphPrintHeight,
                                fc.getSelectedFile().getAbsolutePath() + ".pdf");
                else if (fc.getFileFilter().getClass().equals((new EPSFilter()).getClass()))
                    printGraphics2DtoEPS(fc.getSelectedFile().getAbsolutePath());
            }
        }
    } catch (Exception e) {
        GUIState.displayWarning(e.getClass().toString(),
                "Couldn't save file " + fc.getSelectedFile().getAbsolutePath());
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java

/**
 * /*from  w  w w  .j a  v  a  2 s .  co m*/
 */
private void addComboBoxActionListeners() {
    if (cboAL == null) {
        cboAL = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == displayCbo) {
                    Object item = displayCbo.getSelectedItem();
                    if (item instanceof DataObjSwitchFormatter) {
                        // display format changed
                        DataObjSwitchFormatter fmt = (DataObjSwitchFormatter) item;
                        selectedAggregator.setFormatName(fmt.getName());
                        setHasChanged(true);
                    }
                } else if (e.getSource() == fieldOrderCbo) {
                    Object item = fieldOrderCbo.getSelectedItem();
                    if (item instanceof DBFieldInfo) {
                        // order by field changed
                        DBFieldInfo fi = (DBFieldInfo) item;
                        selectedAggregator.setOrderFieldName(fi.getName());
                        setHasChanged(true);
                    }
                }
            }
        };
    }

    displayCbo.addActionListener(cboAL);
    fieldOrderCbo.addActionListener(cboAL);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.ADAP3DecompositionV1_5SetupDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);

    final Object source = e.getSource();

    if (source.equals(preview)) {
        if (preview.isSelected()) {
            // Set the height of the preview to 200 cells, so it will span
            // the whole vertical length of the dialog (buttons are at row
            // no 100). Also, we set the weight to 10, so the preview
            // component will consume most of the extra available space.
            mainPanel.add(pnlTabs, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH);
            pnlVisible.add(pnlLabelsFields, BorderLayout.CENTER);
            comboPeakList.setSelectedIndex(0);
        } else {//from   w  w  w.j  a  v  a2 s.c o  m
            mainPanel.remove(pnlTabs);
            pnlVisible.remove(pnlLabelsFields);
        }

        updateMinimumSize();
        pack();
        setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());
    }

    else if (source.equals(comboPeakList)) {
        // -------------------------
        // Retrieve current PeakList
        // -------------------------

        final PeakList peakList = (PeakList) comboPeakList.getSelectedItem();

        final List<Peak> peaks = ADAP3DecompositionV1_5Task.getPeaks(peakList,
                parameterSet.getParameter(ADAP3DecompositionV1_5Parameters.EDGE_TO_HEIGHT_RATIO).getValue(),
                parameterSet.getParameter(ADAP3DecompositionV1_5Parameters.DELTA_TO_HEIGHT_RATIO).getValue());

        // ---------------------------------
        // Calculate retention time clusters
        // ---------------------------------

        List<Double> retTimeValues = new ArrayList<>();
        List<Double> mzValues = new ArrayList<>();
        List<Double> colorValues = new ArrayList<>();

        retTimeCluster(peaks, retTimeValues, mzValues, colorValues);

        final int size = retTimeValues.size();

        retTimeMZPlot.updateData(ArrayUtils.toPrimitive(retTimeValues.toArray(new Double[size])),
                ArrayUtils.toPrimitive(mzValues.toArray(new Double[size])),
                ArrayUtils.toPrimitive(colorValues.toArray(new Double[size])));

        // ------------------------
        // Calculate shape clusters
        // ------------------------

        final ComboClustersItem item = (ComboClustersItem) comboClusters.getSelectedItem();

        if (item != null) {
            final List<List<NavigableMap<Double, Double>>> shapeClusters = new ArrayList<>();
            final List<List<String>> texts = new ArrayList<>();
            final List<Double> colors = new ArrayList<>();

            shapeCluster(item.cluster, shapeClusters, texts, colors);

            retTimeIntensityPlot.updateData(shapeClusters, colors, texts, null);
        }
    }

    else if (source.equals(comboClusters)) {
        // ------------------------
        // Calculate shape clusters
        // ------------------------

        final ComboClustersItem item = (ComboClustersItem) comboClusters.getSelectedItem();

        if (item != null) {
            final List<List<NavigableMap<Double, Double>>> shapeClusters = new ArrayList<>();
            final List<List<String>> texts = new ArrayList<>();
            final List<Double> colors = new ArrayList<>();

            shapeCluster(item.cluster, shapeClusters, texts, colors);

            retTimeIntensityPlot.updateData(shapeClusters, colors, texts, null);
        }
    }
}

From source file:SplineAnim.java

public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    if (source == animateButton) {
        try {//from  w  w w .j av  a2 s .co m
            // toggle animation
            if (animationOn) {
                animationOn = false;
                splineInterpolator.setEnable(false);
                linearInterpolator.setEnable(false);
                animateButton.setLabel("Start Animation");
            } else {
                animationOn = true;
                startInterpolator();
                animateButton.setLabel("Stop Animation");
            }
        } catch (Exception e) {
            System.err.println("Exception " + e);
        }
    }
}