• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PieSliceRenderer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.erichseifert.gral.plots.PiePlot.PieSliceRenderer的典型用法代码示例。如果您正苦于以下问题:Java PieSliceRenderer类的具体用法?Java PieSliceRenderer怎么用?Java PieSliceRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PieSliceRenderer类属于de.erichseifert.gral.plots.PiePlot包,在下文中一共展示了PieSliceRenderer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: SimplePiePlot

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public SimplePiePlot() {
	// Create data
	DataTable data = new DataTable(Integer.class);
	for (int i = 0; i < SAMPLE_COUNT; i++) {
		int val = random.nextInt(8) + 2;
		data.add((random.nextDouble() <= 0.15) ? -val : val);
	}

	// Create new pie plot
	PiePlot plot = new PiePlot(data);

	// Format plot
	plot.getTitle().setText(getDescription());
	// Change relative size of pie
	plot.setRadius(0.9);
	// Display a legend
	plot.setLegendVisible(true);
	// Add some margin to the plot area
	plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));

	PieSliceRenderer pointRenderer =
			(PieSliceRenderer) plot.getPointRenderer(data);
	// Change relative size of inner region
	pointRenderer.setInnerRadius(0.4);
	// Change the width of gaps between segments
	pointRenderer.setGap(0.2);
	// Change the colors
	LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
	pointRenderer.setColor(colors);
	// Show labels
	pointRenderer.setValueVisible(true);
	pointRenderer.setValueColor(Color.WHITE);
	pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));

	// Add plot to Swing component
	add(new InteractivePanel(plot), BorderLayout.CENTER);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:39,代码来源:SimplePiePlot.java


示例2: render

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@Override
public void render(Canvas componentCanvas, PLPieChartBlock component) {
    DataTable dataTable = new DataTable(Integer.class);
    PiePlot plot = new PiePlot(dataTable);
    super.preparePlot(plot, component);
    Integer[] dataset = component.getData();
    Float gap = component.getGap();
    Float innerRadius = component.getInnerRadius();
    Float outerRadius = component.getOuterRadius();
    Color pieColor = PLColor.create(component.getPieColor(), Color.class);
    Color[] colors = (component.getColors() == null)?null:Arrays.stream(component.getColors()).map(color -> PLColor.create(color, Color.class)).toArray(Color[]::new);
    if(dataset != null){
        for(Integer row:dataset){
            dataTable.add(row);
        }
        PieSliceRenderer pointRenderer = (PieSliceRenderer) plot.getPointRenderer(dataTable);

        if(gap != null) pointRenderer.setGap(gap);
        if(innerRadius != null) pointRenderer.setInnerRadius(innerRadius);
        if(outerRadius != null) pointRenderer.setOuterRadius(outerRadius);
        if(pieColor != null && colors != null){
            IndexedColors indexedColors = new IndexedColors(pieColor, colors);
            pointRenderer.setColor(indexedColors);
        }
        super.drawPlot(plot, component, componentCanvas);
    }else{
        logger.warn("no data found for " + component + ", ignoring Block");
    }
}
 
开发者ID:Amine-H,项目名称:PDFLego,代码行数:30,代码来源:PieChartRenderStrategy.java


示例3: testPointRendererSerialization

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
private static void testPointRendererSerialization(
		PointRenderer originalRenderer, PointRenderer deserializedRenderer) {
	PieSliceRenderer original = (PieSliceRenderer) originalRenderer;
	PieSliceRenderer deserialized = (PieSliceRenderer) deserializedRenderer;
	assertEquals(original.getInnerRadius(), deserialized.getInnerRadius(), DELTA);
	assertEquals(original.getOuterRadius(), deserialized.getOuterRadius(), DELTA);
	assertEquals(original.getGap(), deserialized.getGap(), DELTA);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:9,代码来源:PiePlotTest.java


示例4: DynamicPiePlot

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public DynamicPiePlot() {
	// Create initial data
	data = new DataTable(Integer.class);
	DataSource pieData = PiePlot.createPieData(data);

	// Create new pie plot
	plot = new PiePlot(pieData);
	// Change relative size of pie
	plot.setRadius(0.9);
	// Change the starting angle of the first pie slice
	plot.setStart(90.0);
	// Add some margin to the plot area
	plot.setInsets(new Insets2D.Double(20.0));

	PieSliceRenderer pointRenderer =
			(PieSliceRenderer) plot.getPointRenderer(pieData);
	// Change the width of gaps between segments
	pointRenderer.setGap(0.2);
	// Change the colors
	LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
	pointRenderer.setColor(colors);

	// Add plot to Swing component
	InteractivePanel panel = new InteractivePanel(plot);
	add(panel, BorderLayout.CENTER);

	setValueCount(SAMPLE_COUNT);

	// Create a slider to change the number of data values
	valueCountSlider = new JSlider(0, 50, SAMPLE_COUNT);
	valueCountSlider.setBorder(new EmptyBorder(15, 15, 5, 15));
	valueCountSlider.setMajorTickSpacing(10);
	valueCountSlider.setMinorTickSpacing(1);
	valueCountSlider.setSnapToTicks(true);
	valueCountSlider.setPaintTicks(true);
	valueCountSlider.addChangeListener(this);
	add(valueCountSlider, BorderLayout.SOUTH);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:40,代码来源:DynamicPiePlot.java


示例5: SimplePiePlot

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public SimplePiePlot() {
	// Create data
	DataTable data = new DataTable(Integer.class);
	for (int i = 0; i < SAMPLE_COUNT; i++) {
		int val = random.nextInt(8) + 2;
		data.add((random.nextDouble() <= 0.15) ? -val : val);
	}
	DataSource pieData = PiePlot.createPieData(data);

	// Create new pie plot
	PiePlot plot = new PiePlot(pieData);

	// Format plot
	plot.getTitle().setText(getDescription());
	// Change relative size of pie
	plot.setRadius(0.9);
	// Display a legend
	plot.setLegendVisible(true);
	// Add some margin to the plot area
	plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));

	PieSliceRenderer pointRenderer =
			(PieSliceRenderer) plot.getPointRenderer(pieData);
	// Change relative size of inner region
	pointRenderer.setInnerRadius(0.4);
	// Change the width of gaps between segments
	pointRenderer.setGap(0.2);
	// Change the colors
	LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
	pointRenderer.setColor(colors);
	// Show labels
	pointRenderer.setValueVisible(true);
	pointRenderer.setValueColor(Color.WHITE);
	pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));

	// Add plot to Swing component
	add(new InteractivePanel(plot), BorderLayout.CENTER);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:40,代码来源:SimplePiePlot.java


示例6: DynamicPiePlot

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public DynamicPiePlot() {
	// Create initial data
	data = new DataTable(Integer.class);

	// Create new pie plot
	plot = new PiePlot(data);
	// Change relative size of pie
	plot.setRadius(0.9);
	// Change the starting angle of the first pie slice
	plot.setStart(90.0);
	// Add some margin to the plot area
	plot.setInsets(new Insets2D.Double(20.0));

	PieSliceRenderer pointRenderer =
			(PieSliceRenderer) plot.getPointRenderer(data);
	// Change the width of gaps between segments
	pointRenderer.setGap(0.2);
	// Change the colors
	LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
	pointRenderer.setColor(colors);

	// Add plot to Swing component
	InteractivePanel panel = new InteractivePanel(plot);
	add(panel, BorderLayout.CENTER);

	setValueCount(SAMPLE_COUNT);

	// Create a slider to change the number of data values
	valueCountSlider = new JSlider(0, 50, SAMPLE_COUNT);
	valueCountSlider.setBorder(new EmptyBorder(15, 15, 5, 15));
	valueCountSlider.setMajorTickSpacing(10);
	valueCountSlider.setMinorTickSpacing(1);
	valueCountSlider.setSnapToTicks(true);
	valueCountSlider.setPaintTicks(true);
	valueCountSlider.addChangeListener(this);
	add(valueCountSlider, BorderLayout.SOUTH);
}
 
开发者ID:arahusky,项目名称:performance_javadoc,代码行数:39,代码来源:DynamicPiePlot.java


示例7: SimplePiePlot

import de.erichseifert.gral.plots.PiePlot.PieSliceRenderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public SimplePiePlot() {
	// Create data
	DataTable data = new DataTable(Integer.class);
	for (int i = 0; i < SAMPLE_COUNT; i++) {
		int val = random.nextInt(8) + 2;
           int sign = (random.nextDouble() <= 0.15) ? -1 : 1;
           System.out.println("SimplePiePlot.SimplePiePlot(" + val  + ", " + sign + ")");
           data.add(val);
	}

	// Create new pie plot
	PiePlot plot = new PiePlot(data);

	// Format plot
	plot.getTitle().setText(getDescription());
	// Change relative size of pie
	plot.setRadius(0.9);
	// Display a legend
	plot.setLegendVisible(true);
	// Add some margin to the plot area
	plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));

	PieSliceRenderer pointRenderer =
			(PieSliceRenderer) plot.getPointRenderer(data);
	// Change relative size of inner region
	pointRenderer.setInnerRadius(0.4);
	// Change the width of gaps between segments
	pointRenderer.setGap(0.2);
	// Change the colors
	LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
	pointRenderer.setColor(colors);
	// Show labels
	pointRenderer.setValueVisible(true);
	pointRenderer.setValueColor(Color.WHITE);
	pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));

	// Add plot to Swing component
	add(new InteractivePanel(plot), BorderLayout.CENTER);
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:41,代码来源:SimplePiePlot.java



注:本文中的de.erichseifert.gral.plots.PiePlot.PieSliceRenderer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataPacketProvider类代码示例发布时间:2022-05-23
下一篇:
Java PlanarImg类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap