Fix issue with MapViewDrawing and generalize ClickListener for all Drawings.
This commit is contained in:
@@ -7,33 +7,31 @@ import org.insa.drawing.Drawing;
|
||||
import org.insa.graph.Node;
|
||||
|
||||
public class WeaklyConnectedComponentGraphicObserver implements WeaklyConnectedComponentObserver {
|
||||
|
||||
private static final Color[] COLORS = {
|
||||
Color.BLUE, Color.ORANGE, Color.GREEN, Color.YELLOW, Color.RED
|
||||
};
|
||||
|
||||
// Drawing + Graph drawing
|
||||
private Drawing drawing;
|
||||
|
||||
// Current index color
|
||||
private int cindex = -1;
|
||||
|
||||
public WeaklyConnectedComponentGraphicObserver(Drawing drawing) {
|
||||
this.drawing = drawing;
|
||||
}
|
||||
private static final Color[] COLORS = { Color.BLUE, Color.ORANGE, Color.GREEN, Color.YELLOW, Color.RED };
|
||||
|
||||
@Override
|
||||
public void notifyStartComponent(Node curNode) {
|
||||
cindex = (cindex + 1) % COLORS.length;
|
||||
}
|
||||
// Drawing + Graph drawing
|
||||
private Drawing drawing;
|
||||
|
||||
@Override
|
||||
public void notifyNewNodeInComponent(Node node) {
|
||||
this.drawing.drawMarker(node.getPoint(), COLORS[cindex]);
|
||||
}
|
||||
// Current index color
|
||||
private int cindex = -1;
|
||||
|
||||
@Override
|
||||
public void notifyEndComponent(ArrayList<Node> nodes) {
|
||||
}
|
||||
public WeaklyConnectedComponentGraphicObserver(Drawing drawing) {
|
||||
this.drawing = drawing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyStartComponent(Node curNode) {
|
||||
cindex = (cindex + 1) % COLORS.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNewNodeInComponent(Node node) {
|
||||
this.drawing.drawPoint(node.getPoint(), 1, COLORS[cindex]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyEndComponent(ArrayList<Node> nodes) {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user