Example usage for java.awt Point getX

List of usage examples for java.awt Point getX

Introduction

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

Prototype

public double getX() 

Source Link

Usage

From source file:be.ugent.maf.cellmissy.gui.controller.load.generic.DragAndDropController.java

/**
 * Given a location (point), get the wellGui correspondent on the plate
 * panel./*from  w  w w  .j  a v a 2  s .c  o  m*/
 *
 * @param point
 * @return the wellGui correspondent
 */
private WellGui getWellGuiDropTarget(Point point) {
    WellGui wellGuiDropTarget = null;
    for (WellGui wellGui : genericImagedPlateController.getImagedPlatePanel().getWellGuiList()) {
        List<Ellipse2D> ellipsi = wellGui.getEllipsi();
        if (ellipsi.get(0).contains(point.getX(), point.getY())) {
            wellGuiDropTarget = wellGui;
            break;
        }
    }
    return wellGuiDropTarget;
}

From source file:com.o2d.pkayjava.editor.Main.java

private void toggleVisible() {
    mainFrame.setVisible(!mainFrame.isVisible());
    if (mainFrame.isVisible()) {
        mainFrame.toFront();/*from  w  w w.j a v  a  2 s . c o  m*/
        mainFrame.requestFocus();
        mainFrame.setAlwaysOnTop(true);
        try {
            //remember the last location of mouse
            final Point oldMouseLocation = MouseInfo.getPointerInfo().getLocation();

            //simulate a mouse click on title bar of window
            Robot robot = new Robot();
            robot.mouseMove(mainFrame.getX() + 100, mainFrame.getY() + 5);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

            //move mouse to old location
            robot.mouseMove((int) oldMouseLocation.getX(), (int) oldMouseLocation.getY());
        } catch (Exception ex) {
            //just ignore exception, or you can handle it as you want
        } finally {
            mainFrame.setAlwaysOnTop(false);
        }
    }
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 *
 *//*from w w w . j a  va 2 s.c o m*/
protected Rectangle2D getBounds(ShapePoints shape) {
    Rectangle2D bounds = null;

    List<Point> points = shape.getPoints();
    if (points != null && !points.isEmpty()) {
        Integer top = null;
        Integer bottom = null;
        Integer left = null;
        Integer right = null;

        for (int i = 0; i < points.size(); i++) {
            Point point = points.get(i);

            if (top == null || point.getY() < top) {
                top = point.getY();
            }

            if (bottom == null || point.getY() > bottom) {
                bottom = point.getY();
            }

            if (left == null || point.getX() < left) {
                left = point.getX();
            }

            if (right == null || point.getX() > right) {
                right = point.getX();
            }
        }

        bounds = new Rectangle(left, top, right - left, bottom - top);
    }

    return bounds;
}

From source file:com.jgeppert.struts2.jquery.chart.components.ChartData.java

@SuppressWarnings("rawtypes")
public void evaluateExtraParams() {
    super.evaluateExtraParams();
    if (color != null)
        addParameter("color", findString(color));
    if (label != null)
        addParameter("label", findString(label));
    if (lines != null)
        addParameter("lines", findString(lines));
    if (bars != null)
        addParameter("bars", findString(bars));
    if (points != null)
        addParameter("points", findString(points));
    if (xaxis != null)
        addParameter("xaxis", findValue(xaxis, Integer.class));
    if (yaxis != null)
        addParameter("yaxis", findValue(yaxis, Integer.class));
    if (clickable != null)
        addParameter("clickable", findValue(this.clickable, Boolean.class));
    if (hoverable != null)
        addParameter("hoverable", findValue(this.hoverable, Boolean.class));
    if (shadowSize != null)
        addParameter("shadowSize", findValue(shadowSize, Integer.class));
    if (fillBetween != null)
        addParameter("fillBetween", findString(fillBetween));
    if (curvedLines != null)
        addParameter("curvedLines", findValue(this.curvedLines, Boolean.class));
    if (curvedLinesFit != null)
        addParameter("curvedLinesFit", findValue(this.curvedLinesFit, Boolean.class));
    if (curvedLinesFill != null)
        addParameter("curvedLinesFill", findValue(this.curvedLinesFill, Boolean.class));
    if (curvedLinesFillColor != null)
        addParameter("curvedLinesFillColor", findString(curvedLinesFillColor));
    if (curvedLinesLineWidth != null)
        addParameter("curvedLinesLineWidth", findValue(curvedLinesLineWidth, Integer.class));
    if (stack != null)
        addParameter("stack", findString(stack));

    if ((this.id == null || this.id.length() == 0)) {
        // resolves Math.abs(Integer.MIN_VALUE) issue reported by FindBugs
        // http://findbugs.sourceforge.net/bugDescriptions.html#RV_ABSOLUTE_VALUE_OF_RANDOM_INT
        int nextInt = RANDOM.nextInt();
        nextInt = nextInt == Integer.MIN_VALUE ? Integer.MAX_VALUE : Math.abs(nextInt);
        this.id = "chartdata" + String.valueOf(nextInt);
        addParameter("id", this.id);
    }//from  w  w w  .ja va 2s.  c o  m

    Chart chart = (Chart) findAncestor(Chart.class);
    if (chart != null) {
        addParameter("chart", chart.getId());
    }

    if (this.href != null && !this.href.equals("#")) {
        if (list != null) {
            addParameter("remoteList", findString(list.toString()));
        }
        if (listKey != null) {
            addParameter("remoteListKey", findString(listKey));
        }
        if (listValue != null) {
            addParameter("remoteListValue", findString(listValue));
        }
    } else if (data != null) {
        addParameter("data", findString(data));
    } else {
        if (list == null) {
            list = parameters.get("list");
        }

        Object listObject = findValue(list.toString());

        if (listObject instanceof String) {
            addParameter("data", listObject);
        } else if (listObject instanceof Map) {
            Map map = (Map) listObject;
            Set keySet = map.keySet();

            StringBuffer data = new StringBuffer();
            data.append("[");

            boolean setComma = false;
            for (Object key : keySet) {
                if (setComma) {
                    data.append(",");
                }
                if (!setComma) {
                    setComma = true;
                }
                data.append("[");
                if (key instanceof Date) {
                    data.append(((Date) key).getTime());
                } else {
                    data.append(key.toString());
                }
                data.append(",");
                data.append(map.get(key));
                data.append("]");
            }
            data.append("]");
            addParameter("data", data.toString());
        } else {
            Iterator iterator = null;
            if (listObject instanceof Collection) {
                iterator = ((Collection) listObject).iterator();
            } else {
                iterator = MakeIterator.convert(listObject);
            }

            if (iterator != null) {
                StringBuffer data = new StringBuffer();
                data.append("[");

                Object item = iterator.next();
                boolean iterat = true;
                int count = 0;
                while (iterat) {
                    count++;
                    if (item == null) {
                        data.append("null");
                    } else {
                        if (item instanceof Point) {
                            data.append("[");
                            Point point = (Point) item;
                            data.append(point.getX());
                            data.append(",");
                            data.append(point.getY());
                            data.append("]");
                        } else {
                            data.append("[");
                            if (listKey != null) {
                                String key = findString(listKey);
                                Object itemKey = null;
                                try {
                                    itemKey = PropertyUtils.getSimpleProperty(item, key);
                                } catch (IllegalAccessException e) {
                                    LOG.warn("Cannot read listKey", e);
                                } catch (InvocationTargetException e) {
                                    LOG.warn("Cannot read listKey", e);
                                } catch (NoSuchMethodException e) {
                                    LOG.warn("Cannot read listKey", e);
                                }

                                if (itemKey != null) {
                                    if (itemKey instanceof Date) {
                                        data.append(((Date) itemKey).getTime());
                                    } else {
                                        data.append(itemKey.toString());
                                    }
                                } else {
                                    data.append(count);
                                }
                            } else {
                                data.append(count);
                            }

                            data.append(",");

                            if (listValue != null) {
                                String value = findString(listValue);
                                Object itemValue = null;
                                try {
                                    itemValue = PropertyUtils.getSimpleProperty(item, value);
                                } catch (IllegalAccessException e) {
                                    LOG.warn("Cannot read listValue", e);
                                } catch (InvocationTargetException e) {
                                    LOG.warn("Cannot read listValue", e);
                                } catch (NoSuchMethodException e) {
                                    LOG.warn("Cannot read listValue", e);
                                }

                                if (itemValue != null) {
                                    if (itemValue instanceof Date) {
                                        data.append(((Date) itemValue).getTime());
                                    } else {
                                        data.append(itemValue.toString());
                                    }
                                } else {
                                    data.append(item.toString());
                                }
                            } else {
                                data.append(item.toString());
                            }
                            data.append("]");
                        }
                    }

                    if (iterator.hasNext()) {
                        data.append(",");
                        item = iterator.next();
                    } else {
                        iterat = false;
                    }
                }

                data.append("]");
                addParameter("data", data.toString());
            }
        }
    }
}

From source file:com.net2plan.gui.utils.topologyPane.jung.JUNGCanvas.java

@Override
public GUILink getEdge(MouseEvent e) {
    final VisualizationViewer<GUINode, GUILink> vv = (VisualizationViewer<GUINode, GUILink>) e.getSource();
    GraphElementAccessor<GUINode, GUILink> pickSupport = vv.getPickSupport();
    if (pickSupport != null) {
        final Point p = e.getPoint();
        return pickSupport.getEdge(vv.getModel().getGraphLayout(), p.getX(), p.getY());
    }/*www .j a  va2  s  . c o m*/

    return null;
}

From source file:com.offbynull.peernetic.debug.visualizer.JGraphXVisualizer.java

private void changeNode(final ChangeNodeCommand<A> command) {
    Validate.notNull(command);//from  www  .j  a  v  a 2 s.c o  m

    SwingUtilities.invokeLater(() -> {
        A address = command.getNode();

        Object vertex = nodeLookupMap.get(address);
        Validate.isTrue(vertex != null);

        Point center = command.getLocation();
        if (center != null) {
            mxRectangle rect = graph.getView().getBoundingBox(new Object[] { vertex });
            graph.moveCells(new Object[] { vertex }, center.getX() - rect.getCenterX(),
                    center.getY() - rect.getCenterY());
        }

        Double scale = command.getScale();
        if (scale != null) {
            mxGraphView view = graph.getView();
            mxRectangle rect = graph.getBoundingBox(vertex);

            rect.setWidth(rect.getWidth() / view.getScale() * scale);
            rect.setHeight(rect.getHeight() / view.getScale() * scale);
            rect.setX(rect.getX() / view.getScale());
            rect.setY(rect.getY() / view.getScale());
            graph.resizeCell(vertex, rect);
        }

        Color color = command.getColor();
        if (color != null) {
            graph.setCellStyle(mxConstants.STYLE_FILLCOLOR + "=" + "#"
                    + String.format("%06x", color.getRGB() & 0x00FFFFFF), new Object[] { vertex });
            nodeLookupMap.put(address, vertex);
        }

        zoomFit();
    });
}

From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java

/**
 * /*from  w w  w  .j  ava  2 s.co m*/
 * @param point
 */
protected void updateMouseMarker(Point point) {

    double xValue = 0;

    if (!markerLocked) {
        double pointerX = point.getX();

        PlotRenderingInfo renderingInfo = chartPanel.getChartRenderingInfo().getPlotInfo();
        Rectangle2D dataArea = renderingInfo.getDataArea();
        Rectangle2D plotArea = renderingInfo.getPlotArea();
        RectangleEdge domainEdge = plot.getDomainAxisEdge();

        xValue = frequencyAxis.java2DToValue(pointerX, dataArea, domainEdge);

        previousMarkerX = xValue;

    } else {
        xValue = previousMarkerX;
    }

    int bin = (int) Math.round(xValue);

    try {
        XYDataItem item = series.getDataItem(bin);
        if (item != null) {
            double yValue = item.getYValue();
            markerAnnotation.setXY(xValue, yValue);
            markerAnnotation.setVisible(true);

            plot.setDomainCrosshairValue(xValue);
            plot.setDomainCrosshairVisible(true);

            markerTitle.setText("Frequency: " + binToFrequencyStr(bin) + " \nPower: "
                    + String.format("%5.1f", PowerAxis.valueToDb(yValue)) + " dB");

            markerTitle.setVisible(true);
        } else {
            markerAnnotation.setVisible(false);
            plot.setDomainCrosshairVisible(false);
        }
    } catch (Exception e) {
        markerAnnotation.setVisible(false);
        plot.setDomainCrosshairVisible(false);
    }
}

From source file:com.net2plan.gui.utils.topologyPane.jung.JUNGCanvas.java

@Override
public GUINode getVertex(MouseEvent e) {
    final VisualizationViewer<GUINode, GUILink> vv = (VisualizationViewer<GUINode, GUILink>) e.getSource();
    GraphElementAccessor<GUINode, GUILink> pickSupport = vv.getPickSupport();
    if (pickSupport != null) {
        final Point p = e.getPoint();
        final GUINode vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY());
        if (vertex != null)
            return vertex;
    }/*from   w w w  .  j a  v  a 2s  .c  om*/

    return null;
}

From source file:business.ImageManager.java

public void doDrawPathArmyOrder(Graphics2D big, Point ori, Point dest) {
    final int x = 30;
    final int y = 30;
    doDrawPathOrdemArmy(big, new Point((int) ori.getX() + x, (int) ori.getY() + y),
            new Point((int) dest.getX() + x, (int) dest.getY() + y), colorMineArmyOrdem);
}

From source file:business.ImageManager.java

public void doDrawPathArmyAllyOrder(Graphics2D big, Point ori, Point dest) {
    final int x = 45;
    final int y = 45;
    doDrawPathOrdemArmy(big, new Point((int) ori.getX() + x, (int) ori.getY() + y),
            new Point((int) dest.getX() + x, (int) dest.getY() + y), colorAllyArmyOrdem);
}