19 package com.generalrobotix.ui.view;
21 import java.util.ArrayList;
22 import java.util.List;
24 import org.eclipse.jface.resource.StringConverter;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.graphics.RGB;
27 import org.eclipse.swt.widgets.Composite;
47 @SuppressWarnings(
"serial")
49 public static final String TITLE =
"Graph";
50 public static final int NumOfGraph = 3;
55 private List<GrxModelItem> currentModels_ =
new ArrayList<GrxModelItem>();
60 super(
name, manager, vp, parent);
61 isScrollable_ =
false;
64 gpanel_ =
new GraphPanel(manager_, graphManager_, composite_ );
65 setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
71 manager_.registerItemChangeListener(
this,
GrxGraphItem.class);
72 manager_.registerItemChangeListener(
this,
GrxModelItem.class);
76 if(currentGraph_!=
null){
80 if(currentGraph_!=
null){
81 _updateGraph(currentGraph_);
83 if(currentWorld_!=
null){
88 if(currentWorld_!=
null){
111 if(currentWorld_!=worldStateItem){
112 currentWorld_ = worldStateItem;
121 if(currentWorld_==worldStateItem){
124 currentWorld_ =
null;
136 _updateGraph(graphItem);
137 currentGraph_ = graphItem;
142 currentGraph_ =
null;
151 if(!currentModels_.contains(modelItem)){
152 currentModels_.add(modelItem);
158 if(currentModels_.contains(modelItem)){
159 currentModels_.remove(modelItem);
170 if(simItem_!=simItem){
177 if(simItem_==simItem){
201 String graphName =
"Graph" +
i;
202 String header = graphName +
".";
203 String ditems = p.
getStr(header +
"dataItems");
208 List<String> addedList =
new ArrayList<String>();
209 String[] str = ditems.split(
",");
210 for (
int j = 0; j < str.length; j++) {
211 if (str[j].equals(
""))
213 String
object= p.
getStr(header + str[j] +
".object");
214 String node = p.
getStr(header + str[j] +
".node");
215 String attr = p.
getStr(header + str[j] +
".attr");
216 int index = p.
getInt(header + str[j] +
".index", -1);
217 String sColor= p.
getStr(header + str[j] +
".color");
220 color=StringConverter.asRGB(sColor);
221 String legend= p.
getStr(header + str[j] +
".legend");
223 if(attr.equals(
"angle"))
225 else if (attr.equals(
"force"))
226 type =
"ForceSensor";
227 else if (attr.equals(
"torque"))
228 type =
"ForceSensor";
229 else if (attr.equals(
"acceleration"))
230 type =
"AccelerationSensor";
231 else if (attr.equals(
"angularVelocity"))
235 if (!addedList.contains(ditem.
toString())){
241 double[] vRange = p.
getDblAry(header +
"vRange",
null);
242 if (vRange !=
null) {
243 tgraph.
setRange(vRange[0], vRange[1]);
247 double[] timeRange = p.
getDblAry(
"timeRange",
new double[]{1.0, 0.8});
253 private boolean isSimulation =
false;
255 if(simItem_==plugin){
256 if((String)
arg[0]==
"StartSimulation"){
257 double step = currentWorld_.
getDbl(
"logTimeStep", 0.001);
261 }
else if((String)
arg[0]==
"StopSimulation"){
262 isSimulation =
false;
265 }
else if(currentWorld_==plugin) {
266 if((String)
arg[0]==
"ClearLog"){
269 }
else if((String)
arg[0]==
"LoadLog"){
277 if(currentWorld_!=plugin)
return;
279 int pos = arg_pos.intValue();
282 updateGraph(
new Time(0));
297 manager_.removeItemChangeListener(
this,
GrxGraphItem.class);
298 manager_.removeItemChangeListener(
this,
GrxModelItem.class);
301 if(currentWorld_!=
null)