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:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Handles a 'mouse released' event. On Windows, we need to check if this is a popup trigger,
 * but only if we haven't already been tracking a zoom rectangle.
 * //from   www. j  a  v a2 s . c  o m
 * @param e
 *            information about the event.
 */

@Override
public void mouseReleased(MouseEvent e) {
    // if we've been panning, we need to reset now that the mouse is
    // released...
    if (this.panLast != null) {
        this.panLast = null;
        setCursor(Cursor.getDefaultCursor());
    } else if (this.selectionRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            hZoom = this.rangeZoomable;
            vZoom = this.domainZoomable;
        } else {
            hZoom = this.domainZoomable;
            vZoom = this.rangeZoomable;
        }

        boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
        if (zoomTrigger1 || zoomTrigger2) {
            if (hZoom && e.getX() < this.zoomPoint.getX() || vZoom && e.getY() < this.zoomPoint.getY()) {
                restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                double maxX = screenDataArea.getMaxX();
                double maxY = screenDataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = this.zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = this.zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
                } else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
                    h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
                selectRectangle(zoomArea, e);
            }
            this.zoomPoint = null;
            this.selectionRectangle = null;
        } else {
            this.zoomPoint = null;
            this.selectionRectangle = null;
        }

    }

    else if (e.isPopupTrigger()) {
        if (this.popup != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }

}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

protected void updateCursorForIndicator() {
    if (currentIndicator == null) {
        setCursor(Cursor.getDefaultCursor());
        return;/*ww w . j  ava2 s.c  om*/
    }
    switch (currentIndicator) {
    case NOT_IN_RANGE:
        setCursor(Cursor.getDefaultCursor());
        break;
    case MOVE:
        setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
        break;
    case BOTTOM_CENTER:
        setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
        break;
    case BOTTOM_LEFT:
        setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
        break;
    case BOTTOM_RIGHT:
        setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
        break;
    case MIDDLE_LEFT:
        setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
        break;
    case MIDDLE_RIGHT:
        setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
        break;
    case TOP_LEFT:
        setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
        break;
    case TOP_CENTER:
        setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
        break;
    case TOP_RIGHT:
        setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
        break;
    }
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void showWaitCursor(boolean show) {
    Frame frame = getFrame();/*from   w w w  .j  a  v a  2  s .c  o  m*/
    if (frame == null)
        return;
    if (show)
        frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    else
        frame.setCursor(Cursor.getDefaultCursor());
}

From source file:stainingestimation.StainingEstimation.java

/**
 * Opens a dialog to let the user choose a file in which the table of the staining estimation parameters is saved.
 *//*from   ww  w .  j  av  a  2  s  .co m*/
private void saveTable() {
    if (previewOriginal != null && jXTable1.getRowCount() > 0) {
        String sep = manager.getColumnSeparator();
        String currentDir = manager.getCurrentDir();
        File file;
        List<String> exts = new ArrayList<>(1);
        exts.add("csv");
        List<String> descrs = new ArrayList<>(1);
        descrs.add("Semicolon separated file");
        String filename = null;
        if (manager.getVisibleTMAspot() != null) {
            filename = Misc.FilePathStringtoFilenameWOExtension(manager.getVisibleTMAspot().getName()) + ".csv";
        }
        file = FileChooser.chooseSavingFile(this, currentDir, filename, exts, descrs);

        if (file != null) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            // Save csv
            try {
                BufferedWriter bfw = new BufferedWriter(new FileWriter(file));
                for (int i = 0; i < jXTable1.getModel().getColumnCount(); i++) {
                    bfw.write("\"" + jXTable1.getModel().getColumnName(i) + "\"");
                    if (i < jXTable1.getModel().getColumnCount() - 1)
                        bfw.write(sep);
                }
                for (int i = 0; i < jXTable1.getRowCount(); i++) {
                    bfw.newLine();
                    for (int j = 0; j < jXTable1.getModel().getColumnCount(); j++) {
                        Object o = jXTable1.getModel().getValueAt(i, j);
                        if (((DefaultTableModel) jXTable1.getModel()).getColumnClass(j) == Double.class) {
                            bfw.write((Double.toString((Double) jXTable1.getModel().getValueAt(i, j))));
                        } else if (((DefaultTableModel) jXTable1.getModel())
                                .getColumnClass(j) == Integer.class) {
                            bfw.write((Integer.toString((Integer) jXTable1.getModel().getValueAt(i, j))));
                        } else if (((DefaultTableModel) jXTable1.getModel())
                                .getColumnClass(j) == String.class) {
                            bfw.write("\"" + (String) (jXTable1.getModel().getValueAt(i, j)) + "\"");
                        } else {
                            bfw.write(jXTable1.getModel().getValueAt(i, j).toString());
                        }
                        if (j < jXTable1.getModel().getColumnCount() - 1)
                            bfw.write(sep);
                    }
                }
                bfw.close();
            } catch (Exception e) {
                Logger.getLogger(StainingEstimation.class.getName()).log(Level.SEVERE, null, e);
                JOptionPane.showMessageDialog(this,
                        "Could not save file " + file.getName() + "\n(Maybe it is in use?)",
                        "Error writing file", JOptionPane.ERROR_MESSAGE);
            }

            manager.setCurrentDir(file.getAbsolutePath());
            setCursor(Cursor.getDefaultCursor());
        }

    }
}