JButton zoomToNodeButton = new JButton("Zoom to node");
zoomToNodeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String nodeName = (String) JOptionPane.showInputDialog(frame, "Node id",
JOptionPane.PLAIN_MESSAGE);
Vertex v = getGraph().getVertex(nodeName);
if (v == null) {
System.out.println("no such node " + nodeName);
} else {
showGraph.zoomToVertex(v);
}
}
});
buttonPanel.add(zoomToNodeButton);
JButton zoomToLocationButton = new JButton("Zoom to location");
zoomToLocationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String result = JOptionPane.showInputDialog("Enter the location (lat lon)");
if (result == null || result.length() == 0)
return;
String[] tokens = result.split("[\\s,]+");
double lat = Double.parseDouble(tokens[0]);
double lon = Double.parseDouble(tokens[1]);
Coordinate c = new Coordinate(lon, lat);
showGraph.zoomToLocation(c);
}
});
buttonPanel.add(zoomToLocationButton);
JButton zoomOutButton = new JButton("Zoom out");
zoomOutButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showGraph.zoomOut();
}
});
buttonPanel.add(zoomOutButton);
JButton routeButton2 = new JButton("Route");
routeButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// String initialFrom = "";
// Object selected = nearbyVertices.getSelectedValue();
// if (selected != null) {
// initialFrom = selected.toString();
// }
// RouteDialog dlg = new RouteDialog(frame, initialFrom); // modal
String from = sourceVertex.getText();
String to = sinkVertex.getText();
route(from, to);
}
});
buttonPanel.add(routeButton2);
JButton findButton = new JButton("Find node");
findButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String nodeName = (String) JOptionPane.showInputDialog(frame, "Node id",
JOptionPane.PLAIN_MESSAGE);
Vertex v = getGraph().getVertex(nodeName);
if (v == null) {
System.out.println("no such node " + nodeName);
} else {
showGraph.highlightVertex(v);
ArrayList<Vertex> l = new ArrayList<Vertex>();
l.add(v);
verticesSelected(l);
}
}
});
buttonPanel.add(findButton);
JButton findEdgeButton = new JButton("Find edge");
findEdgeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String edgeName = (String) JOptionPane.showInputDialog(frame, "Edge name like",
JOptionPane.PLAIN_MESSAGE);
for (Vertex gv : getGraph().getVertices()) {
for (Edge edge : gv.getOutgoing()) {
if (edge.getName() != null && edge.getName().contains(edgeName)) {
showGraph.highlightVertex(gv);
ArrayList<Vertex> l = new ArrayList<Vertex>();
l.add(gv);
verticesSelected(l);
}
}
}
}
});
buttonPanel.add(findEdgeButton);
JButton checkButton = new JButton("Check graph");
checkButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkGraph();
}
});
buttonPanel.add(checkButton);
JButton traceButton = new JButton("Trace");
traceButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
trace();
}
});
buttonPanel.add(traceButton);
// annotation search button
JButton annotationButton = new JButton("Find annotations");
annotationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
findAnnotation();
}
});
buttonPanel.add(annotationButton);
JButton findEdgeByIdButton = new JButton("Find edge ID");
findEdgeByIdButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String edgeIdStr = (String) JOptionPane.showInputDialog(frame, "Edge ID",
JOptionPane.PLAIN_MESSAGE);
Integer edgeId = Integer.parseInt(edgeIdStr);
Edge edge = getGraph().getEdgeById(edgeId);
if (edge != null) {
showGraph.highlightEdge(edge);
showGraph.highlightVertex(edge.getFromVertex());
} else {
System.out.println("Found no edge with ID " + edgeIdStr);
}
}
});
buttonPanel.add(findEdgeByIdButton);
JButton snapButton = new JButton("Snap location");
snapButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String locString = (String) JOptionPane.showInputDialog(frame, "Location string",
"");
GenericLocation loc = GenericLocation.fromOldStyleString(locString);
RoutingRequest rr = new RoutingRequest();
Vertex v = graph.streetIndex.getVertexForLocation(
loc, rr);
showGraph.highlightVertex(v);
}
});
buttonPanel.add(snapButton);