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);
}
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);
}
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);
}
}
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));
}
}
}
}
}
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.");
}
Aggregations