📄 abstractcategoryitemrenderer.java
字号:
this.toolTipGeneratorList.set(series, generator); notifyListeners(new RendererChangeEvent(this)); } /** * Returns the base tool tip generator (the "layer 2" generator). * * @return The tool tip generator (possibly <code>null</code>). */ public CategoryToolTipGenerator getBaseToolTipGenerator() { return this.baseToolTipGenerator; } /** * Sets the base tool tip generator and sends a * {@link org.jfree.chart.event.RendererChangeEvent} to all registered listeners. * * @param generator the generator (<code>null</code> permitted). */ public void setBaseToolTipGenerator(CategoryToolTipGenerator generator) { this.baseToolTipGenerator = generator; notifyListeners(new RendererChangeEvent(this)); } // URL GENERATOR /** * Returns the URL generator for a data item. This method just calls the * getSeriesItemURLGenerator method, but you can override this behaviour if you want to. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The URL generator. */ public CategoryURLGenerator getItemURLGenerator(int row, int column) { return getSeriesItemURLGenerator(row); } /** * Returns the URL generator for a series. * * @param series the series index (zero based). * * @return The URL generator for the series. */ public CategoryURLGenerator getSeriesItemURLGenerator(int series) { // return the generator for ALL series, if there is one... if (this.itemURLGenerator != null) { return this.itemURLGenerator; } // otherwise look up the generator table CategoryURLGenerator generator = (CategoryURLGenerator) this.itemURLGeneratorList.get(series); if (generator == null) { generator = this.baseItemURLGenerator; } return generator; } /** * Sets the item URL generator for ALL series. * * @param generator the generator. */ public void setItemURLGenerator(CategoryURLGenerator generator) { this.itemURLGenerator = generator; } /** * Sets the URL generator for a series. * * @param series the series index (zero based). * @param generator the generator. */ public void setSeriesItemURLGenerator(int series, CategoryURLGenerator generator) { this.itemURLGeneratorList.set(series, generator); } /** * Returns the base item URL generator. * * @return The item URL generator. */ public CategoryURLGenerator getBaseItemURLGenerator() { return this.baseItemURLGenerator; } /** * Sets the base item URL generator. * * @param generator the item URL generator. */ public void setBaseItemURLGenerator(CategoryURLGenerator generator) { this.baseItemURLGenerator = generator; } /** * Returns the number of rows in the dataset. This value is updated in the * {@link AbstractCategoryItemRenderer#initialise} method. * * @return the row count. */ public int getRowCount() { return this.rowCount; } /** * Returns the number of columns in the dataset. This value is updated in the * {@link AbstractCategoryItemRenderer#initialise} method. * * @return the column count. */ public int getColumnCount() { return this.columnCount; } /** * Initialises the renderer and returns a state object that will be used for the * remainder of the drawing process for a single chart. The state object allows * for the fact that the renderer may be used simultaneously by multiple threads (each * thread will work with a separate state object). * <P> * Stores a reference to the {@link PlotRenderingInfo} object (which might be * <code>null</code>), and then sets the useCategoriesPaint flag according to the special case * conditions a) there is only one series and b) the categoriesPaint array is not null. * * @param g2 the graphics device. * @param dataArea the data area. * @param plot the plot. * @param rendererIndex the renderer index. * @param info an object for returning information about the structure of the plot * (<code>null</code> permitted). * * @return the renderer state. * */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { setPlot(plot); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { this.rowCount = data.getRowCount(); this.columnCount = data.getColumnCount(); } else { this.rowCount = 0; this.columnCount = 0; } return new CategoryItemRendererState(info); } /** * Returns the range of values the renderer requires to display all the items from the * specified dataset. * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (or <code>null</code> if the dataset is <code>null</code> or empty). */ public Range getRangeExtent(CategoryDataset dataset) { return DatasetUtilities.getRangeExtent(dataset); } /** * Draws a background for the data area. The default implementation just gets the plot to * draw the outline, but some renderers will override this behaviour. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { plot.drawBackground(g2, dataArea); } /** * Draws an outline for the data area. The default implementation just gets the plot to * draw the outline, but some renderers will override this behaviour. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { plot.drawOutline(g2, dataArea); } /** * Draws a grid line against the domain axis. * <P> * Note that this default implementation assumes that the horizontal axis is the domain axis. * If this is not the case, you will need to override this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any 3D effect). * @param value the Java2D value at which the grid line should be drawn. */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } Paint paint = plot.getDomainGridlinePaint(); if (paint == null) { paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; } g2.setPaint(paint); Stroke stroke = plot.getDomainGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); } /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D effect). * @param value the value at which the grid line should be drawn. * */ public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } Paint paint = plot.getRangeGridlinePaint(); if (paint == null) { paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; } g2.setPaint(paint); Stroke stroke = plot.getRangeGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); } /** * Draws a marker for the range axis. * * @param g2 the graphics device (not <code>null</code>). * @param plot the plot (not <code>null</code>). * @param axis the range axis (not <code>null</code>). * @param marker the marker to be drawn (not <code>null</code>). * @param dataArea the area inside the axes (not <code>null</code>). */ public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(marker.getOutlinePaint()); g2.setStroke(marker.getOutlineStroke()); g2.draw(line); String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); double[] coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, line.getBounds2D(), marker.getLabelOffset(), anchor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -