Revision 222:afa32bbeb8e0

View differences:

src/main/java/tt/jointeuclid2ni/probleminstance/VisUtil.java
84 84
    }
85 85

  
86 86
    public static void visualizeProblem(final EarliestArrivalProblem problem) {
87
    	
88
    	KeyToggleLayer polygonsToggle = KeyToggleLayer.create("p");
89
    	
87 90
        // boundary
88
        VisManager.registerLayer(RegionsLayer.create(
91
        polygonsToggle.addSubLayer(RegionsLayer.create(
89 92
                new RegionsLayer.RegionsProvider() {
90 93

  
91 94
                    @Override
......
93 96
                        return Collections.singleton(problem.getEnvironment().getBoundary());
94 97
                    }
95 98

  
96
                }, Color.RED, null)
99
                }, Color.BLACK, Color.GRAY)
97 100
        );
98 101

  
99
//        VisManager.registerLayer(RegionsLayer.create(
100
//                new RegionsLayer.RegionsProvider() {
101
//
102
//                    @Override
103
//                    public Collection<Region> getRegions() {
104
//                        LinkedList<Region> list = new LinkedList<Region>();
105
//                        list.add(new Rectangle(new Point(0, 0), new Point(1000, 1000)));
106
//                        return list;
107
//                    }
108
//
109
//                }, Color.LIGHT_GRAY));
110

  
111
        VisManager.registerLayer(RegionsLayer.create(
102
        polygonsToggle.addSubLayer(RegionsLayer.create(
112 103
                new RegionsLayer.RegionsProvider() {
113 104

  
114 105
                    @Override
......
118 109

  
119 110
                }, Color.BLACK, null
120 111
        ));
121

  
122
        VisManager.registerLayer(LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
112
        
113
        VisManager.registerLayer(polygonsToggle);
114
        
115
        // starts
116
        VisManager.registerLayer(KeyToggleLayer.create("s", LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
123 117

  
124 118
            @Override
125 119
            public Collection<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>> getLabeledCircles() {
......
129 123
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getStart(i), problem.getBodyRadius(i), "s" + i, AgentColors.getColorForAgent(i)));
130 124
                }
131 125

  
126
                return list;
127
            }
128

  
129
        }, new tt.euclid2i.vis.ProjectionTo2d())));
130
        
131
        
132
        // destinations 
133
        VisManager.registerLayer(KeyToggleLayer.create("d", LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
134

  
135
            @Override
136
            public Collection<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>> getLabeledCircles() {
137
                LinkedList<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>> list = new LinkedList<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>>();
138

  
132 139
                for (int i = 0; i < problem.getStarts().length; i++) {
133 140
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getTarget(i), problem.getBodyRadius(i), "g" + i, AgentColors.getColorForAgent(i).darker().darker()));
134 141
                }
......
136 143
                return list;
137 144
            }
138 145

  
139
        }, new tt.euclid2i.vis.ProjectionTo2d()));
146
        }, new tt.euclid2i.vis.ProjectionTo2d())));
140 147

  
141 148
        // Overlay
142 149
        VisManager.registerLayer(VisInfoLayer.create());
src/main/java/tt/vis/FastAgentsLayer.java
3 3
import cz.agents.alite.vis.Vis;
4 4
import cz.agents.alite.vis.layer.AbstractLayer;
5 5
import cz.agents.alite.vis.layer.VisLayer;
6

  
6 7
import org.apache.log4j.Logger;
8

  
7 9
import tt.discrete.Trajectory;
8 10
import tt.euclid2i.Point;
9 11
import tt.euclidtime3i.vis.TimeParameter;
......
63 65
                    Vis.transY(projectedPoint.y - radius),
64 66
                    Vis.transH(radius * 2), Vis.transW(radius * 2));
65 67
            canvas.setColor(Color.WHITE);
66
            canvas.drawString(Integer.toString(i), Vis.transX(projectedPoint.x), Vis.transY(projectedPoint.y));
68
            
69
            String label = Integer.toString(i);
70
            int labelWidth = (int)  canvas.getFontMetrics().getStringBounds(label, canvas).getWidth();  
71
            int labelHeight = (int)  canvas.getFontMetrics().getStringBounds(label, canvas).getHeight();  
72
            
73
            canvas.drawString(label, Vis.transX(projectedPoint.x) - (labelWidth / 2), Vis.transY(projectedPoint.y) + (labelHeight / 2));
67 74
        }
68 75
    }
69 76
}

Also available in: Unified diff