public static Graph createMultiGraph(String name, String style) { Graph g = new MultiGraph(name); g.addAttribute("ui.quality"); g.addAttribute("ui.antialias"); g.addAttribute("ui.stylesheet", style); return g; }
private void addEdge(String edgeId, String fromNode, String toNode) { graph.addEdge(edgeId, fromNode, toNode, true); markEdgeInserted(edgeId); }
private void addNode(String nodeId, Coordinate nodeCoord) { Node node = graph.addNode(nodeId); node.addAttribute("x", nodeCoord.getX()); node.addAttribute("y", nodeCoord.getY()); }
String prevIdentifier = makeId(route.getVehicle().getId(), route.getVehicle().getStartLocation().getId()); if (label.equals(Label.ACTIVITY) || label.equals(Label.JOB_NAME)) { Node n = g.getNode(prevIdentifier); n.addAttribute("ui.label", "start"); String currIdentifier = makeId(job.getId(), act.getLocation().getId()); if (label.equals(Label.ACTIVITY)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", act.getName()); } else if (label.equals(Label.JOB_NAME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", job.getName()); } else if (label.equals(Label.ARRIVAL_TIME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", Time.parseSecondsToTime(act.getArrTime())); } else if (label.equals(Label.DEPARTURE_TIME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", Time.parseSecondsToTime(act.getEndTime())); g.addEdge(makeEdgeId(routeId, vehicle_edgeId), prevIdentifier, currIdentifier, true); if (act instanceof PickupActivity) g.getNode(currIdentifier).addAttribute("ui.class", "pickupInRoute"); else if (act instanceof DeliveryActivity) g.getNode(currIdentifier).addAttribute("ui.class", "deliveryInRoute"); prevIdentifier = currIdentifier; vehicle_edgeId++; g.addEdge(makeEdgeId(routeId, vehicle_edgeId), prevIdentifier, lastIdentifier, true);
public void display(String dgsFile) { System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); Graph graph = GraphStreamViewer.createMultiGraph("g", GraphStreamViewer.StyleSheets.BLUE_FOREST); Viewer viewer = graph.display(); viewer.disableAutoLayout(); FileSource fs = new FileSourceDGS(); fs.addSink(graph); DelayContainer delayContainer = new DelayContainer(); DelaySink delaySink = new DelaySink(delayContainer); delaySink.setDelay(delay); delaySink.setRecreateDelay(delayRecreation); delaySink.setRuinDelay(delayRuin); fs.addSink(delaySink); try { fs.begin(dgsFile); while (fs.nextEvents()) { sleep(delayContainer.delay); } } catch (IOException e) { e.printStackTrace(); } try { fs.end(); } catch (IOException e) { e.printStackTrace(); } finally { fs.removeSink(graph); } }
public void init(Graph graph) { if (this.graph != null) this.graph.removeSink(this); this.graph = graph; this.graph.addSink(this); }
@Override public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) { if (!record()) return; fileSink.stepBegins(graph.getId(), 0, RECREATE); } }
this.manager = manager; if (!manager.graph.hasAttribute(completeId)) { if (position != null) { manager.graph.addAttribute(completeId, position); this.position = position; } else { this.position = new Values(Style.Units.GU, 0f, 0f, 0f); manager.graph.addAttribute(completeId, this.position); manager.graph.setAttribute(completeId, position); this.position = position; } else { this.position = SpriteManager.getPositionValue(manager.graph .getAttribute(completeId));
+ "}" + "edge {" + " fill-color: black;" + "}"; g.addAttribute("ui.stylesheet", stylesheet); g.addAttribute("ui.quality"); g.display();
private void removeEdge(String edgeId) { markEdgeRemoved(edgeId); graph.removeEdge(edgeId); }
private void markPickup(String id) { graph.getNode(id).addAttribute("ui.class", "pickup"); }
public AlgorithmEventsRecorder(VehicleRoutingProblem vrp, String dgsFileLocation) { this.vrp = vrp; graph = new MultiGraph("g"); try { File dgsFile = new File(dgsFileLocation); fos = new FileOutputStream(dgsFile); fileSink = new FileSinkDGS(); if (dgsFile.getName().endsWith("gz")) { gzipOs = new GZIPOutputStream(fos); fileSink.begin(gzipOs); } else { fileSink.begin(fos); } graph.addSink(fileSink); } catch (IOException e) { e.printStackTrace(); } initialiseGraph(vrp); }
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) { Node n1 = g.addNode(makeId(shipment.getId(), shipment.getPickupLocation().getId())); if (label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId()); n1.addAttribute("x", shipment.getPickupLocation().getCoordinate().getX()); n1.addAttribute("y", shipment.getPickupLocation().getCoordinate().getY()); n1.setAttribute("ui.class", "pickup"); Node n2 = g.addNode(makeId(shipment.getId(), shipment.getDeliveryLocation().getId())); if (label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId()); n2.addAttribute("x", shipment.getDeliveryLocation().getCoordinate().getX()); n2.addAttribute("y", shipment.getDeliveryLocation().getCoordinate().getY()); n2.setAttribute("ui.class", "delivery"); if (renderShipments) { Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(), shipment.getPickupLocation().getId()), makeId(shipment.getId(), shipment.getDeliveryLocation().getId()), true); s.addAttribute("ui.class", "shipment"); } }
public void init(Graph graph) { this.graph = graph; graph.addElementSink(this); double initialRank = 1.0 / graph.getNodeCount(); for (Node node : graph) node.addAttribute(rankAttribute, initialRank); newRanks = new ArrayList<Double>(graph.getNodeCount()); upToDate = false; iterationCount = 0; }
public void addElementSink(ElementSink sink) { elementLock.lock(); wrappedElement.addElementSink(sink); elementLock.unlock(); }
public Viewer display() { return wrappedElement.display(); }
/** * @see Algorithm#init(Graph) */ public void init(Graph graph) { if (this.graph != null) this.graph.removeSink(this); this.graph = graph; if (this.graph != null){ graphChanged = true; this.graph.addSink(this); } }
private void markEdgeRemoved(String edgeId) { graph.getEdge(edgeId).addAttribute("ui.class", "removed"); }