/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
/** * Creates a sample chart. * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(IntervalXYDataset dataset,String s) { final JFreeChart chart = ChartFactory.createXYBarChart( "Histogram Plot: "+s, "Keyword index", false, "frequency", dataset, PlotOrientation.VERTICAL, true, true, false ); XYPlot plot = (XYPlot) chart.getPlot(); final IntervalMarker target = new IntervalMarker(400.0, 700.0); //target.setLabel("Target Range"); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); target.setLabelAnchor(RectangleAnchor.LEFT); target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); target.setPaint(new Color(222, 222, 255, 128)); plot.addRangeMarker(target, Layer.BACKGROUND); return chart; }
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart( "XY Bar Chart", // chart title "Domain", false, "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); }
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; }
/** * TODO Documentation * TODO Refactor to fit DistributionChart2D * * @param dataset * @return */ private JFreeChart createPopCellLengthBeforAfterDivisionChart(IntervalXYDataset dataset) { String lengthUnit = "μm"; // Set default value if (forest != null) { lengthUnit = forest.getMetaxml().getAllCellsInMetaXML().get(0).getLengthUnit(); } final JFreeChart chartLocal = ChartFactory.createHistogram( "Cell length before and after division", String.format("Cell length [%s]", lengthUnit), "Distribution", dataset, PlotOrientation.VERTICAL, true, true, false ); styleChart(chartLocal); return chartLocal; }
/** * TODO Documentation * * @param dataset * @return */ private JFreeChart createPopDivisionTimesChart(IntervalXYDataset dataset) { String timeUnit = "min"; // Set default value if (forest != null) { timeUnit = forest.getMetaxml().getExperimentDurationUnit(); } final JFreeChart chartLocal = ChartFactory.createHistogram( "Division times distribution", String.format("Division times [%s]", timeUnit), "Occurrence [-]", dataset, PlotOrientation.VERTICAL, true, true, false ); styleChart(chartLocal); return chartLocal; }
/** * Constructs a {@link PopulationElongationrateDistributionChart2D} from a * {@link Forest}. * * @param forest * The underlying data model for a chart. */ public PopulationElongationrateDistributionChart2D(Forest forest) { super(forest); if(forest != null) { this.setLayout(new BorderLayout()); colorPalette = new LinkedList<Color>(); final IntervalXYDataset dataset = createPopElongationrateDataset(forest); final JFreeChart chart = createPopElongationrateChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(800, 250)); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseZoomable(true, false); chartPanel.setBorder(BorderFactory.createLineBorder(new java.awt.Color(214, 214, 214))); legendPanel = createLegendPanel(chart); this.add(BorderLayout.CENTER, chartPanel); this.add(BorderLayout.EAST, legendPanel); this.setBackground(Color.white); } else { throw new IllegalArgumentException("Error"); } }
/** * TODO Documentation * * @param dataset * @return */ private JFreeChart createPopElongationrateChart(IntervalXYDataset dataset) { final JFreeChart chartLocal = ChartFactory.createHistogram( "Cell elongatrion rate", "Elongation rate [mu/min]", "Distribution", dataset, PlotOrientation.VERTICAL, true, true, false ); styleChart(chartLocal); return chartLocal; }
/** * Creates a chart. * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart( chartTitle, // chart title "Date", // domain axis label true, "Y", // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, false ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
protected JFreeChart createLegend(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart( chartTitle, // chart title "Date", // domain axis label true, "Y", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); return chart; }
/** * Creates a new chart. * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, false ); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new YIntervalRenderer()); setXSummary(dataset); return chart; }
private IntervalXYDataset createDatasetNumberRequestsTampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Tampered Requests per Second" ); if ( model.getMapLogEntryIntervalTampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalTampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }
private JFreeChart crearHistograma(IntervalXYDataset datos) { JFreeChart jfreechart = ChartFactory. createHistogram("Histograma", "X","Y", datos, PlotOrientation.VERTICAL, false, false, false); //createHistogram("Histograma", "X","Y", datos, PlotOrientation.VERTICAL, false, false, false); //createXYBarChart("Histograma", "X", false, "Y", datos, PlotOrientation.VERTICAL, false, false, false); //jfreechart.getCategoryPlot(); jfreechart.getPlot().setOutlinePaint(Color.black); XYPlot cp=(XYPlot)jfreechart.getPlot(); XYBarRenderer renderer=(XYBarRenderer)cp.getRenderer(); cp.setWeight(80); renderer.setSeriesPaint(0,Color.GRAY); jfreechart.setAntiAlias(true); jfreechart.setBackgroundPaint(Color.white); return jfreechart; }
/** * create chart using data from the dataTable */ public void doChart(){ if(dataTable.isEditing()) dataTable.getCellEditor().stopCellEditing(); if (! hasExample ) { SOCROptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE); resetChart(); return; } isDemo = false; IntervalXYDataset dataset = createDataset(isDemo); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, isDemo); setChart(); }
private IntervalXYDataset createDatasetNumberRequestsUntampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Untampered Requests per Second" ); if ( model.getMapLogEntryIntervalUntampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalUntampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }
/** * create chart using data from the dataTable */ public void doChart(){ //System.out.println("doChart"); reset_BinSlider();// need to recaculate the slider range if(dataTable.isEditing()) dataTable.getCellEditor().stopCellEditing(); if (! hasExample ) { SOCROptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE); resetChart(); return; } isDemo = false; IntervalXYDataset dataset = createDataset(isDemo); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, isDemo); setChart(); }
protected void redoChart(){ //System.out.println("redoChart"); do_histogram(raw_x, row_count); // System.out.println("bin_count="+bin_count); try{ IntervalXYDataset dataset = new SimpleIntervalXYDataset(bin_count, x_start, x_end, y_freq); JFreeChart chart = createChart(dataset); chartPanel = new ChartPanel(chart, false); setChart(); }catch(OutOfMemoryError e){ SOCROptionPane.showMessageDialog(this, "out of memory, please increase bin_ size."); return; } }
protected JFreeChart createLegend(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart( chartTitle, // chart title domainLabel, // domain axis label true, rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
/** * Creates a chart. * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart( chartTitle, // chart title domainLabel, // domain axis label true, rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, false ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
/** * Creates the chart. * * @param dataset the dataset * @return the j free chart */ private JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart( this.title, this.x_axis, false, this.y_axis, dataset, PlotOrientation.VERTICAL, true, true, false ); return chart; }
/** * Execute. */ public void execute() { IntervalXYDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); this.pack(); RefineryUtilities.centerFrameOnScreen(this); exportFigure(chart); //this.setVisible(true); }
/** * Creates a sample dataset. You wouldn't normally hard-code the * population of a dataset in this way (it would be better to read the * values from a file or a database query), but for a self-contained demo * this is the least complicated solution. * * @return The dataset. */ private static IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); // Month m1 = new Month(2, 2005); // TimeSeriesDataItem item = new TimeSeriesDataItem(m1,300); // series1.add(m1, 7627.743); series1.add(new Month(2, 2005), 7713.138); series1.add(new Month(3, 2005), 6776.939); series1.add(new Month(4, 2005), 5764.537); series1.add(new Month(5, 2005), 4777.880); series1.add(new Month(6, 2005), 4836.496); series1.add(new Month(7, 2005), 3887.618); series1.add(new Month(8, 2005), 3926.933); series1.add(new Month(9, 2005), 4932.710); series1.add(new Month(10, 2005), 4027.123); series1.add(new Month(11, 2005), 8092.322); series1.add(new Month(12, 2005), 8170.414); series1.add(new Month(1, 2006), 8196.070); series1.add(new Month(2, 2006), 8269.886); series1.add(new Month(3, 2006), 5371.156); series1.add(new Month(4, 2006), 5355.718); series1.add(new Month(5, 2006), 5356.777); series1.add(new Month(6, 2006), 8420.042); series1.add(new Month(7, 2006), 8444.347); series1.add(new Month(8, 2006), 8515.034); series1.add(new Month(9, 2006), 8506.974); series1.add(new Month(10, 2006), 8584.329); series1.add(new Month(11, 2006), 8633.246); series1.add(new Month(12, 2006), 8680.224); series1.add(new Month(1, 2007), 8707.561); return new TimeSeriesCollection(series1); }
/** * Creates a sample dataset. You wouldn't normally hard-code the * population of a dataset in this way (it would be better to read the * values from a file or a database query), but for a self-contained demo * this is the least complicated solution. * * @return A sample dataset. */ private static IntervalXYDataset createDataset2() { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries series1 = new TimeSeries("Series 2"); series1.add(new Month(1, 2005), 1200); series1.add(new Month(2, 2005), 1400); series1.add(new Month(3, 2005), 1500); series1.add(new Month(4, 2005), 1700); series1.add(new Month(5, 2005), 1600); series1.add(new Month(6, 2005), 2400); series1.add(new Month(7, 2005), 2100); series1.add(new Month(8, 2005), 2200); series1.add(new Month(9, 2005), 800); series1.add(new Month(10, 2005), 2350); series1.add(new Month(11, 2005), 500); series1.add(new Month(12, 2005), 700); series1.add(new Month(1, 2006), 900); series1.add(new Month(2, 2006), 1500); series1.add(new Month(3, 2006), 2100); series1.add(new Month(4, 2006), 2200); series1.add(new Month(5, 2006), 1900); series1.add(new Month(6, 2006), 3000); series1.add(new Month(7, 2006), 3780); series1.add(new Month(8, 2006), 4000); series1.add(new Month(9, 2006), 4500); series1.add(new Month(10, 2006), 7000); series1.add(new Month(11, 2006), 5500); series1.add(new Month(12, 2006), 6000); series1.add(new Month(1, 2007), 6500); dataset.addSeries(series1); return dataset; }
/** * Creates a new demo instance. * * @param title the frame title. */ public HistogramExample(final String title,final double[] hist,final String s) { super(title); IntervalXYDataset dataset = createDataset(hist); JFreeChart chart = createChart(dataset,s); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
/** * Creates a sample dataset. * * @return A sample dataset. */ private IntervalXYDataset createDataset(final double[] hist) { final XYSeries series = new XYSeries("normalised values"); int i=0; for(double d:hist){ series.add(i, d); i++; } final XYSeriesCollection dataset = new XYSeriesCollection(series); return dataset; }
/** * Creates a histogram chart. This chart is constructed with an {@link XYPlot} using an * {@link XYBarRenderer}. The domain and range axes are {@link NumberAxis} instances. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel the x axis label (<code>null</code> permitted). * @param yAxisLabel the y axis label (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param orientation the orientation (horizontal or vertical) (<code>null</code> NOT * permitted). * @param legend create a legend? * @param tooltips display tooltips? * @param urls generate URLs? * * @return The chart. */ public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } ValueAxis xAxis = new NumberAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYBarRenderer(); if (tooltips) { renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, SerialDate.MARCH, 2002), 12353.3); series1.add(new Day(2, SerialDate.MARCH, 2002), 13734.4); series1.add(new Day(3, SerialDate.MARCH, 2002), 14525.3); series1.add(new Day(4, SerialDate.MARCH, 2002), 13984.3); series1.add(new Day(5, SerialDate.MARCH, 2002), 12999.4); series1.add(new Day(6, SerialDate.MARCH, 2002), 14274.3); series1.add(new Day(7, SerialDate.MARCH, 2002), 15943.5); series1.add(new Day(8, SerialDate.MARCH, 2002), 14845.3); series1.add(new Day(9, SerialDate.MARCH, 2002), 14645.4); series1.add(new Day(10, SerialDate.MARCH, 2002), 16234.6); series1.add(new Day(11, SerialDate.MARCH, 2002), 17232.3); series1.add(new Day(12, SerialDate.MARCH, 2002), 14232.2); series1.add(new Day(13, SerialDate.MARCH, 2002), 13102.2); series1.add(new Day(14, SerialDate.MARCH, 2002), 14230.2); series1.add(new Day(15, SerialDate.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); collection.setDomainIsPointsInTime(false); // this tells the time series collection that // we intend the data to represent time periods // NOT points in time. This is required when // determining the min/max values in the // dataset's domain. return collection; }
/** * Returns the starting X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the starting X value for the specified series and item. */ public Number getStartX(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getStartX(this.map[series], item); } else { return getX(series, item); } }
/** * Returns the ending X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the ending X value for the specified series and item. */ public Number getEndX(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getEndX(this.map[series], item); } else { return getX(series, item); } }
/** * Returns the starting Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getStartY(this.map[series], item); } else { return getY(series, item); } }
/** * Returns the ending Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getEndY(this.map[series], item); } else { return getY(series, item); } }
/** * Returns the starting X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The value. */ public Number getStartX(int series, int item) { final DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getStartX(di.series, item); } else { return getX(series, item); } }
/** * Returns the ending X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The value. */ public Number getEndX(int series, int item) { final DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getEndX(di.series, item); } else { return getX(series, item); } }
/** * Returns the starting Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { final DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getStartY(di.series, item); } else { return getY(series, item); } }
/** * Returns the ending Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return the ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { final DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getEndY(di.series, item); } else { return getY(series, item); } }