Example usage for java.awt Point getY

List of usage examples for java.awt Point getY

Introduction

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

Prototype

public double getY() 

Source Link

Usage

From source file:op.care.prescription.DlgRegular.java

private void tblDosisMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDosisMousePressed
    if (!SwingUtilities.isRightMouseButton(evt)) {
        return;//from   www .  j  a  v a  2  s  .c  o m
    }

    final TMDose tm = (TMDose) tblDosis.getModel();
    if (tm.getRowCount() == 0) {
        return;
    }
    Point p = evt.getPoint();
    Point p2 = evt.getPoint();
    // Convert a coordinate relative to a component's bounds to screen coordinates
    SwingUtilities.convertPointToScreen(p2, tblDosis);

    //        final Point screenposition = p2;
    final int row = tblDosis.rowAtPoint(p);

    ListSelectionModel lsm = tblDosis.getSelectionModel();
    lsm.setSelectionInterval(row, row);

    // Meneintrge
    SYSTools.unregisterListeners(menu);
    menu = new JPopupMenu();

    //-----------------------------------------
    JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.msg.delete"), SYSConst.icon22delete);
    itemPopupDelete.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PrescriptionSchedule schedule = prescription.getPrescriptionSchedule().get(row);
            prescription.getPrescriptionSchedule().remove(schedule);
            schedules2delete.add(schedule);
            reloadTable();
        }
    });
    menu.add(itemPopupDelete);
    menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY());

}

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

protected void paintSelectionRectangle(final Graphics2D g2) {
    final Point origin = selectionHandler.getSelectionRectangleOrigin();
    final Point target = selectionHandler.getSelectionRectangleTarget();

    if (origin == null || target == null) {
        return;/*from w w w  .  ja v a2 s  .  c  o m*/
    }

    g2.setColor(Color.BLUE);
    g2.setStroke(SELECTION_STROKE);

    final double y1 = Math.min(origin.getY(), target.getY());
    final double x1 = Math.min(origin.getX(), target.getX());
    final double y2 = Math.max(origin.getY(), target.getY());
    final double x2 = Math.max(origin.getX(), target.getX());

    g2.draw(new Rectangle2D.Double(x1, y1, x2 - x1, y2 - y1));
}

From source file:org.forester.archaeopteryx.ControlPanel.java

private void buildJSlider(int width, int min, int max) {
    _color_branches_edpl_slider = new JSlider(min, max);
    Dimension d = _color_branches_edpl_slider.getSize();
    d.width = width;//from  ww  w.  j  av a  2 s .  c  o m
    d.height = 100;
    _color_branches_edpl_slider.setPreferredSize(d);
    //       _color_branches_edpl_slider.setLayout(null);

    // slider popup with cutoff value
    _slider_popup = new JPopupMenu();
    JLabel text = new JLabel();
    text.setText(String.valueOf(_edpl_current_cutoff));
    _slider_popup.add(text);
    if (!_configuration.isUseNativeUI()) {
        _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color);
        _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color);
    }
    _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)");
    _color_branches_edpl_slider.setMinorTickSpacing(10);
    _color_branches_edpl_slider.setMajorTickSpacing(50);
    _color_branches_edpl_slider.setPaintTicks(true);
    _color_branches_edpl_slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // get Treepanel function
            final TreePanel tp = getMainPanel().getCurrentTreePanel();
            if (tp == null) {
                return;
            }
            Phylogeny phy = tp.getPhylogeny();
            _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0);
            tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff);
            _edpl_current_cutoff = _edpl_next_cutoff;
            //              System.out.println("Neuer Wert: "+
            //              ((JSlider)(e.getSource())).getValue());
        }
    });
    _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                _slider_popup.setVisible(false);
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                //               Point p = getMainPanel().getMainFrame().getLocation();
                Point p = _color_branches_edpl_slider.getLocationOnScreen();
                JLabel text = (JLabel) _slider_popup.getComponent(0);
                text.setText(String.valueOf(_edpl_current_cutoff));
                int x = (int) p.getX() + 18;
                int y = (int) p.getY() - 25;
                _slider_popup.setLocation(x, y);
                _slider_popup.setVisible(true);
            }

        }
    });
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Translates a screen location to a Java2D point.
 * //from   w  w w . j a v  a  2  s  .  co  m
 * @param screenPoint
 *            the screen location.
 * @return The Java2D coordinates.
 */
public Point2D translateScreenToJava2D(Point screenPoint) {
    Insets insets = getInsets();
    double x = (screenPoint.getX() - insets.left) / this.scaleX;
    double y = (screenPoint.getY() - insets.top) / this.scaleY;
    return new Point2D.Double(x, y);
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

private int calcDropPosition(final AbstractElement destination, final Point dropPoint) {
    int result = DRAG_POSITION_UNKNOWN;
    if (destination.getClass() == ElementRoot.class) {
        result = dropPoint.getX() < destination.getBounds().getCenterX() ? DRAG_POSITION_LEFT
                : DRAG_POSITION_RIGHT;/*  w ww.  j av  a2s .c  om*/
    } else {
        final boolean destinationIsLeft = destination.isLeftDirection();
        final Rectangle2D bounds = destination.getBounds();

        if (bounds != null && dropPoint != null) {
            final double edgeOffset = bounds.getWidth() * 0.2d;
            if (dropPoint.getX() >= (bounds.getX() + edgeOffset)
                    && dropPoint.getX() <= (bounds.getMaxX() - edgeOffset)) {
                result = dropPoint.getY() < bounds.getCenterY() ? DRAG_POSITION_TOP : DRAG_POSITION_BOTTOM;
            } else if (destinationIsLeft) {
                result = dropPoint.getX() < bounds.getCenterX() ? DRAG_POSITION_LEFT : DRAG_POSITION_UNKNOWN;
            } else {
                result = dropPoint.getX() > bounds.getCenterX() ? DRAG_POSITION_RIGHT : DRAG_POSITION_UNKNOWN;
            }
        }
    }
    return result;
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * Shows information in a tooltip about the sequence over which the mouse
 * moved./*from   ww w  . ja  va 2 s  .  c  om*/
 * 
 * @param e
 *            MouseEvent
 */
public void mouseMoved(MouseEvent e) {

    Point p = e.getPoint();

    String str = "<html>";
    int height = (int) ((double) (getHeight() - (2 * border)));
    int unitHeight = height / getHashMapSize();
    int currentTop = 0;

    String key = null;
    AbstractLogUnit item = null;
    boolean flag = false;
    // for dot
    int index = -1;
    for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) {
        key = (String) itSets.next();

        if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key))
            continue;
        index++;
        LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key);
        currentTop = unit2Cord(index) + unitHeight / 2;
        if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5)
            continue;
        // get the descriptiveStatistics object
        for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) {
            item = (AbstractLogUnit) itItm.next();
            if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType())
                    || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName())))
                continue;
            int x = 0;

            x = time2coord(item.getCurrentTimeStamp()) + border;
            if (x - 5 <= p.getX() && p.getX() <= x + 5) {
                flag = true;
                str += item.getProcessInstance().getName() + " | " + item.getElement() + " | "
                        + item.getOriginator() + " | " + item.getTimestamp() + " | " + item.getType();
                if (!timeOption.equals(TIME_ACTUAL))
                    str += " | Position:" + timeFormat(item.getCurrentTimeStamp());
                str += "<br>";
            }
        }
    }
    // for item line
    index = -1;
    for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) {
        key = (String) itSets.next();

        if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key))
            continue;
        index++;
        LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key);
        currentTop = unit2Cord(index) + unitHeight / 2;
        if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5)
            continue;
        LogUnitList tempUnitList = new LogUnitList();
        // get the descriptiveStatistics object
        for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) {
            item = (AbstractLogUnit) itItm.next();
            if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType())
                    || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName())))
                continue;
            if (bDrawLine && item.getType().equals(dca.getSettingPanel().getStartEvent())) {
                tempUnitList.addEvent(item);
                continue;
            }
            if (bDrawLine && item.getType().equals(dca.getSettingPanel().getEndEvent())) {
                for (Iterator itr = tempUnitList.iterator(); itr.hasNext();) {
                    AbstractLogUnit item2 = (AbstractLogUnit) itr.next();
                    if (item2.getElement().equals(item.getElement())
                            && item2.getProcessInstance().equals(item.getProcessInstance())) {
                        int x1 = time2coord(item2.getCurrentTimeStamp()) + border;
                        int x2 = time2coord(item.getCurrentTimeStamp()) + border;
                        if (x1 + 5 <= p.getX() && p.getX() <= x2 - 5) {
                            flag = true;
                            str += item.getProcessInstance().getName() + " | " + item.getElement() + " | "
                                    + item.getOriginator() + " |(start)" + item.getTimestamp() + "-(complete)"
                                    + item2.getTimestamp() + "<br>";
                            tempUnitList.removeEvent(item2);
                        }
                        break;
                    }
                }
            }
        }
    }

    str += "</html>";
    if (flag) {
        this.setToolTipText(str);
        repaint();
        bTooltip = true;
    } else {
        this.setToolTipText(null);
        if (bTooltip) {
            repaint();
            bTooltip = false;
        }
    }
}

From source file:view.WorkspacePanel.java

private void btnApplySignatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplySignatureActionPerformed
    if (tempCCAlias != null) {
        signatureSettings.setPageNumber(imagePanel.getPageNumber());
        signatureSettings.setCcAlias(tempCCAlias);
        signatureSettings.setReason(tfReason.getText());
        signatureSettings.setLocation(tfLocation.getText());
        if (jRadioButton1.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
        } else if (jRadioButton2.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
        } else if (jRadioButton3.isSelected()) {
            signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING);
        } else if (jRadioButton4.isSelected()) {
            signatureSettings//from w w w.j a v a 2s . co m
                    .setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS);
        }
        signatureSettings.setOcspClient(true);
        if (cbTimestamp.isSelected()) {
            signatureSettings.setTimestamp(true);
            if (tfTimestamp.getText().isEmpty()) {
                JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.timestampEmpty"),
                        "", JOptionPane.ERROR_MESSAGE);
                return;
            } else {
                signatureSettings.setTimestampServer(tfTimestamp.getText());
            }
        } else {
            signatureSettings.setTimestamp(false);
            cbTimestamp.setSelected(false);
            tfTimestamp.setVisible(false);
        }
        signatureSettings.setVisibleSignature(cbVisibleSignature.isSelected());

        if (cbVisibleSignature.isSelected()) {
            Point p = tempSignature.getScaledPositionOnDocument();
            Dimension d = tempSignature.getScaledSizeOnDocument();
            float p1 = (float) p.getX();
            float p3 = (float) d.getWidth() + p1;
            float p2 = (float) ((document.getPageDimension(imagePanel.getPageNumber(), 0).getHeight())
                    - (p.getY() + d.getHeight()));
            float p4 = (float) d.getHeight() + p2;

            signatureSettings.setVisibleSignature(true);
            if (tempSignature.getImageLocation() != null) {
                signatureSettings.getAppearance().setImageLocation(tempSignature.getImageLocation());
            }
            Rectangle rect = new Rectangle(p1, p2, p3, p4);
            signatureSettings.setSignaturePositionOnDocument(rect);
            signatureSettings.setText(tfText.getText());
        } else {
            signatureSettings.setVisibleSignature(false);
        }
        if (mainWindow.getOpenedFiles().size() > 1) {
            Object[] options = { Bundle.getBundle().getString("menuItem.allDocuments"),
                    Bundle.getBundle().getString("menuItem.onlyThis"),
                    Bundle.getBundle().getString("btn.cancel") };
            int i = JOptionPane.showOptionDialog(null,
                    Bundle.getBundle().getString("msg.multipleDocumentsOpened"),
                    Bundle.getBundle().getString("msg.multipleDocumentsOpenedTitle"),
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (i == 0) {
                signBatch(signatureSettings);
            } else if (i == 1) {
                signDocument(document, true, true);
            }
        } else {
            signDocument(document, true, true);
        }
    } else {
        JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("noSmartcardFound"),
                WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE);
        changeCard(CardEnum.SIGN_PANEL, false);
    }
}

From source file:Creator.WidgetPanel.java

public String createWidget(WidgetLink wl, Rectangle rect, int[] io_id) {

    if (widgetList.containsKey(wl.getWidgetCodeName())) {
        WidgetCode wc = widgetList.get(wl.getWidgetCodeName());
        Point per = wl.getPositionPercentage();

        int xPos = rect.x + (int) (per.getX() * rect.getWidth() / 100.0);
        int yPos = rect.y + (int) (per.getY() * rect.getHeight() / 100.0);

        String code = wc.getFullWidgetText();

        code = code.replace("`%IO_ID%`", String.valueOf(io_id[0])).replace("`%XPOS%`", String.valueOf(xPos))
                .replace("`%YPOS%`", String.valueOf(yPos));

        for (int i = 1; i < io_id.length; i++) {
            code = code.replace("`%IO_ID" + String.valueOf(i + 1) + "%`", String.valueOf(io_id[i]));
        }/*from   ww  w  .  j a  v a2s. co m*/

        for (Map.Entry<String, String> entry : wl.getVariables().entrySet()) {

            code = code.replace(entry.getKey(), entry.getValue());
        }

        return code;
    } else {
        System.out.println("Could not find a link for the widget named: " + wl.getWidgetCodeName());
        return "";
    }
}

From source file:org.gumtree.vis.awt.JChartPanel.java

private void findSelectedMarker(Point point) {
    Line2D marker = null;//from w w  w . jav  a 2 s .  com
    double distance = Double.MAX_VALUE;
    double cDis;
    for (Entry<Line2D, Color> entry : domainMarkerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p2 = line.getP2();
        double height = p2.getY();
        cDis = Double.MAX_VALUE;
        if (height < 1e-4) {
            double xScr = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart()).getX();
            cDis = Math.abs(point.getX() - xScr);
        } else {
            Point2D newP2 = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart());
            if (newP2.getY() < point.getY()) {
                cDis = Math.abs(point.getX() - newP2.getX());
            } else {
                cDis = newP2.distance(point);
            }
        }
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    for (Entry<Line2D, Color> entry : rangeMarkerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p1 = line.getP1();
        Point2D p2 = line.getP2();
        double width = p2.getX();
        cDis = Double.MAX_VALUE;
        if (width < 1e-4) {
            double yScr = ChartMaskingUtilities.translateChartPoint(p1, getScreenDataArea(), getChart()).getY();
            cDis = Math.abs(point.getY() - yScr);
        } else {
            Point2D newP2 = ChartMaskingUtilities.translateChartPoint(p2, getScreenDataArea(), getChart());
            if (newP2.getX() > point.getX()) {
                cDis = Math.abs(point.getY() - newP2.getY());
            } else {
                cDis = newP2.distance(point);
            }
        }
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    for (Entry<Line2D, Color> entry : markerMap.entrySet()) {
        Line2D line = entry.getKey();
        Point2D p1 = line.getP1();
        p1 = ChartMaskingUtilities.translateChartPoint(p1, getScreenDataArea(), getChart());
        cDis = p1.distance(point);
        if (cDis <= distance) {
            distance = cDis;
            marker = line;
        }
    }
    if (distance < 5) {
        selectedMarker = marker;
    } else {
        selectedMarker = null;
    }
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Given the element, and the (offsetX, offsetY) relative to element.
 * This function will calculate the offset point screen coordination.
 * /*from w ww  . j a  v a2s.c o m*/
 * @param element WebElement, the element relative to which the coordination will be calculated.
 * @param offsetX String, the offset on x axis, in pixel or in percentage, for example 15 or 30%.
 * @param offsetX String, the offset on y axis, in pixel or in percentage, for example 45 or 50%.
 * 
 * @return Point, the offset point screen coordination; or null if any exception occured.
 *
 **/
public static Point getElementOffsetScreenLocation(WebElement element, String offsetX, String offsetY) {
    String debugmsg = StringUtils.debugmsg(false);

    try {
        Point screenLoc = WDLibrary.getScreenLocation(element);
        Dimension dimemsion = element.getSize();

        //calc coords according to the offset and element's location and dimension
        double dx, dy;
        dx = ImageUtils.calculateAbsoluteCoordinate(screenLoc.getX(), dimemsion.getWidth(), offsetX);
        dy = ImageUtils.calculateAbsoluteCoordinate(screenLoc.getY(), dimemsion.getHeight(), offsetY);

        return new Point((int) dx, (int) dy);
    } catch (Exception e) {
        IndependantLog.error(debugmsg + ": Exception", e);
        return null;
    }
}