本文整理匯總了Java中org.jfree.chart.title.LegendTitle類的典型用法代碼示例。如果您正苦於以下問題:Java LegendTitle類的具體用法?Java LegendTitle怎麽用?Java LegendTitle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LegendTitle類屬於org.jfree.chart.title包,在下文中一共展示了LegendTitle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: exportAsImage
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Exports the current chart as an image.
* @param width The width of the image
* @param height The height of the image
* @param hideLegend If true, the image will not contain the legend
* @return The image
*/
public BufferedImage exportAsImage(int width, int height, boolean hideLegend){
LegendTitle legend = null;
if(hideLegend){
// Remove legend while exporting the image
legend = this.chartPanel.getChart().getLegend();
this.chartPanel.getChart().removeLegend();
}
BufferedImage thumb = this.chartPanel.getChart().createBufferedImage(width, height, 600, 400, null);
if(hideLegend){
// If the legend was removed, add it after exporting the image
this.chartPanel.getChart().addLegend(legend);
}
return thumb;
}
示例2: legendPositionChanged
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
private void legendPositionChanged(LegendPosition legendPosition) {
JFreeChart chart = getCurrentChart();
if (chart != null) {
LegendTitle legend = chart.getLegend();
RectangleEdge position = legendPosition.getPosition();
if (legend != null) {
if (position != null) {
legend.setPosition(position);
} else {
while (chart.getLegend() != null) {
chart.removeLegend();
}
}
} else {
if (position != null) {
resetLegend();
}
}
}
}
示例3: paintDeviationChart
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
public void paintDeviationChart(Graphics graphics, int width, int height) {
prepareData();
JFreeChart chart = createChart(this.dataset);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
}
Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height);
chart.draw((Graphics2D) graphics, drawRect);
}
示例4: getLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Returns the nth legend for a chart, or <code>null</code>.
*
* @param index the legend index (zero-based).
*
* @return The legend (possibly <code>null</code>).
*
* @see #addLegend(LegendTitle)
*/
public LegendTitle getLegend(int index) {
int seen = 0;
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title subtitle = (Title) iterator.next();
if (subtitle instanceof LegendTitle) {
if (seen == index) {
return (LegendTitle) subtitle;
}
else {
seen++;
}
}
}
return null;
}
示例5: updateLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Update legend
*/
private void updateLegend() {
_chart.removeLegend();
final LegendTitle legend = new LegendTitle(() -> {
final LegendItemCollection collection = new LegendItemCollection();
if (_currentMode == DisplayMode.TIME) {
collection.add(new LegendItem(Legend.LATENCY.label, null, null, null, new Rectangle(30, 20), Legend.LATENCY.color));
if (_dnsLookup && _services.isEmbeddedTRAvailable() && !Env.INSTANCE.isUseOSTraceroute()) {
collection.add(new LegendItem(Legend.DNS.label, null, null, null, new Rectangle(30, 20), Legend.DNS.color));
}
} else {
collection.add(new LegendItem(Legend.DISTANCE.label, Legend.DISTANCE.color));
}
return collection;
});
legend.setPosition(RectangleEdge.BOTTOM);
_chart.addLegend(legend);
}
示例6: getLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Returns the nth legend for a chart, or <code>null</code>.
*
* @param index the legend index (zero-based).
*
* @return The legend (possibly <code>null</code>).
*
* @see #addLegend(LegendTitle)
*/
public LegendTitle getLegend(int index) {
int seen = 0;
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title subtitle = (Title) iterator.next();
if (subtitle instanceof LegendTitle) {
if (seen == index) {
return (LegendTitle) subtitle;
}
else {
seen++;
}
}
}
return null;
}
示例7: getLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Returns the nth legend for a chart, or {@code null}.
*
* @param index the legend index (zero-based).
*
* @return The legend (possibly {@code null}).
*
* @see #addLegend(LegendTitle)
*/
public LegendTitle getLegend(int index) {
int seen = 0;
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title subtitle = (Title) iterator.next();
if (subtitle instanceof LegendTitle) {
if (seen == index) {
return (LegendTitle) subtitle;
}
else {
seen++;
}
}
}
return null;
}
示例8: fillChart
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
private void fillChart(String title, List<String> names,
List<String> colors, List<Float> values) throws Exception {
DefaultPieDataset data=new DefaultPieDataset();
for (int ix=0; ix<names.size(); ix++) {
data.setValue( names.get(ix), values.get(ix) );
}
this.chart=ChartFactory.createPieChart3D(
title,
data,
true,
true,
false);
LegendTitle legend=this.chart.getLegend();
legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9) );
PiePlot plot=(PiePlot)this.chart.getPlot();
plot.setCircular(true);
plot.setBackgroundAlpha(0.9f);
plot.setForegroundAlpha(0.5f);
plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
this.setPlotColor( plot, names, colors );
this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) );
}
示例9: styleChart
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* TODO Documentation
*
* @param chart
* @return
*/
protected JFreeChart styleChart(JFreeChart chart) {
chart.setBackgroundPaint(Color.white);
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);
legend.setVisible(false);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.lightGray);
final LineAndShapeRenderer renderer = new LineAndShapeRenderer();
renderer.setSeriesLinesVisible(0,true);
renderer.setSeriesShapesVisible(1, true);
renderer.setBaseLinesVisible(true);
renderer.setBaseShapesFilled(true);
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.lightGray);
plot.setRenderer(renderer);
// customise the range axis...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
rangeAxis.setStandardTickUnits(rangeAxis.getStandardTickUnits());
return chart;
}
示例10: styleChart
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* TODO Documentation
*
* @param chart
* @return
*/
public JFreeChart styleChart(JFreeChart chart) {
chart.setBackgroundPaint(Color.white);
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);
legend.setVisible(false);
XYPlot chartPlot = chart.getXYPlot();
chartPlot.setBackgroundPaint(Color.white);
chartPlot.setForegroundAlpha(0.7F);
XYItemRenderer brRenderer = chartPlot.getRenderer();
chartPlot.setDomainGridlinesVisible(true);
chartPlot.setDomainGridlinePaint(Color.GRAY);
chartPlot.setRangeGridlinePaint(Color.GRAY);
brRenderer.setSeriesPaint(0, new Color(0,0,139));
// customise the range axis...
final ValueAxis domainAxis = chartPlot.getDomainAxis();
domainAxis.setLowerMargin(0.0);
return chart;
}
示例11: createChart
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return The chart.
*/
protected JFreeChart createChart(CategoryDataset dataset) {
// get a reference to the plot for further customisation...
SOCRSpiderWebPlot plot = new SOCRSpiderWebPlot(dataset);
JFreeChart chart = new JFreeChart(
chartTitle, TextTitle.DEFAULT_FONT, plot, false
);
LegendTitle legend = new LegendTitle(plot);
legend.setPosition(RectangleEdge.BOTTOM);
//renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
chart.addSubtitle(legend);
setCategorySummary(dataset);
if (legendPanelOn)
chart.removeLegend();
return chart;
}
示例12: getLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Returns the nth legend for a chart, or <code>null</code>.
*
* @param index the legend index (zero-based).
*
* @return The legend (possibly <code>null</code>).
*/
public LegendTitle getLegend(int index) {
int seen = 0;
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title subtitle = (Title) iterator.next();
if (subtitle instanceof LegendTitle) {
if (seen == index) {
return (LegendTitle) subtitle;
}
else {
seen++;
}
}
}
return null;
}
示例13: getLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Returns the nth legend for a chart, or <code>null</code>.
*
* @param index the legend index (zero-based).
* @return The legend (possibly <code>null</code>).
* @see #addLegend(LegendTitle)
*/
public LegendTitle getLegend(int index) {
int seen = 0;
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title subtitle = (Title) iterator.next();
if (subtitle instanceof LegendTitle) {
if (seen == index) {
return (LegendTitle) subtitle;
} else {
seen++;
}
}
}
return null;
}
示例14: setLegend
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
private void setLegend(JFreeChart chart) {
chart.removeLegend();
final LegendTitle legend = new LegendTitle(new SpectrumLegendItemSource());
legend.setPosition(RectangleEdge.BOTTOM);
LineBorder border = new LineBorder(Color.BLACK, new BasicStroke(), new RectangleInsets(2, 2, 2, 2));
legend.setFrame(border);
chart.addLegend(legend);
}
示例15: createLegendTitles
import org.jfree.chart.title.LegendTitle; //導入依賴的package包/類
/**
* Creates {@link LegendTitle}s for all dimensions from the PlotConfiguration of this Plotter2D.
* Expects that all {@link ValueSource} s in the provided PlotConfiguration use the same
* {@link DimensionConfig} s.
*/
private List<LegendTitle> createLegendTitles() {
List<LegendTitle> legendTitles = new LinkedList<LegendTitle>();
LegendConfiguration legendConfiguration = plotInstance.getCurrentPlotConfigurationClone().getLegendConfiguration();
LegendTitle legendTitle = new SmartLegendTitle(this, new FlowArrangement(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 30, 2), new ColumnArrangement(
HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 2));
legendTitle.setItemPaint(legendConfiguration.getLegendFontColor());
RectangleEdge position = legendConfiguration.getLegendPosition().getPosition();
if (position == null) {
return legendTitles;
}
legendTitle.setPosition(position);
if (legendConfiguration.isShowLegendFrame()) {
legendTitle.setFrame(new BlockBorder(legendConfiguration.getLegendFrameColor()));
}
ColoredBlockContainer wrapper = new ColoredBlockContainer(legendConfiguration.getLegendBackgroundColor());
wrapper.add(legendTitle.getItemContainer());
wrapper.setPadding(3, 3, 3, 3);
legendTitle.setWrapper(wrapper);
legendTitles.add(legendTitle);
return legendTitles;
}