org.jfree.data.category.CategoryDataset Java Examples
The following examples show how to use
org.jfree.data.category.CategoryDataset.
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: MultiplePiePlot.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param dataset the dataset (<code>null</code> permitted). */ public void setDataset(CategoryDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... if (this.dataset != null) { this.dataset.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self to trigger plot change event datasetChanged(new DatasetChangeEvent(this, dataset)); }
Example #2
Source File: Arja_0063_s.java From coming with MIT License | 6 votes |
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
Example #3
Source File: JGenProg2017_0081_s.java From coming with MIT License | 6 votes |
/** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (<code>null</code> permitted). * * @see #getDataset(int) */ public void setDataset(int index, CategoryDataset dataset) { CategoryDataset existing = (CategoryDataset) this.datasets.get(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); }
Example #4
Source File: Cardumen_00243_s.java From coming with MIT License | 6 votes |
/** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (<code>null</code> permitted). * * @see #getDataset(int) */ public void setDataset(int index, CategoryDataset dataset) { CategoryDataset existing = (CategoryDataset) this.datasets.get(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); }
Example #5
Source File: CategoryPlot.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * A utility method that returns a list of datasets that are mapped to a * given range axis. * * @param index the axis index. * * @return A list of datasets. */ private List datasetsMappedToRangeAxis(int index) { Integer key = new Integer(index); List result = new ArrayList(); for (CategoryDataset dataset : this.datasets.values()) { int i = indexOf(dataset); List mappedAxes = (List) this.datasetToRangeAxesMap.get( new Integer(i)); if (mappedAxes == null) { if (key.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(key)) { result.add(this.datasets.get(i)); } } } return result; }
Example #6
Source File: Cardumen_00194_s.java From coming with MIT License | 6 votes |
/** * Returns <code>true</code> if the dataset is empty (or <code>null</code>), * and <code>false</code> otherwise. * * @param dataset the dataset (<code>null</code> permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(CategoryDataset dataset) { if (dataset == null) { return true; } int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); if (rowCount == 0 || columnCount == 0) { return true; } for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { if (dataset.getValue(r, c) != null) { return false; } } } return true; }
Example #7
Source File: CategoryPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
@Test public void testAxisLocationIndices() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); CategoryAxis xAxis2 = new CategoryAxis("X2"); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setDomainAxis(99, xAxis2); plot.setRangeAxis(99, yAxis2); plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT); assertEquals(AxisLocation.BOTTOM_OR_RIGHT, plot.getDomainAxisLocation(99)); plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT); assertEquals(AxisLocation.BOTTOM_OR_LEFT, plot.getRangeAxisLocation(99)); }
Example #8
Source File: JGenProg2017_00102_s.java From coming with MIT License | 6 votes |
/** * 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). * @param includeInterval include the y-interval if the dataset has one. * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). * * @since 1.0.13 */ protected Range findRangeBounds(CategoryDataset dataset, boolean includeInterval) { if (dataset == null) { return null; } if (getDataBoundsIncludesVisibleSeriesOnly()) { List visibleSeriesKeys = new ArrayList(); int seriesCount = dataset.getRowCount(); for (int s = 0; s < seriesCount; s++) { if (isSeriesVisible(s)) { visibleSeriesKeys.add(dataset.getRowKey(s)); } } return DatasetUtilities.findRangeBounds(dataset, visibleSeriesKeys, includeInterval); } else { return DatasetUtilities.findRangeBounds(dataset, includeInterval); } }
Example #9
Source File: arja3_three_s.java From coming with MIT License | 6 votes |
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
Example #10
Source File: StackedBarChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); }
Example #11
Source File: CategoryPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testMapDatasetToRangeAxis() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(22, yAxis2); // add a second dataset DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(1, "R1", "C1"); plot.setDataset(99, dataset); assertEquals(yAxis, plot.getRangeAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToRangeAxis(99, 22); assertEquals(yAxis2, plot.getRangeAxisForDataset(99)); }
Example #12
Source File: CategoryAxis.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Returns the middle coordinate (in Java2D space) for a series within a * category. * * @param category the category (<code>null</code> not permitted). * @param seriesKey the series key (<code>null</code> not permitted). * @param dataset the dataset (<code>null</code> not permitted). * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); * @param area the area (<code>null</code> not permitted). * @param edge the edge (<code>null</code> not permitted). * * @return The coordinate in Java2D space. * * @since 1.0.7 */ public double getCategorySeriesMiddle(Comparable category, Comparable seriesKey, CategoryDataset dataset, double itemMargin, Rectangle2D area, RectangleEdge edge) { int categoryIndex = dataset.getColumnIndex(category); int categoryCount = dataset.getColumnCount(); int seriesIndex = dataset.getRowIndex(seriesKey); int seriesCount = dataset.getRowCount(); double start = getCategoryStart(categoryIndex, categoryCount, area, edge); double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); double width = end - start; if (seriesCount == 1) { return start + width / 2.0; } else { double gap = (width * itemMargin) / (seriesCount - 1); double ww = (width * (1 - itemMargin)) / seriesCount; return start + (seriesIndex * (ww + gap)) + ww / 2.0; } }
Example #13
Source File: Cardumen_00194_t.java From coming with MIT License | 6 votes |
/** * Returns the range of values in the range for the dataset. * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly <code>null</code>). */ public static Range findRangeBounds(CategoryDataset dataset, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; result = info.getRangeBounds(includeInterval); } else { result = iterateCategoryRangeBounds(dataset, includeInterval); } return result; }
Example #14
Source File: CategoryPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
@Test public void testRendererIndices() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(renderer, plot.getRenderer(0)); // we should be able to give a renderer an arbitrary index CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setRenderer(20, renderer2); assertEquals(2, plot.getRendererCount()); assertEquals(renderer2, plot.getRenderer(20)); assertEquals(20, plot.getIndexOf(renderer2)); }
Example #15
Source File: jKali_001_t.java From coming with MIT License | 6 votes |
/** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (<code>null</code> permitted). * * @see #getDataset(int) */ public void setDataset(int index, CategoryDataset dataset) { CategoryDataset existing = (CategoryDataset) this.datasets.get(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); }
Example #16
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
private CategoryDataset getTopActivitiesDataSet () { List<ServerWideStatsRecord> topActivitiesList = getTop20Activities (); if (topActivitiesList == null) { return null; } DefaultCategoryDataset dataset = new DefaultCategoryDataset (); for (ServerWideStatsRecord regularUsers : topActivitiesList) { String event = (String) regularUsers.get (0); dataset.addValue ((Double) regularUsers.get (1), "last 7 days", event); dataset.addValue ((Double) regularUsers.get (2), "last 30 days", event); dataset.addValue ((Double) regularUsers.get (3), "last 365 days", event); } return dataset; }
Example #17
Source File: BarChartFXDemo1.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Returns a sample dataset. * * @return The dataset. */ private static CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(7445, "JFreeSVG", "Warm-up"); dataset.addValue(24448, "Batik", "Warm-up"); dataset.addValue(4297, "JFreeSVG", "Test"); dataset.addValue(21022, "Batik", "Test"); return dataset; }
Example #18
Source File: RadarChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns a collection of legend items for the spider web chart. * * @return The legend items (never <code>null</code>). */ public LegendItemCollection getLegendItems() { final LegendItemCollection result = new LegendItemCollection(); if ( getDataset() == null ) { return result; } List keys = null; final CategoryDataset dataset = getDataset(); final TableOrder dataExtractOrder = getDataExtractOrder(); if ( dataExtractOrder == TableOrder.BY_ROW ) { keys = dataset.getRowKeys(); } else if ( dataExtractOrder == TableOrder.BY_COLUMN ) { keys = dataset.getColumnKeys(); } if ( keys == null ) { return result; } int series = 0; final Iterator iterator = keys.iterator(); final Shape shape = getLegendItemShape(); while ( iterator.hasNext() ) { final Comparable key = (Comparable) iterator.next(); if ( key instanceof GridCategoryItem ) { continue; } final String label = key.toString(); final Paint paint = getSeriesPaint( series ); final Paint outlinePaint = getSeriesOutlinePaint( series ); final Stroke stroke = getSeriesOutlineStroke( series ); final LegendItem item = new LegendItem( label, label, null, null, shape, paint, stroke, outlinePaint ); item.setDataset( getDataset() ); item.setSeriesKey( key ); item.setSeriesIndex( series ); result.add( item ); series++; } return result; }
Example #19
Source File: StackedBarRenderer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int columns = data.getColumnCount(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = xAxis.getCategoryMargin(); } double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } }
Example #20
Source File: DatasetUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the minimum range value for the specified dataset. This is * easy if the dataset implements the {@link RangeInfo} interface (a good * idea if there is an efficient way to determine the minimum value). * Otherwise, it involves iterating over the entire data-set. Returns * <code>null</code> if all the data values in the dataset are * <code>null</code>. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The minimum value (possibly <code>null</code>). */ public static Number findMinimumRangeValue(CategoryDataset dataset) { ParamChecks.nullNotPermitted(dataset, "dataset"); if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeLowerBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getStartValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { minimum = Math.min(minimum, value.doubleValue()); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Double(minimum); } } }
Example #21
Source File: UserChartController.java From subsonic with GNU General Public License v3.0 | 5 votes |
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String type = request.getParameter("type"); CategoryDataset dataset = createDataset(type); JFreeChart chart = createChart(dataset, request); int imageHeight = Math.max(IMAGE_MIN_HEIGHT, 15 * dataset.getColumnCount()); ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, IMAGE_WIDTH, imageHeight); return null; }
Example #22
Source File: Cardumen_0075_t.java From coming with MIT License | 5 votes |
/** * Adds an entity to the collection. * * @param entities the entity collection being populated. * @param hotspot the entity area (if <code>null</code> a default will be * used). * @param dataset the dataset. * @param row the series. * @param column the item. * @param selected is the item selected? * @param entityX the entity's center x-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * @param entityY the entity's center y-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * * @since 1.2.0 */ protected void addEntity(EntityCollection entities, Shape hotspot, CategoryDataset dataset, int row, int column, boolean selected, double entityX, double entityY) { if (!getItemCreateEntity(row, column, selected)) { return; } Shape s = hotspot; if (hotspot == null) { double r = getDefaultEntityRadius(); double w = r * 2; if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { s = new Ellipse2D.Double(entityX - r, entityY - r, w, w); } else { s = new Ellipse2D.Double(entityY - r, entityX - r, w, w); } } String tip = null; CategoryToolTipGenerator generator = getToolTipGenerator(row, column, selected); if (generator != null) { tip = generator.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getURLGenerator(row, column, selected); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(s, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
Example #23
Source File: JGenProg2017_0047_t.java From coming with MIT License | 5 votes |
/** * Calculates the range of values for a dataset where each item is the * running total of the items for the current series. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The range. * * @see #findRangeBounds(CategoryDataset) */ public static Range findCumulativeRangeBounds(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column < dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } }
Example #24
Source File: CategoryPlot.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Returns a list of the categories that should be displayed for the * specified axis. * * @param axis the axis (<code>null</code> not permitted) * * @return The categories. * * @since 1.0.3 */ public List getCategoriesForAxis(CategoryAxis axis) { List result = new ArrayList(); int axisIndex = getDomainAxisIndex(axis); for (CategoryDataset dataset : datasetsMappedToDomainAxis(axisIndex)) { // add the unique categories from this dataset for (int i = 0; i < dataset.getColumnCount(); i++) { Comparable category = dataset.getColumnKey(i); if (!result.contains(category)) { result.add(category); } } } return result; }
Example #25
Source File: 1_CategoryPlot.java From SimFix with GNU General Public License v2.0 | 5 votes |
/** * Returns the range of data values that will be plotted against the range * axis. If the dataset is <code>null</code>, this method returns * <code>null</code>. * * @param axis the axis. * * @return The data range. */ public Range getDataRange(ValueAxis axis) { Range result = null; List mappedDatasets = new ArrayList(); int rangeIndex = this.rangeAxes.indexOf(axis); if (rangeIndex >= 0) { mappedDatasets.addAll(datasetsMappedToRangeAxis(rangeIndex)); } else if (axis == getRangeAxis()) { mappedDatasets.addAll(datasetsMappedToRangeAxis(0)); } // iterate through the datasets that map to the axis and get the union // of the ranges. Iterator iterator = mappedDatasets.iterator(); while (iterator.hasNext()) { CategoryDataset d = (CategoryDataset) iterator.next(); CategoryItemRenderer r = getRendererForDataset(d); if (r != null) { result = Range.combine(result, r.findRangeBounds(d)); } } return result; }
Example #26
Source File: AbstractCategoryItemLabelGenerator.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a for the specified item. * * @param dataset the dataset (<code>null</code> not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The label (possibly <code>null</code>). */ protected String generateLabelString(CategoryDataset dataset, int row, int column) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String result = null; Object[] items = createItemArray(dataset, row, column); result = MessageFormat.format(this.labelFormat, items); return result; }
Example #27
Source File: AbstractCategoryItemRenderer.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Draws an item label. * * @param g2 the graphics device. * @param orientation the orientation. * @param dataset the dataset. * @param row the row. * @param column the column. * @param x the x coordinate (in Java2D space). * @param y the y coordinate (in Java2D space). * @param negative indicates a negative value (which affects the item * label position). */ protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, CategoryDataset dataset, int row, int column, double x, double y, boolean negative) { CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null) { Font labelFont = getItemLabelFont(row, column); Paint paint = getItemLabelPaint(row, column); g2.setFont(labelFont); g2.setPaint(paint); String label = generator.generateLabel(dataset, row, column); ItemLabelPosition position; if (!negative) { position = getPositiveItemLabelPosition(row, column); } else { position = getNegativeItemLabelPosition(row, column); } Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } }
Example #28
Source File: Cardumen_00139_t.java From coming with MIT License | 5 votes |
/** * Adds an entity to the collection. * * @param entities the entity collection being populated. * @param hotspot the entity area (if <code>null</code> a default will be * used). * @param dataset the dataset. * @param row the series. * @param column the item. * @param selected is the item selected? * @param entityX the entity's center x-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * @param entityY the entity's center y-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * * @since 1.2.0 */ protected void addEntity(EntityCollection entities, Shape hotspot, CategoryDataset dataset, int row, int column, boolean selected, double entityX, double entityY) { if (!getItemCreateEntity(row, column, selected)) { return; } Shape s = hotspot; if (hotspot == null) { double r = getDefaultEntityRadius(); double w = r * 2; if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { s = new Ellipse2D.Double(entityX - r, entityY - r, w, w); } else { s = new Ellipse2D.Double(entityY - r, entityX - r, w, w); } } String tip = null; CategoryToolTipGenerator generator = getToolTipGenerator(row, column, selected); if (generator != null) { tip = generator.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getURLGenerator(row, column, selected); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(s, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
Example #29
Source File: CategoryPlot.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Draws the domain gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { if (!isDomainGridlinesVisible()) { return; } CategoryAnchor anchor = getDomainGridlinePosition(); RectangleEdge domainAxisEdge = getDomainAxisEdge(); CategoryDataset dataset = getDataset(); if (dataset == null) { return; } CategoryAxis axis = getDomainAxis(); if (axis != null) { int columnCount = dataset.getColumnCount(); for (int c = 0; c < columnCount; c++) { double xx = axis.getCategoryJava2DCoordinate(anchor, c, columnCount, dataArea, domainAxisEdge); CategoryItemRenderer renderer1 = getRenderer(); if (renderer1 != null) { renderer1.drawDomainLine(g2, this, dataArea, xx, getDomainGridlinePaint(), getDomainGridlineStroke()); } } } }
Example #30
Source File: CategoryPlot.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Returns a list of the categories that should be displayed for the * specified axis. * * @param axis the axis (<code>null</code> not permitted) * * @return The categories. * * @since 1.0.3 */ public List getCategoriesForAxis(CategoryAxis axis) { List result = new ArrayList(); int axisIndex = getDomainAxisIndex(axis); for (CategoryDataset dataset : datasetsMappedToDomainAxis(axisIndex)) { // add the unique categories from this dataset for (int i = 0; i < dataset.getColumnCount(); i++) { Comparable category = dataset.getColumnKey(i); if (!result.contains(category)) { result.add(category); } } } return result; }