List of usage examples for java.awt.geom Rectangle2D getX
public abstract double getX();
From source file:org.tsho.dmc2.core.chart.BasinRenderer.java
public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) { basinComponent.setDataobject(null);//from ww w . j av a 2s . c o m attractorsSamplePoints = new Vector(); state = STATE_RUNNING; gridWidth = (int) dataArea.getWidth(); gridHeight = (int) dataArea.getHeight(); this.imageX = (int) dataArea.getX() + 1; this.imageY = (int) dataArea.getY(); this.image = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB); this.g2 = g2; WritableRaster raster = image.getRaster(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); double maxCoordinate = Math.abs(domainAxis.getUpperBound()); if (Math.abs(domainAxis.getLowerBound()) > maxCoordinate) maxCoordinate = Math.abs(domainAxis.getLowerBound()); if (Math.abs(rangeAxis.getLowerBound()) > maxCoordinate) maxCoordinate = Math.abs(rangeAxis.getLowerBound()); if (Math.abs(rangeAxis.getUpperBound()) > maxCoordinate) maxCoordinate = Math.abs(rangeAxis.getUpperBound()); if (infinity < maxCoordinate) infinity = maxCoordinate + 1; grid = new Grid(new double[] { domainAxis.getLowerBound(), domainAxis.getUpperBound(), rangeAxis.getLowerBound(), rangeAxis.getUpperBound() }, gridHeight, gridWidth); imageData = ((DataBufferInt) raster.getDataBuffer()).getData(); rate = gridHeight * gridWidth / 100; attractorsSamplePoints = new Vector(); BasinsAlgorithm bA = null; if (type == FAST_ALGORITHM) bA = new FastBasinsAlgorithm(this); else if (type == SLOW_ALGORITHM) bA = new SlowBasinsAlgorithm(this); bA.run(); /** Now that grid is computed, pass it to the BasinComponent for possible storing */ int[] tmp = grid.getData(); grid.setData((int[]) tmp.clone());//from now on, grid data is disconnected from image data basinComponent.setDataobject(grid); drawImage(); state = STATE_FINISHED; }
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 ww w. jav a 2 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:ImageLabel.java
public void paint(Graphics g) { /*/*www . j ava 2 s . c o m*/ * Draw the image stretched to exactly cover the size of the drawing area. */ Dimension size = getSize(); g.drawImage(img, 0, 0, size.width, size.height, 0, 0, img.getWidth(null), img.getHeight(null), null); /* * Fill a rounded rectangle centered in the drawing area. Calculate the size * of the rectangle from the size of the text */ g.setFont(font); FontRenderContext frc = ((Graphics2D) g).getFontRenderContext(); Rectangle2D bounds = font.getStringBounds(text, frc); int wText = (int) bounds.getWidth(); int hText = (int) bounds.getHeight(); int rX = (size.width - wText) / 2; int rY = (size.height - hText) / 2; g.setColor(Color.yellow); g.fillRoundRect(rX, rY, wText, hText, hText / 2, hText / 2); /* * Draw text positioned in the rectangle. Since the rectangle is sized based * on the bounds of the String we can position it using those bounds. */ int xText = rX - (int) bounds.getX(); int yText = rY - (int) bounds.getY(); g.setColor(Color.black); g.setFont(font); g.drawString(text, xText, yText); }
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 ww w .j a v a 2s . c om*/ // 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.pentaho.reporting.libraries.pixie.wmf.WmfFile.java
public synchronized void draw(final Graphics2D graphics, final Rectangle2D bounds) { // this adjusts imageWidth and imageHeight scaleToFit((float) bounds.getWidth(), (float) bounds.getHeight()); // adjust translation if needed ... graphics.translate(bounds.getX(), bounds.getY()); // adjust to the image origin graphics.translate(-imageX, -imageY); this.graphics = graphics; for (int i = 0; i < records.size(); i++) { try {/*from w w w. ja va 2 s .co m*/ final MfCmd command = (MfCmd) records.get(i); command.setScale((float) imageWidth / (float) maxWidth, (float) imageHeight / (float) maxHeight); command.replay(this); } catch (Exception e) { logger.warn("Error while processing image record #" + i, e); } } resetStates(); }
From source file:com.appnativa.rare.ui.chart.jfreechart.XYPlotEx.java
@Override protected void fillBackground(Graphics2D g2, Rectangle2D area, PlotOrientation orientation) { Paint p = this.getBackgroundPaint(); if (p == null) { return;/*from w w w. j av a 2 s . c om*/ } iPainter painter = ChartHelper.getPainter(p); if (painter == null) { super.fillBackground(g2, area, orientation); return; } Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getBackgroundAlpha())); graphics = SwingGraphics.fromGraphics(g2, null, graphics); float x = UIScreen.snapToPosition(area.getX()); float y = UIScreen.snapToPosition(area.getY()); float w = UIScreen.snapToSize(area.getWidth()); float h = UIScreen.snapToSize(area.getHeight()); painter.paint(graphics, x, y, w, h, iPainter.UNKNOWN); g2.setComposite(originalComposite); }
From source file:ro.nextreports.engine.util.chart.CylinderRenderer.java
/** * Draws a cylinder to represent one data item. * // w ww . ja va 2s . c om * @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); } } }
From source file:fr.amap.commons.javafx.chart.ChartViewer.java
/** * A handler for the export to JPEG option in the context menu. *//*from w ww . j a v a 2s . com*/ private void handleExportToJPEG() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to JPEG"); fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("JPEG", "jpg")); File file = fileChooser.showSaveDialog(stage); if (file != null) { try { CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize(); BufferedImage image = new BufferedImage((int) canvasPositionAndSize.totalWidth, (int) canvasPositionAndSize.totalHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); int index = 0; for (ChartCanvas canvas : chartCanvasList) { Rectangle2D rectangle2D = canvasPositionAndSize.positionsAndSizes.get(index); ((Drawable) canvas.chart).draw(g2, new Rectangle((int) rectangle2D.getX(), (int) rectangle2D.getY(), (int) rectangle2D.getWidth(), (int) rectangle2D.getHeight())); index++; } try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) { ImageIO.write(image, "jpg", out); } /*ExportUtils.writeAsJPEG(chartCanvasList.get(0).chart, (int)chartCanvasList.get(0).getWidth(), (int)chartCanvasList.get(0).getHeight(), file);*/ } catch (IOException ex) { // FIXME: show a dialog with the error } } }
From source file:fr.amap.commons.javafx.chart.ChartViewer.java
/** * A handler for the export to PNG option in the context menu. */// w w w . j a v a2 s . c o m private void handleExportToPNG() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to PNG"); fileChooser.setSelectedExtensionFilter( new FileChooser.ExtensionFilter("Portable Network Graphics (PNG)", "png")); File file = fileChooser.showSaveDialog(stage); if (file != null) { try { CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize(); BufferedImage image = new BufferedImage((int) canvasPositionAndSize.totalWidth, (int) canvasPositionAndSize.totalHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); int index = 0; for (ChartCanvas canvas : chartCanvasList) { Rectangle2D rectangle2D = canvasPositionAndSize.positionsAndSizes.get(index); ((Drawable) canvas.chart).draw(g2, new Rectangle((int) rectangle2D.getX(), (int) rectangle2D.getY(), (int) rectangle2D.getWidth(), (int) rectangle2D.getHeight())); index++; } try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) { ImageIO.write(image, "png", out); } } catch (IOException ex) { // FIXME: show a dialog with the error } } }
From source file:com.bdaum.zoom.report.internal.jfree.custom.CylinderRenderer.java
/** * Draws a cylinder to represent one data item. * * @param g2 the graphics device./* w w w. jav a 2s . c om*/ * @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(); Shape top = null; if (orientation == PlotOrientation.HORIZONTAL) { bar.moveTo((float) (barL0 + getXOffset() / 2), (float) barW0); bar.lineTo((float) (barL0 + barLength + getXOffset() / 2), (float) barW0); Arc2D arc = new Arc2D.Double(barL0 + barLength, barW0, getXOffset(), state.getBarWidth(), 90, 180, Arc2D.OPEN); bar.append(arc, true); bar.lineTo((float) (barL0 + getXOffset() / 2), (float) (barW0 + state.getBarWidth())); arc = new Arc2D.Double(barL0, barW0, getXOffset(), state.getBarWidth(), 270, -180, Arc2D.OPEN); bar.append(arc, true); bar.closePath(); top = new Ellipse2D.Double(barL0 + barLength, barW0, getXOffset(), state.getBarWidth()); } 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(); top = new Ellipse2D.Double(barW0, barL0 - getYOffset(), state.getBarWidth(), getYOffset()); } 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); if (itemPaint instanceof GradientPaint) { g2.setPaint(((GradientPaint) itemPaint).getColor2()); } else { g2.setPaint(PaintAlpha.darker(itemPaint)); // bd } if (top != null) { g2.fill(top); } if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (top != null) { g2.draw(top); } } 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); } } }