List of usage examples for org.jfree.chart LegendItem LegendItem
public LegendItem(AttributedString label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint)
From source file:gda.plots.SimpleXYBarRenderer.java
/** * Creates a SimpleLegendItem for a SimpleXYSeries in the dataset. * /*from w w w . j ava 2 s . c o m*/ * @param datasetIndex * which dataset (left or right effectively) * @param series * which data series * @return the created legend */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot plot = getPlot(); if (plot != null) { SimpleXYSeriesCollection dataset = (SimpleXYSeriesCollection) plot.getDataset(datasetIndex); if (dataset != null) { SimpleXYSeries sxys = (SimpleXYSeries) dataset.getSeries(series); if (sxys.isVisible() && sxys.isVisibleInLegend()) { result = new LegendItem(sxys.getName(), sxys.getName(), null, null, sxys.isDrawMarkers(), sxys.getSymbol(), sxys.getFilled(), sxys.getSymbolPaint(), !sxys.getFilled(), sxys.getSymbolPaint(), new BasicStroke(), sxys.isDrawLines(), new Line2D.Double(-8.0, 0.0, 8.0, 0.0), sxys.getStroke(), sxys.getPaint()); } } } return result; }
From source file:daylightchart.daylightchart.chart.DaylightChartLegendItemSource.java
private LegendItem createLegendItem(final String label, final Paint paint, final boolean isLine) { final LegendItem legendItem = new LegendItem(label, /* description */ null, /* toolTipText */null, /* urlText */ null, /* shapeVisible */!isLine, /* shape */new Rectangle(10, 10), /* shapeFilled */true, paint, /* shapeOutlineVisible */true, /* outlinePaint */Color.black, /* outlineStroke */new BasicStroke(0.2f), /* lineVisible */isLine, /* line */new Rectangle(10, 3), /* lineStroke */new BasicStroke(0.6f), /* linePaint */Color.black); return legendItem; }
From source file:com.newatlanta.bluedragon.CustomBarRenderer.java
/** * Returns a legend item for a series.//from www. jav a2s. c o m * * @param datasetIndex * the dataset index (zero-based). * @param series * the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } CategoryDataset dataset; dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke outlineStroke = getSeriesOutlineStroke(series); // This is the fix for bug #2695 if (paint instanceof java.awt.GradientPaint) { // When the paintstyle is "shade" use the lighter // color while with "light" use the darker color // NOTE: if we take the lighter color (Color2) and make it darker // and it equals the darker color (Color1) then the paintstyle // is "shade". GradientPaint gp = ((GradientPaint) paint); if (cfCHART.getDarkerColor(gp.getColor2()).equals(gp.getColor1())) paint = gp.getColor2(); // the lighter color else paint = gp.getColor1(); // the darker color } return new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black); }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
private static LegendItem getCopy(LegendItem original, String newLabel) { return new LegendItem(newLabel, null, //description null, //tooltip text null, //URL original.isShapeVisible(), original.getShape(), original.isShapeFilled(), original.getFillPaint(), original.isShapeOutlineVisible(), original.getOutlinePaint(), original.getOutlineStroke(), original.isLineVisible(), original.getLine(), original.getLineStroke(), original.getLinePaint()); }
From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java
/** process the lines */ private final void __processLines() { final LegendItemCollection legendCollection; final boolean addLegend; final ChartPalette palette; Stroke legendStroke;/* w w w. ja va2s .c o m*/ Color legendColor; int index; Line2D line; List<Line2D> lines; Iterator<Point2D> it; Point2D p; boolean foreground; XYSeries ser; String name; LegendItem item; lines = this.getBackgroundLines(); ((_JFCXYLineAndShapeRenderer) (this.m_plot.getDrawingSupplier())).m_backgroundCount = lines.size(); foreground = false; legendCollection = new LegendItemCollection(); addLegend = (this.getLegendType() != ELegendType.NO_LEGEND); palette = this.getDriver().getPalette(); // first add all foreground lines, than all background lines outer: for (;;) { index = 0; while (lines.size() > 0) { line = lines.remove(0); it = this.iterateLinePoints(line); // // are there any points to plot? // if (it.hasNext()) { // // then let's make a series and plot them! name = line.name(); ser = new XYSeries(((name != null) ? name : EmptyUtils.EMPTY_STRING), false, true); while (it.hasNext()) { p = it.next(); ser.add(_JFCLineChart2D.__format(p.getX()), _JFCLineChart2D.__format(p.getY())); } this.m_dataset.addSeries(ser); if (addLegend && (name != null) && (name.length() > 0)) { legendColor = (foreground ? // palette.getForegroundDataColor(index)// : palette.getBackgroundDataColor(index)); legendStroke = (foreground ? // palette.getForegroundDataStroke(index)// : palette.getBackgroundDataStroke(index)); item = new LegendItem(// name, null, null, null, // text false, _JFCLineChart2D.EMPTY_SHAPE, false, // shape legendColor, // false, // legendColor, // legendStroke, // false, _JFCLineChart2D.EMPTY_SHAPE, // line legendStroke, // legendColor// ); item.setLabelFont(palette.getLegendFont()); item.setLabelPaint(legendColor); legendCollection.add(item); } index++; // } } if (foreground) { break outer; } foreground = true; lines = this.getLines(); } this.m_plot.setFixedLegendItems(legendCollection); }
From source file:msi.gama.outputs.layers.charts.StandardXYItemRenderer.java
/** * Returns a legend item for a series.// w w w. j a v a 2 s. co m * * @param datasetIndex * the dataset index (zero-based). * @param series * the series index (zero-based). * * @return A legend item for the series. */ @Override public LegendItem getLegendItem(final int datasetIndex, final int series) { final XYPlot plot = getPlot(); if (plot == null) { return null; } LegendItem result = null; final XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { final String label = getLegendItemLabelGenerator().generateLabel(dataset, series); final String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } final Shape shape = lookupLegendShape(series); final boolean shapeFilled = getItemShapeFilled(series, 0); final Paint paint = lookupSeriesPaint(series); final Paint linePaint = paint; final Stroke lineStroke = lookupSeriesStroke(series); result = new LegendItem(label, description, toolTipText, urlText, this.baseShapesVisible, shape, shapeFilled, paint, !shapeFilled, paint, lineStroke, this.plotLines, this.legendLine, lineStroke, linePaint); result.setLabelFont(lookupLegendTextFont(series)); final Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result; }
From source file:org.openfaces.component.chart.impl.renderers.XYLineFillRenderer.java
private LegendItem createLegendItem(int dataSetIndex, int series, XYDataset dataSet) { Shape shape = lookupLegendShape(series); Paint fillPaint = (getUseFillPaint() ? lookupSeriesFillPaint(series) : lookupSeriesPaint(series)); Paint outlinePaint = (getUseOutlinePaint() ? lookupSeriesOutlinePaint(series) : lookupSeriesPaint(series)); Stroke outlineStroke = lookupSeriesOutlineStroke(series); Stroke lineStroke = lookupSeriesStroke(series); Paint linePaint = lookupSeriesPaint(series); Paint labelPaint = lookupLegendTextPaint(series); Font labelFont = lookupLegendTextFont(series); String itemLegendLabel = getLegendItemLabelGenerator().generateLabel(dataSet, series); final XYSeriesLabelGenerator toolTipGenerator = getLegendItemToolTipGenerator(); String toolTipText = (toolTipGenerator != null) ? toolTipGenerator.generateLabel(dataSet, series) : null; final XYSeriesLabelGenerator urlGenerator = getLegendItemURLGenerator(); String urlText = urlGenerator != null ? urlGenerator.generateLabel(dataSet, series) : null; boolean isItemShapeVisible = getItemShapeVisible(series, 0); boolean isItemShapeFilled = getItemShapeFilled(series, 0); boolean isItemShapeOutlineVisible = getDrawOutlines(); boolean isItemLineVisible = getItemLineVisible(series, 0); LegendItem legendItem = new LegendItem(itemLegendLabel, itemLegendLabel, toolTipText, urlText, isItemShapeVisible, shape, isItemShapeFilled, fillPaint, isItemShapeOutlineVisible, outlinePaint, outlineStroke, isItemLineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), lineStroke, linePaint); legendItem.setLabelFont(labelFont);/*www.j a v a 2s . c o m*/ legendItem.setLabelPaint(labelPaint); legendItem.setSeriesKey(dataSet.getSeriesKey(series)); legendItem.setSeriesIndex(series); legendItem.setDataset(dataSet); legendItem.setDatasetIndex(dataSetIndex); return legendItem; }
From source file:edu.dlnu.liuwenpeng.render.BarRenderer.java
/** * Returns a legend item for a series. * /*w ww .j a v a 2 s . c om*/ * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; }
From source file:edu.dlnu.liuwenpeng.render.LineAndShapeRenderer.java
/** * Returns a legend item for a series. * //from w ww. j av a 2 s .co m * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupSeriesShape(series); Paint paint = lookupSeriesPaint(series); Paint fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); boolean lineVisible = getItemLineVisible(series, 0); boolean shapeVisible = getItemShapeVisible(series, 0); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeVisible, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; }
From source file:KIDLYRenderer.java
/** * Returns a legend item for a series.//from w w w .ja va 2s . c om * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; }