List of usage examples for org.jfree.ui RectangleAnchor LEFT
RectangleAnchor LEFT
To view the source code for org.jfree.ui RectangleAnchor 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 );//w w w. jav a2 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:org.jfree.chart.demo.XYSeriesDemo3.java
/** * Creates a sample chart./*from w w w.jav a2 s. co m*/ * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createXYBarChart("XY Series Demo", "X", false, "Y", 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; }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java
private JFreeChart createProgressChart(Object dataset) { final double plotGap = 10.0; final int axisUpperBoundPadding = 50; final int labelFontSize = 10; XYDataset data1 = (XYDataset) dataset; XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2)); plot.setGap(plotGap);/*from ww w .j av a 2s.c o m*/ plot.add(subplot1, 1); plot.setOrientation(PlotOrientation.VERTICAL); CountMassnahmen command = new CountMassnahmen(); try { command = ServiceFactory.lookupCommandService().executeCommand(command); } catch (CommandException e) { ExceptionUtil.log(e, Messages.RealisierungLineChart_3); } int totalNum = command.getTotalCount(); NumberAxis axis = (NumberAxis) subplot1.getRangeAxis(); axis.setUpperBound(totalNum + axisUpperBoundPadding); ValueMarker bst = new ValueMarker(totalNum); bst.setPaint(Color.GREEN); bst.setLabel(Messages.RealisierungLineChart_4); bst.setLabelAnchor(RectangleAnchor.LEFT); bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$ bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT); subplot1.addRangeMarker(bst, Layer.BACKGROUND); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:inflor.core.plots.CategoryResponseChart.java
public JFreeChart createChart(FCSFrame dataFrame) { CategoryXYZDataSet categoryData = new CategoryXYZDataSet(); double zMin = Double.MAX_VALUE; double zMax = 1; if (dataFrame.getKeywords().containsKey(FCSUtilities.KEY_MERGE_MAP)) { String[] mergeMap = dataFrame.getKeywordValue(FCSUtilities.KEY_MERGE_MAP) .split(NodeUtilities.DELIMITER_REGEX); FCSDimension dim = dataFrame.getDimension(axisName); double[] transformedData = transform.transform(dim.getData()); int perFileSize = dim.getData().length / mergeMap.length; for (int i = 0; i < mergeMap.length; i++) { double[] unMergedData = new double[perFileSize]; for (int j = 0; j < unMergedData.length; j++) { unMergedData[j] = transformedData[i * unMergedData.length + j]; }//from w w w . j a v a 2 s .co m double tMin = transform.getMinTranformedValue(); double tMax = transform.getMaxTransformedValue(); Histogram1D hist = new Histogram1D(unMergedData, tMin, tMax, ChartingDefaults.BIN_COUNT); double[] x = hist.getNonZeroX(); double[] y = new double[x.length]; for (int j = 0; j < y.length; j++) { y[j] = i; } double[] z = hist.getNonZeroY(); double currentZMin = Doubles.min(z); double currentZMax = Doubles.max(z); if (currentZMin < zMin) { zMin = currentZMin; } else if (currentZMax > zMax) { zMax = currentZMax; } categoryData.addCategoricalSeries(mergeMap[i], x, z); } } else { FCSDimension dim = dataFrame.getDimension(axisName); double[] transformedData = transform.transform(dim.getData()); Histogram1D hist = new Histogram1D(transformedData, transform.getMinTranformedValue(), transform.getMaxTransformedValue(), ChartingDefaults.BIN_COUNT); double[] x = hist.getNonZeroX(); double[] y = new double[x.length]; for (int j = 0; j < y.length; j++) { y[j] = 0; } double[] z = hist.getNonZeroY(); double currentZMin = Doubles.min(z); double currentZMax = Doubles.max(z); if (currentZMin < zMin) { zMin = currentZMin; } else if (currentZMax > zMax) { zMax = currentZMax; } categoryData.addCategoricalSeries(dataFrame.getDisplayName(), x, z); } ValueAxis domainAxis = PlotUtils.createAxis(axisName, transform); NumberAxis rangeAxis = new CategoricalNumberAxis("", categoryData.getLabelMap()); // Renderer configuration XYBlockRenderer renderer = new XYBlockRenderer(); double xWidth = (transform.getMaxTransformedValue() - transform.getMinTranformedValue()) / ChartingDefaults.BIN_COUNT; renderer.setBlockWidth(xWidth); renderer.setBlockHeight(0.5); renderer.setBlockAnchor(RectangleAnchor.LEFT); PaintScale paintScale = PlotUtils.createPaintScale(zMax, ChartingDefaults.DEFAULT_COLOR_SCHEME); renderer.setPaintScale(paintScale); // Add to panel. XYPlot responsePlot = new XYPlot(categoryData, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(responsePlot); chart.removeLegend(); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo2.java
/** * Creates a chart.// w ww . j a v a2 s .com * * @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.//from w w w . j a v a 2s. 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./* w w w.j a va 2s . 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 om * * @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:wef.articulab.view.ui.BNXYPlot.java
/** * Creates an overlaid chart./*from w w w. ja v a 2 s .c o m*/ * * @return The chart. */ private JFreeChart createChart() { createDataset(); final JFreeChart chart = ChartFactory.createXYLineChart("Real Time Network Dynamics", "Time", "Activation", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); target = new IntervalMarker(14, 16); target.setLabel("Activation Threshold"); 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); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); BasicStroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); for (int i = 0; i < series.length - 1; i++) { renderer.setSeriesStroke(i, stroke); } renderer.setSeriesStroke(series.length - 1, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f)); plot.setRenderer(renderer); return chart; }
From source file:reports.util.BarChart2Scriptlet.java
/** * *//*from www . j a va 2 s. c om*/ public void afterReportInit() throws JRScriptletException { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", // chart title "States", // X Label "Sell Amount", // Y Label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = jfreechart.getCategoryPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0); legendtitle.setPosition(RectangleEdge.RIGHT); legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D)); IntervalMarker intervalmarker = new IntervalMarker(200D, 250D); intervalmarker.setLabel("Target Range"); intervalmarker.setLabelFont(new Font("SansSerif", 2, 11)); intervalmarker.setLabelAnchor(RectangleAnchor.LEFT); intervalmarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); intervalmarker.setPaint(new Color(222, 222, 255, 128)); categoryplot.addRangeMarker(intervalmarker, Layer.BACKGROUND); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setItemMargin(0.10000000000000001D); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setItemLabelGenerator(new LabelGenerator()); barrenderer.setItemLabelsVisible(true); //ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -1.5707963267948966D); //barrenderer.setPositiveItemLabelPosition(itemlabelposition); ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.5707963267948966D); barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); /* */ this.setVariableValue("Chart", new JCommonDrawableRenderer(jfreechart)); }