use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class DefaultMapViewManager method setBoundingBox.
@Override
public void setBoundingBox(BoundingBox boundingBox) {
BoundingBox oldBoundingBox = getCurrentBoundingBox();
BoundingBox bbPrime = boundingBox.computeWithAspectRatio(getViewPortAspectRatio());
BoundingBox mPrime = m_mapBounds.computeWithAspectRatio(getViewPortAspectRatio());
double oldScale = m_scale;
m_scale = Math.log(bbPrime.getWidth() / (double) mPrime.getWidth()) / Math.log((m_viewPortWidth / 2.0) / (double) mPrime.getWidth());
m_scale = Math.min(1.0, m_scale);
m_scale = Math.max(0.0, m_scale);
m_scale = ((double) Math.round(m_scale * 10.0)) / 10.0;
Point oldCenter = m_center;
m_center = boundingBox.getCenter();
BoundingBox newBoundingBox = getCurrentBoundingBox();
// TODO: Sonar is warning on the equals comparison of m_scale and oldScale
if (!oldCenter.equals(m_center) || oldScale != m_scale || !oldBoundingBox.equals(newBoundingBox)) {
fireUpdate();
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class DefaultLayout method getBounds.
@Override
public BoundingBox getBounds() {
if (m_locations.size() > 0) {
return computeBoundingBox(m_locations.keySet());
} else {
BoundingBox bBox = new BoundingBox();
bBox.addPoint(new Point(0, 0));
return bBox;
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class DefaultMapViewManager method setCenter.
@Override
public void setCenter(Point point) {
Point oldCenter = m_center;
m_center = point;
if (!oldCenter.equals(m_center)) {
fireUpdate();
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class TopologyComponent method updateVertex.
private void updateVertex(String vertexUpdate) {
String[] vertexProps = vertexUpdate.split("\\|");
String id = vertexProps[0].split(",")[1];
int x = (int) Double.parseDouble(vertexProps[1].split(",")[1]);
int y = (int) Double.parseDouble(vertexProps[2].split(",")[1]);
boolean selected = vertexProps[3].split(",")[1].equals("true");
Vertex vertex = getGraph().getVertexByKey(id);
getGraph().getLayout().setLocation(vertex, new Point(x, y));
if (selected) {
m_graphContainer.getSelectionManager().selectVertexRefs(Collections.singleton(vertex));
} else {
m_graphContainer.getSelectionManager().deselectVertexRefs(Collections.singleton(vertex));
}
}
Aggregations