List of usage examples for org.jfree.text TextBlockAnchor CENTER_LEFT
TextBlockAnchor CENTER_LEFT
To view the source code for org.jfree.text TextBlockAnchor CENTER_LEFT.
Click Source Link
From source file:edu.coeia.charts.BarChartPanel.java
private JFreeChart createChart(final CategoryDataset dataset, String str) { final JFreeChart chart = ChartFactory.createBarChart3D(str, // chart title "Names", // domain axis label "Values(%)", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips false // urls );//ww w .j a v a 2 s . c o m final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... final CategoryAxis axis = plot.getDomainAxis(); final CategoryLabelPositions p = axis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(from, to); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo2.java
/** * Creates a chart./* w w w . j a v a2 s . c om*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... CategoryAxis axis = plot.getDomainAxis(); CategoryLabelPositions p = axis.getCategoryLabelPositions(); CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:org.jfree.chart.demo.SurveyResultsDemo3.java
/** * Creates a chart./*w w w. ja va2 s . co m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, false); chart.setBackgroundPaint(Color.white); chart.getPlot().setOutlinePaint(null); final TextTitle title = new TextTitle("Figure 6 | Overall SEO Rating"); title.setHorizontalAlignment(HorizontalAlignment.LEFT); title.setBackgroundPaint(Color.red); title.setPaint(Color.white); chart.setTitle(title); final CategoryPlot plot = chart.getCategoryPlot(); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setRange(0.0, 4.0); rangeAxis.setVisible(false); final ExtendedCategoryAxis domainAxis = new ExtendedCategoryAxis(null); domainAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12)); domainAxis.setCategoryMargin(0.30); domainAxis.addSubLabel("Sm.", "(10)"); domainAxis.addSubLabel("Med.", "(10)"); domainAxis.addSubLabel("Lg.", "(10)"); domainAxis.addSubLabel("All", "(10)"); final CategoryLabelPositions p = domainAxis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); plot.setDomainAxis(domainAxis); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A)); renderer.setBaseOutlineStroke(null); // final StandardCategoryLabelGenerator generator = new StandardCategoryLabelGenerator( // "{2}", new DecimalFormat("0.00") // ); // renderer.setLabelGenerator(generator); renderer.setItemLabelsVisible(true); renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 18)); final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setPositiveItemLabelPosition(position); renderer.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); return chart; }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of a Comparative Response Model * Histogram./*from w w w . java 2 s . c o m*/ * * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param dataBefore * The array of values before the response. * @param dataAfter * The array of values after the response. * @return a chart panel with the graphical representation. */ public static ChartPanel createDailyResponseHistogram(String title, String x, String y, double[] dataBefore, double[] dataAfter) { final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < dataBefore.length; i++) { dataset.addValue(dataBefore[i], "Basic Scheme", "" + i + ""); if (i < dataAfter.length) dataset.addValue(dataAfter[i], "New Scheme", "" + i + ""); else dataset.addValue(0, "New Scheme", "" + i + ""); } JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title x, // domain axis label y, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... final CategoryAxis axis = plot.getDomainAxis(); final CategoryLabelPositions p = axis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); return new ChartPanel(chart); }
From source file:j2se.jfreechart.barchart.BarChart3DDemo2.java
/** * Creates a chart.//from www . j a v a 2 s . c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo 2", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... final CategoryAxis axis = plot.getDomainAxis(); final CategoryLabelPositions p = axis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void testCreateUpRotationCategoryLabelPosition() { TestableCategoricalChartExpression e = new TestableCategoricalChartExpression(); {// w w w . j av a2 s . co m CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 0.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, -90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 180.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 0.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, -90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 180.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP, 0.0); Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, 0.0); Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } }
From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java
/** * @return the categoryAxis/*from w w w . ja v a2 s .c o m*/ */ private CategoryAxis getCategoryAxis() { if (categoryAxis == null) { categoryAxis = new CategoryAxis(); categoryAxis.setMaximumCategoryLabelWidthRatio(0.2f); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition( CategoryLabelPositions.STANDARD, new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1.0f))); } return categoryAxis; }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Create the JFreeChart.//from w w w . j a va 2s .c o m * @param dataset * task list for the JFreeChart. * @return JFreeChart of tasks. */ private JFreeChart createChart(final IntervalCategoryDataset dataset) { final JFreeChart chart = ChartFactory.createGanttChart("", "", "", dataset, true, false, false); chart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.4); chart.getCategoryPlot().getDomainAxis().setLowerMargin(0); chart.getCategoryPlot().getDomainAxis().setUpperMargin(0); chart.getCategoryPlot().getDomainAxis().setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().getDomainAxis().setTickLabelInsets(new RectangleInsets(0, 0, 0, 0)); chart.getCategoryPlot().getDomainAxis() .setCategoryLabelPositions(new CategoryLabelPositions( new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1))); return chart; }
From source file:hr.restart.util.chart.ChartXY.java
/** * Creates a BAR CHART/*from ww w .java 2s. c o m*/ * @param dataset The org.jfree.data.CategoryDataset * @param title The title * @return org.jfree.chart.JFreeChart */ private JFreeChart createBarChart(final CategoryDataset dataset, String title, PlotOrientation orientation) { final JFreeChart chart = ChartFactory.createBarChart(title, // chart title "", // domain axis label "", // range axis label dataset, // data orientation, // the plot orientation false, // include legend true, false); chart.setBackgroundPaint(Color.white); // the subtitle from the combobox if (jcb != null) chart.addSubtitle(new TextTitle(jcb.getSelectedItem().toString())); //subtitles setted by the user. if (getSubtitles() != null) for (int i = 0; i < getSubtitles().size(); i++) { chart.addSubtitle(new TextTitle(getSubtitles().get(i).toString())); } final Plot plot = chart.getPlot(); // get a reference to the plot for further customisation... final CategoryPlot categoryPlot = (CategoryPlot) plot; categoryPlot.setNoDataMessage("NO DATA!"); categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); categoryPlot.setRenderer(renderer); renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); // inside //renderer.setBaseItemLabelPaint(Color.white); Font font = new Font("SansSerif", Font.PLAIN, 7); Font derive = font.deriveFont(Font.BOLD); renderer.setBaseItemLabelFont(derive); // margin final CategoryAxis domainAxis = categoryPlot.getDomainAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); //domainAxis.setBottomCategoryLabelPosition(new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER)); domainAxis.setCategoryLabelPositions(new CategoryLabelPositions( new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER), // TOP new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER), // BOTTOM new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 0.30f), // LEFT new CategoryLabelPosition(RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT, CategoryLabelWidthType.RANGE, 0.30f) // RIGHT) )); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 0.0); renderer.setPositiveItemLabelPosition(p); if (comboBoxOrientation != null) { if (comboBoxOrientation.getSelectedItem() == "Vertikalni") { domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); } } return chart; }
From source file:com.afunms.system.manage.equipManager.java
/** * Creates a chart.//from www . j a v a 2s . co m * * @param dataset * the dataset. * * @return The chart. */ private JFreeChart _createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("IP", // chart // title "IP", // domain axis label "", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... final CategoryAxis axis = plot.getDomainAxis(); final CategoryLabelPositions p = axis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); return chart; }