Java Code Examples for org.jfree.chart.util.GradientPaintTransformer#transform()
The following examples show how to use
org.jfree.chart.util.GradientPaintTransformer#transform() .
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: StandardXYBarPainter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param selected is the data item selected? * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. * * @since 1.2.0 */ public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, boolean selected, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column, selected); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (renderer.isDrawBarOutline()) { // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = renderer.getItemOutlineStroke(row, column, selected); Paint paint = renderer.getItemOutlinePaint(row, column, selected); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }
Example 2
Source File: StandardBarPainter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param selected is the item selected? * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, boolean selected, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column, selected); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (renderer.isDrawBarOutline()) { // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = renderer.getItemOutlineStroke(row, column, selected); Paint paint = renderer.getItemOutlinePaint(row, column, selected); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }
Example 3
Source File: BarRenderer.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], dataArea, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], dataArea, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.max(Math.abs(transL1 - transL0), getMinimumBarLength()); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); GradientPaintTransformer t = getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } }