Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.generalrobotix.ui.view.graph;
00011
00012
00013
00014
00015 import org.eclipse.swt.SWT;
00016 import org.eclipse.swt.custom.SashForm;
00017 import org.eclipse.swt.events.MouseEvent;
00018 import org.eclipse.swt.events.MouseListener;
00019 import org.eclipse.swt.events.PaintEvent;
00020 import org.eclipse.swt.events.PaintListener;
00021 import org.eclipse.swt.events.SelectionListener;
00022 import org.eclipse.swt.graphics.Color;
00023 import org.eclipse.swt.graphics.Font;
00024 import org.eclipse.swt.layout.GridData;
00025 import org.eclipse.swt.layout.GridLayout;
00026 import org.eclipse.swt.widgets.Composite;
00027 import com.generalrobotix.ui.grxui.Activator;
00028 import com.generalrobotix.ui.view.graph.LegendPanel;
00029
00037 public class GraphElement extends Composite implements MouseListener
00038
00039 {
00040 SashForm graphPane_;
00041 DroppableXYGraph graph_;
00042 LegendPanel legend_;
00043 TrendGraph tg_;
00044 GraphPanel gp_;
00045
00046 SelectionListener actionListener_;
00047
00048 private static final int GRAPH_LEFT_MARGIN = 50;
00049 private static final int GRAPH_RIGHT_MARGIN = 50;
00050 private static final int GRAPH_TOP_MARGIN = 20;
00051 private static final int GRAPH_BOTTOM_MARGIN = 30;
00052
00053 private static final Color normalColor_ = Activator.getDefault().getColor("black");
00054 private static final Font GRAPH_LEGEND_FONT = Activator.getDefault().getFont( "dialog12" );
00055
00056
00064 public GraphElement(
00065 GraphPanel gp,
00066 Composite parent,
00067 TrendGraph tg
00068 ) {
00069 super(parent, SWT.NONE);
00070
00071
00072 tg_ = tg;
00073 gp_ = gp;
00074
00075 GridData gridData0 = new GridData();
00076 gridData0.horizontalAlignment = GridData.FILL;
00077 gridData0.grabExcessHorizontalSpace = true;
00078 setLayoutData(gridData0);
00079
00080 GridLayout layout=new GridLayout(1,true);
00081 layout.marginHeight=0;
00082 setLayout(layout);
00083
00084
00085 graphPane_ = new SashForm( this, SWT.HORIZONTAL );
00086 GridData gridData = new GridData();
00087 gridData.horizontalAlignment = GridData.FILL;
00088 gridData.grabExcessHorizontalSpace = true;
00089 gridData.verticalAlignment = GridData.FILL;
00090 gridData.grabExcessVerticalSpace = true;
00091 graphPane_.setLayoutData(gridData);
00092
00093 graph_ = new DroppableXYGraph(
00094 graphPane_,
00095 GRAPH_LEFT_MARGIN,
00096 GRAPH_RIGHT_MARGIN,
00097 GRAPH_TOP_MARGIN,
00098 GRAPH_BOTTOM_MARGIN
00099 );
00100 legend_ = new LegendPanel(
00101 graphPane_,
00102 Activator.getDefault().getFont( "dialog10" ),
00103 Activator.getDefault().getColor("black"),
00104 Activator.getDefault().getColor("white")
00105 );
00106 graphPane_.setWeights(new int[] { 4,1});
00107 graphPane_.SASH_WIDTH = 6;
00108
00109 ((XYLineGraph)graph_).setBorderColor(normalColor_);
00110 legend_.setBackColor(normalColor_);
00111 legend_.setFont(GRAPH_LEGEND_FONT);
00112
00113 tg.setGraph((XYLineGraph) graph_, legend_);
00114
00115
00116
00117 graph_.addMouseListener(this);
00118 legend_.addMouseListener(this);
00119
00120
00121 }
00122
00123
00124
00130 public TrendGraph getTrendGraph() {
00131 return tg_;
00132 }
00133
00139 public DroppableXYGraph getGraph() {
00140 return graph_;
00141 }
00142
00148 public LegendPanel getLegend() {
00149 return legend_;
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 public void setBorderColor(Color color) {
00220 graph_.setBorderColor(color);
00221 legend_.setBackColor(color);
00222
00223 }
00224
00225 public void mouseDoubleClick(MouseEvent e) {
00226
00227
00228 }
00229
00230 public void mouseDown(MouseEvent e) {
00231
00232
00233 }
00234
00235 public void mouseUp(MouseEvent e) {
00236 gp_.setFocuse(this);
00237 }
00238 }