List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setPlot
public void setPlot(XYPlot plot);
From source file:org.mwc.asset.netasset2.sensor2.VSensor.java
/** * Create the composite.//from w ww .j a va2 s.co m * * @param parent * @param style */ public VSensor(final Composite parent, final int style) { super(parent, style); setLayout(new BorderLayout(0, 0)); final ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT); toolBar.setLayoutData(BorderLayout.NORTH); // ToolItem testBtn = new ToolItem(toolBar, SWT.NONE); // testBtn.setText("Test 1"); // testBtn.addSelectionListener(new SelectionAdapter() // { // // @Override // public void widgetSelected(SelectionEvent e) // { // doTest(); // } // }); final ToolItem tltmDropdownItem = new ToolItem(toolBar, SWT.DROP_DOWN); tltmDropdownItem.setText("Visible period"); final DropdownSelectionListener drops = new DropdownSelectionListener(tltmDropdownItem); drops.add("5 Mins", 5 * 60); drops.add("15 Mins", 15 * 60); drops.add("60 Mins", 60 * 60); drops.add("All data", 0); tltmDropdownItem.addSelectionListener(drops); final Composite sashForm = new Composite(this, SWT.EMBEDDED); // now we need a Swing object to put our chart into final Frame _plotControl = SWT_AWT.new_Frame(sashForm); // the y axis is common to hi & lo res. Format it here final NumberAxis yAxis = new NumberAxis("Degs"); // yAxis.setRange(0, 360); yAxis.setAutoRange(true); yAxis.setTickUnit(new NumberTickUnit(45)); // create a date-formatting axis _dateAxis = new RelativeDateAxis(); _dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); _dateAxis.setAutoRange(true); final XYItemRenderer theRenderer = new XYShapeRenderer(); _thePlot = new XYPlot(null, _dateAxis, yAxis, theRenderer); _thePlot.setOrientation(PlotOrientation.HORIZONTAL); _thePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); _thePlot.setBackgroundPaint(Color.BLACK); theRenderer.setPlot(_thePlot); _dateAxis.setLabelPaint(Color.GREEN); _dateAxis.setTickLabelPaint(Color.GREEN); _dateAxis.setAxisLinePaint(Color.GREEN); yAxis.setLabelPaint(Color.GREEN); yAxis.setTickLabelPaint(Color.GREEN); _thePlotArea = new JFreeChart(null, _thePlot); _thePlotArea.setBackgroundPaint(Color.BLACK); _thePlotArea.setBorderPaint(Color.BLACK); // set the color of the area surrounding the plot // - naah, don't bother. leave it in the application background color. // //////////////////////////////////////////////// // put the holder into one of our special items // //////////////////////////////////////////////// _chartInPanel = new ChartPanel(_thePlotArea, true); _plotControl.add(_chartInPanel); }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * Sets a renderer and sends a {@link PlotChangeEvent} is sent to all * registered listeners./*from w ww. ja va 2 s . co m*/ * * @param index the index. * @param renderer the renderer. */ public void setRenderer(int index, XYItemRenderer renderer) { XYItemRenderer existing = getRenderer(index); if (existing != null) { existing.removeChangeListener(this); } this.renderers.set(index, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } configureDomainAxes(); configureRangeAxes(); notifyListeners(new PlotChangeEvent(this)); }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * Creates a new plot./*from w w w .j a va2 s . co m*/ * * @param dataset the dataset (<code>null</code> permitted). * @param domainAxis the domain axis (<code>null</code> permitted). * @param rangeAxis the range axis (<code>null</code> permitted). * @param renderer the renderer (<code>null</code> permitted). */ public MyXYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.weight = 1; // only relevant when this is a subplot this.axisOffset = RectangleInsets.ZERO_INSETS; // allocate storage for datasets, axes and renderers (all optional) this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.datasets = new ObjectList(); this.renderers = new ObjectList(); this.datasetToDomainAxisMap = new TreeMap(); this.datasetToRangeAxisMap = new TreeMap(); this.datasets.set(0, dataset); if (dataset != null) { dataset.addChangeListener(this); } this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); domainAxis.addChangeListener(this); } this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); rangeAxis.addChangeListener(this); } this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); configureDomainAxes(); configureRangeAxes(); this.domainGridlinesVisible = true; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeGridlinesVisible = true; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = Color.black; this.rangeZeroBaselineStroke = new BasicStroke(0.5f); this.domainCrosshairVisible = false; this.domainCrosshairValue = 0.0; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = false; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.annotations = new java.util.ArrayList(); }