当前位置: 首页>>代码示例>>Java>>正文


Java LegendTitle.setHorizontalAlignment方法代码示例

本文整理汇总了Java中org.jfree.chart.title.LegendTitle.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java LegendTitle.setHorizontalAlignment方法的具体用法?Java LegendTitle.setHorizontalAlignment怎么用?Java LegendTitle.setHorizontalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.title.LegendTitle的用法示例。


在下文中一共展示了LegendTitle.setHorizontalAlignment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:ROCChartPlotter.java

示例2: 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);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:20,代码来源:ROCChartPlotter.java

示例3: createLegend

import org.jfree.chart.title.LegendTitle; //导入方法依赖的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;
}
 
开发者ID:uq-eresearch,项目名称:aorra,代码行数:26,代码来源:ErrorIndicatorLegend.java

示例4: setLegend

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
private void setLegend(JFreeChart chart, Plot plot, Font font) {
	if(!showlegend) return;
		
		
	Color bg = backgroundcolor==null?databackgroundcolor:backgroundcolor;
	if(font==null)font=getFont();
	
	
	
	LegendTitle legend = legendMultiLine?
       		new LegendTitle(plot,new ColumnArrangement(), new ColumnArrangement()):
       		new LegendTitle(plot);
       legend.setBackgroundPaint(bg);
       legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
       legend.setFrame(new LineBorder());
       legend.setPosition(RectangleEdge.BOTTOM);
       legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
       
       legend.setWidth(chartwidth-20);// geht nicht
       legend.setItemFont(font);
	legend.setItemPaint(foregroundcolor);

	//RectangleInsets labelPadding;
	legend.setItemLabelPadding(new RectangleInsets(2,2,2,2));
	legend.setBorder(0,0,0,0); 
	legend.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT);
	legend.setLegendItemGraphicPadding(new RectangleInsets(8,10,0,0));
	chart.addLegend(legend);
	
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:31,代码来源:Chart.java

示例5: updatePlotter

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
@Override
protected void updatePlotter() {
	int categoryCount = prepareData();
	String maxClassesProperty = ParameterService
			.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
	int maxClasses = 20;
	try {
		if (maxClassesProperty != null) {
			maxClasses = Integer.parseInt(maxClassesProperty);
		}
	} catch (NumberFormatException e) {
		// LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
		// LogService.WARNING);
		LogService.getRoot().log(Level.WARNING,
				"com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
	}
	boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

	JFreeChart chart = createChart(this.dataset, createLegend);

	// set the background color for the chart...
	chart.setBackgroundPaint(Color.white);

	// domain axis
	if (axis[INDEX] >= 0) {
		if (!dataTable.isNominal(axis[INDEX])) {
			if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
				DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
				domainAxis.setTimeZone(Tools.getPreferredTimeZone());
				chart.getXYPlot().setDomainAxis(domainAxis);
				if (getRangeForDimension(axis[INDEX]) != null) {
					domainAxis.setRange(getRangeForDimension(axis[INDEX]));
				}
				domainAxis.setLabelFont(LABEL_FONT_BOLD);
				domainAxis.setTickLabelFont(LABEL_FONT);
				domainAxis.setVerticalTickLabels(isLabelRotating());
			}
		} else {
			LinkedHashSet<String> values = new LinkedHashSet<String>();
			for (DataTableRow row : dataTable) {
				String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
				if (stringValue.length() > 40) {
					stringValue = stringValue.substring(0, 40);
				}
				values.add(stringValue);
			}
			ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
					values.toArray(new String[values.size()]));
			categoryAxis.setLabelFont(LABEL_FONT_BOLD);
			categoryAxis.setTickLabelFont(LABEL_FONT);
			categoryAxis.setVerticalTickLabels(isLabelRotating());
			chart.getXYPlot().setDomainAxis(categoryAxis);
		}
	}

	// legend settings
	LegendTitle legend = chart.getLegend();
	if (legend != null) {
		legend.setPosition(RectangleEdge.TOP);
		legend.setFrame(BlockBorder.NONE);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
		legend.setItemFont(LABEL_FONT);
	}

	AbstractChartPanel panel = getPlotterPanel();
	if (panel == null) {
		panel = createPanel(chart);
	} else {
		panel.setChart(chart);
	}

	// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
	panel.getChartRenderingInfo().setEntityCollection(null);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:75,代码来源:SeriesChartPlotter.java

示例6: createChart

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
private JFreeChart createChart(XYDataset dataset) {
	// create the chart...
	JFreeChart chart = ChartFactory.createXYLineChart(null,      // chart title
			null,                      // x axis label
			null,                      // y axis label
			dataset,                  // data
			PlotOrientation.VERTICAL, true,                     // include legend
			true,                     // tooltips
			false                     // urls
			);

	chart.setBackgroundPaint(Color.white);

	// get a reference to the plot for further customisation...
	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setBackgroundPaint(Color.WHITE);
	plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
	plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
	plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

	ValueAxis valueAxis = plot.getRangeAxis();
	valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
	valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);

	ValueAxis domainAxis = plot.getDomainAxis();
	domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
	domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);

	DeviationRenderer renderer = new DeviationRenderer(true, false);
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	if (dataset.getSeriesCount() == 1) {
		renderer.setSeriesStroke(0, stroke);
		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesFillPaint(0, Color.RED);
	} else if (dataset.getSeriesCount() == 2) {
		renderer.setSeriesStroke(0, stroke);
		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesFillPaint(0, Color.RED);

		renderer.setSeriesStroke(1, stroke);
		renderer.setSeriesPaint(1, Color.BLUE);
		renderer.setSeriesFillPaint(1, Color.BLUE);
	} else {
		for (int i = 0; i < dataset.getSeriesCount(); i++) {
			renderer.setSeriesStroke(i, stroke);
			Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
			renderer.setSeriesPaint(i, color);
			renderer.setSeriesFillPaint(i, color);
		}
	}
	renderer.setAlpha(0.12f);
	plot.setRenderer(renderer);

	// legend settings
	LegendTitle legend = chart.getLegend();
	if (legend != null) {
		legend.setPosition(RectangleEdge.TOP);
		legend.setFrame(BlockBorder.NONE);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
		legend.setItemFont(PlotterAdapter.LABEL_FONT);
	}
	return chart;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:64,代码来源:ROCChartPlotter.java

示例7: setChartLegend

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
protected void setChartLegend(JFreeChart jfreeChart, Integer baseFontSize)
{

	//The legend visibility is already taken into account in the jfreeChart object's constructor
	
	LegendTitle legend = jfreeChart.getLegend();
	if (legend != null)
	{
		Font themeLegendFont = getFont((JRFont)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FONT), getChart().getLegendFont(), baseFontSize);
		legend.setItemFont(themeLegendFont);

		Color legendForecolor = getChart().getOwnLegendColor() != null ? 
				getChart().getOwnLegendColor() :
				(getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) != null ? 
						(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) :
						getChart().getLegendColor());
		if (legendForecolor != null)
			legend.setItemPaint(legendForecolor);

		Color legendBackcolor = getChart().getOwnLegendBackgroundColor() != null ? 
				getChart().getOwnLegendBackgroundColor() :
				(getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) != null ? 
						(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) :
						getChart().getLegendBackgroundColor());
		if (legendBackcolor != null)
			legend.setBackgroundPaint(legendBackcolor);
		
		BlockFrame frame = (BlockFrame)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FRAME);
		if (frame != null)
			legend.setFrame(frame);
		
		HorizontalAlignment defaultLegendHAlignment = (HorizontalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_HORIZONTAL_ALIGNMENT);
		if (defaultLegendHAlignment != null)
			legend.setHorizontalAlignment(defaultLegendHAlignment);
		
		VerticalAlignment defaultLegendVAlignment = (VerticalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_VERTICAL_ALIGNMENT);
		if (defaultLegendVAlignment != null)
			legend.setVerticalAlignment(defaultLegendVAlignment);
		
		RectangleInsets defaultLegendPadding = (RectangleInsets)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_PADDING);
		RectangleInsets legendPadding = legend.getPadding() != null ? legend.getPadding() : defaultLegendPadding;
		if (legendPadding != null)
			legend.setPadding(legendPadding);

		RectangleEdge defaultLegendPosition = (RectangleEdge)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_POSITION);
		if (getEdge(getChart().getLegendPositionValue(), defaultLegendPosition) != null)
			legend.setPosition(getEdge(getChart().getLegendPositionValue(), defaultLegendPosition));
		
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:51,代码来源:GenericChartTheme.java

示例8: updatePlotter

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
@Override
protected void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null)
            maxClasses = Integer.parseInt(maxClassesProperty);
    } catch (NumberFormatException e) {
        //LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING);
        LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    JFreeChart chart = createChart(this.dataset, createLegend);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // domain axis
    if (axis[INDEX] >= 0) {
        if (!dataTable.isNominal(axis[INDEX])) {
            if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
                DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
                domainAxis.setTimeZone(Tools.getPreferredTimeZone());
                chart.getXYPlot().setDomainAxis(domainAxis);
                if (getRangeForDimension(axis[INDEX]) != null)
                    domainAxis.setRange(getRangeForDimension(axis[INDEX]));
                domainAxis.setLabelFont(LABEL_FONT_BOLD);
                domainAxis.setTickLabelFont(LABEL_FONT);
                domainAxis.setVerticalTickLabels(isLabelRotating());
            }
        } else {
            LinkedHashSet<String> values = new LinkedHashSet<String>();
            for (DataTableRow row : dataTable) {
                String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
                if (stringValue.length() > 40)
                    stringValue = stringValue.substring(0, 40);
                values.add(stringValue);
            }
            ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]), values.toArray(new String[values.size()]));
            categoryAxis.setLabelFont(LABEL_FONT_BOLD);
            categoryAxis.setTickLabelFont(LABEL_FONT);
            categoryAxis.setVerticalTickLabels(isLabelRotating());
            chart.getXYPlot().setDomainAxis(categoryAxis);
        }
    }

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:68,代码来源:SeriesChartPlotter.java

示例9: updatePlotter

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
public void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null)
            maxClasses = Integer.parseInt(maxClassesProperty);
    } catch (NumberFormatException e) {
        //LogService.getGlobal().log("Pie Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING);
        LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.pie_chart_plotter_parsing_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    if (categoryCount <= MAX_CATEGORIES) {
        JFreeChart chart = createChart(pieDataSet, createLegend);

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.white);

        PiePlot plot = (PiePlot) chart.getPlot();

        plot.setBackgroundPaint(Color.WHITE);
        plot.setSectionOutlinesVisible(true);
        plot.setShadowPaint(new Color(104, 104, 104, 100));

        int size = pieDataSet.getKeys().size();
        for (int i = 0; i < size; i++) {
            Comparable key = pieDataSet.getKey(i);
            plot.setSectionPaint(key, getColorProvider().getPointColor(i / (double) (size - 1)));

            boolean explode = false;
            for (String explosionGroup : explodingGroups) {
                if (key.toString().startsWith(explosionGroup) || explosionGroup.startsWith(key.toString())) {
                    explode = true;
                    break;
                }
            }

            if (explode) {
                plot.setExplodePercent(key, this.explodingAmount);
            }
        }

        plot.setLabelFont(LABEL_FONT);
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        plot.setOutlinePaint(Color.WHITE);

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }

        if (panel instanceof AbstractChartPanel) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        //LogService.getGlobal().logNote("Too many columns (" + categoryCount + "), this chart is only able to plot up to " + MAX_CATEGORIES + " different categories.");
        LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.too_many_columns", 
        		new Object[] {categoryCount, MAX_CATEGORIES});
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:76,代码来源:AbstractPieChartPlotter.java

示例10: createChart

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
private JFreeChart createChart(XYDataset dataset) {
      // create the chart...
      JFreeChart chart = ChartFactory.createXYLineChart(
          null,      // chart title
          null,                      // x axis label
          null,                      // y axis label
          dataset,                  // data
          PlotOrientation.VERTICAL,
          true,                     // include legend
          true,                     // tooltips
          false                     // urls
      );

      chart.setBackgroundPaint(Color.white);
     
      // get a reference to the plot for further customisation...
      XYPlot plot = (XYPlot) chart.getPlot();
      plot.setBackgroundPaint(Color.WHITE);
      plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
      plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
      plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
     
      ValueAxis valueAxis = plot.getRangeAxis();
      valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
      valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);

      ValueAxis domainAxis = plot.getDomainAxis();
      domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
      domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
      
      DeviationRenderer renderer = new DeviationRenderer(true, false);
      Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
      if (dataset.getSeriesCount() == 1) {
          renderer.setSeriesStroke(0, stroke);
          renderer.setSeriesPaint(0, Color.RED);
          renderer.setSeriesFillPaint(0, Color.RED);            
      } else if (dataset.getSeriesCount() == 2) {        	
      	renderer.setSeriesStroke(0, stroke);
      	renderer.setSeriesPaint(0, Color.RED);
      	renderer.setSeriesFillPaint(0, Color.RED);
      	
      	renderer.setSeriesStroke(1, stroke);
      	renderer.setSeriesPaint(1, Color.BLUE);
      	renderer.setSeriesFillPaint(1, Color.BLUE);
      } else {
          for (int i = 0; i < dataset.getSeriesCount(); i++) {
              renderer.setSeriesStroke(i, stroke);
              Color color = colorProvider.getPointColor((double)i / (double)(dataset.getSeriesCount() - 1));
              renderer.setSeriesPaint(i, color);
              renderer.setSeriesFillPaint(i, color);
          }
      }
      renderer.setAlpha(0.12f);        
      plot.setRenderer(renderer);
        
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
	legend.setPosition(RectangleEdge.TOP);
	legend.setFrame(BlockBorder.NONE);
	legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
	legend.setItemFont(PlotterAdapter.LABEL_FONT);
}
      return chart;
  }
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:66,代码来源:ROCChartPlotter.java

示例11: getPieChart

import org.jfree.chart.title.LegendTitle; //导入方法依赖的package包/类
public String getPieChart(String type , String title , Map hashMap , Date startDate , Date endDate) {
	CHARTS_PATH = "C://" + type + startDate.getTime()+endDate.getTime()+".jpg";
	File file = new File(CHARTS_PATH);
	if(file.exists()){
		file.delete();
	}
	try {
		DefaultPieDataset dataset = new DefaultPieDataset();
		for(Object o : hashMap.keySet()){
			dataset.setValue(String.valueOf(o), Integer.parseInt((String) hashMap.get(o)));
		}
		JFreeChart chart = ChartFactory.createPieChart3D( title,       // 图表标题
			      dataset,     // 绘图数据集
			      false,       // 设定是否显示图例
			      false,       // 设定是否显示图例名称
			      false);      // 设定是否生成链接
		chart.setAntiAlias(false);
		
		PiePlot pieplot = (PiePlot)chart.getPlot();
		pieplot.setLabelFont(new Font("宋体", 0, 15));
        pieplot.setNoDataMessage("NO DATA!");
        pieplot.setCircular(true);
        pieplot.setLabelGap(0.02D);
        pieplot.setBackgroundPaint(new Color(199,237,204));
                pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator(
                "{0} {2}",
                NumberFormat.getNumberInstance(),
                new DecimalFormat("0.00%")));
        pieplot.setForegroundAlpha(0.6f);
                
        LegendTitle legendtitle = new LegendTitle(chart.getPlot());
        legendtitle.setWidth(100D);
        BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
       	blockcontainer.setBorder(new BlockBorder(1.0D, 1.0D, 1.0D, 1.0D));
       
       
		LabelBlock labelblock = new LabelBlock("Percent:", new Font("宋体", 1, 16));
		labelblock.setPadding(5D, 5D, 5D, 5D);
		blockcontainer.add(labelblock, RectangleEdge.TOP);
		BlockContainer blockcontainer1 = legendtitle.getItemContainer();
		blockcontainer1.setPadding(2D, 10D, 5D, 2D);
		blockcontainer.add(blockcontainer1);
		legendtitle.setWrapper(blockcontainer);
		legendtitle.setPosition(RectangleEdge.RIGHT);
		legendtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
		chart.addSubtitle(legendtitle);
		chart.setBackgroundPaint(new Color(199,237,204));
		
		TextTitle pcTitle = chart.getTitle();
		pcTitle.setFont(new Font("汉真广标", Font.BOLD, 21));
		pcTitle.setPaint(Color.RED);
		
		ChartUtilities.saveChartAsJPEG(file, chart, CHARTS_WIDTH, CHARTS_HEIGHT);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return CHARTS_PATH;
}
 
开发者ID:jbosschina,项目名称:jcommerce,代码行数:59,代码来源:ReportManagerImpl.java


注:本文中的org.jfree.chart.title.LegendTitle.setHorizontalAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。