Example usage for java.awt.geom Rectangle2D getHeight

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

Introduction

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

Prototype

public abstract double getHeight();

Source Link

Document

Returns the height of the framing rectangle in double precision.

Usage

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);/*from www. j a v a 2s .  com*/
        g2.drawString(geneName, 5.0F, (float) y);
    } else {
        g2.drawString(geneName, (float) stringstartx, (float) y);
    }
}

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;//from   w w  w .  j av  a 2 s.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:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java

/**
 * Creates the listener responsible for calling the correct handlers based
 * on mouse events, and to select invidual cells.
 *///from w  w  w.j a va2 s .  c o  m
protected MouseListener createMouseListener() {

    return new MouseHandler() {

        /**
         * Invoked when a mouse button has been pressed on a component.
         *
         //@Override
         public void mousePressed(MouseEvent e) {
                
         Object o = graph.getFirstCellForLocation(e.getX(), e.getY());
                
         if (o instanceof VGraphCell) {
                
         VGraphCell cell = (VGraphCell) o;
                
         JPopupMenu menu = new JPopupMenu();
                
         VChartPanel chartPanel = (VChartPanel) cell.getUserObject();
                
         if (chartPanel.isShowPopUp()) {
                
         LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems();
         JMenu first = new JMenu("1-39");
         int checker = 0;
                
         for (Iterator iter = collect.iterator(); iter.hasNext();) {
         LegendItem item = (LegendItem) iter.next();
         checker++;
         first.add(new JMenuItem(item.getLabel()));
         if ((checker % 40) == 0) {
         menu.add(first);
                
         first = new JMenu("" + checker + "-" + (checker + 39));
         }
         if (!iter.hasNext()) {
         menu.add(first);
         }
         }
                
         menu.show(graph, e.getX(), e.getY());
         }
         }
                
         super.mousePressed(e);
         }
         */

        /**
         * Invoked when a mouse button has been pressed on a component.
         */
        @Override
        public void mousePressed(MouseEvent e) {

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (SwingUtilities.isLeftMouseButton(e) && e.isAltDown()) {
                if (o instanceof VGraphCell) {

                    VGraphCell cell = (VGraphCell) o;

                    JPopupMenu menu = new JPopupMenu();

                    VChartPanel chartPanel = (VChartPanel) cell.getUserObject();

                    LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems();
                    JMenu first = new JMenu("1-39");
                    int checker = 0;

                    for (Iterator iter = collect.iterator(); iter.hasNext();) {
                        LegendItem item = (LegendItem) iter.next();
                        checker++;
                        first.add(new JMenuItem(item.getLabel()));
                        if ((checker % 40) == 0) {
                            menu.add(first);

                            first = new JMenu("" + checker + "-" + (checker + 39));
                        }
                        if (!iter.hasNext()) {
                            menu.add(first);
                        }
                    }

                    menu.show(graph, e.getX(), e.getY());
                }
            }

            super.mousePressed(e);

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    for (MouseListener l : chart.getMouseListeners()) {
                        l.mousePressed(e);
                    }
                }
            }
        }

        // Event may be null when called to cancel the current operation.
        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    for (MouseListener l : chart.getMouseListeners()) {
                        l.mouseReleased(e);
                    }
                }
            }
        }

        /**
         * Invoked when the mouse has been clicked on a component.
         */
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    if (SwingUtilities.isRightMouseButton(e)) {
                        JPopupMenu menu = chart.createPopupMenu(true, true, true, true);

                        menu.show(graph, e.getX(), e.getY());
                    }

                    /*
                    for (MouseListener l : chart.getMouseListeners()) {
                    System.out.println("LISTENS CLI");
                    l.mouseClicked(e);
                    }
                    */
                }
            }
        }

        /*
        // Event may be null when called to cancel the current operation.
        @Override
        public void mouseReleased(MouseEvent e) {
        super.mouseReleased(e);
                
        Object[] cells = graphSelectionModel.getSelectionCells();
                
        Rectangle2D bounds = graph.getCellBounds(cells);
                
        if (bounds != null) {
            Rectangle2D b2 = graph.toScreen((Rectangle2D) bounds.clone());
            graph.scrollRectToVisible(new Rectangle((int) b2.getX(), (int) b2.getY(), (int) b2.getWidth(), (int) b2.getHeight()));
        }
        }
        */

        /**
         * Invoked when the mouse pointer has been moved on a component (with no
         * buttons down).
         */
        @Override
        public void mouseMoved(MouseEvent e) {

            if (graph.isMoveable()) {
                super.mouseMoved(e);
            }

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                selectedCell = (VGraphCell) o;

                Rectangle2D bounds = graph.getCellBounds(selectedCell);

                menu.show(graph, (int) (bounds.getX() + bounds.getWidth()),
                        (int) bounds.getY() + (int) (bounds.getHeight() - menu.getHeight()));
            }
        }
    };
}

From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java

private XYAnnotation slopeLine() {
    return new XYAnnotation() {

        private double x1, y1, x2, y2;

        @Override//from   w  w w .  j  a va  2  s  .c  om
        public void removeChangeListener(final AnnotationChangeListener listener) {
            // ignore
        }

        @Override
        public void addChangeListener(final AnnotationChangeListener listener) {
            // ignore
        }

        @Override
        public void draw(final Graphics2D g2, final XYPlot plot, final Rectangle2D dataArea,
                final ValueAxis domainAxis, final ValueAxis rangeAxis, final int rendererIndex,
                final PlotRenderingInfo info) {
            calcLineCoords(dataArea);
            drawLine(g2);
        }

        private void drawLine(final Graphics2D g2) {
            final Color origColor = g2.getColor();
            g2.setColor(Color.black);
            g2.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            g2.setColor(Color.lightGray);
            g2.drawLine((int) x1, 0, (int) x1, 192);
            g2.drawLine((int) x2, 0, (int) x2, 192);
            g2.setColor(origColor);
        }

        @SuppressWarnings("synthetic-access")
        private void calcLineCoords(final Rectangle2D rect) {
            // offset necessary since chart is not drawn on whole rectangle
            int offset = 12;
            final double x = rect.getMinX() + offset;
            final double y = rect.getMinY();
            final double w = rect.getWidth() - 2 * offset;
            final double h = rect.getHeight();
            final double min = bundle.getTheoreticalMin();
            final double max = bundle.getTheoreticalMax();
            final double defaultMin = bundle.getDataMin();
            final double defaultMax = bundle.getDataMax();
            final double scale = w / (defaultMax - defaultMin);
            double slope = 0.0;
            if (max != min) {
                slope = h / (max - min);
            }
            if (min >= defaultMin) {
                x1 = scale * (min - defaultMin);
                y1 = h;
            } else {
                x1 = 0;
                if (max > min) {
                    y1 = h - ((defaultMin - min) * slope);
                } else {
                    y1 = h;
                }
            }
            if (max <= defaultMax) {
                x2 = (scale * (max - defaultMin));
                y2 = 0;
            } else {
                x2 = w;
                if (max > min) {
                    y2 = h - ((defaultMax - min) * slope);
                } else {
                    y2 = 0;
                }
            }
            x1 += x;
            x2 += x;
            y1 += y;
            y2 += 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;
    }//from  w w  w  .  j  a  v  a 2  s  . com

    // 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.talend.dataprofiler.chart.preview.HideSeriesGanttRenderer.java

/**
 * Calculates the coordinate of the first "side" of a bar. This will be the minimum x-coordinate for a vertical bar,
 * and the minimum y-coordinate for a horizontal bar.
 * /*from   ww w.j a  v  a  2s  . co  m*/
 * @param plot the plot.
 * @param orientation the plot orientation.
 * @param dataArea the data area.
 * @param domainAxis the domain axis.
 * @param state the renderer state (has the bar width precalculated).
 * @param row the row index.
 * @param column the column index.
 * 
 * @return The coordinate.
 */
@Override
protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea,
        CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column) {
    // calculate bar width...
    double space = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        space = dataArea.getHeight();
    } else {
        space = dataArea.getWidth();
    }
    double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();
    if (seriesCount > 1) {
        double seriesGap = space * getItemMargin() / (categoryCount * (seriesCount - 1));
        double seriesW = calculateSeriesWidth(space, domainAxis, categoryCount, seriesCount);
        barW0 = barW0 + row * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0);
    } else {
        barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge())
                - state.getBarWidth() / 2.0;
    }
    return barW0;
}

From source file:MWC.GUI.JFreeChart.StepperXYPlot.java

/**
 * draw the new stepper line into the plot
 * //w  ww.java  2  s  .  c  om
 * @param g2
 * @param linePosition
 * @param dataArea
 */
protected void plotStepperLine(final Graphics2D g2, final double linePosition, final Rectangle2D dataArea) {
    // prepare to draw
    final Stroke oldStroke = g2.getStroke();
    g2.setXORMode(Color.darkGray);

    // thicken up the line
    g2.setStroke(new BasicStroke(3));

    if (this.getOrientation() == PlotOrientation.VERTICAL) {
        // draw the line
        g2.drawLine((int) linePosition - 1, (int) dataArea.getY() + 1, (int) linePosition - 1,
                (int) dataArea.getY() + (int) dataArea.getHeight() - 1);
    } else {
        // draw the line
        g2.drawLine((int) dataArea.getY() + 1, (int) linePosition - 1,
                (int) dataArea.getY() + (int) dataArea.getHeight() - 1, (int) linePosition - 1);

    }

    // and restore everything
    g2.setStroke(oldStroke);
    g2.setPaintMode();
}

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

public Bounds getInitialSVGBounds(String url, InputStream svgInput) throws IOException {
    try {/*from   w  w w  .  j  ava  2  s .c  om*/
        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;// w  ww  .  java 2s  .  c  om
    }
    return modelBounds;
}

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

/**
 * Draws a cylinder to represent one data item.
 * /*from   ww  w. j  a va  2 s  .co  m*/
 * @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);
        }
    }

}