private void createYesterdayProvider() { // create the trace yesterdayDataProvider = new CircularBufferDataProvider(true); yesterdayDataProvider.setBufferSize(288); yesterdayDataProvider.setCurrentXDataArray(new double[] {}); yesterdayDataProvider.setCurrentYDataArray(new double[] {}); Trace yesterdayTrace = new Trace( "yesterday_total", xyGraph.primaryXAxis, xyGraph.primaryYAxis, yesterdayDataProvider); // set trace property yesterdayTrace.setPointStyle(PointStyle.NONE); yesterdayTrace.getXAxis().setFormatPattern("HH:mm:ss"); yesterdayTrace.getYAxis().setFormatPattern("#,##0"); yesterdayTrace.setLineWidth( PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); yesterdayTrace.setAreaAlpha(90); yesterdayTrace.setTraceType(TraceType.AREA); yesterdayTrace.setTraceColor(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY)); // add the trace to xyGraph xyGraph.addTrace(yesterdayTrace); // ChartUtil.addSolidLine(xyGraph, yesterdayDataProvider, // Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY)); }
public static void main(String[] args) { final Shell shell = new Shell(); shell.setSize(600, 400); shell.open(); // use LightweightSystem to create the bridge between SWT and draw2D final LightweightSystem lws = new LightweightSystem(shell); // create a new XY Graph. XYGraph xyGraph = new XYGraph(); ToolbarArmedXYGraph toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); xyGraph.setTitle("Simple Toolbar Armed XYGraph Example"); // set it as the content of LightwightSystem lws.setContents(toolbarArmedXYGraph); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setShowMajorGrid(true); // create a trace data provider, which will provide the data to the trace. CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(false); traceDataProvider.setBufferSize(100); traceDataProvider.setCurrentXDataArray(new double[] {10, 23, 34, 45, 56, 78, 88, 99}); traceDataProvider.setCurrentYDataArray(new double[] {11, 44, 55, 45, 88, 98, 52, 23}); // create the trace Trace trace = new Trace("Trace1-XY Plot", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.XCROSS); // add the trace to xyGraph xyGraph.addTrace(trace); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
private void createDataProvider() { traceDataProvider = new CircularBufferDataProvider(true); traceDataProvider.setBufferSize(288); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); // create the trace trace = new Trace("TOTAL", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); trace.getXAxis().setFormatPattern("HH:mm:ss"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); trace.setTraceType(TraceType.AREA); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); // add the trace to xyGraph xyGraph.addTrace(trace); ChartUtil.addSolidLine(xyGraph, traceDataProvider, ColorUtil.getInstance().TOTAL_CHART_COLOR); }
public void createPartControl(Composite parent) { String displayCounter = defaultServer.getCounterEngine().getCounterDisplayName(objType, counter); String objectDisplay = defaultServer.getCounterEngine().getDisplayNameObjectType(objType); setPartName(grpName + " - " + displayCounter); mode = CounterUtil.getTotalMode(objType, counter); desc = grpName + " | (Today) [" + objectDisplay + "] " + displayCounter; GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; parent.setLayout(layout); parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); parent.setBackgroundMode(SWT.INHERIT_FORCE); canvas = new FigureCanvas(parent); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); canvas.addControlListener( new ControlListener() { boolean lock = false; public void controlResized(ControlEvent e) { org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea(); if (!lock) { lock = true; if (ChartUtil.isShowDescriptionAllowSize(r.height)) { CounterTodayGroupCountView.this.setContentDescription(desc); } else { CounterTodayGroupCountView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } if (xyGraph == null) return; xyGraph.setSize(r.width, r.height); lineWidth = r.width / 30; trace.setLineWidth(lineWidth); xAxisUnitWidth = xyGraph.primaryXAxis.getValuePosition(1, false) - xyGraph.primaryXAxis.getValuePosition(0, false); } public void controlMoved(ControlEvent e) {} }); canvas.addMouseListener( new MouseListener() { public void mouseUp(MouseEvent e) { writedValueMode = false; canvas.redraw(); } public void mouseDown(MouseEvent e) { writeValue(e.x); } public void mouseDoubleClick(MouseEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(false); xyGraph.primaryXAxis.setShowMajorGrid(false); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); traceDataProvider = new CircularBufferDataProvider(true); traceDataProvider.setBufferSize(24); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); this.xyGraph.primaryXAxis.setRange(0, 24); // create the trace trace = new Trace("TotalCount", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); // trace.getXAxis().setFormatPattern("HH"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(15); trace.setTraceType(TraceType.BAR); trace.setAreaAlpha(200); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); // add the trace to xyGraph xyGraph.addTrace(trace); thread = new RefreshThread(this, 5000); thread.start(); thread.setName( this.toString() + " - " + "objType:" + objType + ", counter:" + counter + ", grpName:" + grpName); }
public void createPartControl(Composite parent) { window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); Composite composite = new Composite(parent, SWT.NONE); GridLayout gLayout = new GridLayout(1, true); gLayout.horizontalSpacing = 0; gLayout.marginHeight = 0; gLayout.marginWidth = 0; composite.setLayout(gLayout); createUpperMenu(composite); Composite chartComposite = new Composite(composite, SWT.NONE); chartComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); chartComposite.setLayout(UIUtil.formLayout(0, 0)); this.marginTargetComposite = chartComposite; chartComposite.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); canvas = new FigureCanvas(chartComposite); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); canvas.setLayoutData(UIUtil.formData(0, leftMargin, 0, 0, 100, 0, 100, 0)); canvas.addControlListener( new ControlListener() { boolean lock = false; public void controlResized(ControlEvent e) { org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea(); if (!lock) { lock = true; if (ChartUtil.isShowDescriptionAllowSize(r.height)) { CounterPastLongDateTotalView.this.setContentDescription(desc); } else { CounterPastLongDateTotalView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } xyGraph.setSize(r.width, r.height); } public void controlMoved(ControlEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(true); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); traceDataProvider = new CircularBufferDataProvider(true); // traceDataProvider.setBufferSize(buffer); traceDataProvider.setCurrentXDataArray(new double[] {}); traceDataProvider.setCurrentYDataArray(new double[] {}); // create the trace trace = new Trace("TOTAL", xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider); // set trace property trace.setPointStyle(PointStyle.NONE); trace.getXAxis().setFormatPattern("yyyy-MM-dd\n HH:mm:ss"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); trace.setTraceType(TraceType.AREA); trace.setTraceColor(ColorUtil.getInstance().TOTAL_CHART_COLOR); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); // add the trace to xyGraph xyGraph.addTrace(trace); ChartUtil.addSolidLine(xyGraph, traceDataProvider, ColorUtil.getInstance().TOTAL_CHART_COLOR); ScouterUtil.addShowTotalValueListener(canvas, xyGraph); man = getViewSite().getActionBars().getToolBarManager(); canvas.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F5) { ExUtil.asyncRun( new Runnable() { public void run() { try { setInput(sDate, eDate, objType, counter, serverId); } catch (Exception e) { e.printStackTrace(); } } }); } } }); man.add( new Action("Reload", ImageUtil.getImageDescriptor(Images.refresh)) { public void run() { ExUtil.exec( new Runnable() { public void run() { try { setInput(sDate, eDate, objType, counter, serverId); } catch (Exception e) { e.printStackTrace(); } } }); } }); man.add(new Separator()); man.add( new Action("Duplicate", ImageUtil.getImageDescriptor(Images.copy)) { public void run() { ExUtil.exec( new Runnable() { public void run() { duplicateView(); } }); } }); restoreState(); }
public void createPartControl(Composite parent) { window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; parent.setLayout(layout); parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); parent.setBackgroundMode(SWT.INHERIT_FORCE); canvas = new FigureCanvas(parent); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.addControlListener( new ControlListener() { boolean lock = false; public void controlResized(ControlEvent e) { org.eclipse.swt.graphics.Rectangle r = canvas.getClientArea(); if (!lock) { lock = true; if (ChartUtil.isShowDescriptionAllowSize(r.height)) { CounterLoadTimeView.this.setContentDescription(desc); } else { CounterLoadTimeView.this.setContentDescription(""); } r = canvas.getClientArea(); lock = false; } xyGraph.setSize(r.width, r.height); } public void controlMoved(ControlEvent e) {} }); xyGraph = new XYGraph(); xyGraph.setShowLegend(false); xyGraph.setShowTitle(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(true); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); provider = new CircularBufferDataProvider(true); provider.setBufferSize(7200); // for 4-hour provider.setCurrentXDataArray(new double[] {}); provider.setCurrentYDataArray(new double[] {}); // create the trace trace = new Trace("TOTAL", xyGraph.primaryXAxis, xyGraph.primaryYAxis, provider); // set trace property trace.setPointStyle(PointStyle.NONE); trace.getXAxis().setFormatPattern("HH:mm"); trace.getYAxis().setFormatPattern("#,##0"); trace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); trace.setTraceType(TraceType.SOLID_LINE); trace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_CYAN)); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); xyGraph.addTrace(trace); restoreState(); }
public void createPartControl(Composite parent) { Server server = ServerManager.getInstance().getServer(serverId); this.setPartName("DB Activity[" + server.getName() + "]"); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; parent.setLayout(layout); parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE)); parent.setBackgroundMode(SWT.INHERIT_FORCE); canvas = new FigureCanvas(parent); canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); canvas.setScrollBarVisibility(FigureCanvas.NEVER); canvas.addControlListener( new ControlListener() { public void controlMoved(ControlEvent arg0) {} public void controlResized(ControlEvent arg0) { Rectangle r = canvas.getClientArea(); xyGraph.setSize(r.width, r.height); } }); xyGraph = new XYGraph(); xyGraph.setShowLegend(true); xyGraph.setShowTitle(false); canvas.setContents(xyGraph); xyGraph.primaryXAxis.setDateEnabled(true); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setFormatPattern("HH:mm:ss"); xyGraph.primaryYAxis.setFormatPattern("#,##0"); xyGraph.primaryXAxis.setTitle(""); xyGraph.primaryYAxis.setTitle(""); CircularBufferDataProvider callProvider = new CircularBufferDataProvider(true); callProvider.setBufferSize(BUFFER_SIZE); callProvider.setCurrentXDataArray(new double[] {}); callProvider.setCurrentYDataArray(new double[] {}); callTrace = new Trace("Call (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, callProvider); callTrace.setPointStyle(PointStyle.NONE); callTrace.setTraceType(TraceType.AREA); callTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); callTrace.setAreaAlpha(255); callTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_BLUE)); xyGraph.addTrace(callTrace); CircularBufferDataProvider selectProvider = new CircularBufferDataProvider(true); selectProvider.setBufferSize(BUFFER_SIZE); selectProvider.setCurrentXDataArray(new double[] {}); selectProvider.setCurrentYDataArray(new double[] {}); selectTrace = new Trace("Select (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, selectProvider); selectTrace.setPointStyle(PointStyle.NONE); selectTrace.setTraceType(TraceType.AREA); selectTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); selectTrace.setAreaAlpha(255); selectTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_CYAN)); xyGraph.addTrace(selectTrace); CircularBufferDataProvider insertProvider = new CircularBufferDataProvider(true); insertProvider.setBufferSize(BUFFER_SIZE); insertProvider.setCurrentXDataArray(new double[] {}); insertProvider.setCurrentYDataArray(new double[] {}); insertTrace = new Trace("Insert (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, insertProvider); insertTrace.setPointStyle(PointStyle.NONE); insertTrace.setTraceType(TraceType.AREA); insertTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); insertTrace.setAreaAlpha(255); insertTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GRAY)); xyGraph.addTrace(insertTrace); CircularBufferDataProvider updateProvider = new CircularBufferDataProvider(true); updateProvider.setBufferSize(BUFFER_SIZE); updateProvider.setCurrentXDataArray(new double[] {}); updateProvider.setCurrentYDataArray(new double[] {}); updateTrace = new Trace("Update (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, updateProvider); updateTrace.setPointStyle(PointStyle.NONE); updateTrace.setTraceType(TraceType.AREA); updateTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); updateTrace.setAreaAlpha(255); updateTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GREEN)); xyGraph.addTrace(updateTrace); CircularBufferDataProvider deleteProvider = new CircularBufferDataProvider(true); deleteProvider.setBufferSize(BUFFER_SIZE); deleteProvider.setCurrentXDataArray(new double[] {}); deleteProvider.setCurrentYDataArray(new double[] {}); deleteTrace = new Trace("Delete (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, deleteProvider); deleteTrace.setPointStyle(PointStyle.NONE); deleteTrace.setTraceType(TraceType.AREA); deleteTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH)); deleteTrace.setAreaAlpha(255); deleteTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_MAGENTA)); xyGraph.addTrace(deleteTrace); ScouterUtil.addHorizontalRangeListener( xyGraph.getPlotArea(), new OpenDigestTableAction(serverId), true); IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); Action fixRangeAct = new Action("Pin Range", IAction.AS_CHECK_BOX) { public void run() { fixRange = isChecked(); } }; fixRangeAct.setImageDescriptor(ImageUtil.getImageDescriptor(Images.pin)); man.add(fixRangeAct); thread = new RefreshThread(this, REFRESH_INTERVAL); thread.start(); }
public XYGraphTest() { xyGraph = new XYGraph(); xyGraph.setTitle("XY Graph Test"); xyGraph.setFont(XYGraphMediaFactory.getInstance().getFont(XYGraphMediaFactory.FONT_TAHOMA)); xyGraph.primaryXAxis.setTitle("Time"); xyGraph.primaryYAxis.setTitle("Amplitude"); xyGraph.primaryXAxis.setRange(new Range(0, 200)); xyGraph.primaryXAxis.setDateEnabled(true); xyGraph.primaryYAxis.setAutoScale(true); xyGraph.primaryXAxis.setAutoScale(true); xyGraph.primaryXAxis.setShowMajorGrid(true); xyGraph.primaryYAxis.setShowMajorGrid(true); xyGraph.primaryXAxis.setAutoScaleThreshold(0); final Axis x2Axis = new Axis("X-2", false); x2Axis.setTickLableSide(LabelSide.Secondary); // x2Axis.setAutoScale(true); xyGraph.addAxis(x2Axis); final Axis y2Axis = new Axis("Log Scale", true); y2Axis.setRange(10, 500); y2Axis.setLogScale(true); // y2Axis.setAutoScale(true); y2Axis.setForegroundColor( XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_PINK)); y2Axis.setTickLableSide(LabelSide.Secondary); xyGraph.addAxis(y2Axis); Axis y3Axis = new Axis("Y-3", true); y3Axis.setForegroundColor( XYGraphMediaFactory.getInstance().getColor(XYGraphMediaFactory.COLOR_BLUE)); y3Axis.setTickLableSide(LabelSide.Secondary); y3Axis.setRange(new Range(-2, 3)); y3Axis.setShowMajorGrid(false); y3Axis.setAutoScale(true); // xyGraph.addAxis(y3Axis); trace2Provider = new CircularBufferDataProvider(true); trace2Provider.setBufferSize(100); trace2Provider.setUpdateDelay(100); trace2 = new Trace("Trace 2", xyGraph.primaryXAxis, xyGraph.primaryYAxis, trace2Provider); trace2.setDataProvider(trace2Provider); trace2.setTraceType(TraceType.SOLID_LINE); trace2.setLineWidth(1); trace2.setPointStyle(PointStyle.POINT); trace2.setPointSize(4); trace2.setBaseLine(BaseLine.NEGATIVE_INFINITY); trace2.setAreaAlpha(100); trace2.setAntiAliasing(true); trace2.setErrorBarEnabled(false); // trace2.setDrawYErrorInArea(true); trace2.setYErrorBarType(ErrorBarType.BOTH); trace2.setXErrorBarType(ErrorBarType.NONE); trace2.setErrorBarCapWidth(3); final CircularBufferDataProvider trace3Provider = new CircularBufferDataProvider(true); trace3 = new Trace("Trace3", xyGraph.primaryXAxis, xyGraph.primaryYAxis, trace3Provider); trace3.setPointStyle(PointStyle.XCROSS); trace3.setTraceType(TraceType.BAR); trace3.setLineWidth(4); trace3Provider.setUpdateDelay(100); xyGraph.addTrace(trace3); xyGraph.addTrace(trace2); final CircularBufferDataProvider trace4Provider = new CircularBufferDataProvider(false); trace4 = new Trace("Trace 4-Lissajous", x2Axis, y2Axis, trace4Provider); // trace4.setPointStyle(PointStyle.POINT); trace4.setPointSize(2); trace4Provider.setUpdateDelay(100); trace4Provider.setBufferSize(100); xyGraph.addTrace(trace4); toolbarArmedXYGraph = new ToolbarArmedXYGraph(xyGraph); add(toolbarArmedXYGraph); // add key listener to XY-Graph. The key pressing will only be monitored when the // graph gains focus. xyGraph.setFocusTraversable(true); xyGraph.setRequestFocusEnabled(true); xyGraph .getPlotArea() .addMouseListener( new MouseListener.Stub() { @Override public void mousePressed(final MouseEvent me) { xyGraph.requestFocus(); } }); xyGraph.addKeyListener( new KeyListener.Stub() { @Override public void keyPressed(final KeyEvent ke) { if ((ke.getState() == SWT.CONTROL) && (ke.keycode == 'z')) { xyGraph.getOperationsManager().undo(); } if ((ke.getState() == SWT.CONTROL) && (ke.keycode == 'y')) { xyGraph.getOperationsManager().redo(); } if ((ke.getState() == SWT.CONTROL) && (ke.keycode == 'x')) { xyGraph.performAutoScale(); } if ((ke.getState() == SWT.CONTROL) && (ke.keycode == 's')) { final ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] {xyGraph.getImage().getImageData()}; final FileDialog dialog = new FileDialog(Display.getDefault().getShells()[0], SWT.SAVE); dialog.setFilterNames(new String[] {"PNG Files", "All Files (*.*)"}); dialog.setFilterExtensions(new String[] {"*.png", "*.*"}); // Windows final String path = dialog.open(); if ((path != null) && !path.equals("")) { loader.save(path, SWT.IMAGE_PNG); } } if ((ke.getState() == SWT.CONTROL) && (ke.keycode + 'a' - 97 == 't')) { switch (xyGraph.getZoomType()) { case RUBBERBAND_ZOOM: xyGraph.setZoomType(ZoomType.HORIZONTAL_ZOOM); break; case HORIZONTAL_ZOOM: xyGraph.setZoomType(ZoomType.VERTICAL_ZOOM); break; case VERTICAL_ZOOM: xyGraph.setZoomType(ZoomType.ZOOM_IN); break; case ZOOM_IN: xyGraph.setZoomType(ZoomType.ZOOM_OUT); break; case ZOOM_OUT: xyGraph.setZoomType(ZoomType.PANNING); break; case PANNING: xyGraph.setZoomType(ZoomType.NONE); break; case NONE: xyGraph.setZoomType(ZoomType.RUBBERBAND_ZOOM); break; default: break; } } } }); updater = new Runnable() { public void run() { t += 60000; trace3Provider.setCurrentYData(Math.cos(updateIndex), t); if (((updateIndex >= 10) && (updateIndex <= 10.5)) || ((updateIndex >= 20) && (updateIndex <= 20.2))) { trace2Provider.addSample(new Sample(t, Double.NaN)); running = false; } else { final Sample sampe = new Sample( t, Math.sin(updateIndex), 0.1 * Math.random(), 0.1 * Math.random(), t * 0.0000001 * Math.random(), t * 0.0000001 * Math.random(), "sdfsf"); trace2Provider.addSample(sampe); } trace2Provider.setCurrentYDataTimestamp(t); trace4Provider.setCurrentXData(Math.sin(updateIndex + 10) * 20 + 50); trace4Provider.setCurrentYData(Math.cos(updateIndex) * 30 + 50); updateIndex += 0.1; if (running) { Display.getCurrent().timerExec(100, this); } } }; Display.getCurrent().timerExec(100, updater); running = true; t = Calendar.getInstance().getTimeInMillis(); }
protected void changeMode() { CircularBufferDataProvider delProvider = (CircularBufferDataProvider) deleteTrace.getDataProvider(); CircularBufferDataProvider upProvider = (CircularBufferDataProvider) updateTrace.getDataProvider(); CircularBufferDataProvider inProvider = (CircularBufferDataProvider) insertTrace.getDataProvider(); CircularBufferDataProvider selProvider = (CircularBufferDataProvider) selectTrace.getDataProvider(); CircularBufferDataProvider callProvider = (CircularBufferDataProvider) callTrace.getDataProvider(); delProvider.clearTrace(); upProvider.clearTrace(); inProvider.clearTrace(); selProvider.clearTrace(); callProvider.clearTrace(); int size = valueLogs.size(); if (size > 0) { ENTRY<ValueLog> entry = valueLogs.getFirst(); if (isStackView) { do { ValueLog log = entry.item; double x = log.time; double delValue = log.delete; double upValue = delValue + log.update; double inValue = upValue + log.insert; double selValue = inValue + log.select; double callValue = selValue + log.call; callProvider.addSample(new Sample(x, callValue)); selProvider.addSample(new Sample(x, selValue)); inProvider.addSample(new Sample(x, inValue)); upProvider.addSample(new Sample(x, upValue)); delProvider.addSample(new Sample(x, delValue)); } while ((entry = entry.next) != null); } else { do { ValueLog log = entry.item; double x = log.time; double delValue = log.delete; double upValue = log.update; double inValue = log.insert; double selValue = log.select; double callValue = log.call; callProvider.addSample(new Sample(x, callValue)); selProvider.addSample(new Sample(x, selValue)); inProvider.addSample(new Sample(x, inValue)); upProvider.addSample(new Sample(x, upValue)); delProvider.addSample(new Sample(x, delValue)); } while ((entry = entry.next) != null); } } if (isStackView) { deleteTrace.setTraceType(TraceType.AREA); updateTrace.setTraceType(TraceType.AREA); insertTrace.setTraceType(TraceType.AREA); selectTrace.setTraceType(TraceType.AREA); callTrace.setTraceType(TraceType.AREA); } else { deleteTrace.setTraceType(TraceType.SOLID_LINE); updateTrace.setTraceType(TraceType.SOLID_LINE); insertTrace.setTraceType(TraceType.SOLID_LINE); selectTrace.setTraceType(TraceType.SOLID_LINE); callTrace.setTraceType(TraceType.SOLID_LINE); } }