Java Code Examples for org.jfree.chart.axis.NumberAxis#setTickUnit()

The following examples show how to use org.jfree.chart.axis.NumberAxis#setTickUnit() . 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: TaChart.java    From TAcharting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns a plot with the given indicators plotted
 * @param chartIndicator org.sjwimmer.tacharting.chart indicators for the plot
 * @return a XYPlot with the indicators as plots
 */
private XYPlot createSubplotFor(ChartIndicator chartIndicator){

    NumberAxis numberAxis = new NumberAxis();

    numberAxis.setLabelFont(new Font("NumberAxisLabelFont",Font.BOLD,8));
    numberAxis.setTickLabelPaint(Color.GRAY);
    numberAxis.setLabelPaint(Color.GRAY);
    numberAxis.setTickUnit(new NumberTickUnit(0.5));
    numberAxis.setTickLabelFont(new Font("NumberAxisBarFont",Font.BOLD,8));
    numberAxis.setAutoTickUnitSelection(true);
    XYPlot indicatorPlot = new XYPlot(chartIndicator.getDataSet(), mainPlot.getDomainAxis(), numberAxis, chartIndicator.getRenderer());
    indicatorPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    return indicatorPlot;
}
 
Example 2
Source File: ChartUtil.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setAutoTickUnit(NumberAxis numberAxis)
{
	if (numberAxis.isAutoTickUnitSelection())
	{
		Range range = numberAxis.getRange();
		if (range.getLength() >= AUTO_TICK_UNIT_THRESHOLD)
		{
			// this is a workaround for a floating point error makes JFreeChart
			// select tick units that are too small when the values are very large
			double autoSize = range.getLength() / AUTO_TICK_UNIT_THRESHOLD;
			TickUnit unit = numberAxis.getStandardTickUnits().getCeilingTickUnit(autoSize);
			numberAxis.setTickUnit((NumberTickUnit) unit, false, false);
		}
	}
}
 
Example 3
Source File: DefaultNumberAxisEditor.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
 
Example 4
Source File: TICVisualizerWindow.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax,
    double yTickSize) {
  NumberAxis xAxis = (NumberAxis) ticPlot.getXYPlot().getDomainAxis();
  NumberAxis yAxis = (NumberAxis) ticPlot.getXYPlot().getRangeAxis();
  xAxis.setRange(xMin, xMax);
  xAxis.setTickUnit(new NumberTickUnit(xTickSize));
  yAxis.setRange(yMin, yMax);
  yAxis.setTickUnit(new NumberTickUnit(yTickSize));
}
 
Example 5
Source File: SpectraVisualizerWindow.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax,
    double yTickSize) {
  NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis();
  NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis();
  xAxis.setRange(xMin, xMax);
  xAxis.setTickUnit(new NumberTickUnit(xTickSize));
  yAxis.setRange(yMin, yMax);
  yAxis.setTickUnit(new NumberTickUnit(yTickSize));
}
 
Example 6
Source File: DefaultNumberAxisEditor.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
 
Example 7
Source File: DefaultNumberAxisEditor.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
 
Example 8
Source File: AbstractAxisCustomizer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void configNumberAxis(
	NumberAxis numberAxis,
	String tickUnitProp
	) 
{
	if (numberAxis != null)
	{
		Double tickUnit = getDoubleProperty(tickUnitProp);
		if (tickUnit != null)
		{
			numberAxis.setTickUnit(new NumberTickUnit(tickUnit));
		}
	}
}
 
Example 9
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));

    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));

    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));

}
 
Example 10
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));
    
    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));
    
    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));
    
}
 
Example 11
Source File: DefaultNumberAxisEditor.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
 
Example 12
Source File: DefaultNumberAxisEditor.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
 
Example 13
Source File: TICVisualizerWindow.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax,
    double yTickSize) {
  NumberAxis xAxis = (NumberAxis) ticPlot.getXYPlot().getDomainAxis();
  NumberAxis yAxis = (NumberAxis) ticPlot.getXYPlot().getRangeAxis();
  xAxis.setRange(xMin, xMax);
  xAxis.setTickUnit(new NumberTickUnit(xTickSize));
  yAxis.setRange(yMin, yMax);
  yAxis.setTickUnit(new NumberTickUnit(yTickSize));
}
 
Example 14
Source File: SpectraVisualizerWindow.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax,
    double yTickSize) {
  NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis();
  NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis();
  xAxis.setRange(xMin, xMax);
  xAxis.setTickUnit(new NumberTickUnit(xTickSize));
  yAxis.setRange(yMin, yMax);
  yAxis.setTickUnit(new NumberTickUnit(yTickSize));
}
 
Example 15
Source File: TrafficLoadLineChart.java    From EdgeSim with MIT License 4 votes vote down vote up
public TrafficLoadLineChart() {	
		this.collection = this.getCollection();
		initial();
		this.chart = ChartFactory.createXYLineChart(
				null, 
				"Time Slice",
				"Traffic Load(100GB)", 
				collection, 
				PlotOrientation.VERTICAL, 
				true, 
				true, 
				false
		);
		this.chart.getPlot().setBackgroundPaint(SystemColor.white);
		LegendTitle legend = chart.getLegend();
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

		

		
		XYPlot plot = (XYPlot) chart.getPlot();		
		
		NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis();
		numberAxisX.setAutoRangeIncludesZero(false);
		
		numberAxisX.setAutoRangeMinimumSize(0.1);
		numberAxisX.setAxisLineVisible(false);
		numberAxisX.setTickMarkInsideLength(4f);
		numberAxisX.setTickMarkOutsideLength(0);
		
		
		NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis();
		numberAxisY.setTickUnit(new NumberTickUnit(5));
		numberAxisY.setRangeWithMargins(0,40);
		numberAxisY.setAutoRangeIncludesZero(true);
		numberAxisY.setAxisLineVisible(false);
		numberAxisY.setTickMarkInsideLength(4f);
		numberAxisY.setTickMarkOutsideLength(0);
		numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance());

		
		
		XYLineAndShapeRenderer renderer =  (XYLineAndShapeRenderer)plot.getRenderer();
		renderer.setDefaultItemLabelsVisible(true);
		renderer.setDefaultShapesVisible(true);
		renderer.setDrawOutlines(true);
			
		renderer.setSeriesOutlineStroke(0, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(1, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(2, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(3, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(4, new BasicStroke(5F));



			
		renderer.setSeriesPaint(1, Color.RED);
		renderer.setSeriesPaint(2, new Color(53,101,253));
		renderer.setSeriesPaint(3, new Color(0,161,59));//����ɫ
		renderer.setSeriesPaint(4, new Color(148,103,189));//��ɫ
		renderer.setSeriesPaint(0, new Color(255,125,11));//�ٻ�ɫ

			

		renderer.setSeriesStroke(0, new BasicStroke(4.0F));
		renderer.setSeriesStroke(1, new BasicStroke(4.0F));
		renderer.setSeriesStroke(2, new BasicStroke(4.0F));
		renderer.setSeriesStroke(3, new BasicStroke(4.0F));
		renderer.setSeriesStroke(4, new BasicStroke(2.0F));
		renderer.setSeriesStroke(5, new BasicStroke(2.0F));




//		renderer.setUseFillPaint(true);
		
		
		this.chartFrame = new ChartFrame("Line Chart", chart);
		chartFrame.pack();
		chartFrame.setSize(1600,1200);
		chartFrame.setLocation(300,200);
		chartFrame.setVisible(true);
	}
 
Example 16
Source File: BaseLineChart.java    From EdgeSim with MIT License 4 votes vote down vote up
protected void generateLineChart(String xAisTitle, String yAisTitle,
									 NumberTickUnit xAisSpace, NumberTickUnit yAisSpace, double yaisMinValue, double yAisMaxValue,
									 XYSeriesCollection collection) {
		this.chart = ChartFactory.createXYLineChart(null, xAisTitle, yAisTitle,
				collection, PlotOrientation.VERTICAL, true, true, false);

		this.chart.getPlot().setBackgroundPaint(SystemColor.white);

		LegendTitle legend = chart.getLegend();
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

		XYPlot plot = (XYPlot) chart.getPlot();
		NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis();
		numberAxisX.setAutoRangeIncludesZero(false);

		numberAxisX.setTickUnit(xAisSpace);
		numberAxisX.setAxisLineVisible(false);
		numberAxisX.setTickMarkInsideLength(4f);
		numberAxisX.setTickMarkOutsideLength(0);

		NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis();
		numberAxisY.setTickUnit(yAisSpace);
		numberAxisY.setRangeWithMargins(yaisMinValue, yAisMaxValue);
		numberAxisY.setAutoRangeIncludesZero(true);
		numberAxisY.setAxisLineVisible(false);
		numberAxisY.setTickMarkInsideLength(4f);
		numberAxisY.setTickMarkOutsideLength(0);
		numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance());

		XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot
				.getRenderer();
//		renderer.setBaseItemLabelsVisible(true);
		renderer.setDefaultItemLabelsVisible(true);
		renderer.setDefaultShapesVisible(true);
//		renderer.setBaseShapesVisible(true);
		renderer.setDrawOutlines(true);

		renderer.setSeriesOutlineStroke(0, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(1, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(2, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(3, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(4, new BasicStroke(5F));

		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesPaint(1, Color.BLUE);
		renderer.setSeriesPaint(2, new Color(255, 125, 11));
		renderer.setSeriesPaint(3, new Color(0, 161, 59));
		renderer.setSeriesPaint(4, new Color(148, 103, 189));

		renderer.setSeriesStroke(0, new BasicStroke(4.0F));
		renderer.setSeriesStroke(1, new BasicStroke(4.0F));
		renderer.setSeriesStroke(2, new BasicStroke(4.0F));
		renderer.setSeriesStroke(3, new BasicStroke(4.0F));
		renderer.setSeriesStroke(4, new BasicStroke(2.0F));
		renderer.setSeriesStroke(5, new BasicStroke(2.0F));

		// renderer.setUseFillPaint(true);

		this.chartFrame = new ChartFrame("Line Chart", chart);
		chartFrame.pack();
		chartFrame.setSize(800, 600);
		chartFrame.setLocation(300, 200);
		chartFrame.setVisible(true);
	}
 
Example 17
Source File: AggregationExecutionChartBuilder.java    From livingdoc-confluence with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = ( CategoryPlot ) chart.getPlot();
    plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);

    int index = 0;
    renderer.setSeriesPaint(index ++ , GREEN_COLOR);
    if (settings.isShowIgnored()) {
        renderer.setSeriesPaint(index ++ , Color.yellow);
    }
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        @Override
        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable< ? > valueKey = data.getColumnKey(category);
            ChartLongValue value = ( ChartLongValue ) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = ( NumberAxis ) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}
 
Example 18
Source File: NumberLineChart.java    From EdgeSim with MIT License 4 votes vote down vote up
public NumberLineChart() {	
		this.collection = this.getCollection();
		initial();
		this.chart = ChartFactory.createXYLineChart(
				null, 
				"Request",
				"Hit Rate", 
				collection, 
				PlotOrientation.VERTICAL, 
				true, 
				true, 
				false
		);
		
		this.chart.getPlot().setBackgroundPaint(SystemColor.white);
		LegendTitle legend = chart.getLegend();
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

		

		
		XYPlot plot = (XYPlot) chart.getPlot();		
		
		NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis();
		numberAxisX.setTickUnit(new NumberTickUnit(500));
//		numberAxisX.setAutoRangeMinimumSize(0.1);
		numberAxisX.setAutoRangeIncludesZero(true);
		numberAxisX.setAxisLineVisible(false);
		numberAxisX.setTickMarkInsideLength(4f);
		numberAxisX.setTickMarkOutsideLength(0);

		
		
		NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis();
		numberAxisY.setTickUnit(new NumberTickUnit(0.2));
		numberAxisY.setRangeWithMargins(0,1);
		numberAxisY.setAutoRangeIncludesZero(true);
		numberAxisY.setAxisLineVisible(false);
		numberAxisY.setTickMarkInsideLength(4f);
		numberAxisY.setTickMarkOutsideLength(0);
		// ����Y������Ϊ�ٷֱ�
		numberAxisY.setNumberFormatOverride(NumberFormat.getPercentInstance());
		
		
		
		XYItemRenderer xyitem = plot.getRenderer();   
        xyitem.setDefaultItemLabelsVisible(true);
//        ItemLabelsVisible(true);

		xyitem.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
//        xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
//        xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 12));
		xyitem.setDefaultItemLabelFont(new Font("Dialog", 1, 12));
        plot.setRenderer(xyitem);
		
		 	XYLineAndShapeRenderer renderer =  (XYLineAndShapeRenderer)plot.getRenderer();
			renderer.setDefaultItemLabelsVisible(true);
			renderer.setDefaultShapesVisible(true);
			renderer.setDrawOutlines(true);
			
			renderer.setSeriesOutlineStroke(0, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(1, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(2, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(3, new BasicStroke(5F));


			
			renderer.setSeriesPaint(0, Color.RED);
			renderer.setSeriesPaint(1, new Color(53,101,253));
			renderer.setSeriesPaint(2, new Color(0,161,59));//����ɫ
			renderer.setSeriesPaint(3, new Color(148,103,189));//��ɫ
			

			renderer.setSeriesStroke(0, new BasicStroke(4.0F));
			renderer.setSeriesStroke(1, new BasicStroke(4.0F));
			renderer.setSeriesStroke(2, new BasicStroke(4.0F));
			renderer.setSeriesStroke(3, new BasicStroke(4.0F));
			renderer.setSeriesStroke(4, new BasicStroke(2.0F));
			renderer.setSeriesStroke(5, new BasicStroke(2.0F));
		
			this.chartFrame = new ChartFrame("Line Chart", chart);
			chartFrame.pack();
			chartFrame.setSize(1600,1200);
			chartFrame.setLocation(300,200);
			chartFrame.setVisible(true);
	}
 
Example 19
Source File: MonitoringPage.java    From webanno with Apache License 2.0 4 votes vote down vote up
private JFreeChart createProgressChart(Map<String, Integer> chartValues, int aMaxValue,
        boolean aIsPercentage)
{
    // fill dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (aMaxValue > 0) {
        for (String chartValue : chartValues.keySet()) {
            dataset.setValue(chartValues.get(chartValue), "Completion", chartValue);
        }
    }
    
    // create chart
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset,
            PlotOrientation.HORIZONTAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(null);
    plot.setNoDataMessage("No data");
    plot.setInsets(new RectangleInsets(0, 20, 0, 20));
    if (aMaxValue > 0) {
        plot.getRangeAxis().setRange(0.0, aMaxValue);
        ((NumberAxis) plot.getRangeAxis()).setNumberFormatOverride(new DecimalFormat("0"));
        // For documents less than 10, avoid repeating the number of documents such
        // as 0 0 1 1 1 - NumberTickUnit automatically determines the range
        if (!aIsPercentage && aMaxValue <= 10) {
            TickUnits standardUnits = new TickUnits();
            NumberAxis tick = new NumberAxis();
            tick.setTickUnit(new NumberTickUnit(1));
            standardUnits.add(tick.getTickUnit());
            plot.getRangeAxis().setStandardTickUnits(standardUnits);
        }
    }
    else {
        plot.getRangeAxis().setVisible(false);
        plot.getDomainAxis().setVisible(false);
    }

    BarRenderer renderer = new BarRenderer();
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    // renderer.setGradientPaintTransformer(new
    // StandardGradientPaintTransformer(
    // GradientPaintTransformType.HORIZONTAL));
    renderer.setSeriesPaint(0, Color.BLUE);
    chart.getCategoryPlot().setRenderer(renderer);

    return chart;
}
 
Example 20
Source File: ScatterPlot.java    From Benchmark with GNU General Public License v2.0 4 votes vote down vote up
public void initializePlot( XYPlot xyplot ) {
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    rangeAxis.setRange(-9.99, 109.99);
    rangeAxis.setNumberFormatOverride(pctFormat);
    rangeAxis.setTickLabelPaint(Color.decode("#666666"));
    rangeAxis.setMinorTickCount(5);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setAxisLineVisible(true);
    rangeAxis.setMinorTickMarksVisible(true);
    rangeAxis.setTickMarksVisible(true);
    rangeAxis.setLowerMargin(10);
    rangeAxis.setUpperMargin(10);
    
    domainAxis.setRange(-5, 175);
    domainAxis.setNumberFormatOverride(pctFormat);
    domainAxis.setTickLabelPaint(Color.decode("#666666"));
    domainAxis.setMinorTickCount(5);
    domainAxis.setTickUnit(new NumberTickUnit(10));
    domainAxis.setAxisLineVisible(true);
    domainAxis.setTickMarksVisible(true);
    domainAxis.setMinorTickMarksVisible(true);
    domainAxis.setLowerMargin(10);
    domainAxis.setUpperMargin(10);
    
    xyplot.setRangeGridlineStroke(new BasicStroke());
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setRangeMinorGridlinesVisible(true);
    xyplot.setOutlineVisible(true);
    xyplot.setDomainGridlineStroke(new BasicStroke());
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setDomainMinorGridlinesVisible(true);
    xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7"));

    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
    chart.removeLegend();
    chart.setPadding(new RectangleInsets(20, 20, 20, 20));
    
    Point2D legendLocation = new Point2D.Double( 101, -10 );
    makeRect(xyplot, legendLocation, 120, 74, Color.WHITE );
   
    Point2D triangleLocation = new Point2D.Double( 101, -10 );
    Color grey = new Color(0.1f,0.1f,0.1f,0.1f);
    makeTriangle(xyplot, triangleLocation, grey );
    
    makeGuessingLine( xyplot );
}