Skip to content

Commit

Permalink
adding QuadtreeTest, it doesn't do much right now
Browse files Browse the repository at this point in the history
  • Loading branch information
thedesloge committed Apr 16, 2014
1 parent 59ce37f commit c1f265d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class D3TopoLayout<V, E> extends AbstractLayout<V, E> implements Iterativ
private static final double LINK_STRENGTH = 1.0;
private static final int DEFAULT_CHARGE = -120;
private double EPSILON = 0.00000000001D;
private int m_charge = -30;

private double m_alpha = 0.1;
private Map<V, VertexData> m_vertexData = LazyMap.decorate(new HashMap<V, VertexData>(), new Factory<VertexData>(){
Expand Down Expand Up @@ -147,6 +148,9 @@ public void step() {

//Compute quad tree center of mass and apply charge force
//TODO create a quadtree implementation from D3
if(getDefaultCharge() != 0){

}


}
Expand All @@ -171,6 +175,14 @@ private EdgeData getEdgeData(E e) {
return m_edgeData.get(e);
}

public int getDefaultCharge() {
return m_charge;
}

public void setDefaultCharge(int m_charge) {
this.m_charge = m_charge;
}

protected static class VertexData extends Point2D.Double{

private int m_weight;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2012 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.features.topology.app.internal.jung;

import org.junit.Test;
import org.opennms.features.topology.api.Point;
import org.opennms.features.topology.api.topo.Vertex;

import java.awt.geom.Point2D;

public class QuadTreeTest {

@Test
public void testQuadTree() {
QuadTree<Integer, String> quadTree = new QuadTree<Integer, String>();
quadTree.insert(10, 10, "Vertex1");
quadTree.insert(10, 20, "Vertex2");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex3");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex4");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex5");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex6");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex7");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex8");
quadTree.insert((int)(Math.random() * 100), (int) (Math.random() * 100), "Vertex9");


}
}

0 comments on commit c1f265d

Please sign in to comment.