List of usage examples for org.jfree.text G2TextMeasurer G2TextMeasurer
public G2TextMeasurer(final Graphics2D g2)
From source file:org.pentaho.plugin.jfreereport.reportcharts.backport.FormattedCategoryAxis.java
protected TextBlock createLabel(final Comparable category, final float width, final RectangleEdge edge, final Graphics2D g2) { return TextUtilities.createTextBlock(format.format(new Object[] { category }), getTickLabelFont(category), getTickLabelPaint(category), width, getMaximumCategoryLabelLines(), new G2TextMeasurer(g2)); }
From source file:com.bdaum.zoom.report.internal.jfree.custom.SparseCategoryAxis.java
@Override protected TextBlock createLabel(@SuppressWarnings("rawtypes") Comparable category, float width, RectangleEdge edge, Graphics2D g2) { return TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category), getTickLabelPaint(category), width * nth, 1, new G2TextMeasurer(g2)); }
From source file:org.jboss.weld.benchmark.charts.Chart.java
/** * Saving a chart to hard disk as png image * * @param path absolute path//from w w w . j a va 2 s . c o m * @return true if no errors occurred */ public Boolean saveImageTo(String path) { try { JFreeChart lineChartObject = ChartFactory.createBarChart(NAME, X_AXIS_NAME, Y_AXIS_NAME, lineChartDataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) lineChartObject.getPlot(); plot.setDomainAxis(new CategoryAxis() { private static final long serialVersionUID = 1L; @Override protected TextBlock createLabel(@SuppressWarnings("rawtypes") Comparable category, float width, RectangleEdge edge, Graphics2D g2) { TextBlock label = TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category), getTickLabelPaint(category), ONE_PART_WIDTH - 30, 2, new G2TextMeasurer(g2)); label.setLineAlignment(HorizontalAlignment.LEFT); return label; } }); File lineChart = new File(path, NAME + ".png"); ChartUtilities.saveChartAsPNG(lineChart, lineChartObject, ONE_PART_WIDTH * lineChartDataset.getColumnCount(), GRAPH_HEIGHT); } catch (IOException e) { e.printStackTrace(); return false; } return true; }
From source file:org.jfree.demo.TextBlockPanel.java
/** * Paints the panel./*from w w w.j av a 2 s . co m*/ * * @param g the graphics device. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; final Dimension size = getSize(); final Insets insets = getInsets(); final Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); final double x = available.getX(); final double y = available.getY(); final float width = (float) available.getWidth(); final TextBlock block = TextUtilities.createTextBlock(this.text, this.font, Color.black, width, new G2TextMeasurer(g2)); g2.setPaint(Color.black); block.draw(g2, (float) x, (float) y, TextBlockAnchor.TOP_LEFT, 0.0f, 0.0f, 0.0); }