16 package com.generalrobotix.ui.view.graph;
18 import java.util.Enumeration;
19 import java.util.List;
21 import org.eclipse.jface.dialogs.IDialogConstants;
22 import org.eclipse.jface.dialogs.MessageDialog;
23 import org.eclipse.jface.resource.StringConverter;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.custom.SashForm;
26 import org.eclipse.swt.custom.ScrolledComposite;
27 import org.eclipse.swt.events.PaintEvent;
28 import org.eclipse.swt.events.PaintListener;
29 import org.eclipse.swt.events.SelectionAdapter;
30 import org.eclipse.swt.events.SelectionEvent;
31 import org.eclipse.swt.graphics.Color;
32 import org.eclipse.swt.layout.GridData;
33 import org.eclipse.swt.layout.GridLayout;
34 import org.eclipse.swt.layout.RowLayout;
35 import org.eclipse.swt.widgets.Button;
36 import org.eclipse.swt.widgets.Composite;
37 import org.eclipse.swt.widgets.Label;
38 import org.eclipse.swt.widgets.Scale;
46 @SuppressWarnings(
"serial")
52 private List<GrxModelItem> currentModels_ =
null;
65 hRangeButton_.setEnabled(b);
66 vRangeButton_.setEnabled(b);
67 seriesButton_.setEnabled(b);
72 hRangeButton_.setEnabled(b);
73 vRangeButton_.setEnabled(b);
88 super(comp, SWT.NONE);
90 trendGraphMgr_ = trendGraphMgr;
92 setLayout(
new GridLayout(1,
true));
93 graphScrollPane_ =
new ScrolledComposite(
this, SWT.H_SCROLL | SWT.V_SCROLL| SWT.BORDER);
94 graphScrollPane_.setExpandHorizontal(
true);
95 graphScrollPane_.setExpandVertical(
true);
96 GridData gridData0 =
new GridData();
97 gridData0.horizontalAlignment = GridData.FILL;
98 gridData0.grabExcessHorizontalSpace =
true;
99 gridData0.verticalAlignment = GridData.FILL;
100 gridData0.grabExcessVerticalSpace =
true;
101 graphScrollPane_.setLayoutData(gridData0);
102 Composite graphControlPanel =
new Composite(
this, SWT.NONE);
103 GridData gridData1 =
new GridData();
104 gridData1.horizontalAlignment = GridData.FILL;
105 gridData1.grabExcessHorizontalSpace =
true;
106 graphControlPanel.setLayoutData(gridData1);
107 graphControlPanel.setLayout(
new RowLayout());
108 graphElementBase_ =
new SashForm(graphScrollPane_, SWT.VERTICAL);
109 graphElementBase_.SASH_WIDTH = 6;
110 graphScrollPane_.setContent(graphElementBase_);
114 for (
int i = 0;
i < numGraph_;
i ++) {
121 graphScrollPane_.setMinSize(graphElementBase_.computeSize(SWT.DEFAULT, SWT.DEFAULT));
123 currentGraph_ = graphElement_[0];
126 hRangeButton_ =
new Button(graphControlPanel, SWT.PUSH);
128 hRangeDialog_ =
new HRangeDialog(graphControlPanel.getShell());
129 hRangeButton_.addSelectionListener(
new SelectionAdapter(){
130 public void widgetSelected(SelectionEvent e) {
132 if (graphItem ==
null)
140 if(hRangeDialog_.open() == IDialogConstants.OK_ID){
144 double hRange = hRangeDialog_.
getHRange();
150 graphItem.
setDblAry(
"timeRange",
new double[]{hRange, mpos});
157 vRangeButton_ =
new Button(graphControlPanel, SWT.PUSH);
159 vRangeDialog_ =
new VRangeDialog(graphControlPanel.getShell());
160 vRangeButton_.addSelectionListener(
new SelectionAdapter(){
161 public void widgetSelected(SelectionEvent e) {
166 if(vRangeDialog_.open() == IDialogConstants.OK_ID){
167 double base = vRangeDialog_.
getBase();
168 double extent = vRangeDialog_.
getExtent();
171 if (graphItem ==
null)
174 redraw(getLocation().
x,getLocation().
y,getSize().
x,getSize().
y,
true);
180 seriesButton_ =
new Button(graphControlPanel, SWT.PUSH);
183 seriesDialog_ =
new SeriesDialog(currentGraph_, graphControlPanel.getShell());
184 seriesButton_.addSelectionListener(
new SelectionAdapter(){
185 public void widgetSelected(SelectionEvent e) {
187 if (graphItem ==
null)
189 if(MessageDialog.openQuestion(
205 if(seriesDialog_.
open() == IDialogConstants.OK_ID){
207 for (
int i = 0;
i < dii.length;
i++) {
211 for (
int i = 0;
i < dii.length;
i++) {
216 for (
int i = 0;
i < addedArray_.length;
i++) {
220 String graphName = tg.getNodeName();
221 Enumeration<?> enume = graphItem.propertyNames();
222 while (enume.hasMoreElements()) {
223 String key = (String)enume.nextElement();
224 if (key.startsWith(graphName))
225 graphItem.remove(key);
227 String dataItems =
"";
229 for (
int i = 0;
i<list.length;
i++) {
231 String header = tg._getDataItemNodeName(di);
236 dataItems +=
"_"+di.
index;
241 graphItem.
setProperty(header+
".legend", list[
i].legend);
244 graphItem.
setProperty(graphName+
".dataItems",dataItems);
337 setEnabledRangeButton(
false);
344 redraw(getLocation().
x,getLocation().
y,getSize().
x,getSize().
y,
true);
382 vRangeButton_.setEnabled(enabled);
383 seriesButton_.setEnabled(
true);
387 setEnabledRangeButton(p !=
null);
462 currentModels_ = list;
GraphPanel(GrxPluginManager manager, TrendGraphModel trendGraphMgr, Composite comp)
static final String get(String key)
void itemChange(GrxBaseItem item, int event)
DataItemInfo[] getRemovedList()
#define null
our own NULL pointer
void setUnit(String unit)
GrxBaseItem createItem(Class<?extends GrxBaseItem > cls, String name)
アイテムの作成. 指定したアイテムプラグインに、指定したアイテム名で新しいアイテムを作る。 ...
DataItemInfo[] getAddedList()
void setExtent(double extent)
TrendGraphModel trendGraphMgr_
item corresponds to a robot model
static final int ADD_ITEM
void setBase(double base)
void setFocuse(GraphElement ge)
void setHRange(double hRange)
static Activator getDefault()
void removeDataItem(DataItemInfo dataItemInfo)
static final int RANGE_UPDATED
static final int POS_UPDATED
DataItemInfo[] addedArray_
int addDataItem(DataItemInfo di)
ScrolledComposite graphScrollPane_
void setSelectedItem(GrxBaseItem item, boolean select)
select/unselect item
void setDataItemInfoList(DataItemInfo[] dii)
void setMinHRange(double minHRange)
SeriesDialog seriesDialog_
Object setProperty(String key, String value)
set property value associated with a keyword
TrendGraph getTrendGraph()
void setEnabledRangeButton(boolean b)
void setDataItemInfo(DataItemInfo dii)
void setBorderColor(Color color)
DataItemInfo[] getDataItemInfoList()
HRangeDialog hRangeDialog_
GraphElement[] graphElement_
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
void setModelList(List< GrxModelItem > list)
void setTimeRangeAndPos(double timeRange, double markerPos)
void setMaxHRange(double maxHRange)
DataItemInfo[] getDataItemInfoList()
VRangeDialog vRangeDialog_
GraphElement currentGraph_
void setEnabled(boolean b)
void setModelList(List< GrxModelItem > list)
SashForm graphElementBase_
GrxPluginManager manager_
void setRange(double base, double extent)
png_infop png_uint_32 flag
final void setDblAry(String key, double[] value, int digits)
associate double array to key
TrendGraph getTrendGraph(int index)
void setCurrentGraph(GraphElement currentGraph)
void setMarkerPos(double markerPos)