Search in sources :

Example 1 with Point2D

use of java.awt.geom.Point2D in project opennms by OpenNMS.

the class DblBoundingBox method computeWithAspectRatio.

public DblBoundingBox computeWithAspectRatio(double R) {
    double r = getAspectRatio();
    double width = r < R ? Math.round(getHeight() * R) : getWidth();
    double height = r < R ? getHeight() : Math.round(getWidth() / R);
    Point2D center = getCenter();
    return new DblBoundingBox(center, width, height);
}
Also used : Point2D(java.awt.geom.Point2D)

Example 2 with Point2D

use of java.awt.geom.Point2D in project opennms by OpenNMS.

the class TopoFRLayout method calcPositions.

protected synchronized void calcPositions(V v) {
    FRVertexData fvd = getFRData(v);
    if (fvd == null)
        return;
    Point2D xyd = transform(v);
    double deltaLength = fvd.norm();
    if (deltaLength <= 0.005)
        return;
    double newXDisp = fvd.getX() * percentage() / deltaLength * Math.min(deltaLength, temperature);
    if (Double.isNaN(newXDisp)) {
        throw new IllegalArgumentException("Unexpected mathematical result in FRLayout:calcPositions [xdisp]");
    }
    double newYDisp = fvd.getY() * percentage() / deltaLength * Math.min(deltaLength, temperature);
    xyd.setLocation(xyd.getX() + newXDisp, xyd.getY() + newYDisp);
    double borderWidth = getSize().getWidth() / 50.0;
    double newXPos = xyd.getX();
    if (newXPos < borderWidth) {
        newXPos = borderWidth + Math.random() * borderWidth * 2.0;
    } else if (newXPos > (getSize().getWidth() - borderWidth)) {
        newXPos = getSize().getWidth() - borderWidth - Math.random() * borderWidth * 2.0;
    }
    double newYPos = xyd.getY();
    if (newYPos < borderWidth) {
        newYPos = borderWidth + Math.random() * borderWidth * 2.0;
    } else if (newYPos > (getSize().getHeight() - borderWidth)) {
        newYPos = getSize().getHeight() - borderWidth - Math.random() * borderWidth * 2.0;
    }
    xyd.setLocation(newXPos, newYPos);
}
Also used : Point2D(java.awt.geom.Point2D)

Example 3 with Point2D

use of java.awt.geom.Point2D in project opennms by OpenNMS.

the class TopoFRLayout method calcRepulsion.

protected void calcRepulsion(V v1) {
    FRVertexData fvd1 = getFRData(v1);
    if (fvd1 == null)
        return;
    fvd1.setLocation(0, 0);
    try {
        for (V v2 : getGraph().getVertices()) {
            if (v1 != v2) {
                Point2D p1 = transform(v1);
                Point2D p2 = transform(v2);
                if (p1 == null || p2 == null)
                    continue;
                double xDelta = p1.getX() - p2.getX();
                double yDelta = p1.getY() - p2.getY();
                xDelta = Math.abs(xDelta) > EPSILON ? xDelta : xDelta == 0 ? epsilon() : Math.signum(xDelta) * EPSILON;
                yDelta = Math.abs(yDelta) > EPSILON ? yDelta : yDelta == 0 ? epsilon() : Math.signum(yDelta) * EPSILON;
                double deltaLength = Math.sqrt((xDelta * xDelta) + (yDelta * yDelta));
                double force = (repulsion_constant * repulsion_constant) / deltaLength;
                if (Double.isNaN(force)) {
                    throw new RuntimeException("Unexpected mathematical result in FRLayout:calcPositions [repulsion]");
                }
                fvd1.offset((xDelta / deltaLength) * force, (yDelta / deltaLength) * force);
            }
        }
    } catch (ConcurrentModificationException cme) {
        calcRepulsion(v1);
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) Point2D(java.awt.geom.Point2D)

Example 4 with Point2D

use of java.awt.geom.Point2D in project GNS by MobilityFirst.

the class EC2Runner method populateIDTableForRunset.

private static void populateIDTableForRunset(String name) {
    AWSCredentials credentials = null;
    try {
        //
        credentials = new PropertiesCredentials(new File(CREDENTIALSFILE));
    } catch (IOException e) {
        System.out.println("Problem contacting EC2 instances: " + e);
    }
    //Create Amazon Client object
    AmazonEC2 ec2 = new AmazonEC2Client(credentials);
    for (RegionRecord region : RegionRecord.values()) {
        AWSEC2.setRegion(ec2, region);
        System.out.println("Retrieving instance information in " + region.name() + "...");
        for (Instance instance : AWSEC2.getInstances(ec2)) {
            if (!instance.getState().getName().equals(InstanceStateRecord.TERMINATED.getName())) {
                String idString = getTagValue(instance, "id");
                if (idString != null && name.equals(getTagValue(instance, "runset"))) {
                    String id = new String(idString);
                    String hostname = instance.getPublicDnsName();
                    String ip = getHostIPSafe(hostname);
                    // and take a guess at the location (lat, long) of this host
                    Point2D location = GEOLocator.lookupIPLocation(ip);
                    hostTable.put(id, new HostInfo(id, hostname, location));
                }
            }
        }
    }
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) Instance(com.amazonaws.services.ec2.model.Instance) Point2D(java.awt.geom.Point2D) PropertiesCredentials(com.amazonaws.auth.PropertiesCredentials) IOException(java.io.IOException) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) AWSCredentials(com.amazonaws.auth.AWSCredentials) File(java.io.File) RegionRecord(edu.umass.cs.aws.support.RegionRecord)

Example 5 with Point2D

use of java.awt.geom.Point2D in project jdk8u_jdk by JetBrains.

the class Path2DCopyConstructor method testGetCurrentPoint.

static void testGetCurrentPoint(Path2D pathA, Path2D pathB) {
    final Point2D ptA = pathA.getCurrentPoint();
    final Point2D ptB = pathA.getCurrentPoint();
    if (((ptA == null) && (ptB != null)) || ((ptA != null) && !ptA.equals(ptB))) {
        throw new IllegalStateException("getCurrentPoint() are not equals [" + ptA + "|" + ptB + "] !");
    }
    log("testGetCurrentPoint: passed.");
}
Also used : Point2D(java.awt.geom.Point2D)

Aggregations

Point2D (java.awt.geom.Point2D)469 Color (java.awt.Color)53 Rectangle2D (java.awt.geom.Rectangle2D)52 Graphics2D (java.awt.Graphics2D)48 Point (java.awt.Point)46 Line2D (java.awt.geom.Line2D)34 BufferedImage (java.awt.image.BufferedImage)34 BasicStroke (java.awt.BasicStroke)33 ArrayList (java.util.ArrayList)33 LinearGradientPaint (java.awt.LinearGradientPaint)30 Paint (java.awt.Paint)28 AffineTransform (java.awt.geom.AffineTransform)28 RadialGradientPaint (java.awt.RadialGradientPaint)27 Rectangle (java.awt.Rectangle)24 GeneralPath (java.awt.geom.GeneralPath)20 Test (org.junit.Test)20 Ellipse2D (java.awt.geom.Ellipse2D)17 Font (java.awt.Font)16 Stroke (java.awt.Stroke)14 LcdColor (eu.hansolo.steelseries.tools.LcdColor)11