1 package cz.cuni.amis.pogamut.usar2004.communication.messages.usarcommands;
2
3 import java.util.*;
4 import cz.cuni.amis.pogamut.base.communication.messages.*;
5 import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
6
7
8
9
10
11
12
13
14
15
16 public class SetCamera extends CommandMessage
17 {
18
19 public SetCamera(String Type, String Name, Double FOV)
20 {
21 this.Type = Type;
22 this.NamesFovs.put(Name, FOV);
23 }
24
25
26 public SetCamera(String Type, String[] Names, Double[] FOVs)
27 {
28 this.Type = Type;
29 if(Names.length == FOVs.length)
30 {
31 for(int i = 0; i < Names.length; i++)
32 {
33 this.NamesFovs.put(Names[i], FOVs[i]);
34 }
35 }
36 }
37
38
39
40
41
42 public SetCamera()
43 {
44 }
45
46
47
48
49
50
51
52 protected String Type = "Camera";
53
54 public String getType()
55 {
56 return Type;
57 }
58 Map<String, Double> NamesFovs = new HashMap<String, Double>();
59
60 public Map<String, Double> getNamesFovs()
61 {
62 return NamesFovs;
63 }
64
65 public SetCamera setNamesFovs(Map<String, Double> NamesFovs)
66 {
67 this.NamesFovs = NamesFovs;
68 return this;
69 }
70
71 public SetCamera addNameFOV(String Name, Double FOV)
72 {
73 this.NamesFovs.put(Name, FOV);
74 return this;
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 public SetCamera(SetCamera original)
94 {
95 this.NamesFovs.putAll(original.NamesFovs);
96 }
97
98 @Override
99 public String toString()
100 {
101 return toMessage();
102 }
103
104 public String toHtmlString()
105 {
106 StringBuilder buf = new StringBuilder();
107 buf.append(super.toString());
108
109 buf.append("<b>Type</b> : ").append(String.valueOf(Type)).append(" <br/> ");
110
111 if(!NamesFovs.isEmpty())
112 {
113
114 Iterator it = NamesFovs.entrySet().iterator();
115 while(it.hasNext())
116 {
117 Map.Entry en = (Map.Entry) it.next();
118 buf.append("<b>Name</b> : ").append(en.getKey()).append("</br> <b>FOV</b> : ").append(en.getValue()).append("}");
119 }
120 }
121
122
123 return buf.toString();
124
125 }
126
127 public String toMessage()
128 {
129 StringBuilder buf = new StringBuilder();
130 buf.append("SET");
131
132 if(Type != null)
133 {
134 buf.append(" {Type ").append(Type).append("}");
135 }
136
137 if(!NamesFovs.isEmpty())
138 {
139
140 Iterator it = NamesFovs.entrySet().iterator();
141 while(it.hasNext())
142 {
143 Map.Entry en = (Map.Entry) it.next();
144 buf.append(" {Name ").append(en.getKey()).append("} {FOV ").append(en.getValue()).append("}");
145 }
146 }
147
148 return buf.toString();
149 }
150 }