Search in sources :

Example 11 with BoundingBox

use of org.opennms.features.topology.api.BoundingBox 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 12 with BoundingBox

use of org.opennms.features.topology.api.BoundingBox 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)

Aggregations

BoundingBox (org.opennms.features.topology.api.BoundingBox)12 Point (org.opennms.features.topology.api.Point)7 Test (org.junit.Test)4 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 HashMap (java.util.HashMap)2 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 Graph (org.opennms.features.topology.api.Graph)1 GraphVisitor (org.opennms.features.topology.api.GraphVisitor)1 Layout (org.opennms.features.topology.api.Layout)1 MapViewManager (org.opennms.features.topology.api.MapViewManager)1 SelectionManager (org.opennms.features.topology.api.SelectionManager)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchCriteria (org.opennms.features.topology.api.topo.SearchCriteria)1 SearchResult (org.opennms.features.topology.api.topo.SearchResult)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 CircleLayoutAlgorithm (org.opennms.features.topology.app.internal.jung.CircleLayoutAlgorithm)1 AlarmHopCriteria (org.opennms.features.topology.app.internal.support.AlarmHopCriteria)1 CategoryHopCriteria (org.opennms.features.topology.app.internal.support.CategoryHopCriteria)1