Example usage for java.awt Cursor getDefaultCursor

List of usage examples for java.awt Cursor getDefaultCursor

Introduction

In this page you can find the example usage for java.awt Cursor getDefaultCursor.

Prototype

public static Cursor getDefaultCursor() 

Source Link

Document

Return the system default cursor.

Usage

From source file:org.multibit.viewsystem.swing.action.ShowPreferencesSubmitAction.java

/**
 * Change preferences./*ww w . j  a  v  a2 s. com*/
 */
@Override
public void actionPerformed(ActionEvent event) {
    //        boolean feeValidationError = false;

    boolean wantToFireDataStructureChanged = false;

    try {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }

        //            String updateStatusText = "";

        if (dataProvider != null) {
            controller.getModel().setUserPreference(CoreModel.PREVIOUS_UNDO_CHANGES_TEXT,
                    dataProvider.getPreviousUndoChangesText());

            //                String previousSendFee = dataProvider.getPreviousSendFee();
            //                String newSendFee = dataProvider.getNewSendFee();
            //                controller.getModel().setUserPreference(BitcoinModel.PREVIOUS_SEND_FEE, previousSendFee);
            //
            //                // Check fee is set.
            //                if (newSendFee == null || "".equals(newSendFee)) {
            //                    // Fee must be set validation error.
            //                    controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                    feeValidationError = true;
            //                    updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.aFeeMustBeSet");
            //                }
            //
            //                if (!feeValidationError) {
            //                    if (newSendFee.startsWith(ShowPreferencesPanel.UNPARSEABLE_FEE)) {
            //                        String newSendFeeTrimmed = newSendFee.substring(ShowPreferencesPanel.UNPARSEABLE_FEE.length() + 1);
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFeeTrimmed });
            //                    }
            //                }
            //                
            //                if (!feeValidationError) {
            //                    try {
            //                        // Check fee is a number.
            //                        BigInteger feeAsBigInteger = Utils.toNanoCoins(newSendFee);
            //
            //                        // Check fee is at least the minimum fee.
            //                        if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MINIMUM_FEE) < 0) {
            //                            feeValidationError = true;
            //                            updateStatusText = controller.getLocaliser().getString(
            //                                    "showPreferencesPanel.feeCannotBeSmallerThanMinimumFee");
            //                        } else {
            //                            if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MAXIMUM_FEE) >= 0) {
            //                                feeValidationError = true;
            //                                updateStatusText = controller.getLocaliser().getString(
            //                                        "showPreferencesPanel.feeCannotBeGreaterThanMaximumFee");
            //                            } else {
            //                                // Fee is ok.
            //                                controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, newSendFee);
            //                            }
            //                        }
            //                    } catch (NumberFormatException nfe) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    } catch (ArithmeticException ae) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    }
            //                }
        }

        // Disable language selection, uncomment to enable
        /*
             String previousLanguageCode = dataProvider.getPreviousUserLanguageCode();
             String newLanguageCode = dataProvider.getNewUserLanguageCode();
             controller.getModel().setUserPreference(CoreModel.PREVIOUS_USER_LANGUAGE_CODE, previousLanguageCode);
                
             if (previousLanguageCode != null && !previousLanguageCode.equals(newLanguageCode)) {
        // New language to set on model.
        controller.getModel().setUserPreference(CoreModel.USER_LANGUAGE_CODE, newLanguageCode);
        wantToFireDataStructureChanged = true;
             }
        */

        // Open URI - use dialog.
        String openUriDialog = dataProvider.getOpenUriDialog();
        if (openUriDialog != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_SHOW_DIALOG, openUriDialog);
        }

        // Open URI - use URI.
        String openUriUseUri = dataProvider.getOpenUriUseUri();
        if (openUriUseUri != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_USE_URI, openUriUseUri);
        }

        // Messaging servers
        boolean messagingServersHasChanged = false;
        String[] previousMessagingServerURLs = dataProvider.getPreviousMessagingServerURLs();
        String[] newMessagingServerURLs = dataProvider.getNewMessagingServerURLs();
        // newMessagingServerURLs might be NULL, and thus clear out the user preference.
        // So let's be explicit and say if no urls are set, we use the default.
        if (newMessagingServerURLs == null) {
            newMessagingServerURLs = CoreModel.DEFAULT_MESSAGING_SERVER_URLS; // not URL encoded but is okay as no strange characters.
        }
        if (!Arrays.equals(previousMessagingServerURLs, newMessagingServerURLs)) {
            messagingServersHasChanged = true;
            String s = StringUtils.join(newMessagingServerURLs, "|");
            controller.getModel().setUserPreference(CoreModel.MESSAGING_SERVERS, s);
        }

        // Font data.
        boolean fontHasChanged = false;
        String previousFontName = dataProvider.getPreviousFontName();
        String newFontName = dataProvider.getNewFontName();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_NAME, previousFontName);

        if (newFontName != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_NAME, newFontName);

            if (!newFontName.equals(previousFontName)) {
                fontHasChanged = true;
            }
        }

        String previousFontStyle = dataProvider.getPreviousFontStyle();
        String newFontStyle = dataProvider.getNewFontStyle();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_STYLE, previousFontStyle);

        if (newFontStyle != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_STYLE, newFontStyle);

            if (!newFontStyle.equals(previousFontStyle)) {
                fontHasChanged = true;
            }
        }

        String previousFontSize = dataProvider.getPreviousFontSize();
        String newFontSize = dataProvider.getNewFontSize();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_SIZE, previousFontSize);

        if (newFontSize != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_SIZE, newFontSize);

            if (!newFontSize.equals(previousFontSize)) {
                fontHasChanged = true;
            }
        }

        // Look and feel.
        boolean lookAndFeelHasChanged = false;
        String previousLookAndFeel = dataProvider.getPreviousLookAndFeel();
        String newLookAndFeel = dataProvider.getNewLookAndFeel();

        controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, previousLookAndFeel);

        if (newLookAndFeel != null && (!newLookAndFeel.equals(previousLookAndFeel)
                && !newLookAndFeel.equals(UIManager.getLookAndFeel().getName()))) {
            controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, newLookAndFeel);

            lookAndFeelHasChanged = true;
        }
        /*
                    // Currency ticker.
                    boolean showTicker = dataProvider.getNewShowTicker();
                    boolean showBitcoinConvertedToFiat = dataProvider.getNewShowBitcoinConvertedToFiat();
                    boolean showCurrency = dataProvider.getNewShowCurrency();
                    boolean showRate = dataProvider.getNewShowRate();
                    boolean showBid = dataProvider.getNewShowBid();
                    boolean showAsk = dataProvider.getNewShowAsk();
                    boolean showExchange = dataProvider.getNewShowExchange();
                
                    boolean restartTickerTimer = false;
                
                    if (dataProvider.getPreviousShowCurrency() != showCurrency) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBitcoinConvertedToFiat() != showBitcoinConvertedToFiat) {
        wantToFireDataStructureChanged = true;
        if (showBitcoinConvertedToFiat) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowTicker() != showTicker || showTicker != dataProvider.isTickerVisible()) {
        wantToFireDataStructureChanged = true;
        if (showTicker) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowRate() != showRate) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBid() != showBid) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowAsk() != showAsk) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowExchange() != showExchange) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } 
                
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW, Boolean.valueOf(showTicker).toString());
                    controller.getModel().setUserPreference(ExchangeModel.SHOW_BITCOIN_CONVERTED_TO_FIAT,
                      Boolean.valueOf(showBitcoinConvertedToFiat).toString());
                
                    String columnsToShow = "";
                    if (showCurrency)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_CURRENCY;
                    if (showRate)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_LAST_PRICE;
                    if (showBid)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_BID;
                    if (showAsk)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_ASK;
                    if (showExchange)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_EXCHANGE;
                
                    if ("".equals(columnsToShow)) {
        // A user could just switch all the columns off in the settings
        // so
        // put a 'none' in the list of columns
        // this is to stop the default columns appearing.
        columnsToShow = TickerTableModel.TICKER_COLUMN_NONE;
                    }
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW, columnsToShow);
                
                    String previousExchange1 = dataProvider.getPreviousExchange1();
                    String newExchange1 = dataProvider.getNewExchange1();
                    if (newExchange1 != null && !newExchange1.equals(previousExchange1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, newExchange1);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange1);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange1, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency1 = dataProvider.getPreviousCurrency1();
                    String newCurrency1 = dataProvider.getNewCurrency1();
                    if (newCurrency1 != null && !newCurrency1.equals(previousCurrency1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, newCurrency1);
        String newCurrencyCode = newCurrency1;
        if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(newExchange1)) {
            // Use only the last three characters - the currency code.
             if (newCurrency1.length() >= 3) {
                newCurrencyCode = newCurrency1.substring(newCurrency1.length() - 3);
            }
        }
        try {
            CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode));
        } catch ( org.joda.money.IllegalCurrencyException e) {
            e.printStackTrace();
        }
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousShowSecondRow = Boolean.valueOf(dataProvider.getPreviousShowSecondRow()).toString();
                    String newShowSecondRow = Boolean.valueOf(dataProvider.getNewShowSecondRow()).toString();
                    if (newShowSecondRow != null && !newShowSecondRow.equals(previousShowSecondRow)) {
        // New show second row is set on model.
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW, newShowSecondRow);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousExchange2 = dataProvider.getPreviousExchange2();
                    String newExchange2 = dataProvider.getNewExchange2();
                    if (newExchange2 != null && !newExchange2.equals(previousExchange2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, newExchange2);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange2);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange2, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency2 = dataProvider.getPreviousCurrency2();
                    String newCurrency2 = dataProvider.getNewCurrency2();
                    if (newCurrency2 != null && !newCurrency2.equals(previousCurrency2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, newCurrency2);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                            
                    String previousOerApicode = dataProvider.getPreviousOpenExchangeRatesApiCode();
                    String newOerApiCode = dataProvider.getNewOpenExchangeRatesApiCode();
                    if (newOerApiCode != null && !newOerApiCode.equals(previousOerApicode)) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                
        controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, newOerApiCode);
                    }
        */
        // Can undo.
        controller.getModel().setUserPreference(CoreModel.CAN_UNDO_PREFERENCES_CHANGES, "true");
        /*
                    if (restartTickerTimer) {
        // Reinitialise the currency converter.
        CurrencyConverter.INSTANCE.initialise(controller);
                
        // Cancel any existing timer.
        if (mainFrame.getTickerTimer1() != null) {
            mainFrame.getTickerTimer1().cancel();
        }
        if (mainFrame.getTickerTimer2() != null) {
            mainFrame.getTickerTimer2().cancel();
        }                // Start ticker timer.
        Timer tickerTimer1 = new Timer();
        mainFrame.setTickerTimer1(tickerTimer1);
                
        TickerTimerTask tickerTimerTask1 = new TickerTimerTask(this.exchangeController, mainFrame, true);
        tickerTimerTask1.createExchangeObjects(controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE));
        mainFrame.setTickerTimerTask1(tickerTimerTask1);
                
        tickerTimer1.schedule(tickerTimerTask1, 0, TickerTimerTask.DEFAULT_REPEAT_RATE);
                
        boolean showSecondRow = Boolean.TRUE.toString().equals(
                controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW));
                
        if (showSecondRow) {
            Timer tickerTimer2 = new Timer();
            mainFrame.setTickerTimer2(tickerTimer2);
                
            TickerTimerTask tickerTimerTask2 = new TickerTimerTask(this.exchangeController, mainFrame, false);
            tickerTimerTask2.createExchangeObjects(controller.getModel().getUserPreference(
                    ExchangeModel.TICKER_SECOND_ROW_EXCHANGE));
            mainFrame.setTickerTimerTask2(tickerTimerTask2);
                
            tickerTimer2.schedule(tickerTimerTask2, TickerTimerTask.TASK_SEPARATION, TickerTimerTask.DEFAULT_REPEAT_RATE);
        }
                    }
        */
        if (messagingServersHasChanged) {
            // TODO: Maybe something here so messaging servers are updated and go live immediately?
            // Currently servers are set here in class SendRequest:
            /*
                    public void setMessage(CoinSparkMessagePart [] MessageParts,String [] DeliveryServers)
            */

        }

        if (fontHasChanged) {
            wantToFireDataStructureChanged = true;
        }

        if (lookAndFeelHasChanged) {
            try {
                if (CoreModel.SYSTEM_LOOK_AND_FEEL.equals(newLookAndFeel)) {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } else {
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                        if (newLookAndFeel.equalsIgnoreCase(info.getName())) {
                            UIManager.setLookAndFeel(info.getClassName());
                            break;
                        }
                    }
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
        }

        Font newFont = dataProvider.getSelectedFont();
        if (newFont != null) {
            UIManager.put("ToolTip.font", newFont);
        }

        if (wantToFireDataStructureChanged || lookAndFeelHasChanged) {
            ColorAndFontConstants.init();
            FontSizer.INSTANCE.initialise(controller);
            HelpContentsPanel.clearBrowser();

            // Switch off blinks.
            this.bitcoinController.getModel().setBlinkEnabled(false);

            try {
                controller.fireDataStructureChanged();
                SwingUtilities.updateComponentTreeUI(mainFrame);
            } finally {
                // Switch blinks back on.
                this.bitcoinController.getModel().setBlinkEnabled(true);
            }
        }
    } finally {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getDefaultCursor());
        }
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Runs a Signal/Collect SNA method when the "Run" button is clicked
 *
 * @param evt/*from   w w w .  ja  v  a 2 s  .  co m*/
 */
private void runMetricButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runMetricButtonActionPerformed

    try {

        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        String actualMetric = metricDropDown.getSelectedItem().toString();
        if (actualMetric.equals("Degree")) {
            scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("PageRank")) {
            scgc = new PageRankSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Betweenness")) {
            scgc = new BetweennessSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();
            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Closeness")) {
            scgc = new ClosenessSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Local Cluster Coefficient")) {
            scgc = new LocalClusterCoefficientSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setMetricText(scgc.getAverage(), scgc.getAll()));
        } else if (actualMetric.equals("Triad Census")) {
            scgc = new TriadCensusSignalCollectGephiConnectorImpl(fileName);
            scgc.executeGraph();

            metricValuesTextPane.setText(setTriadCensusText(scgc.getAll()));
        } else {
            throw new IllegalArgumentException("invalid Signal/Collect metric chosen!\nPlease try again");
        }
        Dimension dim = new Dimension(750, 450);
        metricResultFrame.setMinimumSize(dim);
        metricResultFrame.pack();
        metricValuesTextPane.setVisible(true);
        metricValuesScrollPane.setVisible(true);
        metricResultFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {
        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:org.esa.snap.smart.configurator.ui.PerformancePanel.java

private void sysComputeButtonActionPerformed() {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    PerformanceParameters optimizedParameters = confOptimizer.computeOptimisedSystemParameters();

    if (VMParameters.canSave()
            && !vmParametersTextField.getText().equals(optimizedParameters.getVMParameters())) {
        vmParametersTextField.setText(optimizedParameters.getVMParameters());
        vmParametersTextField.setForeground(CURRENT_VALUES_COLOR);
        vmParametersTextField.setCaretPosition(0);
    }//from  ww w . j  a v a 2 s .c o  m

    if (!cachePathTextField.getText().equals(optimizedParameters.getCachePath().toString())) {
        cachePathTextField.setText(optimizedParameters.getCachePath().toString());
        cachePathTextField.setForeground(CURRENT_VALUES_COLOR);
    }

    setCursor(Cursor.getDefaultCursor());

    controller.changed();
}

From source file:rod_design_compute.ShowPanel.java

private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
    // TODO add your handling code here:
    if (parent.getStatus() == parent.FOCUS) {
        this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        choosePoint = null;//from  ww  w  . j  a  v  a2s. c  om
        chooseRod = null;

        for (int i = 0; i < parent.arrayRodGroup.size(); i++) {
            if (choosePoint != null || chooseRod != null)
                break;
            chooseIndex = i;
            switch (parent.arrayRodGroup.get(i).getType()) {
            case RodGroup.SR:
                SR sr = (SR) (parent.arrayRodGroup.get(i));
                if (distance(evt.getX(), evt.getY(), sr.getPointA()) < minDistance)
                    choosePoint = sr.getPointA();
                else if (distance(evt.getX(), evt.getY(), sr.getPointB()) < minDistance)
                    choosePoint = sr.getPointB();
                else if (sr.flag == true && distance(evt.getX(), evt.getY(), sr.getPointE()) < minDistance)
                    choosePoint = sr.getPointE();
                else if (distance(evt.getX(), evt.getY(), sr.getPointA(), sr.getPointB()) < minDistance) {
                    chooseRod = sr.getL_dangan();
                    chooseRodPoint1 = sr.getPointA();
                    chooseRodPoint2 = sr.getPointB();
                }
                break;
            case RodGroup.RRR:
                RRR rrr = (RRR) (parent.arrayRodGroup.get(i));
                if (distance(evt.getX(), evt.getY(), rrr.getPointB()) < minDistance)
                    choosePoint = rrr.getPointB();
                else if (distance(evt.getX(), evt.getY(), rrr.getPointC()) < minDistance)
                    choosePoint = rrr.getPointC();
                else if (distance(evt.getX(), evt.getY(), rrr.getPointD()) < minDistance)
                    choosePoint = rrr.getPointD();
                else if ((rrr.flag2 == true || rrr.flag3 == true)
                        && distance(evt.getX(), evt.getY(), rrr.getPointE()) < minDistance)
                    choosePoint = rrr.getPointE();
                else if (distance(evt.getX(), evt.getY(), rrr.getPointB(), rrr.getPointC()) < minDistance) {
                    chooseRod = rrr.getrodL2();
                    chooseRodPoint1 = rrr.getPointB();
                    chooseRodPoint2 = rrr.getPointC();
                } else if (distance(evt.getX(), evt.getY(), rrr.getPointC(), rrr.getPointD()) < minDistance) {
                    chooseRod = rrr.getrodL3();
                    chooseRodPoint1 = rrr.getPointC();
                    chooseRodPoint2 = rrr.getPointD();
                }
                break;
            case RodGroup.RRP:
                RRP rrp = (RRP) (parent.arrayRodGroup.get(i));
                if (distance(evt.getX(), evt.getY(), rrp.getPointB()) < minDistance)
                    choosePoint = rrp.getPointB();
                else if (distance(evt.getX(), evt.getY(), rrp.getPointC()) < minDistance)
                    choosePoint = rrp.getPointC();
                else if (distance(evt.getX(), evt.getY(), rrp.getPointB(), rrp.getPointC()) < minDistance) {
                    chooseRod = rrp.getrodL2();
                    chooseRodPoint1 = rrp.getPointB();
                    chooseRodPoint2 = rrp.getPointC();
                }
                break;
            default:
                break;
            }
        }
        repaint();
    }

    else
        this.setCursor(Cursor.getDefaultCursor());
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets the properties of the current graph by clicking on the property
 * button//from   w  w  w  .ja v a 2  s.  c  o  m
 *
 * @param evt
 */
private void propertyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_propertyButtonActionPerformed
    try {

        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }

        if (scgc == null || !scgc.getFileName().equals(fileName)) {
            scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
        }
        propertyContentDisplay.setText(setPropertyText(scgc.getGraphProperties()));
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private JXTaskPane createLearningExperienceChartPane() {
    JXTaskPane experienceChartPane = new JXTaskPane();
    experienceChartPane.setScrollOnExpand(true);
    experienceChartPane.setTitle("Learning Experiences");
    final LearningExperienceChartMaker maker = new LearningExperienceChartMaker(module);
    final ChartPanel chartPanel = maker.getChartPanel();
    //Add a mouselistener, listening for a double click on a bar of the stacked bar
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override/*from   ww w .  j a  v  a2 s  . c  o  m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //Get the mouse event
            MouseEvent trigger = cme.getTrigger();
            //Test if the mouse event is a left-button
            if (trigger.getButton() == MouseEvent.BUTTON1 && trigger.getClickCount() == 2) {
                //Get the selected segment of the pie
                CategoryItemEntity bar = (CategoryItemEntity) cme.getEntity();
                //Get the row key that corresponds to that segment--this is a learning experience
                String key = bar.getRowKey().toString();
                //Get the set of tlalineitems whose activity contains that learning type
                Set<TLALineItem> relevantTLAs = maker.getLearningExperienceMap().get(key);
                //Create a pop up dialog containing that set of tlalineitems
                LearningExperiencePopupDialog popup = new LearningExperiencePopupDialog(
                        (Frame) SwingUtilities.getWindowAncestor(chartPanel), true, relevantTLAs);
                //Set the title of the popup to indicate which learning type was selected
                popup.setTitle("Activities with \'" + key + "\'");
                //Centre the popup at the location of the mouse click
                Point location = trigger.getLocationOnScreen();
                int w = popup.getWidth();
                int h = popup.getHeight();
                popup.setLocation(location.x - w / 2, location.y - h / 2);
                popup.setVisible(true);
                int returnStatus = popup.getReturnStatus();
                if (returnStatus == LearningTypePopupDialog.RET_OK) {
                    modifyTLALineItem(popup.getSelectedTLALineItem(), 0);
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //Set the cursor shape according to the location of the cursor
            if (cme.getEntity() instanceof CategoryItemEntity) {
                chartPanel.setCursor(HAND);
            } else {
                chartPanel.setCursor(Cursor.getDefaultCursor());
            }
        }
    });
    chartPanel.setPreferredSize(new Dimension(125, 75));
    chartPanel.setMinimumDrawHeight(75);
    experienceChartPane.add(chartPanel);
    return experienceChartPane;
}

From source file:org.micromanager.CRISP.CRISPFrame.java

private void CurveButton_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CurveButton_ActionPerformed
    try {/* www  . j av a  2s.c  om*/
        core_.enableContinuousFocus(false);
        // TODO: emulate pressing Zero button

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        core_.setProperty(CRISP_, "Obtain Focus Curve", "Do it");
        int index = 0;
        String vals = "";
        while (core_.hasProperty(CRISP_, "Focus Curve Data" + index)) {
            vals += core_.getProperty(CRISP_, "Focus Curve Data" + index);
            index++;
        }

        XYSeries data = new XYSeries("");
        String[] valLines = vals.split("\r\n");
        for (int i = 0; i < valLines.length; i++) {
            String[] tokens = valLines[i].split("\\s+");
            data.add(Float.parseFloat(tokens[2]), Integer.parseInt(tokens[3]));
        }

        String na = core_.getProperty(CRISP_, "Objective NA");
        plotData("CRISP Focus Curve, for NA=" + na, data, "Z-position(microns)", "Focus Error Signal", 200,
                200);

    } catch (Exception ex) {
        ReportingUtils.showError("Problem acquiring focus curve");
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}

From source file:com.signalcollect.sna.visualization.SignalCollectSNATopComponent.java

/**
 * Gets and visualizes the chart of the Degree Distribution
 *
 * @param evt//from ww w  . j  ava  2 s .co m
 */
private void degreeDistributionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_degreeDistributionButtonActionPerformed
    try {
        mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (jTextArea1.getText() == null) {
            throw new IllegalArgumentException("No file was chosen!\nPlease choose a valid .gml file");
        }
        if (!jTextArea1.getText().contains(".gml")) {
            throw new IllegalArgumentException(
                    "The chosen file doesn't have the right format!\nPlease choose a valid .gml file");
        }
        distributionFrame.setVisible(false);
        distributionFrame = new JFrame();

        scgc = new DegreeSignalCollectGephiConnectorImpl(fileName);
        JFreeChart chart = scgc.createDegreeDistributionChart(scgc.getDegreeDistribution());
        ChartPanel chartPanel = new ChartPanel(chart);
        Dimension dim = new Dimension(750, 450);
        distributionFrame.setMinimumSize(dim);
        distributionFrame.add(chartPanel);
        chartPanel.setVisible(true);
        chartPanel.validate();

        distributionFrame.pack();
        distributionFrame.setVisible(true);
    } catch (IllegalArgumentException exception) {

        messageFrame = new JFrame();
        JOptionPane.showMessageDialog(messageFrame, exception.getMessage(), "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);

    } catch (Exception exception) {
        messageFrame = new JFrame();
        exception.printStackTrace();
        JOptionPane.showMessageDialog(messageFrame,
                "Technical exception happened (" + exception.getCause() + ")", "Signal/Collect Error",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        mainPanel.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private JXTaskPane createLearnerFeedbackChartPane() {
    JXTaskPane feedbackChartPane = new JXTaskPane();
    feedbackChartPane.setScrollOnExpand(true);
    feedbackChartPane.setTitle("Learner Feedback");
    FeedbackChartMaker maker = new FeedbackChartMaker(module);
    final ChartPanel chartPanel = maker.getChartPanel();
    //Add a mouselistener, listening for a double click on a bar of the stacked bar
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override/*from  w  w  w  .  jav  a  2s.  co m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //Get the mouse event
            MouseEvent trigger = cme.getTrigger();
            //Test if the mouse event is a left-button
            if (trigger.getButton() == MouseEvent.BUTTON1 && trigger.getClickCount() == 2) {

                //Create a pop up dialog containing that the tlalineitems
                FeedbackPopupDialog popup = new FeedbackPopupDialog(
                        (Frame) SwingUtilities.getWindowAncestor(chartPanel), true, module.getTLALineItems());
                //Set the title of the popup 
                popup.setTitle("All Activities");
                //Centre the popup at the location of the mouse click
                Point location = trigger.getLocationOnScreen();
                int w = popup.getWidth();
                int h = popup.getHeight();
                popup.setLocation(location.x - w / 2, location.y - h / 2);
                popup.setVisible(true);
                int returnStatus = popup.getReturnStatus();
                if (returnStatus == LearningTypePopupDialog.RET_OK) {
                    modifyTLALineItem(popup.getSelectedTLALineItem(), 1);
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //Set the cursor shape according to the location of the cursor
            if (cme.getEntity() instanceof CategoryItemEntity) {
                chartPanel.setCursor(HAND);
            } else {
                chartPanel.setCursor(Cursor.getDefaultCursor());
            }
        }
    });
    chartPanel.setPreferredSize(new Dimension(150, 200));
    feedbackChartPane.add(chartPanel);
    return feedbackChartPane;
}

From source file:au.com.jwatmuff.eventmanager.gui.main.MainWindow.java

private void firewallMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firewallMenuItemActionPerformed
    String rule = "EventManager Port 1199";
    String title = "Update Firewall";

    try {//from  www  .  ja v  a  2 s .c  om
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        if (WindowsNetUtil.firewallRuleExists(rule)) {
            GUIUtils.displayMessage(null, "Firewall already configured", title);
            return;
        }
        WindowsNetUtil.openInboundFirewallPort(rule, 1199);
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
    if (WindowsNetUtil.firewallRuleExists(rule)) {
        GUIUtils.displayMessage(null, "Firewall Successfully Updated", title);
    } else {
        GUIUtils.displayError(null, "Failed to update firewall");
    }
}