List of usage examples for org.jfree.chart.axis NumberAxis setTickMarksVisible
public void setTickMarksVisible(boolean flag)
From source file:beproject.MainGUI.java
void liveTweetAnalysis() { new DataGenerator(1000).start(); rate = new TimeSeries("Total count", Second.class); rate.setMaximumItemAge(15);//from w w w . j av a 2 s .c o m TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(rate); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Tweet Count"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setTickLabelsVisible(true); plot.setDomainGridlinesVisible(false); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelsVisible(true); JFreeChart liveTweetAnalysisChart = new JFreeChart("Tweets Per Second", new Font("Tahoma", Font.BOLD, 24), plot, true); liveTweetAnalysisChart.setBorderVisible(false); liveTweetAnalysisChart.setBorderPaint(null); ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart); domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS); range.setTickMarksVisible(false); range.setTickLabelInsets(RectangleInsets.ZERO_INSETS); domain.setTickMarksVisible(false); liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS); ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true); liveTweetAnalysisChartPanel.setBorder(null); liveTweetsAnalysisPanel.add(liveTweetAnalysisChartPanel, BorderLayout.CENTER); liveTweetsAnalysisPanel.validate(); }
From source file:beproject.MainGUI.java
void createTimeLine() throws SQLException { TimeSeriesCollection dataset = new TimeSeriesCollection(); getTimeLineData(dataset);//w ww.jav a 2 s.com DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Tweet Count"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesStroke(0, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); renderer.setSeriesStroke(1, new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); domain.setAutoRange(true); domain.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 2, Regression.sdf)); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setTickLabelsVisible(true); plot.setDomainGridlinesVisible(false); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setBaseItemLabelsVisible(true); JFreeChart liveTweetAnalysisChart = new JFreeChart("Rate of tweets per hour", new Font("Tahoma", Font.BOLD, 24), plot, true); liveTweetAnalysisChart.setBorderVisible(false); ChartUtilities.applyCurrentTheme(liveTweetAnalysisChart); domain.setTickLabelInsets(RectangleInsets.ZERO_INSETS); range.setTickMarksVisible(false); range.setTickLabelInsets(RectangleInsets.ZERO_INSETS); domain.setTickMarksVisible(false); liveTweetAnalysisChart.setPadding(RectangleInsets.ZERO_INSETS); ChartPanel liveTweetAnalysisChartPanel = new ChartPanel(liveTweetAnalysisChart, true); liveTweetAnalysisChartPanel.setBorder(null); if (timeLineChart == null) { timeLineChart = liveTweetAnalysisChartPanel; } else { timeLinePanel.remove(timeLineChart); timeLineChart = liveTweetAnalysisChartPanel; } timeLinePanel.add(timeLineChart); timeLinePanel.validate(); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override public void resetAxes(final IScope scope) { NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(); NumberAxis range2Axis = rangeAxis;// w ww . jav a2 s . c om boolean secondaxis = false; if (getUseSecondYAxis(scope)) { secondaxis = true; range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1); if (range2Axis == null) { NumberAxis secondAxis = new NumberAxis(""); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, secondAxis); range2Axis = secondAxis; range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1); range2Axis = formatYAxis(scope, range2Axis); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, range2Axis); } } if (getX_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis); domainAxis = logAxis; } if (getY_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel()); logAxis.setAllowNegativesFlag(true); logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis); ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis); rangeAxis = logAxis; } if (secondaxis) { if (getY2_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(range2Axis.getLabel()); logAxis.setAllowNegativesFlag(true); logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, logAxis); range2Axis = logAxis; } } if (!getUseXRangeInterval(scope) && !getUseXRangeMinMax(scope)) { domainAxis.setAutoRange(true); } if (this.getUseXRangeInterval(scope)) { domainAxis.setFixedAutoRange(getXRangeInterval(scope)); domainAxis.setAutoRangeMinimumSize(getXRangeInterval(scope)); domainAxis.setAutoRange(true); } if (this.getUseXRangeMinMax(scope)) { domainAxis.setRange(getXRangeMin(scope), getXRangeMax(scope)); } if (this.getXTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setDomainGridlinePaint(this.tickColor); if (getXTickUnit(scope) > 0) { domainAxis.setTickUnit(new NumberTickUnit(getXTickUnit(scope))); ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setDomainGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false); } if (!getUseYRangeInterval(scope) && !getUseYRangeMinMax(scope)) { rangeAxis.setAutoRange(true); } if (this.getUseYRangeInterval(scope)) { rangeAxis.setFixedAutoRange(getYRangeInterval(scope)); rangeAxis.setAutoRangeMinimumSize(getYRangeInterval(scope)); rangeAxis.setAutoRange(true); } if (this.getUseYRangeMinMax(scope)) { rangeAxis.setRange(getYRangeMin(scope), getYRangeMax(scope)); } if (this.getYTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor); if (getYTickUnit(scope) > 0) { rangeAxis.setTickUnit(new NumberTickUnit(getYTickUnit(scope))); ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false); } if (secondaxis) { if (!getUseY2RangeInterval(scope) && !getUseY2RangeMinMax(scope)) { range2Axis.setAutoRange(true); } if (this.getUseY2RangeInterval(scope)) { range2Axis.setFixedAutoRange(getY2RangeInterval(scope)); range2Axis.setAutoRangeMinimumSize(getY2RangeInterval(scope)); range2Axis.setAutoRange(true); } if (this.getUseY2RangeMinMax(scope)) { range2Axis.setRange(getY2RangeMin(scope), getY2RangeMax(scope)); } if (this.getYTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor); if (getY2TickUnit(scope) > 0) { range2Axis.setTickUnit(new NumberTickUnit(getY2TickUnit(scope))); ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false); } } if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) { domainAxis.setLabel(getXLabel(scope)); } if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) { rangeAxis.setLabel(getYLabel(scope)); } if (secondaxis) { if (getY2Label(scope) != null && !getY2Label(scope).isEmpty()) { range2Axis.setLabel(getY2Label(scope)); } } if (this.series_label_position.equals("none")) { (this.chart).getLegend().setVisible(false); } if (!this.getXTickValueVisible(scope)) { domainAxis.setTickMarksVisible(false); domainAxis.setTickLabelsVisible(false); } }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis.//from w w w. j a v a 2 s . c o m * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }