Example usage for java.awt Cursor Cursor

List of usage examples for java.awt Cursor Cursor

Introduction

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

Prototype

protected Cursor(String name) 

Source Link

Document

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.

Usage

From source file:cn.pholance.datamanager.common.components.JRViewer.java

void pnlLinksMouseReleased(MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseReleased
    // Add your handling code here:
    pnlLinks.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

void pnlLinksMousePressed(MouseEvent evt) {//GEN-FIRST:event_pnlLinksMousePressed
    // Add your handling code here:
    pnlLinks.setCursor(new Cursor(Cursor.MOVE_CURSOR));

    downX = evt.getX();/*from ww w .  j  av a 2  s .co  m*/
    downY = evt.getY();
}

From source file:com.vgi.mafscaling.LogView.java

private void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(false);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;/*from   w ww .  j  ava  2s  .  c o m*/
    // close log player
    if (logPlayWindow != null)
        disposeLogView();
    // process log file
    File file = fileChooser.getSelectedFile();
    Properties prop = new Properties();
    prop.put("delimiter", ",");
    prop.put("firstRowHasColumnNames", "true");
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    logDataTable.filter(null);
    filterText.setText("");
    try {
        for (int i = 0; i < logDataTable.getColumnCount(); ++i)
            logDataTable.getTableHeader().removeMouseListener(
                    ((CheckboxHeaderRenderer) logDataTable.getColumn(i).getHeaderRenderer())
                            .getMouseListener());
        logDataTable.refresh(file.toURI().toURL(), prop);
        Column col;
        String colName;
        String lcColName;
        String val;
        CheckboxHeaderRenderer renderer;
        Component comp;
        XYSeries series;
        xAxisColumn.removeAllItems();
        yAxisColumn.removeAllItems();
        plotsColumn.removeAllItems();
        xAxisColumn.addItem("");
        yAxisColumn.addItem("");
        plotsColumn.setText("");
        plot3d.removeAllPlots();
        rpmDataset.removeAllSeries();
        dataset.removeAllSeries();
        xyMarker.clearLabels(true);
        rpmCol = -1;
        displCount = 0;
        selectionCombo.removeAllItems();
        listModel.removeAllElements();
        JTableHeader tableHeader = logDataTable.getTableHeader();
        for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
            col = logDataTable.getColumn(i);
            renderer = new CheckboxHeaderRenderer(i + 1, tableHeader);
            col.setHeaderRenderer(renderer);
            colName = col.getHeaderValue().toString();
            xAxisColumn.addItem(colName);
            yAxisColumn.addItem(colName);
            plotsColumn.addItem(colName);
            comp = renderer.getTableCellRendererComponent(logDataTable.getTable(), colName, false, false, 0, 0);
            col.setPreferredWidth(comp.getPreferredSize().width + 4);
            series = new XYSeries(colName);
            series.setDescription(colName);
            lcColName = colName.toLowerCase();
            dataset.addSeries(series);
            plotRenderer.setSeriesShapesVisible(i, false);
            plotRenderer.setSeriesVisible(i, false);
            selectionCombo.addItem(colName);
            listModel.addElement(new JLabel(colName, renderer.getCheckIcon(), JLabel.LEFT));
            if (rpmDataset.getSeriesCount() == 0
                    && (lcColName.matches(".*rpm.*") || lcColName.matches(".*eng.*speed.*"))) {
                rpmDataset.addSeries(series);
                rpmPlotRenderer.setSeriesShapesVisible(0, false);
                rpmPlotRenderer.setSeriesVisible(0, false);
                rpmCol = i;
            }
            for (int j = 0; j < logDataTable.getRowCount(); ++j) {
                try {
                    val = (String) logDataTable.getValueAt(j, i);
                    series.add(j, Double.valueOf(val), false);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null,
                            "Invalid numeric value in column " + colName + ", row " + (j + 1), "Invalid value",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            series.fireSeriesChanged();
        }
        if (logDataTable.getControlPanel().getComponentCount() > 7)
            logDataTable.getControlPanel().remove(7);
        logDataTable.getControlPanel().add(new JLabel("   [" + file.getName() + "]"));
        initColors();
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:org.colombbus.tangara.EditorFrame.java

/**
 * This method initializes msgButtons/*from   ww w  .j av a  2  s. co  m*/
 *
 * @return javax.swing.JPanel
 */
private JPanel getMsgButtons() {
    if (msgButtons == null) {
        toProgramLabel = new JLabel();
        toProgramLabel.setText(Messages.getString("EditorFrame.button.copyInProgramMode")); //$NON-NLS-1$
        toProgramLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 13)); //$NON-NLS-1$
        toProgramLabel.setForeground(new Color(60, 87, 174));
        toProgramLabel
                .setIcon(new ImageIcon(getClass().getResource("/org/colombbus/tangara/to_program_off.png"))); //$NON-NLS-1$
        toProgramLabel.setEnabled(false);
        toProgramLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                console.insertCodeToProgram();
            }

            @Override
            public void mouseExited(java.awt.event.MouseEvent e) {
                if (!noCodeSelected) {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    toProgramLabel.setForeground(new Color(60, 87, 174));
                }
            }

            @Override
            public void mouseEntered(java.awt.event.MouseEvent e) {
                if (!noCodeSelected) {
                    setCursor(new Cursor(Cursor.HAND_CURSOR));
                    toProgramLabel.setForeground(new Color(100, 100, 255));
                }
            }
        });

        selectAllLabel = new JLabel();
        selectAllLabel.setText(Messages.getString("EditorFrame.button.selectAll")); //$NON-NLS-1$
        selectAllLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 13)); //$NON-NLS-1$
        selectAllLabel.setForeground(new Color(60, 87, 174));
        selectAllLabel.setIcon(new ImageIcon(getClass().getResource("/org/colombbus/tangara/select_all.png"))); //$NON-NLS-1$
        selectAllLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                console.selectAll();
            }

            @Override
            public void mouseExited(java.awt.event.MouseEvent e) {
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                selectAllLabel.setForeground(new Color(60, 87, 174));
            }

            @Override
            public void mouseEntered(java.awt.event.MouseEvent e) {
                setCursor(new Cursor(Cursor.HAND_CURSOR));
                selectAllLabel.setForeground(new Color(100, 100, 255));
            }
        });

        deselectAllLabel = new JLabel();
        deselectAllLabel.setText(Messages.getString("EditorFrame.button.deselectAll")); //$NON-NLS-1$
        deselectAllLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 13)); //$NON-NLS-1$
        deselectAllLabel.setForeground(new Color(60, 87, 174));
        deselectAllLabel
                .setIcon(new ImageIcon(getClass().getResource("/org/colombbus/tangara/select_none.png"))); //$NON-NLS-1$
        deselectAllLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                console.clearSelection();
            }

            @Override
            public void mouseExited(java.awt.event.MouseEvent e) {
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                deselectAllLabel.setForeground(new Color(60, 87, 174));
            }

            @Override
            public void mouseEntered(java.awt.event.MouseEvent e) {
                setCursor(new Cursor(Cursor.HAND_CURSOR));
                deselectAllLabel.setForeground(new Color(100, 100, 255));
            }
        });

        JLabel separatorLabel1 = new JLabel("        "); //$NON-NLS-1$
        JLabel separatorLabel2 = new JLabel("        "); //$NON-NLS-1$

        msgButtons = new JPanel();
        msgButtons.setLayout(new FlowLayout());
        msgButtons.setBackground(new Color(240, 240, 240));
        msgButtons.add(toProgramLabel);
        msgButtons.add(separatorLabel1);
        msgButtons.add(selectAllLabel);
        msgButtons.add(separatorLabel2);
        msgButtons.add(deselectAllLabel);
    }
    return msgButtons;
}

From source file:cobweb.Cobweb.java

/**
 * Load the neighbourhood (conected nodes) of the given node by sending a
 * request to the server using the defined neighbourhood-script
 * /*w  w  w.java2 s.  c om*/
 * @param n
 *            The node whose neighbourhood is to be loaded
 */
public void loadNeighbourhood(Node n) {
    if (params.getNeighbourhoodScript() != null) {
        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        callJavascriptFunctionStatusMessage("loading neighbourhood for " + n.getName(), true);

        String lines[] = loadStrings(
                params.getServerAdress() + params.getNeighbourhoodScript() + "?id=" + n.getId());
        StringBuffer stringBuf = new StringBuffer();
        for (int i = 0; i < lines.length; i++)
            stringBuf.append(lines[i]);
        String content = stringBuf.toString();

        addNetwork(content, n.getPosition().getX(), n.getPosition().getY());

        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

        callJavascriptFunctionStatusMessage("loaded neighbourhood for " + n.getName());
    }
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

/**
 * Handles mouse dragging events: panning, sliding sections, sliding tracks,
 * and trackpad based zooming./*from  ww  w.j  a  v a  2  s. co m*/
 */
public void mouseDragged(final MouseEvent e) {

    Point currentPos = e.getPoint();
    int dX = currentPos.x - prePos.x;
    int dY = currentPos.y - prePos.y;

    float sx, sy;
    float w, h;

    canvasLock.lock();

    w = SceneGraph.getCanvasWidth(canvasId);
    h = SceneGraph.getCanvasHeight(canvasId);

    sx = w / canvas.getWidth();
    sy = h / canvas.getHeight();

    this.convertMousePointToSceneSpace(currentPos, scenePos);

    // play a bit measuring test
    if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) {
        SceneGraph.positionMouse(scenePos[0], scenePos[1]);

        // some work for panning
        // automatically pan mode
        canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR));
        SceneGraph.panScene(-dX * sx, -dY * sy);

        canvasLock.unlock();
        prePos = currentPos;
        CorelyzerApp.getApp().updateGLWindows();
        return;
    } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE) {
        SceneGraph.positionMouse(scenePos[0], scenePos[1]);

        // Don't have a selected section, just pan
        if (selectedTrackSection == -1) {
            canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR));
            SceneGraph.panScene(-dX * sx, -dY * sy);
        }

        canvasLock.unlock();
        prePos = currentPos;

        CorelyzerApp.getApp().updateGLWindows();
        return;
    }

    // check focused marker manipulation
    if (MANIPULATE_MODE == 1) {
        float dx, dy;
        dx = scenePos[0] - prescenePos[0];
        dy = scenePos[1] - prescenePos[1];
        prescenePos[0] = scenePos[0];
        prescenePos[1] = scenePos[1];
        SceneGraph.manipulateMarker(canvasId, dx, dy);
        SceneGraph.positionMouse(scenePos[0], scenePos[1]);
        canvasLock.unlock();
        prePos = currentPos;
        CorelyzerApp.getApp().updateGLWindows();
        return;
    } else {
        if (e.isAltDown()) // slide track section
        {
            // TODO consider separate move of section image and graph
            // moveSectionImage & moveSectionGraph
            if (selectedTrack >= 0 && selectedTrackSection >= 0) {
                if (canvas.getCursor().getType() != Cursor.HAND_CURSOR) {
                    canvas.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                // depth orientation
                float tX = SceneGraph.getDepthOrientation() ? dX * sx : dY * sy;

                // allow vertical movements?
                float tY = 0;
                // float tY = SceneGraph.getDepthOrientation() ?
                // (dY * sy) : (-dX * sx);

                if (selectedGraph >= 0) {
                    // moving graph instead of whole section
                    SceneGraph.moveSectionGraph(selectedTrack, selectedTrackSection, tX, tY);
                } else {
                    Object[] sections = CorelyzerApp.getApp().getSectionList().getSelectedValues();
                    int[] secids = new int[sections.length];
                    for (int i = 0; i < sections.length; i++) {
                        CoreSection cs = (CoreSection) sections[i];
                        secids[i] = (cs != null ? cs.getId() : -1);
                    }
                    SceneGraph.moveSections(selectedTrack, secids, tX, tY);
                }

                // broadcast event to plugins
                String msg = "";
                msg = msg + selectedTrack + "\t" + selectedTrackSection;
                msg = msg + "\t" + dX * sx / SceneGraph.getCanvasDPIX(canvasId) + "\t0";

                CorelyzerApp.getApp().getPluginManager()
                        .broadcastEventToPlugins(CorelyzerPluginEvent.SECTION_MOVED, msg);
            }
        } else if (e.isShiftDown()) { // slide track
            if (selectedTrack >= 0) {
                if (canvas.getCursor().getType() != Cursor.HAND_CURSOR) {
                    canvas.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                // fine tune allows depth movements
                if (isFineTune() && finetuneDialog != null) {
                    // depth orientation
                    if (SceneGraph.getDepthOrientation()) { // landscape
                        SceneGraph.moveTrack(selectedTrack, dX * sx, dY * sy);
                    } else { // Portrait
                        SceneGraph.moveTrack(selectedTrack, dY * sy, -dX * sx);
                    }

                    float currentTrackPosX = SceneGraph.getTrackXPos(selectedTrack);
                    float canvasDPIX = SceneGraph.getCanvasDPIX(0);

                    JTextField fineTuneCoreADepthStatus = finetuneDialog.getCoreAAdjustedDepthTextField();
                    JTextField fineTuneCoreBDepthStatus = finetuneDialog.getCoreBAdjustedDepthTextField();
                    int coreANativeID = finetuneDialog.getCoreANativeID();
                    int coreBNativeID = finetuneDialog.getCoreBNativeID();
                    float coreAOrigDepth = finetuneDialog.getCoreAOrigDepth();
                    float coreBOrigDepth = finetuneDialog.getCoreBOrigDepth();

                    if (fineTuneCoreADepthStatus != null && coreANativeID == selectedTrack) {
                        float depth = coreAOrigDepth + 2.54f * currentTrackPosX / (100 * canvasDPIX);
                        fineTuneCoreADepthStatus.setText(String.valueOf(depth));
                    }

                    if (fineTuneCoreBDepthStatus != null && coreBNativeID == selectedTrack) {
                        float depth = coreBOrigDepth + 2.54f * currentTrackPosX / (100 * canvasDPIX);
                        fineTuneCoreBDepthStatus.setText(String.valueOf(depth));
                    }
                } else { // normal
                    // depth orientation
                    if (SceneGraph.getDepthOrientation()) {
                        SceneGraph.moveTrack(selectedTrack, 0.0f, dY * sy);
                    } else {
                        SceneGraph.moveTrack(selectedTrack, 0.0f, -dX * sx);
                    }
                }

                // broadcast message to plugins
                String msg = "";
                msg = msg + selectedTrack;
                msg = msg + "\t0\t" + dY * sx / SceneGraph.getCanvasDPIY(canvasId);
                CorelyzerApp.getApp().getPluginManager()
                        .broadcastEventToPlugins(CorelyzerPluginEvent.TRACK_MOVED, msg);
            }
        } else if (e.isControlDown()) // zooming
        {
            sy = (float) dY / (float) canvas.getHeight();
            SceneGraph.scaleScene(1.0f + sy);
        } else if (PAN_MODE == 1) {
            // automatically pan mode
            canvas.setCursor(new Cursor(Cursor.MOVE_CURSOR));
            SceneGraph.panScene(-dX * sx, -dY * sy);
        }
    } // end of else (manipulation mode)

    SceneGraph.positionMouse(scenePos[0], scenePos[1]);
    canvasLock.unlock();
    prePos = currentPos;
    CorelyzerApp.getApp().updateGLWindows();

}

From source file:com.vgi.mafscaling.ClosedLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//from  w  w w.j a v  a2s.  co m
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements);

                boolean resetColumns = false;
                if (logClOlStatusColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0 || logTimeColIdx >= 0
                        || logMafvColIdx >= 0 || logIatColIdx >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logClOlStatusColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logAfrColIdx < 0 || logRpmColIdx < 0
                        || logLoadColIdx < 0 || logTimeColIdx < 0 || logMafvColIdx < 0 || logIatColIdx < 0) {
                    ColumnsFiltersSelection selectionWindow = new CLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements))
                        return;
                }

                String[] flds;
                line = br.readLine();
                int clol;
                int i = 2;
                int row = getLogTableEmptyRow();
                double afr = 0;
                double dVdt = 0;
                double prevTime = 0;
                double time = 0;
                double timeMultiplier = 1.0;
                double pmafv = 0;
                double mafv = 0;
                double load;
                double iat;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));

                while (line != null) {
                    flds = line.split(",", -1);
                    try {
                        // Calculate dV/dt
                        prevTime = time;
                        time = Double.valueOf(flds[logTimeColIdx]);
                        if (timeMultiplier == 1.0 && (int) time - time < 0) {
                            timeMultiplier = 1000.0;
                            prevTime *= timeMultiplier;
                        }
                        time *= timeMultiplier;
                        pmafv = mafv;
                        mafv = Double.valueOf(flds[logMafvColIdx]);
                        if ((time - prevTime) == 0.0)
                            dVdt = 100.0;
                        else
                            dVdt = Math.abs(((mafv - pmafv) / (time - prevTime)) * 1000.0);
                        clol = Integer.valueOf(flds[logClOlStatusColIdx]);
                        if (clol == clValue) {
                            // Filters
                            afr = Double.valueOf(flds[logAfrColIdx]);
                            load = Double.valueOf(flds[logLoadColIdx]);
                            iat = Double.valueOf(flds[logIatColIdx]);
                            if (afrMin <= afr && afr <= afrMax && minLoad <= load && dVdt <= maxDvDt
                                    && maxMafV >= mafv && maxIat >= iat) {
                                Utils.ensureRowCount(row + 1, logDataTable);
                                logDataTable.setValueAt(time, row, 0);
                                logDataTable.setValueAt(load, row, 1);
                                logDataTable.setValueAt(Double.valueOf(flds[logRpmColIdx]), row, 2);
                                logDataTable.setValueAt(mafv, row, 3);
                                logDataTable.setValueAt(afr, row, 4);
                                logDataTable.setValueAt(Double.valueOf(flds[logAfCorrectionColIdx]), row, 5);
                                logDataTable.setValueAt(Double.valueOf(flds[logAfLearningColIdx]), row, 6);
                                logDataTable.setValueAt(dVdt, row, 7);
                                logDataTable.setValueAt(iat, row, 8);
                                row += 1;
                            }
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + i + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    line = br.readLine();
                    i += 1;
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}

From source file:com.openbravo.pos.util.JRViewer411.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }/*from   w ww. j  a  v a  2  s  . co m*/
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:neg.JRViewer.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from   ww w . j av  a2  s  . c  om
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            ImageMapRenderable imageMap = null;
            if (element instanceof JRPrintImage) {
                Renderable renderer = ((JRPrintImage) element).getRenderable();
                if (renderer instanceof ImageMapRenderable) {
                    imageMap = (ImageMapRenderable) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//  ww w . jav  a2s .c o m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}