/** * Constructs a Node with the given location. */ public Node(Coordinate pt) { this(pt, new DirectedEdgeStar()); }
/** * Adds an outgoing DirectedEdge to this Node. */ public void addOutEdge(DirectedEdge de) { deStar.add(de); }
/** * Returns the number of edges around this Node. */ public int getDegree() { return deStar.getDegree(); } /**
private static int getDegreeNonDeleted(Node node) { List edges = node.getOutEdges().getEdges(); int degree = 0; for (Iterator i = edges.iterator(); i.hasNext(); ) { PolygonizeDirectedEdge de = (PolygonizeDirectedEdge) i.next(); if (! de.isMarked()) degree++; } return degree; }
/** * Returns the coordinate for the node at wich this star is based */ public Coordinate getCoordinate() { Iterator it = iterator(); if (! it.hasNext()) return null; DirectedEdge e = (DirectedEdge) it.next(); return e.getCoordinate(); }
/** * Returns the DirectedEdges, in ascending order by angle with the positive x-axis. */ public List getEdges() { sortEdges(); return outEdges; }
/** * Returns the zero-based index of the given Edge, after sorting in ascending order * by angle with the positive x-axis. */ public int getIndex(Edge edge) { return deStar.getIndex(edge); }
/** * Removes a {@link DirectedEdge} incident on this node. * Does not change the state of the directed edge. */ public void remove(DirectedEdge de) { deStar.remove(de); }
private static int getDegree(Node node, long label) { List edges = node.getOutEdges().getEdges(); int degree = 0; for (Iterator i = edges.iterator(); i.hasNext(); ) { PolygonizeDirectedEdge de = (PolygonizeDirectedEdge) i.next(); if (de.getLabel() == label) degree++; } return degree; }
private void buildEdgeStringsStartingAt(Node node) { for (Iterator i = node.getOutEdges().iterator(); i.hasNext(); ) { LineMergeDirectedEdge directedEdge = (LineMergeDirectedEdge) i.next(); if (directedEdge.getEdge().isMarked()) { continue; } edgeStrings.add(buildEdgeStringStartingWith(directedEdge)); } }
/** * Returns an Iterator over the DirectedEdges, in ascending order by angle with the positive x-axis. */ public Iterator iterator() { sortEdges(); return outEdges.iterator(); }
/** * Removes a {@link DirectedEdge} incident on this node. * Does not change the state of the directed edge. */ public void remove(DirectedEdge de) { deStar.remove(de); }
/** * Returns all Edges that connect the two nodes (which are assumed to be different). */ public static Collection getEdgesBetween(Node node0, Node node1) { List edges0 = DirectedEdge.toEdges(node0.getOutEdges().getEdges()); Set commonEdges = new HashSet(edges0); List edges1 = DirectedEdge.toEdges(node1.getOutEdges().getEdges()); commonEdges.retainAll(edges1); return commonEdges; }
/** * Finds an {@link DirectedEdge} for an unvisited edge (if any), * choosing the dirEdge which preserves orientation, if possible. * * @param node the node to examine * @return the dirEdge found, or <code>null</code> if none were unvisited */ private static DirectedEdge findUnvisitedBestOrientedDE(Node node) { DirectedEdge wellOrientedDE = null; DirectedEdge unvisitedDE = null; for (Iterator i = node.getOutEdges().iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); if (! de.getEdge().isVisited()) { unvisitedDE = de; if (de.getEdgeDirection()) wellOrientedDE = de; } } if (wellOrientedDE != null) return wellOrientedDE; return unvisitedDE; }
/** * Returns the zero-based index of the given DirectedEdge, after sorting in ascending order * by angle with the positive x-axis. */ public int getIndex(DirectedEdge dirEdge) { sortEdges(); for (int i = 0; i < outEdges.size(); i++) { DirectedEdge de = (DirectedEdge) outEdges.get(i); if (de == dirEdge) return i; } return -1; } /**
/** * Returns the {@link DirectedEdge} on the right-hand (CW) * side of the given {@link DirectedEdge} * (which must be a member of this DirectedEdgeStar). */ public DirectedEdge getNextCWEdge(DirectedEdge dirEdge) { int i = getIndex(dirEdge); return (DirectedEdge) outEdges.get(getIndex(i - 1)); } }
/** * Adds an outgoing DirectedEdge to this Node. */ public void addOutEdge(DirectedEdge de) { deStar.add(de); }
/** * Constructs a Node with the given location. */ public Node(Coordinate pt) { this(pt, new DirectedEdgeStar()); }
/** * Returns the number of edges around this Node. */ public int getDegree() { return deStar.getDegree(); } /**