Java Code Examples for org.jfree.data.xy.XYSeriesCollection#getSeries()
The following examples show how to use
org.jfree.data.xy.XYSeriesCollection#getSeries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionPanel.java From opensim-gui with Apache License 2.0 | 6 votes |
public void updateSelectedNodesAfterAddition(int series, int node) { XYSeriesCollection seriesCollection = (XYSeriesCollection)getChart().getXYPlot().getDataset(); XYSeries dSeries = seriesCollection.getSeries(series); // Unhighlight all nodes in the series that are after the added one. for (int i=node; i<dSeries.getItemCount(); i++) { renderer.unhighlightNode(series, i); } // For all nodes in the series after the added one, increment the node number. for (int i=0; i<selectedNodes.size(); i++) { if (selectedNodes.get(i).series == series && selectedNodes.get(i).node >= node) { selectedNodes.get(i).node++; } } // For each selected node in the series after the added one, highlight it. for (int i=0; i<selectedNodes.size(); i++) { if (selectedNodes.get(i).series == series && selectedNodes.get(i).node > node) { renderer.highlightNode(series, selectedNodes.get(i).node); } } }
Example 2
Source File: ExcitationPanelListener.java From opensim-gui with Apache License 2.0 | 5 votes |
public void duplicateNode(int series, int node) { if (control != null && node >= 0 && node < getControlNodeCountForSeries(series)) { // Make a new point that is offset slightly in the X direction from // the point to be duplicated. ControlLinearNode controlNode=getControlNodeForSeries(series, node); double newX = controlNode.getTime() + 0.00001; double newY = controlNode.getValue(); // function, control, series functions.get(series).addPoint(newX, newY); ControlLinearNode newControlNode = new ControlLinearNode(); // Early garbage collection suspect! newControlNode.setTime(newX); newControlNode.setValue(newY); //getSelectedControlNodes(series).insert(node+1, newControlNode); if (series==0) control.insertNewValueNode(node+1, newControlNode); else if (series==1) control.insertNewMinNode(node+1, newControlNode); else control.insertNewMaxNode(node+1, newControlNode); XYSeriesCollection seriesCollection = (XYSeriesCollection) functionPanel.getChart().getXYPlot().getDataset(); XYSeries dSeries=seriesCollection.getSeries(series); dSeries.add(newX, newY); ((ExcitationPanel)functionPanel).setChanged(true); } }
Example 3
Source File: FunctionPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
protected int addNode(int series, int screenX, int screenY) { XYPlot xyPlot = getChart().getXYPlot(); RectangleEdge xAxisLocation = xyPlot.getDomainAxisEdge(); RectangleEdge yAxisLocation = xyPlot.getRangeAxisEdge(); Rectangle2D dataArea = getScreenDataArea(); double newNodeX = xyPlot.getDomainAxis().java2DToValue(screenX, dataArea, xAxisLocation); double newNodeY = xyPlot.getRangeAxis().java2DToValue(screenY, dataArea, yAxisLocation); // Notify all listeners about the change. Object[] listeners = this.functionPanelListeners.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == FunctionPanelListener.class) { ((FunctionPanelListener) listeners[i + 1]).addNode(series, newNodeX, newNodeY); } } // Now add the point to the series, first figuring out what its index will be. XYSeriesCollection seriesCollection = (XYSeriesCollection)xyPlot.getDataset(); XYSeries dSeries = seriesCollection.getSeries(series); int index = dSeries.getItemCount(); for (int i=0; i<dSeries.getItemCount(); i++) { if (dSeries.getDataItem(i).getX().doubleValue() > newNodeX) { index = i; break; } } dSeries.add(newNodeX, newNodeY); updateSelectedNodesAfterAddition(series, index); return index; }
Example 4
Source File: FunctionPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
public void updateSelectedNodesAfterDeletion(int series, int node) { XYSeriesCollection seriesCollection = (XYSeriesCollection)getChart().getXYPlot().getDataset(); XYSeries dSeries = seriesCollection.getSeries(series); // Unhighlight all nodes in the series that are after the deleted one. for (int i=node; i<dSeries.getItemCount(); i++) { renderer.unhighlightNode(series, i); } // If the deleted node was selected, remove it from selectedNodes. // For all nodes in the series after the deleted one, decrement the node number. for (int i=selectedNodes.size()-1; i>=0; i--) { if (selectedNodes.get(i).series == series && selectedNodes.get(i).node >= node) { if (selectedNodes.get(i).node == node) { selectedNodes.remove(i); } else { selectedNodes.get(i).node--; } } } // For each selected node in the series after the deleted one, highlight it. for (int i=0; i<selectedNodes.size(); i++) { if (selectedNodes.get(i).series == series && selectedNodes.get(i).node >= node) { renderer.highlightNode(series, selectedNodes.get(i).node); } } }
Example 5
Source File: XYChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected TableXYDataset convertToTable( final XYSeriesCollection xyDataset ) { final ExtCategoryTableXYDataset tableXYDataset = new ExtCategoryTableXYDataset(); final int count = xyDataset.getSeriesCount(); for ( int i = 0; i < count; i++ ) { final XYSeries timeSeries = xyDataset.getSeries( i ); final Comparable key = timeSeries.getKey(); final int itemCount = timeSeries.getItemCount(); for ( int ic = 0; ic < itemCount; ic++ ) { final XYDataItem seriesDataItem = timeSeries.getDataItem( ic ); tableXYDataset.add( seriesDataItem.getX(), seriesDataItem.getY(), key, false ); } } return tableXYDataset; }
Example 6
Source File: NumberLineChart.java From EdgeSim with MIT License | 4 votes |
public XYSeriesCollection getCollection() { XYSeriesCollection collection = new XYSeriesCollection(); HashMap<String,LinkedList<cn.edu.tju.simulation.handler.RequestHandler.mydata>> ndMap = RequestHandler.ndMap; Iterator<String> it = ndMap.keySet().iterator(); while(it.hasNext()){ String key = it.next(); XYSeries series = new XYSeries(key); // series.add(0,0); LinkedList<cn.edu.tju.simulation.handler.RequestHandler.mydata> mdList = ndMap.get(key); for(int i=0 ; i<mdList.size();i++){ if(i % 30 ==0 && i !=0){ series.add(i+1,mdList.get(i).hitrate); } } collection.addSeries(series); } @SuppressWarnings("unchecked") List <XYSeries>list = collection.getSeries(); XYSeriesCollection collect = new XYSeriesCollection(); for(int i = 0 ;i<list.size();i++){ if(list.get(i).getKey().equals("Knaspsack")){ collect.addSeries(list.get(i)); break; } } for(int i = 0 ;i<list.size();i++){ if(list.get(i).getKey().equals("Greedy")){ collect.addSeries(list.get(i)); break; } }for(int i = 0 ;i<list.size();i++){ if(list.get(i).getKey().equals("Lru")){ collect.addSeries(list.get(i)); break; } }for(int i = 0 ;i<list.size();i++){ if(list.get(i).getKey().equals("Lfu")){ collect.addSeries(list.get(i)); break; } } return collect; }
Example 7
Source File: ExcitationPanel.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Update a series displayed in the excitationPanel corresponding to passed in index */ public void update(int series) { XYSeriesCollection seriesCollection = (XYSeriesCollection) getChart().getXYPlot().getDataset(); ExcitationRenderer renderer = (ExcitationRenderer) getChart().getXYPlot().getRenderer(); // Current value of use_steps //boolean useStepsFlag = renderer.getControl().getUseSteps(); //renderer.getControl().setUseSteps(!useStepsFlag); // update he functions if (renderer==null) return; SetControlNodes cnodes=null; if (series==0) cnodes = renderer.getControl().getControlValues(); else if (series==1) cnodes=renderer.getControl().getControlMinValues(); else cnodes=renderer.getControl().getControlMaxValues(); XYSeries ser=seriesCollection.getSeries(series); ser.clear(); // RenderingInfo keeps stale refs need to be removed from the Chart XYFunctionInterface ctrlFunction = null; if (series==0) ctrlFunction=ExcitationEditorJPanel.createFunctionFromControlLinear((FunctionXYSeries) ser, cnodes, !renderer.getControl().getUseSteps()); else ctrlFunction=ExcitationEditorJPanel.createFunctionFromControlLinear((FunctionXYSeries) ser, cnodes, true); //XYFunctionInterface xyFunc = new XYFunctionInterface(ctrlFunction); renderer.replaceFunction(series, ctrlFunction); // The following is a hack adopted from the FunctionPanel to nvoke methods on listeners directly instead of using events!! Object[] listeners = functionPanelListeners.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == FunctionPanelListener.class) { ((ExcitationPanelListener) listeners[i + 1]).replaceFunction(ctrlFunction, series); } } seriesCollection.seriesChanged(new SeriesChangeEvent(this)); setChanged(true); }