本文整理汇总了Java中org.jfree.chart.LegendItemSource类的典型用法代码示例。如果您正苦于以下问题:Java LegendItemSource类的具体用法?Java LegendItemSource怎么用?Java LegendItemSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LegendItemSource类属于org.jfree.chart包,在下文中一共展示了LegendItemSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LegendTitle
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Creates a new legend title with the specified arrangement.
*
* @param source the source.
* @param hLayout the horizontal item arrangement (<code>null</code> not
* permitted).
* @param vLayout the vertical item arrangement (<code>null</code> not
* permitted).
*/
public LegendTitle(LegendItemSource source,
Arrangement hLayout, Arrangement vLayout) {
this.sources = new LegendItemSource[] {source};
this.items = new BlockContainer(hLayout);
this.hLayout = hLayout;
this.vLayout = vLayout;
this.backgroundPaint = null;
this.legendItemGraphicEdge = RectangleEdge.LEFT;
this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
this.legendItemGraphicLocation = RectangleAnchor.CENTER;
this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.itemFont = DEFAULT_ITEM_FONT;
this.itemPaint = DEFAULT_ITEM_PAINT;
this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
}
示例2: LegendTitle
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Creates a new legend title with the specified arrangement.
*
* @param source the source.
* @param hLayout the horizontal item arrangement (<code>null</code> not
* permitted).
* @param vLayout the vertical item arrangement (<code>null</code> not
* permitted).
*/
public LegendTitle(LegendItemSource source,
Arrangement hLayout, Arrangement vLayout) {
this.sources = new LegendItemSource[] {source};
this.items = new BlockContainer(hLayout);
this.hLayout = hLayout;
this.vLayout = vLayout;
this.backgroundPaint = null;
this.legendItemGraphicEdge = RectangleEdge.LEFT;
this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
this.legendItemGraphicLocation = RectangleAnchor.CENTER;
this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.itemFont = DEFAULT_ITEM_FONT;
this.itemPaint = DEFAULT_ITEM_PAINT;
this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.sortOrder = SortOrder.ASCENDING;
}
示例3: LegendTitle
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Creates a new legend title with the specified arrangement.
*
* @param source the source.
* @param hLayout the horizontal item arrangement ({@code null} not
* permitted).
* @param vLayout the vertical item arrangement ({@code null} not
* permitted).
*/
public LegendTitle(LegendItemSource source,
Arrangement hLayout, Arrangement vLayout) {
this.sources = new LegendItemSource[] {source};
this.items = new BlockContainer(hLayout);
this.hLayout = hLayout;
this.vLayout = vLayout;
this.backgroundPaint = null;
this.legendItemGraphicEdge = RectangleEdge.LEFT;
this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
this.legendItemGraphicLocation = RectangleAnchor.CENTER;
this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.itemFont = DEFAULT_ITEM_FONT;
this.itemPaint = DEFAULT_ITEM_PAINT;
this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.sortOrder = SortOrder.ASCENDING;
}
示例4: LegendTitle
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Creates a new legend title with the specified arrangement.
*
* @param source the source.
* @param hLayout the horizontal item arrangement (<code>null</code> not
* permitted).
* @param vLayout the vertical item arrangement (<code>null</code> not
* permitted).
*/
public LegendTitle(LegendItemSource source,
Arrangement hLayout, Arrangement vLayout) {
this.sources = new LegendItemSource[] {source};
this.items = new BlockContainer(hLayout);
this.hLayout = hLayout;
this.vLayout = vLayout;
this.backgroundPaint = null;
this.legendItemGraphicEdge = RectangleEdge.LEFT;
this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
this.legendItemGraphicLocation = RectangleAnchor.CENTER;
this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
this.itemFont = DEFAULT_ITEM_FONT;
this.itemPaint = DEFAULT_ITEM_PAINT;
this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
}
示例5: createLegend
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
public static LegendTitle createLegend() {
final LegendItemCollection legendItems = new LegendItemCollection();
FontRenderContext frc = new FontRenderContext(null, true, true);
Font legenfont = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
GlyphVector gv = legenfont.createGlyphVector(frc, new char[] {'I', 'I'});
Shape shape = gv.getVisualBounds();
Rectangle2D bounds = shape.getBounds2D();
{
LegendItem li = new LegendItem("Standard error", null, null, null,
new ErrorIndicator(bounds), new BasicStroke(), ErrorIndicator.ERROR_INDICATOR_COLOR);
li.setLabelFont(legenfont);
legendItems.add(li);
}
LegendTitle legend = new LegendTitle(new LegendItemSource() {
@Override
public LegendItemCollection getLegendItems() {
return legendItems;
}});
legend.setPosition(RectangleEdge.BOTTOM);
legend.setMargin(new RectangleInsets(0,30,0,0));
legend.setPadding(RectangleInsets.ZERO_INSETS);
legend.setLegendItemGraphicPadding(new RectangleInsets(0,20,0,0));
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
return legend;
}
示例6: createLegend
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
private LegendTitle createLegend() {
final LegendItemCollection legendItems = new LegendItemCollection();
FontRenderContext frc = new FontRenderContext(null, true, true);
GlyphVector gv = LEGEND_FONT.createGlyphVector(frc, new char[] {'X'});
Shape shape = gv.getGlyphVisualBounds(0);
for(Pair<String, Color> p : getLegend()) {
LegendItem li = new LegendItem(p.getLeft(), null, null, null, shape, p.getRight());
li.setLabelFont(LEGEND_FONT);
legendItems.add(li);
}
LegendTitle legend = new LegendTitle(new LegendItemSource() {
@Override
public LegendItemCollection getLegendItems() {
return legendItems;
}});
legend.setPosition(RectangleEdge.BOTTOM);
return legend;
}
示例7: createLegend
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
public static void createLegend(JFreeChart kmPlot, List<KMPlotPointSeriesSet> plotPointSeriesSetCollection) {
LegendTitle legend = kmPlot.getLegend();
LegendItemSource[] sources = new LegendItemSource[1];
KMLegendItemSource legendSrc = new KMLegendItemSource();
Comparator<KMPlotPointSeriesSet> nameComparator = new Comparator<KMPlotPointSeriesSet>() {
public int compare(KMPlotPointSeriesSet series1, KMPlotPointSeriesSet series2) {
return series1.getName().compareToIgnoreCase(series2.getName());
}
};
Collections.sort(plotPointSeriesSetCollection, nameComparator);
LegendItem item ;
for (KMPlotPointSeriesSet plotPointSeries : plotPointSeriesSetCollection) {
Color color = plotPointSeries.getColor();
String title = plotPointSeries.getLegendTitle() + " (" + plotPointSeries.getGroupSize() + ")";
item = new LegendItem(title, null, null, null, new Rectangle2D.Double(2,2,10,10), color);
legendSrc.addLegendItem(item);
}
sources[0] = legendSrc;
legend.setSources(sources);
}
示例8: setSources
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Sets the legend item sources and sends a {@link TitleChangeEvent} to
* all registered listeners.
*
* @param sources the sources (<code>null</code> not permitted).
*/
public void setSources(LegendItemSource[] sources) {
if (sources == null) {
throw new IllegalArgumentException("Null 'sources' argument.");
}
this.sources = sources;
notifyListeners(new TitleChangeEvent(this));
}
示例9: setSources
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Sets the legend item sources and sends a {@link TitleChangeEvent} to
* all registered listeners.
*
* @param sources the sources (<code>null</code> not permitted).
*/
public void setSources(LegendItemSource[] sources) {
if (sources == null) {
throw new IllegalArgumentException("Null 'sources' argument.");
}
this.sources = sources;
notifyListeners(new TitleChangeEvent(this));
}
示例10: removeItemFromLegend
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
protected void removeItemFromLegend(int itemToRemove, JFreeChart chart) {
LegendItemCollection legendItems = chart.getPlot().getLegendItems();
final LegendItemCollection newLegendItems = new LegendItemCollection();
for (int i = 0; i < legendItems.getItemCount(); i++) {
if (itemToRemove != i)
newLegendItems.add(legendItems.get(i));
}
LegendItemSource source = new LegendItemSource() {
@Override
public LegendItemCollection getLegendItems() {
return newLegendItems;
}
};
chart.removeLegend();
chart.addLegend(new LegendTitle(source));
}
示例11: createBarChart
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
private static JFreeChart createBarChart(ADCDataset dataset) {
AutoSubCategoryAxis categoryAxis = new AutoSubCategoryAxis(dataset);
categoryAxis.setCategoryLabelPositionOffset(0);
categoryAxis.setLabel(dataset.get(Attribute.X_AXIS_LABEL));
CategoryDataset fixedDataset = categoryAxis.getFixedDataset();
PartitionedNumberAxis vAxis = new PartitionedNumberAxis(
dataset.get(Attribute.Y_AXIS_LABEL));
CategoryPlot plot = new CategoryPlot(fixedDataset,
categoryAxis, vAxis, new Renderer(fixedDataset));
plot.setOrientation(PlotOrientation.VERTICAL);
JFreeChart chart = new JFreeChart(dataset.get(Attribute.TITLE),
JFreeChart.DEFAULT_TITLE_FONT, plot, false);
final LegendItemCollection items = new LegendItemCollection();
for(Condition c : Condition.values()) {
if(c != Condition.NOT_EVALUATED) {
items.add(new LegendItem(c.getLabel(), null, null, null,
new Rectangle2D.Double(-6.0, -6.0, 10.0,10.0), c.getColor()));
}
}
LegendTitle legend = new LegendTitle(new LegendItemSource() {
@Override
public LegendItemCollection getLegendItems() {
return items;
}});
legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
legend.setBackgroundPaint(Color.white);
legend.setPosition(RectangleEdge.BOTTOM);
chart.addLegend(legend);
new StandardChartTheme("JFree").apply(chart);
return chart;
}
示例12: SmartLegendTitle
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
public SmartLegendTitle(LegendItemSource source, Arrangement hLayout, Arrangement vLayout) {
super(source, hLayout, vLayout);
}
示例13: run
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
@Override
public void run() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries serie = new XYSeries("insert", true, false);
for (int ligne = 0; ligne < getDatas().size(); ++ligne) {
serie.add(ligne, getDatas().get(ligne));
}
dataset.addSeries(serie);
NumberAxis Laxis = new NumberAxis("n°revision");
XYBarRenderer revBarRenderer = new XYBarRenderer();
XYPlot revPlot = new XYPlot();
revPlot.setDataset(dataset);
revPlot.setRangeAxis(Laxis);
revPlot.setRenderer(revBarRenderer);
XYSeriesCollection xySerieCollectiondataset = new XYSeriesCollection();
XYLineAndShapeRenderer lengthRenderer = new XYLineAndShapeRenderer();
int i = -1;
int iName = 0;
for (ArrayList<Integer> lengthSerie : lengths) {
serie = new XYSeries(legend.get(iName));
++iName;
lengthRenderer.setSeriesShapesVisible(++i, false);
// PROMPT LENGTHS DATA
for (int ligne = 0; ligne < lengthSerie.size(); ++ligne) {
serie.add(ligne, lengthSerie.get(ligne));
}
xySerieCollectiondataset.addSeries(serie);
}
NumberAxis Raxis = new NumberAxis("length");
XYPlot lengthPlot = new XYPlot();
lengthPlot.setDataset(xySerieCollectiondataset);
lengthPlot.setRangeAxis(Raxis);
lengthRenderer.setSeriesPaint(2, Color.MAGENTA);
lengthPlot.setRenderer(lengthRenderer);
CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot();
mainPlot.add(revPlot);
mainPlot.add(lengthPlot);
setChart(new JFreeChart("Spectrum of " + getOpName(), null, mainPlot,
false));
final LegendItemCollection legendItemsOld = mainPlot.getLegendItems();
LegendItemSource source = new LegendItemSource() {
public LegendItemCollection getLegendItems() {
LegendItemCollection lic = new LegendItemCollection();
int itemCount = legendItemsOld.getItemCount();
for (int i = 0; i < itemCount; i++) {
lic.add(legendItemsOld.get(i));
}
return lic;
}
};
getChart().addLegend(new LegendTitle(source));
getChart().getLegend().setPosition(RectangleEdge.TOP);
getChart().getLegend().getItemContainer().getBlocks();
if (!note.isEmpty()){
TextTitle legendText = new TextTitle("Notes : \n"+note);
legendText.setPosition(RectangleEdge.BOTTOM);
getChart().addSubtitle(legendText);
}
setFrame(new ChartFrame(getPageName(), getChart()));
}
示例14: getSources
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Returns the legend item sources.
*
* @return The sources.
*/
public LegendItemSource[] getSources() {
return this.sources;
}
示例15: getSources
import org.jfree.chart.LegendItemSource; //导入依赖的package包/类
/**
* Returns the legend item sources.
*
* @return The sources.
*/
public LegendItemSource[] getSources() {
return this.sources;
}