List of usage examples for org.jfree.chart ChartFactory createScatterPlot
public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:edu.unc.LCCC.caBIG.DWD.javaCode.visualization.SetUpPlotWindow.java
public static JPanel createXYLineAndShapeRendererChart(XYDataset data, String x, String y, int w, int h) { //XYDataset data = new SampleXYDataset2(); JFreeChart chart = ChartFactory.createScatterPlot(null, // the title of the chart x, // the label for the X axis y, // the label for the Y axis data, // the dataset for the chart PlotOrientation.VERTICAL, // the orientation of the chart true, // a flag specifying whether or not a legend is required true, // a flag specifying whether or not tooltips should be generated false); // a flag specifying whether or not the chart should generate URLs XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6);/*from w ww. j a v a 2 s . c o m*/ plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(w, h)); return chartPanel; }
From source file:CGgui.java
public CGgui() { //main window frame f.setResizable(false);//w ww . j a v a2s. c o m f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(fCenter, BorderLayout.CENTER); f.getContentPane().add(fEast, BorderLayout.EAST); //menu mnuFile.add(mnuLoad); mnuLoad.add(mnuItemOpenFasta); mnuLoad.add(mnuItemOpenBed); mnuFile.add(mnuSaveData); mnuSaveData.add(mnuItemSavePositions); mnuSaveData.add(mnuItemSaveClusters); //mnuFile.add(mnuItemOpenDataFile); mnuFile.add(mnuSaveCharts); mnuSaveCharts.add(mnuItemSaveChrt); mnuSaveCharts.add(mnuItemSaveMinChrt); mnuSaveCharts.add(mnuItemSaveClusterChrt); mnuSaveCharts.add(mnuItemSaveGrayChrt); mnuSaveCharts.add(mnuItemSaveGrayMinChrt); mnuSaveCharts.add(mnuItemSaveGrayClusterChrt); mnuFile.add(mnuItemClearData); mnuFile.add(mnuItemQuit); mnuEdit.add(mnuItemChartProps); mnuEdit.add(mnuItemMinimaProps); mnuEdit.add(mnuItemClusterProps); mnuEdit.add(mnuItemFindMin); mnuEdit.add(mnuItemSetAxes); mnuEdit.add(mnuItemShowGrid); // mnuHelp.add(mnuItemMan); // mnuHelp.add(mnuItemAbout); mb.add(mnuFile); mb.add(mnuEdit); // mb.add(mnuHelp); f.setJMenuBar(mb); //progressbar jprogressbar.setVisible(false); jprogressbar.setBorderPainted(false); f.getContentPane().add(jprogressbar, BorderLayout.SOUTH); //chart area //histogram ChartArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chart = ChartFactory.createXYAreaChart("Fragment Length Histogram", "Fragment Length (l)", "Frequency f(l)", histogramdataset, PlotOrientation.VERTICAL, true, true, false); chart.addSubtitle(0, new TextTitle("n = " + CurrCG)); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setForegroundAlpha(0.85F); xyplot.setDomainCrosshairVisible(false); chartpanel = new ChartPanel(chart); ChartArea.add("Fragment Length", chartpanel); //minima minchart = ChartFactory.createXYLineChart("Local Minima", "Fragment Length (l)", "Number of Matches per Fragment", minimadataset, PlotOrientation.VERTICAL, true, true, false); XYPlot minxyplot = (XYPlot) minchart.getPlot(); minxyplot.setForegroundAlpha(0.85F); minchartpanel = new ChartPanel(minchart); ChartArea.add("Minima", minchartpanel); //optimization clusterchart = ChartFactory.createScatterPlot("Average Cluster Size vs. Maximum Fragment Length", "Number (n) of Matches per Fragment", "Number of Overlapping Fragments per Cluster/Max Fragment Length", clusterdataset, PlotOrientation.VERTICAL, true, true, false); XYPlot clusterplot = (XYPlot) clusterchart.getPlot(); clusterplot.setForegroundAlpha(0.85F); clusterchartpanel = new ChartPanel(clusterchart); ChartArea.add("Optimization", clusterchartpanel); //text area SeqText.setLineWrap(true); SeqText.setWrapStyleWord(true); SeqText.setEditable(false); jScrollPane.setBorder(BorderFactory .createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Debug"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), jScrollPane.getBorder())); textPanel.add(jScrollPane); //this next line is a hack to fix the ScrollPane size when the chart is scrolled jScrollPane.setPreferredSize(jScrollPane.getPreferredSize()); //auto scroll to added text SeqText.setAutoscrolls(true); jScrollPane.setAutoscrolls(true); //center panel layout GroupLayout centerlayout = new GroupLayout(fCenter); fCenter.setLayout(centerlayout); ////Create a sequential and a parallel groups SequentialGroup h1 = centerlayout.createSequentialGroup(); SequentialGroup v1 = centerlayout.createSequentialGroup(); ////grouping h1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea).addComponent(textPanel)); centerlayout.setHorizontalGroup(h1); ////more grouping v1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea)); v1.addGroup(centerlayout.createParallelGroup().addComponent(textPanel)); centerlayout.setVerticalGroup(v1); //CG Panel (search settings panel) CGPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Search Settings"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), CGPanel.getBorder())); //set subpanel1 layout GroupLayout CGsublayout1 = new GroupLayout(CGsubPanel1); CGsubPanel1.setLayout(CGsublayout1); ////Create a sequential and a parallel groups SequentialGroup h4 = CGsublayout1.createSequentialGroup(); SequentialGroup v4 = CGsublayout1.createSequentialGroup(); ////grouping h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternLabel).addComponent(minCGsLabel) .addComponent(maxCGsLabel).addComponent(CGstepLabel).addComponent(smoothCheckBox) .addComponent(CGApplyButton).addComponent(CGsetCurrLabel)); h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternText).addComponent(minCGsText) .addComponent(maxCGsText).addComponent(CGstepText).addComponent(smoothText) .addComponent(CGResetButton).addComponent(CGcurrText)); CGsublayout1.setHorizontalGroup(h4); ////more grouping v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(searchPatternLabel).addComponent(searchPatternText)); v4.addContainerGap(5, 5); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minCGsLabel) .addComponent(minCGsText)); v4.addContainerGap(5, 5); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxCGsLabel) .addComponent(maxCGsText)); v4.addContainerGap(5, 5); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGstepLabel) .addComponent(CGstepText)); v4.addContainerGap(5, 5); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(smoothCheckBox) .addComponent(smoothText)); v4.addContainerGap(5, 5); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGApplyButton) .addComponent(CGResetButton)); v4.addContainerGap(15, 15); v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGsetCurrLabel) .addComponent(CGcurrText)); CGsublayout1.setVerticalGroup(v4); //set subpanel2 layout GroupLayout CGsublayout2 = new GroupLayout(CGsubPanel2); CGsubPanel2.setLayout(CGsublayout2); ////Create a sequential and a parallel groups SequentialGroup hSettingsSub2 = CGsublayout2.createSequentialGroup(); SequentialGroup vSettingsSub2 = CGsublayout2.createSequentialGroup(); ////horizontal grouping hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrLabel)); hSettingsSub2.addContainerGap(25, 25); hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGcurrText)); hSettingsSub2.addContainerGap(25, 25); hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrButton)); CGsublayout2.setHorizontalGroup(hSettingsSub2); ////vertical grouping vSettingsSub2.addGroup(CGsublayout2.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(CGsetCurrLabel).addComponent(CGcurrText).addComponent(CGsetCurrButton)); CGsublayout2.setVerticalGroup(vSettingsSub2); //set overall layout (subpanel3) GroupLayout CGsublayout3 = new GroupLayout(CGsubPanel3); CGsubPanel3.setLayout(CGsublayout3); ////Create a sequential and a parallel groups SequentialGroup h5 = CGsublayout3.createSequentialGroup(); SequentialGroup v5 = CGsublayout3.createSequentialGroup(); ////grouping h5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox).addComponent(CGsubPanel1) .addComponent(CGsubPanel2)); CGsublayout3.setHorizontalGroup(h5); ////more grouping v5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox)); v5.addContainerGap(5, 5); v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel1)); v5.addContainerGap(5, 5); v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel2)); CGsublayout3.setVerticalGroup(v5); //add to resizable container CGPanel.add(CGsubPanel3); //button and slider listeners CGApplyButton.addActionListener(new ListenCGApplyButton()); CGResetButton.addActionListener(new ListenCGResetButton()); CGsetCurrButton.addActionListener(new ListenCGsetCurrButton()); CGcurrText.addActionListener(new ListenCGsetCurrButton()); //minimum area findminPanel.setVisible(true); findminPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Find Minimum"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), findminPanel.getBorder())); GroupLayout minlayout = new GroupLayout(findminPanel); findminPanel.setLayout(minlayout); ////Create a sequential and a parallel groups SequentialGroup h2 = minlayout.createSequentialGroup(); SequentialGroup v2 = minlayout.createSequentialGroup(); ////group find minimum and find all buttons SequentialGroup hFindMinButtons = minlayout.createSequentialGroup(); SequentialGroup vFindMinButtons = minlayout.createSequentialGroup(); hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcButton)); hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcAllButton)); vFindMinButtons.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(CalcButton).addComponent(CalcAllButton)); ////general grouping h2.addGroup(minlayout.createParallelGroup().addComponent(minLabel).addComponent(maxLabel) .addComponent(ClearButton)); h2.addContainerGap(5, 5); h2.addGroup(minlayout.createParallelGroup().addComponent(minText).addComponent(maxText) .addGroup(hFindMinButtons)); h2.addContainerGap(5, 5); h2.addGroup(minlayout.createParallelGroup().addComponent(minGrabButton).addComponent(maxGrabButton) .addComponent(CancelButton)); minlayout.setHorizontalGroup(h2); ////more grouping v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minLabel) .addComponent(minText).addComponent(minGrabButton)); v2.addContainerGap(5, 5); v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxLabel) .addComponent(maxText).addComponent(maxGrabButton)); v2.addContainerGap(5, 5); v2.addContainerGap(5, 5); v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(ClearButton) .addGroup(vFindMinButtons).addComponent(CancelButton)); minlayout.setVerticalGroup(v2); //add button listeners ClearButton.addActionListener(new ListenClearButton()); CalcButton.addActionListener(new ListenCalcButton()); CalcAllButton.addActionListener(new ListenCalcAllButton()); CancelButton.addActionListener(new ListenCancelButton()); minGrabButton.addActionListener(new ListenminGrabButton()); maxGrabButton.addActionListener(new ListenmaxGrabButton()); //axes panel mnuItemSetAxes.setState(false); setaxesPanel.setVisible(false); setaxesPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Set Domain"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), setaxesPanel.getBorder())); GroupLayout setaxeslayout = new GroupLayout(setaxesPanel); setaxesPanel.setLayout(setaxeslayout); ////Create a sequential and a parallel groups SequentialGroup h6 = setaxeslayout.createSequentialGroup(); SequentialGroup v6 = setaxeslayout.createSequentialGroup(); ////grouping h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainLabel).addComponent(maxdomainLabel) .addComponent(SetDomainButton)); h6.addContainerGap(5, 5); h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainText).addComponent(maxdomainText) .addComponent(ResetDomainButton)); setaxeslayout.setHorizontalGroup(h6); ////more grouping v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(mindomainLabel) .addComponent(mindomainText)); v6.addContainerGap(5, 5); v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxdomainLabel) .addComponent(maxdomainText)); v6.addContainerGap(5, 5); v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(SetDomainButton) .addComponent(ResetDomainButton)); setaxeslayout.setVerticalGroup(v6); //add button listeners SetDomainButton.addActionListener(new ListenSetDomainButton()); ResetDomainButton.addActionListener(new ListenResetDomainButton()); //east panel layout GroupLayout eastlayout = new GroupLayout(fEast); fEast.setLayout(eastlayout); ////Create a sequential and a parallel groups SequentialGroup h3 = eastlayout.createSequentialGroup(); SequentialGroup v3 = eastlayout.createSequentialGroup(); ////grouping h3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel).addComponent(findminPanel) .addComponent(setaxesPanel)); eastlayout.setHorizontalGroup(h3); ////more grouping v3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel)); v3.addGroup(eastlayout.createParallelGroup().addComponent(findminPanel)); v3.addGroup(eastlayout.createParallelGroup().addComponent(setaxesPanel)); eastlayout.setVerticalGroup(v3); //listen for exit signals f.addWindowListener(new ListenCloseWdw()); mnuItemQuit.addActionListener(new ListenMenuQuit()); //listen for exit signals f.addWindowListener(new ListenCloseWdw()); mnuItemClearData.addActionListener(new ListenClearData()); //listen for open signal mnuItemOpenFasta.addActionListener(new ListenMenuOpenFasta()); //listen for open signal mnuItemOpenBed.addActionListener(new ListenMenuOpenBed()); //listen for save position signal mnuItemSavePositions.addActionListener(new ListenMenuSavePositions()); //listen for save cluster signal mnuItemSaveClusters.addActionListener(new ListenMenuSaveClusters()); //listen for save histogram chart signal mnuItemSaveChrt.addActionListener(new ListenMenuSaveChrt()); //listen for save chart signal mnuItemSaveMinChrt.addActionListener(new ListenMenuSaveMinChrt()); //listen for save cluster chart signal mnuItemSaveClusterChrt.addActionListener(new ListenMenuSaveClusterChrt()); //listen for save histogram chart in grayscale signal; mnuItemSaveGrayChrt.addActionListener(new ListenMenuSaveGrayChrt()); //listen for save chart signal mnuItemSaveGrayMinChrt.addActionListener(new ListenMenuSaveGrayMinChrt()); //listen for save cluster chart signal mnuItemSaveGrayClusterChrt.addActionListener(new ListenMenuSaveGrayClusterChrt()); //listen for edit histogram properties signal mnuItemChartProps.addActionListener(new ListenMenuChartProps()); //listen for edit minima chart properties signal mnuItemMinimaProps.addActionListener(new ListenMenuMinimaProps()); //listen for edit optimization chart properties signal mnuItemClusterProps.addActionListener(new ListenMenuClusterProps()); //listen for find minimum signal mnuItemFindMin.addActionListener(new ListenMenuFindMin()); //listen for find minimum signal mnuItemSetAxes.addActionListener(new ListenMenuSetAxes()); //listen for show gridlines mnuItemShowGrid.addActionListener(new ListenMenuShowGrid()); //other menu items //garbage collect //System.gc(); }
From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java
public JFreeChart createXYChart(String expId) { ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance(); long eid = Long.parseLong(expId); log.info("Building experiment chart for eid = " + eid); Experiment exp = edao.findExperiment(eid); final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName(); final XYSeries series = new XYSeries(expName); for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) { int i = 1; for (ExecutionRecordImpl exr : batch.getRuns()) { //log.info("Found Record... "+exr+" stages: "+exr.getStages()); if (exr != null && exr.getStages() != null) { // Look up the object, so we can get the name. DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy()); String dobName = "Object " + i; if (dh != null) dobName = dh.getName(); for (ExecutionStageRecordImpl exsr : exr.getStages()) { Double time = exsr.getDoubleMeasurement(TecRegMockup.PROP_SERVICE_TIME); Double size = exsr.getDoubleMeasurement(TecRegMockup.PROP_DO_SIZE); // Look for timing: if (time != null && size != null && size.doubleValue() > 0.0 && time.doubleValue() > 0.0) { series.add(size, time); /* if( exsr.isMarkedAsSuccessful() ) { dataset.addValue( time, "Succeded", dobName); } else {/*from ww w.ja va 2s . co m*/ dataset.addValue( time, "Failed", dobName); } */ } } } // Increment, for the next run. i++; } } // Create the chart. JFreeChart chart = ChartFactory.createScatterPlot(null, "Size [bytes]", "Time [s]", new XYSeriesCollection(series), PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis xAxis = new LogAxis("Size [bytes]"); // Set the base appropriately: xAxis.setBase(1024.0); // xAxis.setTickUnit( new NumberTickUnit(128.0) ); // xAxis.getTickUnit().getMinorTickCount(); // FIXME This should really be a KB/MB/etc number formatter... xAxis.setNumberFormatOverride(new LogFormat(1024.0, "1024", true)); // LogAxis yAxis = new LogAxis("Y"); // yAxis.setNumberFormatOverride(new LogFormat(10.0, "10", true)); plot.setDomainAxis(xAxis); // plot.setRangeAxis(yAxis); // Add some tool-tips plot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator()); return chart; }
From source file:SciTK.PlotXYZBlock.java
private void init(String x_label, String y_label, String window_title) { chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);/*from w w w .j a v a2 s . c o m*/ // turn off borders of the plot: XYPlot p = chart.getXYPlot(); p.getDomainAxis().setLowerMargin(0.0); p.getDomainAxis().setUpperMargin(0.0); p.getRangeAxis().setLowerMargin(0.0); p.getRangeAxis().setUpperMargin(0.0); // -------------------------------------------- // set up a lookup table // -------------------------------------------- // this is how we render the block plots: XYBlockRenderer renderer = new XYBlockRenderer(); // need to find max and min z of the data set: double min = 0; double max = 0; for (int i = 0; i < data.getSeriesCount(); i++) // iterate over data sets { for (int j = 0; j < data.getItemCount(i); j++) // iterate over points in dataset { if (data.getZValue(i, j) < min) min = data.getZValue(i, j); else if (data.getZValue(i, j) > max) max = data.getZValue(i, j); } } // create paint scale using min and max values, default color black: LookupPaintScale paintScale = new LookupPaintScale(min, max, Color.black); // set up the LUT: double step_size = (max - min) / 255.; // step size for LUT for (int i = 0; i < 256; i++) { paintScale.add(min + i * step_size, new Color(i, i, i, 255)); } renderer.setPaintScale(paintScale); // set this renderer to the plot: p.setRenderer(renderer); // -------------------------------------------- // set up a color bar // -------------------------------------------- // create an array of display labels: num_labels = 10; // default to 10 labels on color bar double display_step_size = (max - min) / ((double) num_labels); String[] scale_bar_labels = new String[num_labels + 1]; // to format numbers in scientific notation: DecimalFormat formater = new DecimalFormat("0.#E0"); // create list of labesl: for (int i = 0; i <= num_labels; i++) { scale_bar_labels[i] = formater.format(min + i * display_step_size); } // create axis: SymbolAxis scaleAxis = new SymbolAxis(null, scale_bar_labels); scaleAxis.setRange(min, max); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); // set up the paint scale: psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setBackgroundPaint(new Color(255, 255, 255, 0)); // clear background // set up frame with buffer region to allow text display psl.setFrame(new LineBorder((Paint) Color.BLACK, new BasicStroke((float) 1.0), new RectangleInsets(15, 10, 15, 10))); psl.setAxisOffset(5.0); // display on right side: psl.setPosition(RectangleEdge.RIGHT); // margin around color scale: psl.setMargin(new RectangleInsets(20, 15, 20, 15)); // add to the chart so it will be displayed by default: chart.addSubtitle(psl); // -------------------------------------------- // WINDOW-RELATED UI // -------------------------------------------- // set up the generic plot UI: super.window_title = window_title; super.initUI(); // add another menu item JMenuBar mb = super.getJMenuBar(); // get the menu bar // find menu named "Plot" JMenu menu_plot = null; for (int i = 0; i < mb.getMenuCount(); i++) { if (mb.getMenu(i).getText() == "Plot") menu_plot = mb.getMenu(i); } // Add a new checkbox for the color scale bar JCheckBoxMenuItem menu_plot_scalebar = new JCheckBoxMenuItem("Color Scale"); menu_plot_scalebar.setToolTipText("Show color scale bar?"); menu_plot_scalebar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setScaleBar(selected); } }); // set appropirate checkbox state: menu_plot_scalebar.setState(true); if (menu_plot != null) // sanity check menu_plot.add(menu_plot_scalebar); }
From source file:jmeanshift.ChartProof.java
private void bubblyBubblesScatter(JPanel panel) { JFreeChart chart = ChartFactory.createScatterPlot(TITLE, "X1", "X2", dataset, PlotOrientation.VERTICAL, true, true, false);//from ww w . jav a 2s .co m chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.yellow)); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.CYAN); plot.setForegroundAlpha(0.65f); domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerBound(0); domainAxis.setUpperBound(255); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerBound(0); rangeAxis.setUpperBound(255); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(this); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); }
From source file:com.sun.japex.ChartGenerator.java
private JFreeChart generateDriverScatterChart() { try {//from w w w. j av a2s .co m DefaultTableXYDataset xyDataset = new DefaultTableXYDataset(); // Generate charts for (DriverImpl di : _testSuite.getDriverInfoList()) { if (!di.hasParam(Constants.RESULT_ARIT_MEAN_X)) { System.out.println("Error: Driver '" + di.getName() + "' does not define" + " any values for the X axis needed to generate a scatter chart"); System.exit(1); } XYSeries xySeries = new XYSeries(di.getName(), true, false); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_ARIT_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_ARIT_MEAN)); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_GEOM_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_GEOM_MEAN)); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_HARM_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_HARM_MEAN)); xyDataset.addSeries(xySeries); } String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT); String resultUnitX = _testSuite.getParam(Constants.RESULT_UNIT_X); JFreeChart chart = ChartFactory.createScatterPlot("Result Summary", resultUnitX, resultUnit, xyDataset, PlotOrientation.VERTICAL, true, true, false); // Set log scale depending on japex.resultAxis[_X] XYPlot plot = chart.getXYPlot(); if (_testSuite.getParam(Constants.RESULT_AXIS_X).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxisX = new LogarithmicAxis(resultUnitX); logAxisX.setAllowNegativesFlag(true); plot.setDomainAxis(logAxisX); } if (_testSuite.getParam(Constants.RESULT_AXIS).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxis = new LogarithmicAxis(resultUnit); logAxis.setAllowNegativesFlag(true); plot.setRangeAxis(logAxis); } return chart; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:treegross.standsimulation.TgGrafik.java
public JFreeChart createChart(Stand st) { // create the dataset... XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < st.nspecies; i++) { XYSeries series = new XYSeries(st.sp[i].spDef.shortName); // DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int k = 0; k < st.ntrees; k++) { if ((st.tr[k].d > 0) && st.tr[k].out < 0 && st.tr[k].code == st.sp[i].code) series.add(st.tr[k].d, st.tr[k].h); }// w w w . j a va 2s .c om dataset.addSeries(series); } // JFreeChart chart = ChartFactory.createScatterPlot(messages.getString("heightDiameter"), messages.getString("dbh"), messages.getString("height"), dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false); XYPlot plot = chart.getXYPlot(); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // // XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < st.nspecies; i++) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesPaint(i, new Color(st.sp[i].spDef.colorRed, st.sp[i].spDef.colorGreen, st.sp[i].spDef.colorBlue)); } plot.setRenderer(renderer); return chart; }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * Build a JPanel with plotType of a DesmoJ time-series dataset. * When allowMultipleValues is set, multiple range values of a time value are allowed. * In the opposite Case only the last range value of a time value is accepted. * In the case ts.getShowTimeSpansInReport() the data values are interpreted as * a timespan in a appropriate time unit. * @param ts DesmoJ time-series dataset * @param plotType possible Values: * Plotter.TimeSeries_ScatterPlot, * Plotter.TimeSeries_StepChart * Plotter.TimeSeries_LinePlot * @param allowMultipleValues// w w w.j ava 2s . c om * @return */ private JPanel getTimeSeriesPanel(TimeSeries ts, int plotType, boolean allowMultipleValues) { JFreeChart chart; TimeSeriesDataSetAdapter dataset = new TimeSeriesDataSetAdapter(ts, allowMultipleValues); switch (plotType) { case Plotter.TimeSeries_LineChart: chart = ChartFactory.createXYLineChart(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; case Plotter.TimeSeries_ScatterPlot: chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; case Plotter.TimeSeries_StepChart: chart = ChartFactory.createXYStepChart(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; default: chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset, PlotOrientation.VERTICAL, false, false, false); break; } if (ts.getDescription() != null) chart.setTitle(ts.getDescription()); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setNoDataMessage("NO DATA"); if (ts.getShowTimeSpansInReport() && !dataset.isValid()) xyplot.setNoDataMessage("NO VALID TIMESPANS"); xyplot.setDomainZeroBaselineVisible(false); xyplot.setRangeZeroBaselineVisible(false); DateAxis dateAxis = new DateAxis(); xyplot.setDomainAxis(dateAxis); this.configureDomainAxis(dateAxis); String numberLabel; if (!dataset.isValid()) numberLabel = "Unit: invalid"; else if (ts.getShowTimeSpansInReport()) numberLabel = "Unit: timespan [" + dataset.getRangeTimeUnit().name() + "]"; else if (ts.getUnit() != null) numberLabel = "Unit: [" + ts.getUnit() + "]"; else numberLabel = "Unit: unknown"; NumberAxis numberAxis = new NumberAxis(); xyplot.setRangeAxis(numberAxis); this.configureRangeAxis(numberAxis, numberLabel); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black); xylineandshaperenderer.setUseOutlinePaint(true); ChartPanel panel = new ChartPanel(chart); panel.setVerticalAxisTrace(false); panel.setHorizontalAxisTrace(false); panel.setPopupMenu(null); panel.setDomainZoomable(false); panel.setRangeZoomable(false); return panel; }
From source file:GUI.PlotCreator.java
private ChartPanel createEquirectangularErrorPanel(ArrayList<double[]> dataToDisplay) { title = "Equirectangular vs Haversine - Error Plot"; JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Distance Between Points (meters)", "Error", createEquirectangularErrorData(dataToDisplay), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); //XYItemRenderer renderer = xyPlot.getRenderer(); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setVerticalTickLabels(true);//from w w w . j a v a 2 s . c o m XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); xyPlot.setRenderer(renderer); return new ChartPanel(jfreechart); }
From source file:fr.ens.transcriptome.corsen.gui.qt.ResultGraphs.java
/** * Create a scatter plot/*w w w . j a v a 2 s. c o m*/ * @param particles Particle data to use * @param title Title of the graph * @return a QImage */ public QImage createScatterPlot(final Particles3D particles, final String title, final String unit) { if (particles == null) return null; List<Particle3D> pars = particles.getParticles(); final int count = pars.size(); final double[][] data = new double[2][]; data[0] = new double[count]; data[1] = new double[count]; int i = 0; for (Particle3D p : pars) { data[0][i] = p.getIntensity(); data[1][i] = p.getVolume(); i++; } DefaultXYDataset xydataset = new DefaultXYDataset(); xydataset.addSeries("data", data); JFreeChart chart = ChartFactory.createScatterPlot(title, "Intensity", "Volume" + unitLegendCude(unit), xydataset, PlotOrientation.VERTICAL, false, true, false); addTransparency(chart); XYPlot xyplot = (XYPlot) chart.getPlot(); XYDotRenderer xydotrenderer = new XYDotRenderer(); xydotrenderer.setDotWidth(2); xydotrenderer.setDotHeight(2); xyplot.setRenderer(xydotrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); final BufferedImage image = chart.createBufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB, null); return new QImage(toByte(image.getData().getDataBuffer()), this.width, this.height, QImage.Format.Format_ARGB32); }