Example usage for java.awt Point clone

List of usage examples for java.awt Point clone

Introduction

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

Prototype

public Object clone() 

Source Link

Document

Creates a new object of the same class and with the same contents as this object.

Usage

From source file:Main.java

public static Point getPositionWithinWindow(Component component, Component parent, Point p) {
    Point[] pointCheck = new Point[] { (Point) p.clone(), (Point) p.clone(), (Point) p.clone(),
            (Point) p.clone() };/*from   w  ww  .  j ava  2 s  .  co  m*/
    int w = component.getWidth();
    int h = component.getHeight();
    pointCheck[0].translate(w, h);
    pointCheck[1].translate(0, h);
    pointCheck[2].translate(w, 0);
    pointCheck[3].translate(0, 0);
    for (Point p2 : pointCheck) {
        if (parent.getBounds().contains(p2)) {
            p2.translate(-w, -h);
            return p2;
        }
    }
    return p;
}

From source file:org.jas.dnd.DragAndDropIterators.java

private static Point convertToComponentRelativePoint(Point location, Container currentFrame,
        Component component) {//  www. j a  va 2 s  .co  m
    Point componentLocation = new Point(0, 0);
    if (component == currentFrame) {
        componentLocation = (Point) location.clone();
    } else if (component != null) {
        componentLocation = SwingUtilities.convertPoint(currentFrame, location, component);
    }
    return componentLocation;
}

From source file:savant.view.swing.GraphPane.java

public void tryPopup(Point p) {

    if (tracks == null) {
        return;/*from w  w w. j  av a 2s .com*/
    }

    Point pt = new Point(p.x, p.y - getOffset());

    for (Track t : tracks) {
        Map<Record, Shape> map = t.getRenderer().searchPoint(pt);
        if (map != null) {
            /**
             * XXX: This line is here to get around what looks like a bug in
             * the 1.6.0_20 JVM for Snow Leopard which causes the
             * mouseExited events not to be triggered sometimes. We hide the
             * popup before showing another. This needs to be done exactly
             * here: after we know we have a new popup to show and before we
             * set currentOverRecord. Otherwise, it won't work.
             */
            PopupPanel.hidePopup();

            // Arbitrarily pick the first record in the map.  Most of the time, there will be only one.
            Record overRecord = map.keySet().iterator().next();

            Point p1 = (Point) p.clone();
            SwingUtilities.convertPointToScreen(p1, this);
            PopupPanel.showPopup(this, p1, t, overRecord);

            currentOverRecord = overRecord;
            currentOverShape = map.get(currentOverRecord);
            if (currentOverRecord instanceof ContinuousRecord) {
                currentOverShape = ContinuousTrackRenderer.continuousRecordToEllipse(this, currentOverRecord);
            }

            repaint();
            return;
        }
    }
    // Didn't get a hit on any track.
    currentOverShape = null;
    currentOverRecord = null;
}