Example usage for java.awt Cursor DEFAULT_CURSOR

List of usage examples for java.awt Cursor DEFAULT_CURSOR

Introduction

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

Prototype

int DEFAULT_CURSOR

To view the source code for java.awt Cursor DEFAULT_CURSOR.

Click Source Link

Document

The default cursor type (gets set if no cursor is defined).

Usage

From source file:org.tinymediamanager.ui.dialogs.RegisterDonatorVersionDialog.java

public RegisterDonatorVersionDialog() {
    super(BUNDLE.getString("tmm.registerdonator"), "registerDonator"); //$NON-NLS-1$
    setBounds(166, 5, 400, 300);//w  ww . j  ava 2s  .com
    boolean isDonator = Globals.isDonator();
    Properties props = null;
    if (isDonator) {
        props = License.decrypt();
    }

    {
        JPanel panelContent = new JPanel();
        getContentPane().add(panelContent, BorderLayout.CENTER);
        panelContent.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.PARAGRAPH_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.UNRELATED_GAP_ROWSPEC, }));

        {
            JTextArea textArea = new JTextArea();
            textArea.setOpaque(false);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setEditable(false);
            panelContent.add(textArea, "2, 2, 3, 1, default, center");
            if (isDonator) {
                textArea.setText(BUNDLE.getString("tmm.registerdonator.thanks")); //$NON-NLS-1$
            } else {
                textArea.setText(BUNDLE.getString("tmm.registerdonator.hint")); //$NON-NLS-1$
            }
        }
        {
            JLabel lblName = new JLabel(BUNDLE.getString("tmm.registerdonator.name")); //$NON-NLS-1$
            panelContent.add(lblName, "2, 4, right, default");
            tfName = new JTextField("");
            lblName.setLabelFor(tfName);
            panelContent.add(tfName, "4, 4, fill, default");
            tfName.setColumns(10);
            if (isDonator) {
                tfName.setText(props.getProperty("user"));
                tfName.setEnabled(false);
            }
        }
        {
            JLabel lblEmailAddress = new JLabel(BUNDLE.getString("tmm.registerdonator.email")); //$NON-NLS-1$
            panelContent.add(lblEmailAddress, "2, 6, right, default");
            tfEmailAddress = new JTextField("");
            lblEmailAddress.setLabelFor(tfEmailAddress);
            panelContent.add(tfEmailAddress, "4, 6, fill, default");
            tfEmailAddress.setColumns(10);
            if (isDonator) {
                tfEmailAddress.setText(props.getProperty("email"));
                tfEmailAddress.setEnabled(false);
            }
        }
    }
    {
        JPanel panelButtons = new JPanel();
        panelButtons.setBorder(new EmptyBorder(4, 4, 4, 4));
        getContentPane().add(panelButtons, BorderLayout.SOUTH);
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        panelButtons.setLayout(layout);
        {
            JButton btnRegister = new JButton(BUNDLE.getString("Button.register")); //$NON-NLS-1$
            btnRegister.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    try {
                        LOGGER.debug("registering for donator version: ", tfEmailAddress.getText());
                        Properties p = new Properties();
                        p.setProperty("user", tfName.getText());
                        p.setProperty("email", tfEmailAddress.getText());
                        p.setProperty("generated", String.valueOf(new Date().getTime()));
                        p.setProperty("uuid", FileUtils.readFileToString(new File("tmm.uuid")));

                        // get encrypted string and write tmm.lic
                        if (License.encrypt(p) && License.isValid()) {
                            JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this,
                                    BUNDLE.getString("tmm.registerdonator.success")); //$NON-NLS-1$
                            setVisible(false);
                        } else {
                            JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this,
                                    BUNDLE.getString("tmm.registerdonator.error")); //$NON-NLS-1$
                        }
                    } catch (Exception ex) {
                        LOGGER.error("Error registering donator version: " + ex.getMessage());
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });
            if (isDonator) {
                btnRegister.setEnabled(false);
            }
            panelButtons.add(btnRegister);
        }
        {
            JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$
            btnClose.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    setVisible(false);
                }
            });
            panelButtons.add(btnClose);
        }
    }
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            tfName.requestFocus();
        }
    });
}

From source file:org.ecoinformatics.seek.ecogrid.quicksearch.QuickSearchAction.java

/**
 * The todo Implementation of abstract method. It will search ecogrid site
 * //  w w  w  .  jav  a2s. c  o m
 * @param e
 *            ActionEvent
 */
public synchronized void actionPerformed(ActionEvent e) {
    datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    CacheManager cm;
    try {
        cm = CacheManager.getInstance();
        //cm.showDB();
    } catch (CacheException e1) {
        e1.printStackTrace();
    }
    String searchValue = null;
    if (datasetPanel != null) {
        searchValue = datasetPanel.getSearchTextFieldValue();
        // searchType = datasetPanel.getSearchDataSrcType();
        resultRoot = datasetPanel.getResultRoot();
    }

    //
    // If no search term is entered, return immediately.
    if (searchValue == null || searchValue.trim().equals("")) {
        return;
    }

    System.out.println("searching..");

    searchServicesVector = controller.getSelectedServicesList();
    actionList = new Vector();

    // transfer endpoint based EcoGridService to namespace based Search
    // Scope
    Vector searchScopeVector = transformEcoGridServiceToSearchScope();
    if (!searchScopeVector.isEmpty() && resultRoot != null) {
        resultRoot.removeAllEntities();
        // go through every namespace in search scope
        for (int i = 0; i < searchScopeVector.size(); i++) {
            // vecotr to store the ResultRecord for one search scope
            SearchScope searchScope = (SearchScope) searchScopeVector.elementAt(i);
            // String namespace = searchScope.getNamespace();
            // get quick search query from metadata specification class
            MetadataSpecificationInterface metadataSpecClass = searchScope.getMetadataSpecification();

            // *** Temporary Code
            String namespace = searchScope.getNamespace();

            QueryType quickSearchQuery = null;
            try {
                quickSearchQuery = metadataSpecClass.getQuickSearchEcoGridQuery(searchValue);
            } catch (InvalidEcogridQueryException inE) {
                log.debug("The error to generate quick search query ", inE);
                return;
            }
            Vector searchEndPoints = searchScope.getEndPoints();
            if (searchEndPoints == null) {
                log.debug("No search end points can be found");
                return;
            }

            // go through the end points vector and create query action

            searchEndPointsVector(searchEndPoints, quickSearchQuery, searchValue, metadataSpecClass, namespace);

        } // for
        log.debug("Initial query action ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " + actionList.size());
        completedRequests = new CountDown(actionList.size());
        // start query action
        datasetPanel.resetResultsPanel();

        boolean forRegistryQuery = false;
        datasetPanel.startSearchProgressBar(forRegistryQuery);
        for (int i = 0; i < actionList.size(); i++) {
            QueryAction queryAction = (QueryAction) actionList.elementAt(i);
            queryAction.actionPerformed(null);
        }

    } // if
    datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Supplies the JPanel which is displayed in the main Jogra window.
 *///from  w ww.  ja v a  2 s  . c o  m
public JPanel getMainWindowPlugin() {

    final JPanel ret = new JPanel();
    final JButton loadButton = new JButton("Load Term Rationaliser");
    final JLabel chooseType = new JLabel("Select term: ");
    final JComboBox termTypeBox = new JComboBox(instances.keySet().toArray());
    final JCheckBox showEVCFilter = new JCheckBox("Highlight terms with evidence codes", true);

    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent ae) {

            new SwingWorker<JFrame, Void>() {
                @Override
                protected JFrame doInBackground() throws Exception {
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    setTermType(instances.get((String) termTypeBox.getSelectedItem()));
                    setShowEVC(showEVCFilter.isSelected());
                    return makeWindow();
                }

                @Override
                public void done() {
                    try {
                        final GeneDBMessage e = new OpenWindowEvent(TermRationaliser.this, get());
                        EventBus.publish(e);
                    } catch (final InterruptedException exp) {
                        exp.printStackTrace();
                    } catch (final ExecutionException exp) {
                        exp.printStackTrace();
                    }
                    ret.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }.execute();
        }
    });
    Box verticalBox = Box.createVerticalBox();
    Box horizontalBox = Box.createHorizontalBox();
    horizontalBox.add(chooseType);
    horizontalBox.add(termTypeBox);
    verticalBox.add(horizontalBox);
    verticalBox.add(loadButton);
    verticalBox.add(showEVCFilter);
    ret.add(verticalBox);
    return ret;
}

From source file:mainpackage.FrmXuatThongTin.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w w w. j av a  2  s . c  o  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jTabbedPane1 = new javax.swing.JTabbedPane();
    pnMap = new javax.swing.JPanel();
    map = new org.openstreetmap.gui.jmapviewer.JMapViewer();
    btnZoomIn = new javax.swing.JButton();
    btnZoomOut = new javax.swing.JButton();
    pnCommand = new javax.swing.JPanel();
    btnStartStop = new javax.swing.JButton();
    btnExit = new javax.swing.JButton();
    btnRunMotor = new javax.swing.JButton();
    lblCommand = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    txtaDataInfo = new javax.swing.JTextArea();
    lblDataInformation = new javax.swing.JLabel();
    lblDate = new javax.swing.JLabel();
    lblDisplayDate = new javax.swing.JLabel();
    pnTable = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    tblDatabase = new javax.swing.JTable();
    jScrollPane3 = new javax.swing.JScrollPane();
    txtaTestPacket = new javax.swing.JTextArea();
    pnGraph = new javax.swing.JPanel();
    cbbGraphSelection = new javax.swing.JComboBox();
    pnDisplayGraph = new javax.swing.JPanel();
    lblTitle = new javax.swing.JLabel();
    lblLogoBachKhoa = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    jTabbedPane1.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N

    pnMap.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
    pnMap.add(map, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 840, 510));

    btnZoomIn.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    btnZoomIn.setText("Zoom in");
    btnZoomIn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomInActionPerformed(evt);
        }
    });
    pnMap.add(btnZoomIn, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 520, -1, -1));

    btnZoomOut.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    btnZoomOut.setText("Zoom out");
    btnZoomOut.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomOutActionPerformed(evt);
        }
    });
    pnMap.add(btnZoomOut, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 520, -1, -1));

    pnCommand.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 255)));

    btnStartStop.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    btnStartStop.setText("Start");
    btnStartStop.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnStartStopActionPerformed(evt);
        }
    });
    pnCommand.add(btnStartStop);

    btnExit.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    btnExit.setText("Exit");
    btnExit.setMaximumSize(new java.awt.Dimension(85, 37));
    btnExit.setMinimumSize(new java.awt.Dimension(85, 37));
    btnExit.setPreferredSize(new java.awt.Dimension(85, 37));
    btnExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnExitActionPerformed(evt);
        }
    });
    pnCommand.add(btnExit);

    btnRunMotor.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
    btnRunMotor.setText("Run motor");
    btnRunMotor.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnRunMotorActionPerformed(evt);
        }
    });
    pnCommand.add(btnRunMotor);

    pnMap.add(pnCommand, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 50, 210, 100));

    lblCommand.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    lblCommand.setText("Command");
    pnMap.add(lblCommand, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 30, -1, -1));

    txtaDataInfo.setColumns(20);
    txtaDataInfo.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
    txtaDataInfo.setRows(5);
    jScrollPane1.setViewportView(txtaDataInfo);

    pnMap.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 190, 210, 270));

    lblDataInformation.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    lblDataInformation.setText("Node Information");
    pnMap.add(lblDataInformation, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 170, -1, -1));

    lblDate.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    lblDate.setText("Date");
    pnMap.add(lblDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 480, -1, -1));
    pnMap.add(lblDisplayDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 510, -1, -1));

    jTabbedPane1.addTab("Map", pnMap);

    pnTable.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    tblDatabase.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    tblDatabase.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
    tblDatabase.setModel(new javax.swing.table.DefaultTableModel(
            new Object[][] { { null, null, null, null, null, null, null } }, new String[] { "Node ID",
                    "Address", "Location", "Temperature", "Humidity", "Signal Strength", "Timer" }));
    jScrollPane2.setViewportView(tblDatabase);

    pnTable.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, 1080, 170));

    txtaTestPacket.setColumns(20);
    txtaTestPacket.setRows(5);
    jScrollPane3.setViewportView(txtaTestPacket);

    pnTable.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 300, 300, 260));

    jTabbedPane1.addTab("Table", pnTable);

    pnGraph.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    cbbGraphSelection.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Ch?n Node--" }));
    cbbGraphSelection.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cbbGraphSelectionActionPerformed(evt);
        }
    });
    pnGraph.add(cbbGraphSelection, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 10, -1, -1));

    pnDisplayGraph.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    pnGraph.add(pnDisplayGraph, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 40, 1130, 530));

    jTabbedPane1.addTab("Graph", pnGraph);

    getContentPane().add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 117, 1140, 610));

    lblTitle.setFont(new java.awt.Font("Wide Latin", 1, 48)); // NOI18N
    lblTitle.setForeground(new java.awt.Color(255, 51, 51));
    lblTitle.setText("Smart Agriculture");
    getContentPane().add(lblTitle, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 40, -1, -1));

    lblLogoBachKhoa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mainpackage/LogoBachKhoa.png"))); // NOI18N
    getContentPane().add(lblLogoBachKhoa, new org.netbeans.lib.awtextra.AbsoluteConstraints(930, 0, 130, 140));

    setBounds(0, 0, 1150, 768);
}

From source file:FTPApp.java

protected void disconnect() {
    if (ftpClient != null) {
        try {//  www  . j av a 2 s .  c  o m
            ftpClient.closeServer();
        } catch (IOException ex) {
        }
        ftpClient = null;
    }
    Runnable runner = new Runnable() {
        public void run() {
            m_progress.setValue(0);
            putButton.setEnabled(true);
            getButton.setEnabled(true);
            fileButton.setEnabled(true);
            closeButton.setText("Close");
            FTPApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        }
    };
    SwingUtilities.invokeLater(runner);
}

From source file:com.ssn.listener.SSNInstagramSelectionListener.java

private void createComponents(SSNHomeForm ssnHomeForm, List<InstagramMedia> completePhotoList) {
    SSNHelper.toggleDeleteAndShareImages(false, ssnHomeForm);

    try {/*w w w  .  j av a2 s  .  co  m*/
        List<File> listOfFiles = new ArrayList<File>();

        File instagramPhotosDir = new File(SSNHelper.getInstagramPhotosDirPath());
        if (!instagramPhotosDir.exists()) {
            instagramPhotosDir.mkdir();
        }

        for (InstagramMedia photo : completePhotoList) {
            String imageUrl = photo.getImageUrl();

            URL url = new URL(imageUrl);
            File file = new File(SSNHelper.getInstagramPhotosDirPath() + photo.getId() + ".jpg");
            if (!file.exists()) {
                try {
                    FileUtils.copyURLToFile(url, file);
                    listOfFiles.add(file);
                } catch (Exception e) {
                    // e.printStackTrace();
                }
            } else {
                listOfFiles.add(file);
            }
        }

        File[] fileArray = listOfFiles.toArray(new File[0]);
        SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray, ssnHomeForm);
        contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);

        ssnHomeForm.getSsnHomeCenterPanel().removeAll();
        ssnHomeForm.getSsnHomeCenterMainPanel().removeAll();

        ssnHomeForm.getSsnHomeCenterPanel().add(ssnHomeForm.getScrollPane(contentPane,
                SSNHelper.getAlbumNameFromPath(ssnHomeForm.ssnFileExplorer.m_display.getText())));
        ssnHomeForm
                .getSsnHomeCenterMainPanel().add(
                        ssnHomeForm.getSortPanel("Date", false,
                                SSNHelper
                                        .getAlbumNameFromPath(ssnHomeForm.ssnFileExplorer.m_display.getText())),
                        BorderLayout.NORTH);
        ssnHomeForm.getSsnHomeCenterMainPanel().add(ssnHomeForm.getSsnHomeCenterPanel(), BorderLayout.CENTER);
        ssnHomeForm.getHomeModel().getSSNMediaFolderProperties(
                ssnHomeForm.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(), fileArray);
        //ssnHomeForm.add(ssnHomeForm.getSsnHomeCenterMainPanel());

        //             ssnHomeForm.getSplitPane().setLeftComponent(ssnHomeForm.getSsnHomeLeftMainPanel());
        //             ssnHomeForm.getSplitPane().setRightComponent(ssnHomeForm.getSsnHomeCenterMainPanel());
        //                //ssnHomeForm.getSplitPane().setDividerLocation(200);
        //             ssnHomeForm.getSplitPane().revalidate();
        //             ssnHomeForm.getSplitPane().repaint();
        ssnHomeForm.revalidate();
        ssnHomeForm.repaint();
        ssnHomeForm.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

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

From source file:org.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java

@Override
public JComponent render(DateGapAnalyzerResult result) {

    final TaskSeriesCollection dataset = new TaskSeriesCollection();
    final Set<String> groupNames = result.getGroupNames();
    final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION);
    final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS);
    final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS);
    for (final String groupName : groupNames) {
        final String groupDisplayName;

        if (groupName == null) {
            if (groupNames.size() == 1) {
                groupDisplayName = "All";
            } else {
                groupDisplayName = LabelUtils.NULL_LABEL;
            }/* w ww .  ja v a  2 s . com*/
        } else {
            groupDisplayName = groupName;
        }

        final TimeInterval completeDuration = result.getCompleteDuration(groupName);
        final Task completeDurationTask = new Task(groupDisplayName,
                createTimePeriod(completeDuration.getFrom(), completeDuration.getTo()));
        completeDurationTaskSeries.add(completeDurationTask);

        // plot gaps
        {
            final SortedSet<TimeInterval> gaps = result.getGaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : gaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    gapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " gap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }

        // plot overlaps
        {
            final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : overlaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    overlapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " overlap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }
    }
    dataset.add(overlapsTaskSeries);
    dataset.add(gapsTaskSeries);
    dataset.add(completeDurationTaskSeries);

    final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0,
            GROUPS_VISIBLE);

    final JFreeChart chart = ChartFactory.createGanttChart(
            "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(),
            result.getGroupColumnName(), "Time", slidingDataset, true, true, false);
    ChartUtils.applyStyles(chart);

    // make sure the 3 timeline types have correct coloring
    {
        final CategoryPlot plot = (CategoryPlot) chart.getPlot();

        plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT,
                WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT));
    }

    final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size());
    final ChartPanel chartPanel = ChartUtils.createPanel(chart, ChartUtils.WIDTH_WIDE, visibleLines * 50 + 200);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            ChartEntity entity = event.getEntity();
            if (entity instanceof PlotEntity) {
                cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
            }
            chartPanel.setCursor(cursor);
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // do nothing
        }
    });

    final JComponent decoratedChartPanel;

    final StringBuilder chartDescription = new StringBuilder("<html>");
    chartDescription.append("<p>The chart displays the recorded timeline based on FROM and TO dates.</p>");
    chartDescription.append(
            "<p>The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.</p>");
    chartDescription.append(
            "<p>You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.</p>");

    if (groupNames.size() > GROUPS_VISIBLE) {
        final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL);
        scroll.setMinimum(0);
        scroll.setMaximum(groupNames.size());
        scroll.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                int value = e.getAdjustable().getValue();
                slidingDataset.setFirstCategoryIndex(value);
            }
        });

        chartPanel.addMouseWheelListener(new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                int scrollType = e.getScrollType();
                if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                    int wheelRotation = e.getWheelRotation();
                    scroll.setValue(scroll.getValue() + wheelRotation);
                }
            }
        });

        final DCPanel outerPanel = new DCPanel();
        outerPanel.setLayout(new BorderLayout());
        outerPanel.add(chartPanel, BorderLayout.CENTER);
        outerPanel.add(scroll, BorderLayout.EAST);
        chartDescription.append("<p>Use the right <b>scrollbar</b> to scroll up and down on the chart.</p>");
        decoratedChartPanel = outerPanel;
    } else {
        decoratedChartPanel = chartPanel;
    }

    chartDescription.append("</html>");

    final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString());

    final DCPanel panel = new DCPanel();
    panel.setLayout(new VerticalLayout());
    panel.add(chartDescriptionLabel);
    panel.add(decoratedChartPanel);

    return panel;
}

From source file:com.intel.stl.ui.common.view.JumpChartPanel.java

@Override
public void chartMouseMoved(ChartMouseEvent cme) {
    JPopupMenu popup = getPopupMenu();
    if (popup != null && popup.isShowing()) {
        return;//  ww  w.ja  v  a  2  s  . c  om
    }

    ChartEntity xyItem = cme.getEntity();
    if (xyItem instanceof CategoryLabelEntity) {
        CategoryLabelEntity newCatEntity = (CategoryLabelEntity) xyItem;
        if (highlightedEntity != null && newCatEntity.getKey().equals(highlightedEntity.getKey())) {
            return;
        }

        if (highlightedEntity != null) {
            highlightEntity(highlightedEntity, false);
        }

        highlightedEntity = (CategoryLabelEntity) xyItem;
        if (categoryAxis == null) {
            CategoryPlot plot = getChart().getCategoryPlot();
            categoryAxis = plot.getDomainAxis();
        }
        highlightEntity(highlightedEntity, true);
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        if (highlightedEntity != null) {
            highlightEntity(highlightedEntity, false);
            highlightedEntity = null;
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:Interfaces.EstadisticaGui.java

private void dibujarGraficos() {
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    abrirBase();//from   ww  w  . j a v a  2  s . c o m
    panelGrande.removeAll();
    Integer anio = (Integer) spinnerAnio.getValue();
    // Creamos y rellenamos el modelo de datos
    LazyList<Categoria> categorias = Categoria.findAll();
    Iterator<Categoria> it = categorias.iterator();
    while (it.hasNext()) {
        Categoria c = it.next();
        if (!c.getString("nombre").equals("COMPRAS")) {
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            float[] ingreso = calcularIngreso(c.getInteger("id"), anio);
            dataset.setValue(ingreso[0], c.getString("nombre"), "Enero");
            dataset.setValue(ingreso[1], c.getString("nombre"), "Febrero");
            dataset.setValue(ingreso[2], c.getString("nombre"), "Marzo");
            dataset.setValue(ingreso[3], c.getString("nombre"), "Abril");
            dataset.setValue(ingreso[4], c.getString("nombre"), "Mayo");
            dataset.setValue(ingreso[5], c.getString("nombre"), "Junio");
            dataset.setValue(ingreso[6], c.getString("nombre"), "Julio");
            dataset.setValue(ingreso[7], c.getString("nombre"), "Agosto");
            dataset.setValue(ingreso[8], c.getString("nombre"), "Septiembre");
            dataset.setValue(ingreso[9], c.getString("nombre"), "Octubre");
            dataset.setValue(ingreso[10], c.getString("nombre"), "Noviembre");
            dataset.setValue(ingreso[11], c.getString("nombre"), "Diciembre");
            JFreeChart chart = ChartFactory.createBarChart3D(
                    "Ingresos en la categoria " + c.getString("nombre"), "mes", "Pesos", dataset,
                    PlotOrientation.VERTICAL, true, true, false);
            // Creacin del panel con el grfico
            ChartPanel panelGrafico = new ChartPanel(chart);
            CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
            org.jfree.chart.axis.CategoryAxis categoryaxis = categoryplot.getDomainAxis();
            categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.2D));
            CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
            categoryitemrenderer.setBaseItemLabelsVisible(true);
            JPanel panelParaGrafico = new JPanel();
            panelParaGrafico.setLayout(new BorderLayout());
            panelGrande.add(panelParaGrafico);
            panelParaGrafico.add(panelGrafico);
        }
    }
    this.pack();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

}

From source file:org.eobjects.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java

@Override
public JComponent render(DateGapAnalyzerResult result) {

    final TaskSeriesCollection dataset = new TaskSeriesCollection();
    final Set<String> groupNames = result.getGroupNames();
    final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION);
    final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS);
    final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS);
    for (final String groupName : groupNames) {
        final String groupDisplayName;

        if (groupName == null) {
            if (groupNames.size() == 1) {
                groupDisplayName = "All";
            } else {
                groupDisplayName = LabelUtils.NULL_LABEL;
            }/*from w w  w.ja v  a2 s  .  c o m*/
        } else {
            groupDisplayName = groupName;
        }

        final TimeInterval completeDuration = result.getCompleteDuration(groupName);
        final Task completeDurationTask = new Task(groupDisplayName,
                createTimePeriod(completeDuration.getFrom(), completeDuration.getTo()));
        completeDurationTaskSeries.add(completeDurationTask);

        // plot gaps
        {
            final SortedSet<TimeInterval> gaps = result.getGaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : gaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    gapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " gap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }

        // plot overlaps
        {
            final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName);

            int i = 1;
            Task rootTask = null;
            for (TimeInterval interval : overlaps) {
                final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo());

                if (rootTask == null) {
                    rootTask = new Task(groupDisplayName, timePeriod);
                    overlapsTaskSeries.add(rootTask);
                } else {
                    Task task = new Task(groupDisplayName + " overlap" + i, timePeriod);
                    rootTask.addSubtask(task);
                }

                i++;
            }
        }
    }
    dataset.add(overlapsTaskSeries);
    dataset.add(gapsTaskSeries);
    dataset.add(completeDurationTaskSeries);

    final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0,
            GROUPS_VISIBLE);

    final JFreeChart chart = ChartFactory.createGanttChart(
            "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(),
            result.getGroupColumnName(), "Time", slidingDataset, true, true, false);
    ChartUtils.applyStyles(chart);

    // make sure the 3 timeline types have correct coloring
    {
        final CategoryPlot plot = (CategoryPlot) chart.getPlot();

        plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT,
                WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT));
    }

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            ChartEntity entity = event.getEntity();
            if (entity instanceof PlotEntity) {
                cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
            }
            chartPanel.setCursor(cursor);
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // do nothing
        }
    });

    final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size());

    chartPanel.setPreferredSize(new Dimension(0, visibleLines * 50 + 200));

    final JComponent decoratedChartPanel;

    StringBuilder chartDescription = new StringBuilder();
    chartDescription
            .append("<html><p>The chart displays the recorded timeline based on FROM and TO dates.<br/><br/>");
    chartDescription.append(
            "The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.<br/><br/>");
    chartDescription.append(
            "You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.");

    if (groupNames.size() > GROUPS_VISIBLE) {
        final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL);
        scroll.setMinimum(0);
        scroll.setMaximum(groupNames.size());
        scroll.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                int value = e.getAdjustable().getValue();
                slidingDataset.setFirstCategoryIndex(value);
            }
        });

        chartPanel.addMouseWheelListener(new MouseWheelListener() {

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                int scrollType = e.getScrollType();
                if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                    int wheelRotation = e.getWheelRotation();
                    scroll.setValue(scroll.getValue() + wheelRotation);
                }
            }
        });

        final DCPanel outerPanel = new DCPanel();
        outerPanel.setLayout(new BorderLayout());
        outerPanel.add(chartPanel, BorderLayout.CENTER);
        outerPanel.add(scroll, BorderLayout.EAST);
        chartDescription.append("<br/><br/>Use the right <b>scrollbar</b> to scroll up and down on the chart.");
        decoratedChartPanel = outerPanel;

    } else {
        decoratedChartPanel = chartPanel;
    }

    chartDescription.append("</p></html>");

    final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString());

    chartDescriptionLabel.setBorder(new EmptyBorder(4, 10, 4, 10));

    final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(decoratedChartPanel);
    split.add(chartDescriptionLabel);
    split.setDividerLocation(550);

    return split;
}