Revision 226:3b9be7a7b598

View differences:

src/main/java/tt/jointeuclid2ni/probleminstance/VisUtil.java
1 1
package tt.jointeuclid2ni.probleminstance;
2 2

  
3 3
import cz.agents.alite.vis.VisManager;
4
import cz.agents.alite.vis.element.aggregation.LineElements;
5
import cz.agents.alite.vis.element.implemetation.LineImpl;
4 6
import cz.agents.alite.vis.layer.common.BackgroundLayer;
5 7
import cz.agents.alite.vis.layer.common.ColorLayer;
6 8
import cz.agents.alite.vis.layer.common.VisInfoLayer;
9
import cz.agents.alite.vis.layer.terminal.ArrowLayer;
7 10
import cz.agents.alite.vis.layer.terminal.ImageLayer;
8 11
import cz.agents.alite.vis.layer.toggle.KeyToggleLayer;
9 12

  
......
22 25
import tt.vis.*;
23 26

  
24 27
import javax.vecmath.Point2d;
28
import javax.vecmath.Point3d;
25 29

  
26 30
import java.awt.*;
27 31
import java.awt.image.BufferedImage;
28 32
import java.io.File;
33
import java.util.ArrayList;
29 34
import java.util.Collection;
30 35
import java.util.Collections;
31 36
import java.util.LinkedList;
......
112 117
        
113 118
        VisManager.registerLayer(polygonsToggle);
114 119
        
120
        KeyToggleLayer missionToggle = KeyToggleLayer.create("m");
121
        missionToggle.setEnabled(false);
122
        
115 123
        // starts
116
        VisManager.registerLayer(KeyToggleLayer.create("s", LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
124
       missionToggle.addSubLayer(LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
117 125

  
118 126
            @Override
119 127
            public Collection<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>> getLabeledCircles() {
120 128
                LinkedList<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>> list = new LinkedList<LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>>();
121 129

  
122 130
                for (int i = 0; i < problem.getStarts().length; i++) {
123
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getStart(i), problem.getBodyRadius(i), "s" + i, AgentColors.getColorForAgent(i)));
131
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getStart(i), problem.getBodyRadius(i), "", AgentColors.getColorForAgent(i)));
124 132
                }
125 133

  
126 134
                return list;
127 135
            }
128 136

  
129
        }, new tt.euclid2i.vis.ProjectionTo2d())));
137
        }, new tt.euclid2i.vis.ProjectionTo2d()));
130 138
        
131 139
        
132 140
        // destinations 
133
        VisManager.registerLayer(KeyToggleLayer.create("d", LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
141
        missionToggle.addSubLayer(LabeledCircleLayer.create(new LabeledCircleLayer.LabeledCircleProvider<tt.euclid2i.Point>() {
134 142

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

  
139 147
                for (int i = 0; i < problem.getStarts().length; i++) {
140
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getTarget(i), problem.getBodyRadius(i), "g" + i, AgentColors.getColorForAgent(i).darker().darker()));
148
                    list.add(new LabeledCircleLayer.LabeledCircle<tt.euclid2i.Point>(problem.getTarget(i), problem.getBodyRadius(i), "", AgentColors.getColorForAgent(i).darker().darker()));
141 149
                }
142 150

  
143 151
                return list;
144 152
            }
145 153

  
146
        }, new tt.euclid2i.vis.ProjectionTo2d())));
154
        }, new tt.euclid2i.vis.ProjectionTo2d()));
155
        
156
        // missions
157
        
158
        missionToggle.addSubLayer(ArrowLayer.create(new LineElements() {
159

  
160
            @Override
161
            public Color getColor() {
162
                return Color.BLACK;
163
            }
164

  
165
            @Override
166
            public int getStrokeWidth() {
167
                return 1;
168
            }
169

  
170
            @Override
171
            public Iterable<? extends cz.agents.alite.vis.element.Line> getLines() {
172
            	ArrayList<cz.agents.alite.vis.element.Line> lines = new ArrayList<cz.agents.alite.vis.element.Line>();
173
                for (int i = 0; i < problem.getStarts().length; i++) {
174
                	
175
                	Point start = problem.getStart(i);
176
                	Point end = problem.getTarget(i);
177
                	
178
                	Point3d startLine = new Point3d(start.x, start.y, 0);
179
                	Point3d endLine = new Point3d(end.x, end.y, 0);
180
                	
181
                	lines.add(new LineImpl(startLine, endLine));
182
                }
183
                return lines;
184
            }
185
        }));
186

  
187
        VisManager.registerLayer(missionToggle);
147 188

  
148 189
        // Overlay
149 190
        VisManager.registerLayer(VisInfoLayer.create());

Also available in: Unified diff