Package org.geotools.graph.structure

Examples of org.geotools.graph.structure.Graph


        FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures( filter );
       
        FeatureType schema = features.getSchema();
        Class<?> binding = schema.getGeometryDescriptor().getType().getBinding();
        Graph graph = null;
        if( MultiLineString.class.isAssignableFrom( binding )){
            graph = buildFromMultiLineString( features, new SubProgressMonitor(monitor, 90) );
        }       
        if( graph == null ){
            // prompt or otherwise anny user?  
View Full Code Here


        if ( !mapboard.contains( "graph" ) || !mapboard.contains( "waypoints" ) ) {
            return;
        }

        Graph graph = (Graph ) mapboard.get( "graph" );
        ArrayList<Node> list = (ArrayList<Node> ) mapboard.get( "waypoints" );
        if ( list.size() < 2 ) {
            return;
        }
View Full Code Here

        IBlackboard mapboard = context.getMap().getBlackboard();
        if ( !mapboard.contains( "graph" ) ) {
            return null;
        }
        Graph graph = (Graph) mapboard.get( "graph" );
        Collection<Node> nodes = (Collection<Node>) graph.getNodes();
        for ( Node node : nodes ) {
            Point p = (Point ) node.getObject();
            double d = getDist( coord, p );
            if ( closest == null || d < minDist ) {
                minDist = d;
View Full Code Here

        }
        List<Edge> path = (List<Edge>) mapboard.get("path");
        if( path == null ){
            path = Collections.emptyList();
        }       
        Graph graph = (Graph) mapboard.get("graph");
        ViewportGraphics graphics = context.getGraphics();
        graphics.setColor( Color.LIGHT_GRAY );
        Collection<Node> nodes = graph.getNodes();
        for( Node node : nodes ){
            if( waypoints.contains(node)){
                graphics.setColor( Color.BLACK );               
            }
            Object obj = node.getObject();
            if( obj instanceof Point ){
                Point point = (Point) obj;
                java.awt.Point pixel = context.worldToPixel( point.getCoordinate() );
                graphics.fillOval(pixel.x-2, pixel.y-2, 5, 5 );
            }
            if( waypoints.contains(node)){
                graphics.setColor( Color.LIGHT_GRAY );                               
            }
        }
        Collection<Edge> edges = graph.getEdges();
        graphics.setColor( Color.DARK_GRAY );
        for( Edge edge : edges ){
            Object obj = edge.getObject();
            if( path.contains(edge)){
                graphics.setColor( Color.BLACK );
View Full Code Here

            lgb.add(ft.getDefaultGeometry());
          }
      }

      // lgb is loaded
      Graph g = lgb.getGraph();
     
      return(g.getNodesOfDegree(0).size() == 0);
     
    }
View Full Code Here

    assertEquals(n2.getObject(),p2);
   
    assertNotNull(n3);
    assertEquals(n3.getObject(),p3);
   
    Graph g = gg.getGraph();
    assertEquals(3,g.getNodes().size());
    assertEquals(0,g.getEdges().size());
  }
View Full Code Here

    assertNotNull(n2.getEdge(n1));
   
    assertNull(n2.getEdge(n3));
    assertNull(n2.getEdge(n2));
   
    Graph g = gg.getGraph();
    assertEquals(3,g.getNodes().size());
    assertEquals(2,g.getEdges().size());
  }
View Full Code Here

            allShortEdges.addAll(shortEdges);
            allOtherEdges.addAll(otherEdges);
        }
       
        //for the poster
        Graph gp = new BasicGraph(nodes, edges);
        javax.swing.JFrame frame = new javax.swing.JFrame();
        GraphViewer viewer = new GraphViewer();
        viewer.setLongEdges(allLongEdges);
        viewer.setShortEdges(allShortEdges);
        viewer.setOtherEdges(allOtherEdges);
        viewer.setColorEdges(true);
        viewer.setGraph(gp);
        frame.getContentPane().add(viewer);
        frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
        frame.setSize(new java.awt.Dimension(800, 800));
        frame.setTitle("Assigned edge categories");
        frame.setVisible(true);
       
        //Phase I
        Iterator nodeIt3 = nodes.iterator();
        while (nodeIt3.hasNext()){
            DelaunayNode next = (DelaunayNode) nodeIt3.next();
            AutoClustData acd = (AutoClustData) map.get(next);
            List shortEdges = acd.getShortEdges();
            List longEdges = acd.getLongEdges();
            edges.removeAll(shortEdges);
            LOGGER.finer("removed " + shortEdges);
            edges.removeAll(longEdges);
            LOGGER.finer("removed " + longEdges);
        }
       
        LOGGER.fine("End of phase one and ");
        LOGGER.fine("Nodes are " + nodes);
        LOGGER.fine("Edges are " + edges);               
        showGraph(nodes, edges, 1);       
        Vector connectedComponents = AutoClustUtils.findConnectedComponents(nodes, edges);
       
        //Phase II
        Iterator nodeIt4 = nodes.iterator();
        while (nodeIt4.hasNext()){
            DelaunayNode next = (DelaunayNode) nodeIt4.next();
            AutoClustData acd = (AutoClustData) map.get(next);
            List shortEdges = acd.getShortEdges();
            if (!(shortEdges.isEmpty())){
                Vector shortlyConnectedComponents = new Vector();
                Iterator shortIt = shortEdges.iterator();
                while (shortIt.hasNext()){
                    Edge nextEdge = (Edge) shortIt.next();
                    Node other = nextEdge.getOtherNode(next);
                    Graph g = getMyComponent(other, connectedComponents);
                    if (!(shortlyConnectedComponents.contains(g))){
                        shortlyConnectedComponents.add(g);
                    }
                }
                Graph cv = null;
                if (shortlyConnectedComponents.size() > 1){
                    Iterator sccIt = shortlyConnectedComponents.iterator();
                    int maxSize = 0;
                    while (sccIt.hasNext()){
                        Graph nextGraph = (Graph) sccIt.next();
                        int size = nextGraph.getNodes().size();
                        if (size > maxSize){
                            maxSize = size;
                            cv = nextGraph;
                        }
                    }
                } else {
                    cv = (Graph) shortlyConnectedComponents.get(0);
                }
                Iterator shortIt2 = shortEdges.iterator();
                while (shortIt2.hasNext()){
                    Edge nextEdge = (Edge) shortIt2.next();
                    Node other = nextEdge.getOtherNode(next);
                    if (cv.equals(getMyComponent(other, shortlyConnectedComponents))){
                        edges.add(nextEdge);
                    }
                }
            } //end if shortEdges isn't empty
            Graph gr = getMyComponent(next, connectedComponents);
            if (gr.getNodes().size() == 1){
                Vector shortlyConnectedComponents = new Vector();
                Iterator shortIt = shortEdges.iterator();
                while (shortIt.hasNext()){
                    Edge nextEdge = (Edge) shortIt.next();
                    Node other = nextEdge.getOtherNode(next);
                    Graph g = getMyComponent(other, connectedComponents);
                    if (!(shortlyConnectedComponents.contains(g))){
                        shortlyConnectedComponents.add(g);
                    }
                }
                if (shortlyConnectedComponents.size() == 1){
View Full Code Here

        return new BasicGraph(nodes, edges);
    }
   
    private static Graph getMyComponent(Node node, Vector components){
        Iterator it = components.iterator();
        Graph ret = null;
        boolean found = false;
        while ((it.hasNext()) && (!(found))){
            Graph next = (Graph) it.next();
            if (next.getNodes().contains(node)){
                found = true;
                ret = next;
            }
        }
        if (ret == null){
View Full Code Here

   
    assertTrue(m_builder.getEdges().isEmpty());
  }
 
  public void test_getGraph() {
    Graph graph = m_builder.getGraph()
    assertTrue(graph != null);
  }
View Full Code Here

TOP

Related Classes of org.geotools.graph.structure.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.