Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

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

Prototype

public Point(Point p) 

Source Link

Document

Constructs and initializes a point with the same location as the specified Point object.

Usage

From source file:Main.java

public static void main(String[] argv) {
    JButton component = new JButton();
    Point pt = new Point(component.getLocation());

    SwingUtilities.convertPointFromScreen(pt, component);
}

From source file:Main.java

public static void main(String[] argv) {

    JButton component = new JButton();
    Point pt = new Point(component.getLocation());
    SwingUtilities.convertPointToScreen(pt, component);
}

From source file:Main.java

public static Point convertPoint(Component src, Point p, Component dst) {
    final Point result = new Point(p);

    SwingUtilities.convertPoint(src, result, dst);

    return result;
}

From source file:Main.java

/**
 * <p>/* w  w w .ja v  a2s .c  o m*/
 * Determines if the component is visible in its window at the given screen location.
 * </p>
 *
 * @param    location   A location on the screen.
 * @param    component   A component in a window.
 * @return            True if the component is visible in its window at the given screen location.
 */
public static boolean locationInComponentVisible(Point location, Component component) {

    // Get the root component in the window.
    JRootPane rootPane = getRootPane(component);
    if (rootPane != null) {
        Component rootComponent = rootPane.getContentPane();
        if (rootComponent != null) {
            // Get the location relative to this root component.
            Point locationInRoot = new Point(location);
            SwingUtilities.convertPointFromScreen(locationInRoot, rootComponent);

            // Get the deepest visible component at the given location.
            Component deepestComponent = SwingUtilities.getDeepestComponentAt(rootComponent, locationInRoot.x,
                    locationInRoot.y);
            if (deepestComponent != null) {
                boolean result = SwingUtilities.isDescendingFrom(deepestComponent, component);
                return result;
            }
        }
    }

    return false;

}

From source file:Main.java

/**
 * Returns point copy./*from  w w w  .j  a v a  2 s.  c om*/
 *
 * @param point
 *            point to copy
 * @return point copy
 */
public static Point copy(final Point point) {
    return new Point(point);
}

From source file:ded.model.Inheritance.java

/** Deep copy constructor, except for parent entity. */
public Inheritance(Inheritance obj, Entity parent) {
    this.parent = parent;
    this.open = obj.open;
    this.pt = new Point(obj.pt);
}

From source file:ded.model.Relation.java

/** Deep copy constructor, except for supplied endpoints. */
public Relation(Relation obj, RelationEndpoint start, RelationEndpoint end) {
    this.start = start;
    this.end = end;

    for (Point pt : obj.controlPts) {
        this.controlPts.add(new Point(pt));
    }/*from  ww  w .  j  a v  a 2 s  .  c o m*/

    this.routingAlg = obj.routingAlg;
    this.label = obj.label;
    this.lineWidth = obj.lineWidth;
}

From source file:ded.model.RelationEndpoint.java

/** Set the location of this endpoint to be the same as 're',
  * but leave the arrow style alone. */
public void seLocationTo(RelationEndpoint re) {
    this.entity = re.entity;
    this.inheritance = re.inheritance;
    if (re.pt == null) {
        this.pt = null;
    } else {/* w  w  w .j  av a2s  .  co m*/
        this.pt = new Point(re.pt);
    }
}

From source file:com.pureinfo.srm.reports.impl.CategoryChartBuilder.java

/**
 * @param _format//from w  w w .j  a va  2  s  .com
 * @param _dataset
 */
private void fillChartInfo(CategoryDataset _dataset, DecimalFormat _format) {
    int n = _dataset.getColumnCount();
    m_ChartInfo = new ChartInfo();
    m_ChartInfo.setChartTitle(m_sTitle);
    String[] labels = new String[n];
    for (int i = 0; i < n; i++) {
        labels[i] = "" + _dataset.getColumnKey(i);
        labels[i] += " = ";
        labels[i] += _format.format(_dataset.getValue(0, i));
    }
    m_ChartInfo.setLabels(labels);
    Point size = new Point(n > 20 ? ChartInfo.SIZE_WIDE : ChartInfo.SIZE_NORROW);
    if (n > 20)
        size.x += 40 * (n - 20);
    m_ChartInfo.setChartSize(size);
    m_ChartInfo.setLengedPosition(n > 20 ? ChartInfo.LENGEND_POSITION_BUTTOM : ChartInfo.LENGEND_POSITION_LEFT);
}

From source file:com.haulmont.cuba.desktop.sys.DesktopToolTipManager.java

protected Point getToolTipLocation(PointerInfo pointerInfo, String text) {
    Point mouseLocation = pointerInfo.getLocation();
    Rectangle bounds = getDeviceBounds(pointerInfo.getDevice());

    // Location on the current screen (suitable if there is more than one screen)
    Point currentScreenMouseLocation = getCurrentScreenMouseLocation(mouseLocation, bounds);

    // Location to display tooltip
    Point location = new Point(mouseLocation);

    Dimension dimension = DesktopComponentsHelper.measureHtmlText(text);

    location.x += getIndentation(bounds.width, dimension.width, currentScreenMouseLocation.x,
            DEFAULT_HORIZONTAL_INDENTATION);
    location.y += getIndentation(bounds.height, dimension.height, currentScreenMouseLocation.y,
            DEFAULT_VERTICAL_INDENTATION);

    return location;
}