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


Java PieChart类代码示例

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


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

示例1: start

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Europian Country Population");
    stage.setWidth(500);
    stage.setHeight(500);
 
    ObservableList<PieChart.Data> pieChartData =
            FXCollections.observableArrayList(
            new PieChart.Data("Belgium", 3),
            new PieChart.Data("France", 26),
            new PieChart.Data("Germany", 35),
            new PieChart.Data("Netherlands", 7),
            new PieChart.Data("Sweden", 4),
            new PieChart.Data("United Kingdom", 25));
    final PieChart pieChart = new PieChart(pieChartData);
    pieChart.setTitle("Country Population");

    ((Group) scene.getRoot()).getChildren().add(pieChart);
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:PacktPublishing,项目名称:Java-for-Data-Science,代码行数:23,代码来源:PieChart - MainApp.java

示例2: populationsScreen

import javafx.scene.chart.PieChart; //导入依赖的package包/类
private PieChart populationsScreen(Scene scene) {
    ObservableList<PieChart.Data> pieChartData =
            FXCollections.observableArrayList(
                    new PieChart.Data("Alive",
                            timeLine.getCurrentTimeInstant().getPopulation()),
                    new PieChart.Data("Dead",
                            fieldHeight * fieldWidth - timeLine.getCurrentTimeInstant().getPopulation()));
    final PieChart chart = new PieChart(pieChartData);

    final Timer timer = new java.util.Timer();
    timer.schedule(new TimerTask() {
        public void run() {
            Platform.runLater(() -> {
                pieChartData.get(0).setPieValue(timeLine.getCurrentTimeInstant().getPopulation());
                pieChartData.get(1).setPieValue(fieldHeight * fieldWidth
                        - timeLine.getCurrentTimeInstant().getPopulation());
            });
        }
    }, 0, INTERVAL);

    return chart;
}
 
开发者ID:slemonide,项目名称:GraphSpace,代码行数:23,代码来源:Main.java

示例3: drawNode

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@Override
public Node drawNode() {
    final PieChart chart = (PieChart)createObject();
    Platform.runLater(new Runnable() {
        public void run() {
            int counter = 0;
            chart.setAnimated(true);
            for (Data item : data) {
                if (counter > chart.getData().size()) {
                    chart.getData().add(item);
                } else {
                    chart.getData().add(counter, item);
                }
                counter+= 2;
            }
        }
    });
    return chart;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:20,代码来源:PieChartApp.java

示例4: DrilldownPieChartSample

import javafx.scene.chart.PieChart; //导入依赖的package包/类
public DrilldownPieChartSample() {
    String drilldownCss = DrilldownPieChartSample.class.getResource("DrilldownChart.css").toExternalForm();

    PieChart pie = new PieChart(
            FXCollections.observableArrayList(
            A = new PieChart.Data("A", 20),
            B = new PieChart.Data("B", 30),
            C = new PieChart.Data("C", 10),
            D = new PieChart.Data("D", 40)));
    ((Parent) pie).getStylesheets().add(drilldownCss);

    setDrilldownData(pie, A, "a");
    setDrilldownData(pie, B, "b");
    setDrilldownData(pie, C, "c");
    setDrilldownData(pie, D, "d");
    getChildren().add(pie);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:DrilldownPieChartSample.java

示例5: drawChart

import javafx.scene.chart.PieChart; //导入依赖的package包/类
private void drawChart(List<ClassHistogram.HistoDataEntry> entries){
    long others = entries.stream()
                          .skip(CHART_COLORS.length)
                          .mapToLong(ClassHistogram.HistoDataEntry::getBytes)
                          .sum();

    histoPieChart.getData().clear();
    ObservableList<PieChart.Data> chartData = histoPieChart.getData();
    PieChart.Data data;

    for(int Cnt = 0; Cnt < CHART_COLORS.length; Cnt++){
        data = new PieChart.Data(entries.get(Cnt).getName(), entries.get(Cnt).getBytes());
        chartData.add(data);
        data.getNode().setStyle(String.format("-fx-pie-color: #%08x;", CHART_COLORS[Cnt].hashCode()));
    }

    data = new PieChart.Data("Others", others);
    chartData.add(data);
    data.getNode().setStyle("-fx-pie-color: gray;");
}
 
开发者ID:YaSuenag,项目名称:ulviewer,代码行数:21,代码来源:ClassHistoController.java

示例6: createPieChart

import javafx.scene.chart.PieChart; //导入依赖的package包/类
/** 
 * Creates a pie chart
 * 
 * @return {@link PieChart}
 */
private PieChart createPieChart() {
	PieChart chart = new PieChart();
	chart.setMinHeight(chartHeight);
	chart.setTitle("Time needed in mode");
	chart.setLegendVisible(false);
	chart.getStyleClass().add("statistic-chart");
	chart.getStyleClass().add("statistic-chart-pie");
	
	long[] durations = trackingSession.getDuration();
	
	PieChart.Data redData = new PieChart.Data("RED", durations[0]/1000.0);
	PieChart.Data greenData = new PieChart.Data("GREEN", durations[1]/1000.0);
	PieChart.Data blueData = new PieChart.Data("BLUE", durations[2]/1000.0);
	
	if(durations[0] != 0) {
		chart.getData().addAll(redData, greenData, blueData);
	}
	
	return chart;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:26,代码来源:TrackingStatistic.java

示例7: initialize

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@FXML
public void initialize() {
	StringConverter<PieChart.Data> labelConverter = new StringConverter<PieChart.Data>() {

		@Override
		public String toString(Data d) {
			String formatedValue = String.format("%s\n%.2f %%", d.getName(), d.getPieValue());
			return formatedValue;
		}

		@Override
		public Data fromString(String string) {
			return null;
		}
	};
	picChart.setLabelConverter(labelConverter);
	picChart.setTooltipConverter(labelConverter);

	tbFileProperties.getItems().addAll(apply(this.file));

	tbFileProperties.getSelectionModel().setCellSelectionEnabled(true);
	tbFileProperties.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	FxUtil.installClipboardKeyEvent(tbFileProperties);
	FxClipboardUtil.installCopyPasteHandler(tbFileProperties);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:27,代码来源:FilePropertiesComposite.java

示例8: root_center

import javafx.scene.chart.PieChart; //导入依赖的package包/类
public PieChart root_center(){
	List<Event> startEvents= EventHandler.getPhaseStartEvents();
	int test = 0;
	int code = 0;
	int ref  = 0;
	for(Event e : startEvents){
		switch(((PhaseStartEvent)e).getPhase()){
			case 0: test = test+((PhaseStartEvent)e).getDuration();break;
			case 1: code = code+((PhaseStartEvent)e).getDuration();break;
			case 2: ref = ref+((PhaseStartEvent)e).getDuration();break;
		}
	}
	ObservableList<PieChart.Data> pieChartData =
               FXCollections.observableArrayList(
               new PieChart.Data("Test", test),
               new PieChart.Data("Code", code),
               new PieChart.Data("Refactor", ref));
       PieChart chart = new PieChart(pieChartData);
       chart.setTitle("Time per phase:");
       
	return chart;
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-1,代码行数:23,代码来源:StatisticStage.java

示例9: updateChart

import javafx.scene.chart.PieChart; //导入依赖的package包/类
private void updateChart(CloudSettings set){
    PieChart.Data availableData = new PieChart.Data("Available", set.getAvailableSpace());
    PieChart.Data usingData = new PieChart.Data("Using", set.getUsingSpace());
    PieChart.Data totalData = new PieChart.Data("Empty", set.getTotalSpace()-set.getCloudRaidSpace());


    ObservableList<PieChart.Data> list = FXCollections.observableArrayList(
            availableData, usingData, totalData
    );
    chart.setData(list);

    applyCustomColorSequence(
            list,
            "bisque",
            "red",
            "aqua"
    );
}
 
开发者ID:StnetixDevTeam,项目名称:CloudRaid-DesktopApp,代码行数:19,代码来源:SettingsController.java

示例10: getAddItemHBox

import javafx.scene.chart.PieChart; //导入依赖的package包/类
public HBox getAddItemHBox() {
    HBox hb = new HBox();
    Label lb = new Label("Add item");
    final TextField tf = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_VALUE_TEXT_FIELD_ID).build();
    Label namedLabel = new Label(" named ");
    final TextField name = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_TEXT_FIELD_ID).build();
    Label atLb = new Label("at pos");
    final TextField tfPos = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_POSITION_TEXT_FIELD_ID).build();
    Button bt = ButtonBuilder.create().text("Add!").id(ADD_ITEM_BUTTON_ID).build();
    bt.setOnAction(new EventHandler() {
        public void handle(Event t) {
            int index = Integer.parseInt(tfPos.getText());

            Data newData = new Data("".equals(name.getText()) ? String.valueOf(index) : name.getText(), Double.parseDouble(tf.getText()));

            ((PieChart) testedPieChart).getData().add(index, newData);

            tb.addDoublePropertyLine(newData.pieValueProperty(), -10, 10000, 100, newData);
        }
    });
    hb.getChildren().addAll(lb, tf, namedLabel, name, atLb, tfPos, bt);
    return hb;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:24,代码来源:NewPieChartApp.java

示例11: getData

import javafx.scene.chart.PieChart; //导入依赖的package包/类
/**
 * Be careful, it returns the copy of the data array, and it is not
 * synchronized with he original data array.
 */
final public ObservableList<PieChart.Data> getData() {
    final ObservableList<PieChart.Data> data = FXCollections.observableArrayList();

    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            PieChart chart = (PieChart) piechart.getControl();
            for (PieChart.Data dataItem : chart.getData()) {
                data.add(dataItem);
            }
        }
    }.dispatch(Root.ROOT.getEnvironment());

    return data;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:20,代码来源:PieChartDescriptionProvider.java

示例12: startAnglePropertyTest

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@Test(timeout = 300000)
public void startAnglePropertyTest() throws InterruptedException, Throwable {
    assertEquals(new PieChart().getStartAngle(), 0.0, 0.000001);

    List<Double> initialAngles = pieChartDescriptionProvider.getLinesAngles();

    setPropertyBySlider(SettingType.SETTER, PieChartProperties.startAngle, 30.0);
    checkStartAngle(initialAngles, 30);

    setPropertyBySlider(SettingType.BIDIRECTIONAL, PieChartProperties.startAngle, 90.0);
    checkStartAngle(initialAngles, 90);

    setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, -60.0);
    checkStartAngle(initialAngles, -60);

    for (int i = -50; i < 300; i += 10) {
        setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, i);
        checkStartAngle(initialAngles, i);
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:21,代码来源:PieChartTest.java

示例13: labelLineLengthTest

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@Test(timeout = 300000)//RT-27751
public void labelLineLengthTest() throws Throwable {
    assertEquals(new PieChart().getLabelLineLength(), 20, 0.0);

    checkLineLengths(20);

    setPropertyBySlider(SettingType.BIDIRECTIONAL, PieChartProperties.labelLineLength, 20);
    checkLineLengths(20);

    setPropertyBySlider(SettingType.SETTER, PieChartProperties.labelLineLength, 10);
    checkLineLengths(10);

    setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, 30);
    checkLineLengths(30);

    setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, -30);
    checkLineLengths(0);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:PieChartTest.java

示例14: clockwisePropertyTest

import javafx.scene.chart.PieChart; //导入依赖的package包/类
@Test(timeout = 300000)
public void clockwisePropertyTest() throws Throwable {
    assertTrue(((PieChart) getNewChartInstance()).isClockwise());

    List<Double> angles = pieChartDescriptionProvider.getLinesAngles();

    setPropertyByToggleClick(SettingType.BIDIRECTIONAL, PieChartProperties.clockWise, false);
    checkTextFieldText(PieChartProperties.clockWise, "false");
    checkClockWiseAffecting(angles, false);

    setPropertyByToggleClick(SettingType.SETTER, PieChartProperties.clockWise, true);
    checkTextFieldText(PieChartProperties.clockWise, "true");
    checkClockWiseAffecting(angles, true);

    setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.clockWise, false);
    checkTextFieldText(PieChartProperties.clockWise, "false");
    checkClockWiseAffecting(angles, false);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:PieChartTest.java

示例15: checkLegendContentSizeCorrectness

import javafx.scene.chart.PieChart; //导入依赖的package包/类
protected void checkLegendContentSizeCorrectness() {
    int itemsSize = new GetAction<Integer>() {
        @Override
        public void run(Object... os) throws Exception {
            final Chart chart = testedControl.getControl();
            if (chart instanceof PieChart) {
                setResult(((PieChart) chart).getData().size());
            } else {
                setResult(((XYChart) chart).getData().size());
            }
        }
    }.dispatch(Root.ROOT.getEnvironment());

    final List<Wrap<? extends Label>> legendLabels = chartDescriptionProvider.getLegendLabels();
    Assert.assertEquals(legendLabels.size(), itemsSize);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:17,代码来源:ChartTestsBase.java


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