List of usage examples for org.jfree.chart.labels ItemLabelAnchor OUTSIDE1
ItemLabelAnchor OUTSIDE1
To view the source code for org.jfree.chart.labels ItemLabelAnchor OUTSIDE1.
Click Source Link
From source file:se.backede.jeconomix.forms.report.TransactionReport.java
public void addLineChart(Map<String, List<TransactionReportDto>> reports, Boolean average) { JFreeChart lineChart = ChartFactory.createLineChart("TOTAL", "MONTH", "Kr", ReportUtils.createDataset(reports, average), PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(lineChart); chartPanel.setPreferredSize(new java.awt.Dimension(lineChartPanel.getWidth(), lineChartPanel.getHeight())); CategoryAxis axis = lineChart.getCategoryPlot().getDomainAxis(); CategoryItemRenderer renderer = lineChart.getCategoryPlot().getRenderer(); ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.HALF_ASCENT_CENTER, TextAnchor.BOTTOM_CENTER, 0); renderer.setBasePositiveItemLabelPosition(position); renderer.setBaseItemLabelGenerator(new CategoryItemLabelGenerator() { @Override/*w w w . j a v a 2s.com*/ public String generateLabel(CategoryDataset dataset, int series, int category) { if (average) { if (series == 0) { Number value = dataset.getValue(series, category); String result = value.toString(); // could apply formatting here return result; } } else { Number value = dataset.getValue(series, category); String result = value.toString(); // could apply formatting here return result; } return null; } @Override public String generateRowLabel(CategoryDataset cd, int i) { return null; } @Override public String generateColumnLabel(CategoryDataset cd, int i) { return null; } }); renderer.setBaseItemLabelsVisible(true); lineChartPanel.setLayout(new BorderLayout()); lineChartPanel.add(chartPanel, BorderLayout.NORTH); }
From source file:edu.indiana.htrc.visual.HTRCBarChartDrawer.java
@Override public File draw() { System.out.println("draw bar!!!!!!!!!!!!!"); DefaultCategoryDataset bar_dataset = new DefaultCategoryDataset(); /*dataset.setValue(6, "Profit", "Jane"); dataset.setValue(7, "Profit", "Tom"); dataset.setValue(8, "Profit", "Jill"); dataset.setValue(5, "Profit", "John"); dataset.setValue(12, "Profit", "Fred");*/ Set<String> key_set = input_map.keySet(); Iterator<String> iter = key_set.iterator(); while (iter.hasNext()) { String key = iter.next(); int value = input_map.get(key); bar_dataset.setValue(value, dataset_label, key); }//w ww . java2 s.com JFreeChart chart = null; if (is3D) { chart = ChartFactory.createBarChart3D(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } else { chart = ChartFactory.createBarChart(chart_name, x_axis_label, y_axis_label, bar_dataset, PlotOrientation.VERTICAL, true, true, false); } CategoryPlot p = chart.getCategoryPlot(); /* NumberAxis rangeAxis = (NumberAxis) p.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());*/ BarRenderer renderer = (BarRenderer) p.getRenderer(); DecimalFormat decimalformat1 = new DecimalFormat("##"); StandardCategoryItemLabelGenerator label_generator = new StandardCategoryItemLabelGenerator("{2}", decimalformat1); renderer.setItemLabelGenerator(label_generator); final ItemLabelPosition pos = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0/* -Math.PI / 2.0*/ ); renderer.setPositiveItemLabelPosition(pos); final CategoryAxis domainAxis = p.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); renderer.setMaximumBarWidth(.15); renderer.setItemLabelsVisible(true); chart.getCategoryPlot().setRenderer(renderer); File img = new File("../webapps/HTRC-UI-AuditAnalyzer/images/" + System.currentTimeMillis() + ".jpg"); try { ChartUtilities.saveChartAsJPEG(img, chart, 1400, 600); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } return img; }
From source file:com.newatlanta.bluedragon.CustomClusteredXYBarRenderer.java
private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar, PlotOrientation orientation) {// ww w . j a v a2 s. c o m Point2D result = null; double offset = getItemLabelAnchorOffset(); double x0 = bar.getX() - offset; double x1 = bar.getX(); double x2 = bar.getX() + offset; double x3 = bar.getCenterX(); double x4 = bar.getMaxX() - offset; double x5 = bar.getMaxX(); double x6 = bar.getMaxX() + offset; double y0 = bar.getMaxY() + offset; double y1 = bar.getMaxY(); double y2 = bar.getMaxY() - offset; double y3 = bar.getCenterY(); double y4 = bar.getMinY() + offset; double y5 = bar.getMinY(); double y6 = bar.getMinY() - offset; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x3, y3); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x4, y3); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x3, y2); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x2, y3); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x3, y4); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x5, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x6, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x6, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x6, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x5, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x3, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x1, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x0, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x0, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x0, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x1, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x3, y6); } return result; }
From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java
/** * Calculates the item label anchor point. * * @param anchor the anchor./* w w w.j a v a 2s .com*/ * @param x the x coordinate. * @param y the y coordinate. * @param orientation the plot orientation. * @return The anchor point (never <code>null</code>). */ @Override protected Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, double x, double y, PlotOrientation orientation) { Point2D result = null; double sizeX = 2.0 * this.itemLabelAnchorOffset; double sizeY = 2.0 * this.itemLabelAnchorOffset; if (currCircle != null) { sizeX = currCircle.getWidth() / 2.0 + this.itemLabelAnchorOffset; sizeY = currCircle.getHeight() / 2.0 + this.itemLabelAnchorOffset; } if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x, y); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x + this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x, y + this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x - this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x, y - this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x + sizeX * OPP, y - sizeY * ADJ); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x + sizeX * ADJ, y - sizeY * OPP); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x + sizeX, y); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x + sizeX * ADJ, y + sizeY * OPP); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x + sizeX * OPP, y + sizeY * ADJ); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x, y + sizeY); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x - sizeX * OPP, y + sizeY * ADJ); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x - sizeX * ADJ, y + sizeY * OPP); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x - sizeX, y); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x - sizeX * ADJ, y - sizeY * OPP); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x - sizeX * OPP, y - sizeY * ADJ); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x, y - sizeY); } return result; }
From source file:org.toobsframework.pres.chart.ChartUtil.java
public static void configureDomainItemLabels(IRequest componentRequest, BasePlot plot, AbstractRenderer renderer, Map params, boolean is3D) { if (plot.getShowDomainItemLabels()) { String orientation = ParameterUtil.resolveParam(componentRequest, plot.getOrientation(), params, "horizontal")[0]; if (orientation.equals("horizontal")) { ItemLabelPosition position1; if (is3D) { position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE2, TextAnchor.CENTER_LEFT); renderer.setItemLabelAnchorOffset(15.0d); } else { position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); }//from w ww. j av a2s .c o m renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setNegativeItemLabelPosition(position2); } else if (orientation.equals("vertical")) { ItemLabelPosition position1; if (is3D) { position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER); renderer.setItemLabelAnchorOffset(10.0d); } else { position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); } renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setNegativeItemLabelPosition(position2); } renderer.setBaseItemLabelsVisible(true); ((CategoryItemRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } }
From source file:KIDLYRenderer.java
/** * Calculates the item label anchor point. * * @param anchor the anchor./*from w ww .java 2s. c o m*/ * @param bar the bar. * @param orientation the plot orientation. * * @return The anchor point. */ private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar, PlotOrientation orientation) { Point2D result = null; double offset = getItemLabelAnchorOffset(); double x0 = bar.getX() - offset; double x1 = bar.getX(); double x2 = bar.getX() + offset; double x3 = bar.getCenterX(); double x4 = bar.getMaxX() - offset; double x5 = bar.getMaxX(); double x6 = bar.getMaxX() + offset; double y0 = bar.getMaxY() + offset; double y1 = bar.getMaxY(); double y2 = bar.getMaxY() - offset; double y3 = bar.getCenterY(); double y4 = bar.getMinY() + offset; double y5 = bar.getMinY(); double y6 = bar.getMinY() - offset; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x3, y3); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x4, y3); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x3, y2); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x2, y3); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x3, y4); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x5, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x6, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x6, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x6, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x5, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x3, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x1, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x0, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x0, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x0, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x1, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x3, y6); } return result; }
From source file:KIDLYAbstractRenderer.java
/** * Calculates the item label anchor point. * * @param anchor the anchor.//from w ww .j a v a 2 s.c om * @param x the x coordinate. * @param y the y coordinate. * @param orientation the plot orientation. * * @return The anchor point (never <code>null</code>). */ protected Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, double x, double y, PlotOrientation orientation) { Point2D result = null; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x, y); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x + this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x, y + this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x - this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x, y - this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x + 2.0 * OPP * this.itemLabelAnchorOffset, y - 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x + 2.0 * ADJ * this.itemLabelAnchorOffset, y - 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x + 2.0 * this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x + 2.0 * ADJ * this.itemLabelAnchorOffset, y + 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x + 2.0 * OPP * this.itemLabelAnchorOffset, y + 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x, y + 2.0 * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x - 2.0 * OPP * this.itemLabelAnchorOffset, y + 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x - 2.0 * ADJ * this.itemLabelAnchorOffset, y + 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x - 2.0 * this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x - 2.0 * ADJ * this.itemLabelAnchorOffset, y - 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x - 2.0 * OPP * this.itemLabelAnchorOffset, y - 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x, y - 2.0 * this.itemLabelAnchorOffset); } return result; }