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){
108 GrxWorldStateItem worldStateItem = (GrxWorldStateItem) item;
111 if(currentWorld_!=worldStateItem){
112 currentWorld_ = worldStateItem;
121 if(currentWorld_==worldStateItem){
124 currentWorld_ =
null;
133 GrxGraphItem graphItem = (GrxGraphItem) item;
136 _updateGraph(graphItem);
137 currentGraph_ = graphItem;
142 currentGraph_ =
null;
148 GrxModelItem modelItem = (GrxModelItem) item;
151 if(!currentModels_.contains(modelItem)){
152 currentModels_.add(modelItem);
158 if(currentModels_.contains(modelItem)){
159 currentModels_.remove(modelItem);
167 GrxSimulationItem simItem = (GrxSimulationItem) item;
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");
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())){
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)
void setTotalTime(double totalTime)
png_infop png_charp png_int_32 png_int_32 int * type
final Integer getInt(String key, Integer defaultVal)
get integer value associated to key
void addObserver(GrxObserver v)
final double[] getDblAry(String key, double[] defaultVal)
get double array associated to key
#define null
our own NULL pointer
png_infop png_charpp name
TrendGraphModel graphManager_
item corresponds to a robot model
void deleteObserver(GrxObserver v)
void worldTimeChanged(Time time)
void registerItemChange(GrxBaseItem item, int event)
void updateGraph(Time time_)
static final int SELECTED_ITEM
void setWorldState(GrxWorldStateItem world)
void deletePosObserver(GrxPositionObserver v)
int addDataItem(DataItemInfo di)
void _updateGraph(GrxBasePlugin p)
def j(str, encoding="cp932")
void updatePosition(GrxBasePlugin plugin, Integer arg_pos)
GrxGraphView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
static final int REMOVE_ITEM
final Double getDbl(String key, Double defaultVal)
get double value associated to key
void addPosObserver(GrxPositionObserver v)
void setEnabledRangeButton(boolean b)
void setRangeAndPos(double timeRange, double markerPos)
final String getStr(String key)
get value associated to keyword
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
void setPanel(GraphPanel gPanel)
void update(GrxBasePlugin plugin, Object...arg)
void setStepTime(long stepTime)
void setModelList(List< GrxModelItem > list)
static final int NOTSELECTED_ITEM
void setRange(double base, double extent)
TrendGraph getTrendGraph(int index)