Search in sources :

Example 31 with Point

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();
    }
}
Also used : BoundingBox(org.opennms.features.topology.api.BoundingBox) Point(org.opennms.features.topology.api.Point)

Example 32 with Point

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;
    }
}
Also used : BoundingBox(org.opennms.features.topology.api.BoundingBox) Point(org.opennms.features.topology.api.Point)

Example 33 with Point

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();
    }
}
Also used : Point(org.opennms.features.topology.api.Point)

Example 34 with Point

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));
    }
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) Point(org.opennms.features.topology.api.Point) Point(org.opennms.features.topology.api.Point)

Aggregations

Point (org.opennms.features.topology.api.Point)34 VertexRef (org.opennms.features.topology.api.topo.VertexRef)23 Vertex (org.opennms.features.topology.api.topo.Vertex)15 Layout (org.opennms.features.topology.api.Layout)13 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)9 EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)9 Edge (org.opennms.features.topology.api.topo.Edge)8 SparseGraph (edu.uci.ics.jung.graph.SparseGraph)7 HashMap (java.util.HashMap)7 Test (org.junit.Test)6 BoundingBox (org.opennms.features.topology.api.BoundingBox)6 Dimension (java.awt.Dimension)5 Collection (java.util.Collection)4 Comparator (java.util.Comparator)4 Graph (org.opennms.features.topology.api.Graph)4 LayoutEntity (org.opennms.netmgt.topology.persistence.api.LayoutEntity)4 PointEntity (org.opennms.netmgt.topology.persistence.api.PointEntity)4 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3