Example usage for java.awt.geom Rectangle2D getWidth

List of usage examples for java.awt.geom Rectangle2D getWidth

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getWidth.

Prototype

public abstract double getWidth();

Source Link

Document

Returns the width of the framing rectangle in double precision.

Usage

From source file:org.jfree.chart.demo.CylinderRenderer.java

public void drawItem(Graphics2D graphics2d, CategoryItemRendererState categoryitemrendererstate,
        Rectangle2D rectangle2d, CategoryPlot categoryplot, CategoryAxis categoryaxis, ValueAxis valueaxis,
        CategoryDataset categorydataset, int i, int j, int k) {
    Number number = categorydataset.getValue(i, j);
    if (number == null)
        return;/*  w  w  w.j a  va2s  .  c  o  m*/
    double d = number.doubleValue();
    java.awt.geom.Rectangle2D.Double double1 = new java.awt.geom.Rectangle2D.Double(rectangle2d.getX(),
            rectangle2d.getY() + getYOffset(), rectangle2d.getWidth() - getXOffset(),
            rectangle2d.getHeight() - getYOffset());
    PlotOrientation plotorientation = categoryplot.getOrientation();
    double d1 = calculateBarW0(categoryplot, plotorientation, double1, categoryaxis, categoryitemrendererstate,
            i, j);
    double ad[] = calculateBarL0L1(d);
    if (ad == null)
        return;
    RectangleEdge rectangleedge = categoryplot.getRangeAxisEdge();
    float f = (float) valueaxis.valueToJava2D(ad[0], double1, rectangleedge);
    float f1 = (float) valueaxis.valueToJava2D(ad[1], double1, rectangleedge);
    float f2 = Math.min(f, f1);
    float f3 = Math.abs(f1 - f);
    GeneralPath generalpath = new GeneralPath();
    java.awt.geom.Ellipse2D.Double double2 = null;
    if (plotorientation == PlotOrientation.HORIZONTAL) {
        generalpath.moveTo((float) ((double) f2 + getXOffset() / 2D), (float) d1);
        generalpath.lineTo((float) ((double) (f2 + f3) + getXOffset() / 2D), (float) d1);
        java.awt.geom.Arc2D.Double double3 = new java.awt.geom.Arc2D.Double(f2 + f3, d1, getXOffset(),
                categoryitemrendererstate.getBarWidth(), 90D, 180D, 0);
        generalpath.append(double3, true);
        generalpath.lineTo((float) ((double) f2 + getXOffset() / 2D),
                (float) (d1 + categoryitemrendererstate.getBarWidth()));
        double3 = new java.awt.geom.Arc2D.Double(f2, d1, getXOffset(), categoryitemrendererstate.getBarWidth(),
                270D, -180D, 0);
        generalpath.append(double3, true);
        generalpath.closePath();
        double2 = new java.awt.geom.Ellipse2D.Double(f2 + f3, d1, getXOffset(),
                categoryitemrendererstate.getBarWidth());
    } else {
        generalpath.moveTo((float) d1, (float) ((double) f2 - getYOffset() / 2D));
        generalpath.lineTo((float) d1, (float) ((double) (f2 + f3) - getYOffset() / 2D));
        java.awt.geom.Arc2D.Double double4 = new java.awt.geom.Arc2D.Double(d1,
                (double) (f2 + f3) - getYOffset(), categoryitemrendererstate.getBarWidth(), getYOffset(), 180D,
                180D, 0);
        generalpath.append(double4, true);
        generalpath.lineTo((float) (d1 + categoryitemrendererstate.getBarWidth()),
                (float) ((double) f2 - getYOffset() / 2D));
        double4 = new java.awt.geom.Arc2D.Double(d1, (double) f2 - getYOffset(),
                categoryitemrendererstate.getBarWidth(), getYOffset(), 0.0D, -180D, 0);
        generalpath.append(double4, true);
        generalpath.closePath();
        double2 = new java.awt.geom.Ellipse2D.Double(d1, (double) f2 - getYOffset(),
                categoryitemrendererstate.getBarWidth(), getYOffset());
    }
    Object obj = getItemPaint(i, j);
    if (getGradientPaintTransformer() != null && (obj instanceof GradientPaint)) {
        GradientPaint gradientpaint = (GradientPaint) obj;
        obj = getGradientPaintTransformer().transform(gradientpaint, generalpath);
    }
    graphics2d.setPaint(((java.awt.Paint) (obj)));
    graphics2d.fill(generalpath);
    if (obj instanceof GradientPaint) {
        graphics2d.setPaint(((GradientPaint) obj).getColor2());
    }
    if (double2 != null) {
        graphics2d.fill(double2);
    }
    if (isDrawBarOutline() && categoryitemrendererstate.getBarWidth() > 3D) {
        graphics2d.setStroke(getItemOutlineStroke(i, j));
        graphics2d.setPaint(getItemOutlinePaint(i, j));
        graphics2d.draw(generalpath);
        if (double2 != null)
            graphics2d.draw(double2);
    }
    CategoryItemLabelGenerator categoryitemlabelgenerator = getItemLabelGenerator(i, j);
    if (categoryitemlabelgenerator != null && isItemLabelVisible(i, j))
        drawItemLabel(graphics2d, categorydataset, i, j, categoryplot, categoryitemlabelgenerator,
                generalpath.getBounds2D(), d < 0.0D);
    if (categoryitemrendererstate.getInfo() != null) {
        EntityCollection entitycollection = categoryitemrendererstate.getEntityCollection();
        if (entitycollection != null) {
            String s = null;
            CategoryToolTipGenerator categorytooltipgenerator = getToolTipGenerator(i, j);
            if (categorytooltipgenerator != null)
                s = categorytooltipgenerator.generateToolTip(categorydataset, i, j);
            String s1 = null;
            if (getItemURLGenerator(i, j) != null)
                s1 = getItemURLGenerator(i, j).generateURL(categorydataset, i, j);
            CategoryItemEntity categoryitementity = new CategoryItemEntity(generalpath.getBounds2D(), s, s1,
                    categorydataset, categorydataset.getRowKey(i), categorydataset.getColumnKey(j));
            entitycollection.add(categoryitementity);
        }
    }
}

From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

private void updateToolTipLocation() {
    if (!toolTip.isVisible()) {
        return;//from w  ww  .  j  a va  2  s. c  om
    }
    XYPlot plot = chart.getXYPlot();
    Rectangle2D chartArea = cp.getScreenDataArea();
    if (chartArea.getWidth() == 0) {
        // no idea why that happens
        return;
    }
    double vx = plot.getDomainAxis().valueToJava2D(this.toolTipValue, chartArea, plot.getDomainAxisEdge());
    if (vx + toolTip.getWidth() > cp.getScreenDataArea().getMaxX()) {
        toolTip.setLocation((int) vx - toolTip.getWidth(), 10);
    } else {
        toolTip.setLocation((int) vx, 10);
    }
}

From source file:org.apache.fop.render.pcl.PCLPainter.java

private void drawTextAsBitmap(final int x, final int y, final int letterSpacing, final int wordSpacing,
        final int[] dx, final String text, FontTriplet triplet) throws IFException {
    //Use Java2D to paint different fonts via bitmap
    final Font font = parent.getFontInfo().getFontInstance(triplet, state.getFontSize());

    //for cursive fonts, so the text isn't clipped
    final FontMetricsMapper mapper = (FontMetricsMapper) parent.getFontInfo().getMetricsFor(font.getFontName());
    final int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000;
    final int ascent = mapper.getAscender(font.getFontSize()) / 1000;
    final int descent = mapper.getDescender(font.getFontSize()) / 1000;
    int safetyMargin = (int) (SAFETY_MARGIN_FACTOR * font.getFontSize());
    final int baselineOffset = maxAscent + safetyMargin;

    final Rectangle boundingBox = getTextBoundingBox(x, y, letterSpacing, wordSpacing, dx, text, font, mapper);
    final Dimension dim = boundingBox.getSize();

    Graphics2DImagePainter painter = new Graphics2DImagePainter() {

        public void paint(Graphics2D g2d, Rectangle2D area) {
            if (DEBUG) {
                g2d.setBackground(Color.LIGHT_GRAY);
                g2d.clearRect(0, 0, (int) area.getWidth(), (int) area.getHeight());
            }/*from   w  w w  .j av  a2 s .co m*/
            g2d.translate(-x, -y + baselineOffset);

            if (DEBUG) {
                Rectangle rect = new Rectangle(x, y - maxAscent, 3000, maxAscent);
                g2d.draw(rect);
                rect = new Rectangle(x, y - ascent, 2000, ascent);
                g2d.draw(rect);
                rect = new Rectangle(x, y, 1000, -descent);
                g2d.draw(rect);
            }
            Java2DPainter painter = new Java2DPainter(g2d, getContext(), parent.getFontInfo(), state);
            try {
                painter.drawText(x, y, letterSpacing, wordSpacing, dx, text);
            } catch (IFException e) {
                //This should never happen with the Java2DPainter
                throw new RuntimeException("Unexpected error while painting text", e);
            }
        }

        public Dimension getImageSize() {
            return dim.getSize();
        }

    };
    paintMarksAsBitmap(painter, boundingBox);
}

From source file:savant.view.tracks.TrackRenderer.java

public void drawFeatureLabel(Graphics2D g2, String geneName, double startXPos, double y) {
    FontMetrics fm = g2.getFontMetrics();
    double stringstartx = startXPos - fm.stringWidth(geneName) - 5;

    if (stringstartx <= 0) {
        Rectangle2D r = fm.getStringBounds(geneName, g2);

        int b = 2;
        Color textColor = g2.getColor();
        g2.setColor(new Color(255, 255, 255, 200));
        g2.fill(new RoundRectangle2D.Double(3.0, y - (fm.getHeight() - fm.getDescent()) - b,
                r.getWidth() + 2 * b, r.getHeight() + 2 * b, 8.0, 8.0));
        g2.setColor(textColor);/*w  w w  .j  av a2 s.c  o  m*/
        g2.drawString(geneName, 5.0F, (float) y);
    } else {
        g2.drawString(geneName, (float) stringstartx, (float) y);
    }
}

From source file:net.sf.mzmine.modules.visualization.twod.TwoDXYPlot.java

public boolean render(final Graphics2D g2, final Rectangle2D dataArea, int index, PlotRenderingInfo info,
        CrosshairState crosshairState) {

    // if this is not TwoDDataSet
    if (index != 0)
        return super.render(g2, dataArea, index, info, crosshairState);

    // prepare some necessary constants
    final int x = (int) dataArea.getX();
    final int y = (int) dataArea.getY();
    final int width = (int) dataArea.getWidth();
    final int height = (int) dataArea.getHeight();

    final double imageRTMin = (double) getDomainAxis().getRange().getLowerBound();
    final double imageRTMax = (double) getDomainAxis().getRange().getUpperBound();
    final double imageRTStep = (imageRTMax - imageRTMin) / width;
    final double imageMZMin = (double) getRangeAxis().getRange().getLowerBound();
    final double imageMZMax = (double) getRangeAxis().getRange().getUpperBound();
    final double imageMZStep = (imageMZMax - imageMZMin) / height;

    if ((zoomOutBitmap != null) && (imageRTMin == totalRTRange.getMin())
            && (imageRTMax == totalRTRange.getMax()) && (imageMZMin == totalMZRange.getMin())
            && (imageMZMax == totalMZRange.getMax()) && (zoomOutBitmap.getWidth() == width)
            && (zoomOutBitmap.getHeight() == height)) {
        g2.drawImage(zoomOutBitmap, x, y, null);
        return true;
    }/* w  w  w .  jav a  2s.c  o  m*/

    // Save current time
    Date renderStartTime = new Date();

    // prepare a double array of summed intensities
    double values[][] = new double[width][height];
    maxValue = 0; // now this is an instance variable
    Random r = new Random();

    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++) {

            double pointRTMin = imageRTMin + (i * imageRTStep);
            double pointRTMax = pointRTMin + imageRTStep;
            double pointMZMin = imageMZMin + (j * imageMZStep);
            double pointMZMax = pointMZMin + imageMZStep;

            double lv = dataset.getMaxIntensity(new Range(pointRTMin, pointRTMax),
                    new Range(pointMZMin, pointMZMax), plotMode);

            if (logScale) {
                lv = Math.log10(lv);
                if (lv < 0 || Double.isInfinite(lv))
                    lv = 0;
                values[i][j] = lv;
                //values[r.nextInt(width)][r.nextInt(height)] = lv;
            } else {
                values[i][j] = lv;
            }

            if (lv > maxValue)
                maxValue = lv;

        }

    // This should never happen, but just for correctness
    if (maxValue == 0)
        return false;

    // Normalize all values
    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++) {
            values[i][j] /= maxValue;
        }

    // prepare a bitmap of required size
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

    // draw image points
    for (int i = 0; i < width; i++)
        for (int j = 0; j < height; j++) {
            Color pointColor = paletteType.getColor(values[i][j]);
            image.setRGB(i, height - j - 1, pointColor.getRGB());
        }

    // if we are zoomed out, save the values
    if ((imageRTMin == totalRTRange.getMin()) && (imageRTMax == totalRTRange.getMax())
            && (imageMZMin == totalMZRange.getMin()) && (imageMZMax == totalMZRange.getMax())) {
        zoomOutBitmap = image;
    }

    // Paint image
    g2.drawImage(image, x, y, null);

    Date renderFinishTime = new Date();

    logger.finest("Finished rendering 2D visualizer, "
            + (renderFinishTime.getTime() - renderStartTime.getTime()) + " ms");

    return true;

}

From source file:org.polymap.rhei.batik.engine.svg.Svg2Png.java

public Bounds getInitialSVGBounds(String url, InputStream svgInput) throws IOException {
    try {/*from   ww  w. j a va2s .c  o m*/
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        SVGDocument doc = (SVGDocument) f.createDocument(url, svgInput);
        String widthStr = doc.getRootElement().getAttribute("width");
        String heightStr = doc.getRootElement().getAttribute("height");
        if (!Strings.isNullOrEmpty(widthStr) && !Strings.isNullOrEmpty(heightStr)) {
            int width = Integer.valueOf(doc.getRootElement().getAttribute("width"));
            int height = Integer.valueOf(doc.getRootElement().getAttribute("height"));
            return new Bounds(width, height);
        } else {
            BridgeContext ctx = new BridgeContext(new UserAgentAdapter());
            GVTBuilder builder = new GVTBuilder();
            GraphicsNode gvtRoot = builder.build(ctx, doc);
            Rectangle2D rc = gvtRoot.getSensitiveBounds();
            if (rc == null) {
                System.err.println(url + " has no bounding box.");
                return new Bounds(0f, 0f);
            } else {
                return new Bounds(Double.valueOf(rc.getWidth()).floatValue(),
                        Double.valueOf(rc.getHeight()).floatValue());
            }
        }

    } finally {
        svgInput.close();
    }
}

From source file:org.esa.snap.graphbuilder.gpf.ui.worldmap.NestWorldMapPane.java

private Rectangle2D cropToMaxModelBounds(Rectangle2D modelBounds) {
    final Rectangle2D maxModelBounds = worldMapLayer.getModelBounds();
    if (modelBounds.getWidth() >= maxModelBounds.getWidth() - 1
            || modelBounds.getHeight() >= maxModelBounds.getHeight() - 1) {
        modelBounds = maxModelBounds;/* ww  w .  ja va 2  s. co  m*/
    }
    return modelBounds;
}

From source file:net.sf.mzmine.modules.visualization.twod.PointTwoDXYPlot.java

public boolean render(final Graphics2D g2, final Rectangle2D dataArea, int index, PlotRenderingInfo info,
        CrosshairState crosshairState) {

    // if this is not TwoDDataSet
    if (index != 0)
        return super.render(g2, dataArea, index, info, crosshairState);

    // prepare some necessary constants
    final int x = (int) dataArea.getX();
    final int y = (int) dataArea.getY();
    final int width = (int) dataArea.getWidth();
    final int height = (int) dataArea.getHeight();

    final double imageRTMin = (double) getDomainAxis().getRange().getLowerBound();
    final double imageRTMax = (double) getDomainAxis().getRange().getUpperBound();
    final double imageRTStep = (imageRTMax - imageRTMin) / width;
    final double imageMZMin = (double) getRangeAxis().getRange().getLowerBound();
    final double imageMZMax = (double) getRangeAxis().getRange().getUpperBound();
    final double imageMZStep = (imageMZMax - imageMZMin) / height;

    // This if statement below keeps the min max values at the original values when the user
    // zooms in. We need some variables that scall as the box size so that the points we show
    // have better resolution the more someone zooms in.

    double dynamicImageRTMin = imageRTMin;
    double dynamicImageRTMax = imageRTMax;
    double dynamicImageMZMin = imageMZMin;
    double dynamicImageMZMax = imageMZMax;
    double dynamicImageRTStep = imageRTStep;
    double dynamicImageMZStep = imageMZStep;

    if ((zoomOutBitmap != null) && (imageRTMin == totalRTRange.lowerEndpoint())
            && (imageRTMax == totalRTRange.upperEndpoint()) && (imageMZMin == totalMZRange.lowerEndpoint())
            && (imageMZMax == totalMZRange.upperEndpoint()) && (zoomOutBitmap.getWidth() == width)
            && (zoomOutBitmap.getHeight() == height)) {
        g2.drawImage(zoomOutBitmap, x, y, null);
        return true;
    }//from www .ja  v  a  2 s .c o m

    // Save current time
    Date renderStartTime = new Date();

    // prepare a bitmap of required size
    //BufferedImage image = new BufferedImage(width, height,
    //BufferedImage.TYPE_INT_ARGB);

    //ArrayList<DataPoint> listOfDataPoints = new ArrayList<DataPoint>();
    //ArrayList<DataPoint> listOfRTValues = new ArrayList<DataPoint>();
    ArrayList<DataPoint> listOfDataPoints;
    ArrayList<Double> listOfRTValues;

    // These two function must be run in this order
    Range<Double> rtRangeIn = Range.closed(getDomainAxis().getRange().getLowerBound(),
            getDomainAxis().getRange().getUpperBound());
    Range<Double> mzRangeIn = Range.closed(getRangeAxis().getRange().getLowerBound(),
            getRangeAxis().getRange().getUpperBound());
    listOfDataPoints = dataset.getCentroidedDataPointsInRTMZRange(rtRangeIn, mzRangeIn);
    listOfRTValues = dataset.getrtValuesInUserRange();

    // points to be plotted
    List plotPoints = new ArrayList();

    int count = 0;

    // Store the current mz,rt,int values so that they can be outputed to a file if we want
    //currentlyPlottedMZ = new ArrayList();

    //for (Iterator dpIt = listOfDataPoints.iterator(); dpIt.hasNext();) {

    // make a list to keep track of the intesities of each
    for (DataPoint curDataPoint : listOfDataPoints) {

        //DataPoint curDataPoint = dpIt.next();
        double currentRT = listOfRTValues.get(count).doubleValue();
        double currentMZ = curDataPoint.getMZ();

        plotPoints.add(new Point2D.Double(currentRT, currentMZ));

        count += 1;

        //currentlyPlottedMZ.add()
    }

    // draw image points
    //for (int i = 0; i < width; i++)
    //    for (int j = 0; j < height; j++) {
    //   Color pointColor = paletteType.getColor(values[i][j]);
    //   //image.setRGB(i, height - j - 1, pointColor.getRGB());
    //    points.add(new Point2D.Float(i,j));
    //    }
    count = 0;
    for (Iterator i = plotPoints.iterator(); i.hasNext();) {
        Point2D.Double pt = (Point2D.Double) i.next();
        // using the ''dynamic'' min and max will make the resolution imporve as someone zooms
        // in 
        //float xPlace = (pt.x-(float)dynamicImageRTMin)/((float)dynamicImageRTStep) + x;
        //float yPlace = (pt.y-(float)dynamicImageMZMin)/((float)dynamicImageMZStep) + y;
        double xPlace = (pt.x - dynamicImageRTMin) / (dynamicImageRTStep) + (double) x;
        double yPlace = (double) height - (pt.y - dynamicImageMZMin) / (dynamicImageMZStep) + (double) y;

        //get the current intensity
        // use the R, G B for the intensity

        double curIntensity = listOfDataPoints.get(count).getIntensity();
        curIntensity = curIntensity / dataset.curMaxIntensity;

        //g2.setColor(Color.BLACK);
        Color pointColor = paletteType.getColor(curIntensity);
        g2.setColor(pointColor);
        Ellipse2D dot = new Ellipse2D.Double(xPlace - 1, yPlace - 1, 2, 2);
        g2.fill(dot);

        count += 1;
    }

    //float xPlace = ((float)42.0-(float)dynamicImageRTMin)/((float)dynamicImageRTStep)+x;
    //float yPlace = (float)height - ((float)201.02-(float)dynamicImageMZMin)/((float)dynamicImageMZStep)+y;
    //Ellipse2D dot = new Ellipse2D.Float(xPlace - 1, yPlace - 1, 2, 2);
    //g2.fill(dot);

    //g2.dispose();

    // if we are zoomed out, save the values
    if ((imageRTMin == totalRTRange.lowerEndpoint()) && (imageRTMax == totalRTRange.upperEndpoint())
            && (imageMZMin == totalMZRange.lowerEndpoint()) && (imageMZMax == totalMZRange.upperEndpoint())) {
        //zoomOutBitmap = image;
    }

    // Paint image
    //g2.drawImage(image, x, y, null);

    //g.setColor(Color.BLACK)

    Date renderFinishTime = new Date();

    logger.finest("Finished rendering 2D visualizer, "
            + (renderFinishTime.getTime() - renderStartTime.getTime()) + " ms");

    return true;

}

From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java

private void configureGradientAreaFill(Graphics2D g2, XYPlot plot, PlotRenderingInfo info, Paint itemPaint,
        GradientLineAreaFill gradientLineAreaFill) {
    final Rectangle2D plotArea = info.getPlotArea();
    double plotWidth = plotArea.getWidth();
    double plotHeight = plotArea.getHeight();
    Double mainColorTransparency = gradientLineAreaFill.getMaxValueTransparency();
    Double bgColorTransparency = gradientLineAreaFill.getMinValueTransparency();

    if (itemPaint instanceof Color) {
        Color itemColor = (Color) itemPaint;
        int red = itemColor.getRed();
        int green = itemColor.getGreen();
        int blue = itemColor.getBlue();
        int mainColorAlpha = (mainColorTransparency >= 0.0 && mainColorTransparency <= 1.0)
                ? Math.round(255 * mainColorTransparency.floatValue())
                : 150;//ww w .j ava2 s  . co  m
        int bgColorAlpha = (bgColorTransparency >= 0.0 && bgColorTransparency <= 1.0)
                ? Math.round(255 * bgColorTransparency.floatValue())
                : 128;

        Color mainColor = new Color(red, green, blue, mainColorAlpha);
        Paint bgColor = getBackgroundPaint();
        if (bgColor == null) {
            bgColor = plot.getBackgroundPaint();
        }
        Color secondaryColor = getSecondaryColor(bgColorAlpha, bgColor);

        Paint areaPaint = getAreaFillPaint(plot, plotWidth, plotHeight, mainColor, secondaryColor);
        g2.setPaint(areaPaint);
    } else {
        g2.setPaint(itemPaint);
    }
}

From source file:ro.nextreports.engine.util.chart.CylinderRenderer.java

/**
 * Draws a cylinder to represent one data item.
 * //from  w  w  w  .  j  av a  2  s  .com
 * @param g2 the graphics device.
 * @param state the renderer state.
 * @param dataArea the area for plotting the data.
 * @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) {

    // check the value we are plotting...
    Number dataValue = dataset.getValue(row, column);
    if (dataValue == null) {
        return;
    }

    double value = dataValue.doubleValue();

    Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(),
            dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset());

    PlotOrientation orientation = plot.getOrientation();

    double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column);
    double[] barL0L1 = calculateBarL0L1(value);
    if (barL0L1 == null) {
        return; // the bar is not visible
    }

    RectangleEdge edge = plot.getRangeAxisEdge();
    float transL0 = (float) rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge);
    float transL1 = (float) rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge);
    float barL0 = Math.min(transL0, transL1);
    float barLength = Math.abs(transL1 - transL0);

    // draw the bar...
    GeneralPath bar = new GeneralPath();
    if (orientation == PlotOrientation.HORIZONTAL) {
        bar.moveTo(barL0, (float) barW0);
        bar.lineTo(barL0, (float) (barW0 + state.getBarWidth()));
        bar.lineTo(barL0 + barLength, (float) (barW0 + state.getBarWidth()));
        bar.lineTo(barL0 + barLength, (float) barW0);
        bar.closePath();
    } else {
        bar.moveTo((float) barW0, (float) (barL0 - getYOffset() / 2));
        bar.lineTo((float) barW0, (float) (barL0 + barLength - getYOffset() / 2));
        Arc2D arc = new Arc2D.Double(barW0, (barL0 + barLength - getYOffset()), state.getBarWidth(),
                getYOffset(), 180, 180, Arc2D.OPEN);
        bar.append(arc, true);
        bar.lineTo((float) (barW0 + state.getBarWidth()), (float) (barL0 - getYOffset() / 2));
        arc = new Arc2D.Double(barW0, (barL0 - getYOffset()), state.getBarWidth(), getYOffset(), 0, -180,
                Arc2D.OPEN);
        bar.append(arc, true);
        bar.closePath();
    }
    Paint itemPaint = getItemPaint(row, column);
    if (getGradientPaintTransformer() != null && itemPaint instanceof GradientPaint) {
        GradientPaint gp = (GradientPaint) itemPaint;
        itemPaint = getGradientPaintTransformer().transform(gp, bar);
    }
    g2.setPaint(itemPaint);
    g2.fill(bar);

    Shape bar3dTop = new Ellipse2D.Double(barW0, barL0 - getYOffset(), state.getBarWidth(), getYOffset());
    if (itemPaint instanceof GradientPaint) {
        g2.setPaint(((GradientPaint) itemPaint).getColor2());
    }
    g2.fill(bar3dTop);

    if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        g2.setStroke(getItemOutlineStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(bar);
        if (bar3dTop != null) {
            g2.draw(bar3dTop);
        }
    }

    CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column);
    if (generator != null && isItemLabelVisible(row, column)) {
        drawItemLabel(g2, dataset, row, column, plot, generator, bar.getBounds2D(), (value < 0.0));
    }

    // collect entity and tool tip information...
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {

            String tip = null;
            CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
            if (tipster != null) {
                tip = tipster.generateToolTip(dataset, row, column);
            }
            String url = null;
            if (getItemURLGenerator(row, column) != null) {
                url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
            }
            CategoryItemEntity entity = new CategoryItemEntity(bar.getBounds2D(), tip, url, dataset,
                    dataset.getRowKey(row), dataset.getColumnKey(column));
            entities.add(entity);
        }
    }

}