Java Code Examples for org.jfree.chart.ChartPanel#setPreferredSize()
The following examples show how to use
org.jfree.chart.ChartPanel#setPreferredSize() .
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: KafkaFT.java From flink-perf with Apache License 2.0 | 6 votes |
public KafkaFT(String s, String generatorLogPath, String stateMachineLogPath) throws Exception { super(s); WhyOO res = createDataset(generatorLogPath, stateMachineLogPath); JFreeChart jfreechart = createChart(res.ds); // add kill events: for(Long killEventTime: res.killEventTime) { addKillEvent(jfreechart.getXYPlot(), killEventTime); } // add illegal state trans events: for(Long illegalEventTime: res.illegalStates) { addIllegalEvent(jfreechart.getXYPlot(), illegalEventTime); } ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(1200, 600)); setContentPane(chartpanel); }
Example 2
Source File: MultipleAxisChart.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void finish(java.awt.Dimension preferredSize) { ChartUtilities.applyCurrentTheme(chart); XYPlot plot = (XYPlot) chart.getPlot(); for (int i = 0; i < axisNum; i++) { XYItemRenderer renderer = plot.getRenderer(i); if (renderer == null) continue; renderer.setSeriesPaint(0, colors[i]); ValueAxis axis = plot.getRangeAxis(i); axis.setLabelPaint(colors[i]); axis.setTickLabelPaint(colors[i]); } ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(preferredSize); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); }
Example 3
Source File: PulseDistributionTab.java From ProtocolAnalyzer with GNU General Public License v3.0 | 5 votes |
public PulseDistributionTab(RawProtocolMessage message, CTabFolder chartFolder) { distributionData = createPulseDistributionPlot(message.m_PulseLengths); selectedIntervalSeries = new XYSeries("Selected Interval"); distributionData.addSeries(selectedIntervalSeries); CTabItem distributionTab = new CTabItem(chartFolder, SWT.NONE); distributionTab.setText("Pulse length Distribution"); // Create a Chart and a panel for pulse length distribution JFreeChart distributionChart = ChartFactory.createXYLineChart("Pulse Length Distribution", "Pulse Length (us)", "# Pulses", distributionData, PlotOrientation.VERTICAL, true, false, false); ChartPanel distributionChartPanel = new ChartPanel(distributionChart); RawSignalWindow.configurePanelLooks(distributionChart, 2); distributionChartPanel.setPreferredSize(new Dimension(700, 270));// 270 // Make the mark line dashed, so we can see the space line when they overlap float pattern[] = {5.0f, 5.0f}; BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, pattern, 0.0f); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) distributionChart.getXYPlot().getRenderer(); renderer.setSeriesStroke(0, stroke); // Create a ChartComposite on our tab for pulse distribution ChartComposite distributionFrame = new ChartComposite(chartFolder, SWT.NONE, distributionChart, true); distributionFrame.setHorizontalAxisTrace(false); distributionFrame.setVerticalAxisTrace(false); distributionFrame.setDisplayToolTips(true); GridData distributionGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); distributionGridData.grabExcessHorizontalSpace = true; distributionGridData.grabExcessVerticalSpace = false; distributionGridData.heightHint = 270; distributionFrame.setLayoutData(distributionGridData); distributionTab.setControl(distributionFrame); }
Example 4
Source File: BarChartDemo1.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
Example 5
Source File: Histogram.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public Histogram( final List< Double > values, final int numBins, final String title, final String units ) { super( title ); final IntervalXYDataset dataset = createDataset( values, numBins, title ); final JFreeChart chart = createChart( dataset, title, units ); final ChartPanel chartPanel = new ChartPanel( chart ); chartPanel.addChartMouseListener( new MouseListenerValue( chartPanel, getMin() + ( getMax() - getMin() ) / 2 )); chartPanel.setPreferredSize( new Dimension( 600, 270 ) ); setContentPane( chartPanel ); }
Example 6
Source File: BarChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
Example 7
Source File: BarChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
Example 8
Source File: StatisticChart.java From BART with MIT License | 5 votes |
public static JPanel createStatisticBarChart(String title,String categoryX,String valueY,CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis(categoryX); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.05d); // percentage of space between categories final ValueAxis yAxis = new NumberAxis("Value"); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, new StatisticalBarRenderer()); JFreeChart statChart = new JFreeChart(title, new Font("Helvetica", Font.BOLD, 14), plot, true); ChartPanel panel = new ChartPanel(statChart); panel.setPreferredSize(new Dimension(700, 440)); return panel; }
Example 9
Source File: HouseholdsPanel.java From computational-economy with GNU General Public License v3.0 | 5 votes |
protected ChartPanel createPriceTimeSeriesChartPanel(final Currency currency) { final JFreeChart priceChart = ChartFactory.createCandlestickChart(GoodType.LABOURHOUR + " Prices", "Time", "Price in " + currency.getIso4217Code(), getDefaultHighLowDataset(currency), false); final ChartPanel chartPanel = new ChartPanel(priceChart); chartPanel.setDomainZoomable(true); chartPanel.setPreferredSize(new java.awt.Dimension(800, 400)); return chartPanel; }
Example 10
Source File: PieChartDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(createDataset()); chart.setPadding(new RectangleInsets(4, 8, 2, 2)); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new Dimension(600, 300)); return panel; }
Example 11
Source File: ChartExportUtil.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * takes Only Width in account * * @param chart * @param sett * @throws Exception */ public static void writeChartToImage(ChartPanel chart, GraphicsExportParameters sett) throws Exception { boolean repaint = false; FixedSize fixed = sett.getFixedSize(); double oldW = sett.getWidthPixel(); double oldH = sett.getHeightPixel(); // Size only by width? if (sett.isUseOnlyWidth()) { // fixed size for chart or plot if (fixed.equals(FixedSize.Chart)) { sett.setHeightPixel(ChartLogics.calcHeightToWidth(chart, oldW, false)); } else { // fixed plot width sett.setPixelSize(ChartLogics.calcSizeForPlotWidth(chart, oldW)); } } else if (fixed.equals(FixedSize.Plot)) { // fixed plot size - width and height are given sett.setPixelSize(ChartLogics.calcSizeForPlotSize(chart, oldW, oldH)); } Dimension size = sett.getPixelSize(); // resize chart.setPreferredSize(size); chart.setMaximumSize(size); chart.setMinimumSize(size); // repaint if (repaint) { chart.revalidate(); chart.repaint(); } writeChartToImage(chart.getChart(), sett, chart.getChartRenderingInfo()); // reset size sett.setPixelSize(oldW, oldH); }
Example 12
Source File: TimeSeriesChartDemo1.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A demonstration application showing how to create a simple time series * chart. This example uses monthly data. * * @param title the frame title. */ public TimeSeriesChartDemo1(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
Example 13
Source File: BarChartDemo1.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
Example 14
Source File: StatisticChart.java From BART with MIT License | 5 votes |
public static JPanel createBarChart(String title,String category,String value,CategoryDataset dataset) { JFreeChart barChart = ChartFactory .createBarChart3D(title, category, value, dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel = new ChartPanel(barChart); panel.setPreferredSize(new Dimension(700, 440)); return panel; }
Example 15
Source File: BarChartDemo1.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
Example 16
Source File: XYTitleAnnotationDemo1.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A demonstration application showing how to create a simple time series * chart. This example uses monthly data. * * @param title the frame title. */ public XYTitleAnnotationDemo1(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); }
Example 17
Source File: HM.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public static void histogram( Map<String, Object> options, List<List<Number>> values ) { String title = ""; String xLabel = "x"; String yLabel = "y"; int width = 1600; int height = 1000; if (options != null) { Object object = options.get("title"); if (object instanceof String) { title = (String) object; } object = options.get("xlabel"); if (object instanceof String) { xLabel = (String) object; } object = options.get("ylabel"); if (object instanceof String) { yLabel = (String) object; } object = options.get("width"); if (object instanceof Number) { width = ((Number) object).intValue(); } object = options.get("height"); if (object instanceof Number) { height = ((Number) object).intValue(); } } String[] categories = new String[values.size()]; double[] valuesDouble = new double[values.size()]; for( int i = 0; i < valuesDouble.length; i++ ) { List<Number> pair = values.get(i); categories[i] = pair.get(0).toString(); valuesDouble[i] = pair.get(1).doubleValue(); } CategoryHistogram categoryHistogram = new CategoryHistogram(title, categories, valuesDouble); categoryHistogram.setXLabel(xLabel); categoryHistogram.setYLabel(yLabel); ChartPanel chartPanel = new ChartPanel(categoryHistogram.getChart(), true); Dimension preferredSize = new Dimension(width, height); chartPanel.setPreferredSize(preferredSize); GuiUtilities.openDialogWithPanel(chartPanel, "HM Chart Window", preferredSize, false); }
Example 18
Source File: HM.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public static void histogram( Map<String, Object> options, List<String> categories, List<Number> values ) { String title = ""; String xLabel = "x"; String yLabel = "y"; int width = 1600; int height = 1000; if (options != null) { Object object = options.get("title"); if (object instanceof String) { title = (String) object; } object = options.get("xlabel"); if (object instanceof String) { xLabel = (String) object; } object = options.get("ylabel"); if (object instanceof String) { yLabel = (String) object; } object = options.get("width"); if (object instanceof Number) { width = ((Number) object).intValue(); } object = options.get("height"); if (object instanceof Number) { height = ((Number) object).intValue(); } } double[] valuesDouble = new double[values.size()]; for( int i = 0; i < valuesDouble.length; i++ ) { valuesDouble[i] = values.get(i).doubleValue(); } CategoryHistogram categoryHistogram = new CategoryHistogram(title, categories.toArray(new String[categories.size()]), valuesDouble); categoryHistogram.setXLabel(xLabel); categoryHistogram.setYLabel(yLabel); ChartPanel chartPanel = new ChartPanel(categoryHistogram.getChart(), true); Dimension preferredSize = new Dimension(width, height); chartPanel.setPreferredSize(preferredSize); GuiUtilities.openDialogWithPanel(chartPanel, "HM Chart Window", preferredSize, false); }
Example 19
Source File: SymmetryInSCOPSuperfamilies.java From symmetry with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates a new demo instance. * * @param title the frame title. */ public SymmetryInSCOPSuperfamilies() { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setPreferredSize(new Dimension(500, 270)); JFrame f = new JFrame("SCOP Classes"); f.setContentPane(chartPanel); f.pack(); f.setVisible(true); }
Example 20
Source File: GraphPlot.java From NSGA-II with MIT License | 3 votes |
public void configureMultiplePlotter(final String x_axis, final String y_axis, final String graphTitle) { JFreeChart xyLineChart = ChartFactory.createXYLineChart(graphTitle, x_axis, y_axis, GraphPlot.MULTIPLE_DATASET, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xyLineChart); chartPanel.setPreferredSize(new java.awt.Dimension(GraphPlot.DIMENSION_X, GraphPlot.DIMENSION_Y)); final XYPlot plot = xyLineChart.getXYPlot(); plot.setRenderer(GraphPlot.MULTIPLE_RENDERER); setContentPane(chartPanel); }