List of usage examples for org.jfree.chart JFreeChart setNotify
public void setNotify(boolean notify)
From source file:org.nbheaven.sqe.codedefects.dashboard.controlcenter.panels.Statistics.java
private static JFreeChart createOverviewPanel(DefaultCategoryDataset dataSet) { JFreeChart overview = org.jfree.chart.ChartFactory.createStackedBarChart(null, null, "CodeDefects", dataSet, PlotOrientation.HORIZONTAL, false, true, false); overview.setBorderVisible(false);// ww w . java 2 s . c om overview.setBackgroundPaint(Color.WHITE); overview.setAntiAlias(true); overview.setNotify(true); CategoryPlot overviewPlot = overview.getCategoryPlot(); overviewPlot.setRangeGridlinePaint(Color.BLACK); overviewPlot.setDomainGridlinePaint(Color.BLACK); overviewPlot.setBackgroundPaint(Color.WHITE); overviewPlot.setForegroundAlpha(0.7f); overviewPlot.setRangeAxisLocation(AxisLocation.getOpposite(overviewPlot.getRangeAxisLocation())); CategoryAxis domainAxis = overviewPlot.getDomainAxis(); domainAxis.setVisible(true); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setLabel(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); overviewPlot.setRangeAxis(rangeAxis); CategoryItemRenderer categoryItemRenderer = new StackedBarRenderer(); //3D(); // categoryItemRenderers[0].setPaint(Color.RED); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); categoryItemRenderer.setBaseItemLabelsVisible(true); overviewPlot.setRenderer(categoryItemRenderer); return overview; }
From source file:org.mwc.cmap.LiveDataMonitor.views.LiveDataMonitor.java
/** * This is a callback that will allow us to create the viewer and initialize * it./*from w w w . j a v a 2s . c o m*/ */ public void createPartControl(final Composite parent) { _chart = createChart(null); _chartFrame = new ChartComposite(parent, SWT.NONE, _chart, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; configureListeners(); }
From source file:org.mwc.cmap.xyplot.views.CrossSectionViewer.java
protected CrossSectionViewer(final Composite parent) { _chartFrame = new ChartComposite(parent, SWT.NONE, null, true) { @Override//from w w w. jav a2s . c o m public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; _chart = ChartFactory.createXYLineChart("Cross Section", // Title "Distance (km)", // X-Axis label "Elevation (m)", // Y-Axis label _dataset, // Dataset, PlotOrientation.VERTICAL, true, // Show legend, true, // tooltips true // urs ); // Fix the axises start at zero final ValueAxis yAxis = _chart.getXYPlot().getRangeAxis(); yAxis.setLowerBound(0); final ValueAxis xAxis = _chart.getXYPlot().getDomainAxis(); xAxis.setLowerBound(0); _chartFrame.setChart(_chart); _chartFrame.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { clearPlot(); _chartFrame.removeDisposeListener(this); } }); }
From source file:org.mwc.debrief.multipath2.MultiPathView.java
private void createPlot(final Composite ui) { // create a date-formatting axis final DateAxis dateAxis = new RelativeDateAxis(); dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); final NumberAxis valAxis = new NumberAxis("Delay (Secs)"); final DefaultXYItemRenderer theRenderer = new DefaultXYItemRenderer(); theRenderer.setBaseShapesVisible(false); _thePlot = new XYPlot(null, dateAxis, valAxis, theRenderer); final JFreeChart _plotArea = new JFreeChart(_thePlot); final ChartComposite _plotControl = new ChartComposite(ui, SWT.NONE, null, true) { @Override//from w w w . j a va2 s . co m public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; _plotControl.setChart(_plotArea); }
From source file:org.mwc.debrief.dis.views.DisListenerView.java
@Override public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); composite.setLayoutData(gd);//from w w w . jav a2 s. co m GridLayout layout = new GridLayout(1, false); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); Composite buttonComposite = new Composite(composite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.widthHint = 300; buttonComposite.setLayoutData(gd); layout = new GridLayout(4, false); layout.marginWidth = 5; layout.marginHeight = 5; buttonComposite.setLayout(layout); connectButton = createButton(buttonComposite, "Connect", 2); connectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME connect } }); disconnectButton = createButton(buttonComposite, "Disconnect", 2); disconnectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME disconnect } }); final Link link = new Link(buttonComposite, SWT.NONE); gd = new GridData(SWT.END, SWT.FILL, false, false); gd.horizontalSpan = 4; link.setLayoutData(gd); link.setText("<a href=\"id\">Server Prefs</a>"); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), DisPrefs.ID, null, null); dialog.open(); } }); link.setToolTipText("Dis Preferences"); stopButton = createButton(buttonComposite, "Stop"); stopButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME stop } }); pauseButton = createButton(buttonComposite, "Pause"); pauseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME pause } }); resumeButton = createButton(buttonComposite, "Resume"); resumeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME resume } }); playButton = createButton(buttonComposite, "Play"); playButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME play } }); stopButton.setEnabled(false); pauseButton.setEnabled(false); resumeButton.setEnabled(false); disconnectButton.setEnabled(false); Label label = new Label(buttonComposite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, false, false); label.setLayoutData(gd); label.setText("Path to input file:"); Text text = new Text(buttonComposite, SWT.SINGLE | SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.horizontalSpan = 2; gd.widthHint = 150; text.setLayoutData(gd); final Button browseButton = new Button(buttonComposite, SWT.PUSH); gd = new GridData(SWT.FILL, SWT.FILL, false, false); browseButton.setLayoutData(gd); browseButton.setText("Browse..."); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SINGLE); String value = pathText.getText(); if (value.trim().length() == 0) { value = Platform.getLocation().toOSString(); } dialog.setFilterPath(value); String result = dialog.open(); if (result == null || result.trim().length() == 0) { return; } pathText.setText(result); } }); Composite chartWrapperComposite = new Composite(composite, SWT.BORDER); gd = new GridData(SWT.FILL, SWT.FILL, true, true); chartWrapperComposite.setLayoutData(gd); layout = new GridLayout(1, false); chartWrapperComposite.setLayout(layout); chartComposite = new ChartComposite(chartWrapperComposite, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800, true, true, true, true, true, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; Composite checkboxComposite = new Composite(composite, SWT.NONE); gd = new GridData(SWT.FILL, SWT.FILL, true, false); checkboxComposite.setLayoutData(gd); layout = new GridLayout(2, false); layout.marginWidth = 5; layout.marginHeight = 5; checkboxComposite.setLayout(layout); newPlotButton = new Button(checkboxComposite, SWT.CHECK); gd = new GridData(SWT.FILL, SWT.FILL, true, false); newPlotButton.setLayoutData(gd); newPlotButton.setText("New plot per replication"); newPlotButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME new plot ... } }); liveUpdatesButton = new Button(checkboxComposite, SWT.CHECK); gd = new GridData(SWT.FILL, SWT.FILL, true, false); liveUpdatesButton.setLayoutData(gd); liveUpdatesButton.setText("Live updates"); liveUpdatesButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // FIXME Live updates. } }); liveUpdatesButton.setSelection(true); }
From source file:org.mwc.debrief.track_shift.views.BaseStackedDotsView.java
/** * This is a callback that will allow us to create the viewer and initialize * it./* w ww . ja v a2s . c o m*/ */ @Override public void createPartControl(final Composite parent) { _holder = new ChartComposite(parent, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800, true, true, true, true, true, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; // hey - now create the stacked plot! createStackedPlot(); // ///////////////////////////////////////// // ok - listen out for changes in the view // ///////////////////////////////////////// _selProviders = new Vector<ISelectionProvider>(); _mySelListener = new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final ISelection sel = event.getSelection(); final Vector<DraggableItem> dragees = new Vector<DraggableItem>(); if (sel instanceof StructuredSelection) { final StructuredSelection str = (StructuredSelection) sel; final Iterator<?> iter = str.iterator(); while (iter.hasNext()) { final Object object = (Object) iter.next(); if (object instanceof EditableWrapper) { final EditableWrapper ew = (EditableWrapper) object; final Editable item = ew.getEditable(); if (item instanceof DraggableItem) { dragees.add((DraggableItem) item); } } else { return; } } // ok, we've just got draggable items - override the current // item _draggableSelection = dragees; } } }; // sort out the part monitor _myPartMonitor = new PartMonitor(getSite().getWorkbenchWindow().getPartService()); // now start listening out for people's parts watchMyParts(); // put the actions in the UI contributeToActionBars(); }
From source file:org.mwc.debrief.sensorfusion.views.SensorFusionView.java
/** * This is a callback that will allow us to create the viewer and initialize * it./* w w w.j a v a2 s .c om*/ */ public void createPartControl(final Composite parent) { makeActions(); contributeToActionBars(); // and the selection provider bits _selectionHelper = new SelectionHelper(); getSite().setSelectionProvider(_selectionHelper); // declare our context sensitive help CorePlugin.declareContextHelp(parent, "org.mwc.debrief.help.BulkSensorData"); parent.setLayout(new FillLayout()); // ok, let's mockup the UI final JFreeChart myChart = DataSupport.createChart(null); myChart.setTitle(CHART_NAME); myChart.getXYPlot().setRenderer(_plotRenderer); // and the chart frame _myChartFrame = new ChartComposite(parent, SWT.NONE, myChart, 400, 600, 300, 200, 1800, 1800, true, true, true, true, true, true) { @Override protected Menu createPopupMenu(boolean arg0, boolean arg1, boolean arg2, boolean arg3) { // prevent the JFreeChart menu from opening return null; } @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; _myChartFrame.setDisplayToolTips(false); _myChartFrame.setHorizontalAxisTrace(false); _myChartFrame.setVerticalAxisTrace(false); _myChartFrame.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(final ChartMouseEvent event) { final ChartEntity entity = event.getEntity(); if (entity instanceof XYItemEntity) { final XYItemEntity xyi = (XYItemEntity) entity; final TimeSeriesCollection coll = (TimeSeriesCollection) xyi.getDataset(); final TacticalSeries ts = (TacticalSeries) coll .getSeries(((XYItemEntity) entity).getSeriesIndex()); if (ts instanceof SensorSeries) { final SensorSeries ss = (SensorSeries) ts; // check which mouse it si if (event.getTrigger().getButton() == 3) { // get the sensor itself final SensorWrapper sensor = ss.getSensor(); // get the parent layer final TrackWrapper parentLayer = (TrackWrapper) _trackData.getPrimaryTrack(); // ok, create ourselves a menu final MenuManager mmgr = new MenuManager(); // insert the relevant menu items RightClickSupport.getDropdownListFor(mmgr, new Editable[] { sensor }, null, new Layer[] { parentLayer }, _currentLayers, false); // get the SWT menu object for it final Menu thisM = mmgr.createContextMenu(_myChartFrame); // and display it thisM.setVisible(true); } else { // right, is ctrl-key pressed final int mods = event.getTrigger().getModifiers(); if ((mods & InputEvent.CTRL_MASK) == 0) { _selectedTracks.removeAllElements(); _selectedTracks.add(ss); } else { if (_selectedTracks.contains(ts)) _selectedTracks.remove(ts); else _selectedTracks.add(ss); } // and update the UI updatedSelection(); // ok, we need to redraw redrawPlot(); } } } else { _selectedTracks.removeAllElements(); // and update the UI updatedSelection(); // ok, we need to redraw redrawPlot(); } } public void chartMouseMoved(final ChartMouseEvent event) { } }); _selectionChangeListener = new ISelectionChangedListener() { @SuppressWarnings({ "rawtypes" }) public void selectionChanged(final SelectionChangedEvent event) { // right, see what it is final ISelection sel = event.getSelection(); if (sel instanceof StructuredSelection) { final StructuredSelection ss = (StructuredSelection) sel; final Iterator eles = ss.iterator(); boolean processingThese = false; while (eles.hasNext()) { final Object datum = eles.next(); if (datum instanceof EditableWrapper) { final EditableWrapper pw = (EditableWrapper) datum; final Editable ed = pw.getEditable(); if (ed instanceof SensorWrapper) { if (!processingThese) { processingThese = true; _selectedTracks.removeAllElements(); } final SensorSeries thisSeries = _trackIndex.get(ed); _selectedTracks.add(thisSeries); } } } if (processingThese) redrawPlot(); } } }; // and sort out the listeners setupListeners(); }
From source file:com.planetmayo.debrief.satc_rcp.views.SpatialView.java
@Override public void createPartControl(Composite parent) { _solversManager = SATC_Activator.getDefault().getService(ISolversManager.class, true); _settings = SATC_Activator.getDefault().getService(SpatialViewSettings.class, true); // get the data ready _myData = new XYSeriesCollection(); JFreeChart chart = createChart(_myData); _chartComposite = new ChartComposite(parent, SWT.NONE, chart, true) { @Override//from w w w . j a v a2s . c om public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; makeActions(); IActionBars bars = getViewSite().getActionBars(); bars.getToolBarManager().add(_saveSpeedPlot); bars.getToolBarManager().add(_saveCoursePlot); bars.getToolBarManager().add(new Separator()); bars.getToolBarManager().add(_showLegend); bars.getToolBarManager().add(_debugMode); bars.getToolBarManager().add(_resizeButton); bars.getMenuManager().add(new AbstractGroupMarker("num") { }); bars.getMenuManager().appendToGroup("num", new RouteNumSelector(10)); bars.getMenuManager().appendToGroup("num", new RouteNumSelector(50)); bars.getMenuManager().appendToGroup("num", new RouteNumSelector(100)); bars.getMenuManager().appendToGroup("num", new RouteNumSelector()); // add some handlers to sort out how many routes to shw initListener(parent.getDisplay()); _solversManager.addSolversManagerListener(solversManagerListener); _settings.addListener(spatialSettingsListener); setActiveSolver(_solversManager.getActiveSolver()); _targetSolution = new TestSupport().loadSolutionTrack(); }
From source file:org.mwc.cmap.xyplot.views.XYPlotView.java
/** * This is a callback that will allow us to create the viewer and initialize * it./* w w w . j a va 2s.c o m*/ */ public void createPartControl(final Composite parent) { _plotControl = new ChartComposite(parent, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800, true, true, true, true, true, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; // and lastly do the remaining bits... makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); // put in the plot-copy support final IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), _exportToClipboard); // and the selection provider bits _selectionHelper = new SelectionHelper(); getSite().setSelectionProvider(_selectionHelper); // hey, have we got our data? if (_myMemento != null) { // yup, better restore it then. restorePreviousPlot(); } _modifiedListener = new DataListener() { @Override public void dataModified(final Layers theData, final Layer changedLayer) { regenerateData(); } @Override public void dataExtended(final Layers theData) { regenerateData(); } @Override public void dataReformatted(final Layers theData, final Layer changedLayer) { try { regenerateData(); } catch (org.eclipse.swt.SWTException se) { CorePlugin.logError(Status.WARNING, "Trouble redrawing XT Plot", se); } } }; getSite().getWorkbenchWindow().getPartService().addPartListener(editorListener); }
From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java
/** * This is a callback that will allow us to create the viewer and initialize * it./*from ww w. ja v a2 s.c om*/ */ public Composite initLegGraph(final Composite parent) { legChart = ChartFactory.createTimeSeriesChart("Ownship & Target Legs", // String "Time", // String timeAxisLabel null, // String valueAxisLabel, null, // XYDataset dataset, true, // include legend true, // tooltips false); // urls legPlot = (XYPlot) legChart.getPlot(); legPlot.setDomainCrosshairVisible(true); legPlot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) legPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); legPlot.setBackgroundPaint(java.awt.Color.WHITE); legPlot.setRangeGridlinePaint(java.awt.Color.LIGHT_GRAY); legPlot.setDomainGridlinePaint(java.awt.Color.LIGHT_GRAY); // format the cross hairs, when they're clicked legPlot.setDomainCrosshairVisible(true); legPlot.setRangeCrosshairVisible(true); legPlot.setDomainCrosshairPaint(java.awt.Color.GRAY); legPlot.setRangeCrosshairPaint(java.awt.Color.GRAY); legPlot.setDomainCrosshairStroke(new BasicStroke(1)); legPlot.setRangeCrosshairStroke(new BasicStroke(1)); // and the plot object to display the cross hair value final XYTextAnnotation annot = new XYTextAnnotation("-----", 0, 0); annot.setTextAnchor(TextAnchor.TOP_LEFT); annot.setPaint(java.awt.Color.black); annot.setBackgroundPaint(java.awt.Color.white); legPlot.addAnnotation(annot); legChart.addProgressListener(new ChartProgressListener() { public void chartProgress(final ChartProgressEvent cpe) { if (cpe.getType() != ChartProgressEvent.DRAWING_FINISHED) return; // double-check our label is still in the right place final double xVal = legPlot.getRangeAxis().getUpperBound(); final double yVal = legPlot.getDomainAxis().getLowerBound(); boolean annotChanged = false; if (annot.getX() != yVal) { annot.setX(yVal); annotChanged = true; } if (annot.getY() != xVal) { annot.setY(xVal); annotChanged = true; } // and write the text final NumberFormat _oneDPFormat = new DecimalFormat("0.0", new java.text.DecimalFormatSymbols(java.util.Locale.UK)); final String numA = _oneDPFormat.format(legPlot.getRangeCrosshairValue()); final Date newDate = new Date((long) legPlot.getDomainCrosshairValue()); final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss"); _df.setTimeZone(TimeZone.getTimeZone("GMT")); final String dateVal = _df.format(newDate); final String theMessage = " [" + dateVal + "," + numA + "]"; if (!theMessage.equals(annot.getText())) { annot.setText(theMessage); annotChanged = true; } // aah, now we have to add and then remove the annotation in order // for the new text value to be displayed. Watch and learn... if (annotChanged) { legPlot.removeAnnotation(annot); legPlot.addAnnotation(annot); } } }); ChartComposite chartFrame = new ChartComposite(parent, SWT.NONE, legChart, true) { @Override public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; chartFrame.setDisplayToolTips(true); chartFrame.setHorizontalAxisTrace(false); chartFrame.setVerticalAxisTrace(false); return chartFrame; }