Search in sources :

Example 6 with Data

use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.

the class PMDViolationbyPieChartComposite method build.

/* (non-Javadoc)
	 * @see com.kyj.fx.voeditor.visual.component.pmd.chart.PMDViolationChartVisualable#build()
	 */
@Override
public void build() {
    Optional<Integer> reduce = observableHashMap.values().stream().reduce((a, b) -> a + b);
    reduce.ifPresent(size -> {
        total.set(size);
        observableHashMap.entrySet().forEach(v -> {
            String name = v.getKey().toString();
            Integer value = v.getValue();
            dataList.add(new Data(name, value));
        });
    });
//		Integer size = reduce.get();
}
Also used : Data(javafx.scene.chart.PieChart.Data)

Example 7 with Data

use of javafx.scene.chart.PieChart.Data in project VocabHunter by VocabHunter.

the class ProgressController method slice.

private Data slice(final I18nKey key, final ObservableNumberValue property) {
    double value = property.getValue().intValue();
    Data slice = new Data(i18nManager.text(key), value);
    slice.pieValueProperty().bind(property);
    return slice;
}
Also used : Data(javafx.scene.chart.PieChart.Data)

Example 8 with Data

use of javafx.scene.chart.PieChart.Data in project Gargoyle by callakrsos.

the class PMDViolationbyPieChartComposite method createNode.

/* (non-Javadoc)
	 * @see com.kyj.fx.voeditor.visual.component.pmd.chart.PMDViolationChartVisualable#createNode()
	 */
@Override
public Node createNode() {
    picChart = new AttachedTextValuePieChart();
    picChart.setLabelConverter(new StringConverter<PieChart.Data>() {

        @Override
        public String toString(PieChart.Data object) {
            int value = (int) object.getPieValue();
            double percent = (value * 100) / total.get();
            return String.format("%s\ncount : %d\n%.2f%%", object.getName(), value, percent);
        }

        @Override
        public PieChart.Data fromString(String string) {
            // TODO Auto-generated method stub
            return null;
        }
    });
    picChart.setChartGraphicsCustomAction((data, node) -> {
        chartGraphicsCustomAction(data, node);
    });
    dataList = picChart.getData();
    return picChart;
}
Also used : AttachedTextValuePieChart(com.kyj.fx.voeditor.visual.component.chart.AttachedTextValuePieChart) Data(javafx.scene.chart.PieChart.Data) AttachedTextValuePieChart(com.kyj.fx.voeditor.visual.component.chart.AttachedTextValuePieChart) PieChart(javafx.scene.chart.PieChart) Data(javafx.scene.chart.PieChart.Data)

Example 9 with Data

use of javafx.scene.chart.PieChart.Data in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceList method loadPieChart.

/**
 * 加载饼图数据
 */
private void loadPieChart() {
    String keyword = search.getText();
    int picNum = picCheck.isSelected() ? action.countResourceByType(type, ResourceType.IMAGE.getType(), keyword, creator) : 0;
    int swfNum = swfCheck.isSelected() ? action.countResourceByType(type, ResourceType.SWF.getType(), keyword, creator) : 0;
    int videoNum = videoCheck.isSelected() ? action.countResourceByType(type, ResourceType.VIDEO.getType(), keyword, creator) : 0;
    int txtNum = txtCheck.isSelected() ? action.countResourceByType(type, ResourceType.TXT.getType(), keyword, creator) : 0;
    int wordNum = wordCheck.isSelected() ? action.countResourceByType(type, ResourceType.WORD.getType(), keyword, creator) : 0;
    int pptNum = pptCheck.isSelected() ? action.countResourceByType(type, ResourceType.PPT.getType(), keyword, creator) : 0;
    int excelNum = excelCheck.isSelected() ? action.countResourceByType(type, ResourceType.EXCEL.getType(), keyword, creator) : 0;
    int pdfNum = pdfCheck.isSelected() ? action.countResourceByType(type, ResourceType.PDF.getType(), keyword, creator) : 0;
    ObservableList<Data> datas = // 
    FXCollections.observableArrayList(// 
    new PieChart.Data(MsgUtil.getMessage("resource.pdf"), pdfNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.ppt"), pptNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.txt"), txtNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.excel"), excelNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.pic"), picNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.video"), videoNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.word"), wordNum), // 
    new PieChart.Data(MsgUtil.getMessage("resource.swf"), swfNum));
    chart.setData(datas);
    chart.setOnMouseMoved(e -> {
        tip.setTranslateX(e.getX());
        tip.setTranslateY(e.getY());
    });
    for (final PieChart.Data data : chart.getData()) {
        Node node = data.getNode();
        node.setOnMouseEntered(e -> {
            tip.setText(data.getName() + ":" + (int) data.getPieValue());
            tip.setVisible(true);
        });
        node.setOnMouseExited(e -> {
            tip.setVisible(false);
        });
    }
    pic.setText(MsgUtil.getMessage("resource.pic") + ":" + picNum);
    swf.setText(MsgUtil.getMessage("resource.swf") + ":" + swfNum);
    video.setText(MsgUtil.getMessage("resource.video") + ":" + videoNum);
    txt.setText(MsgUtil.getMessage("resource.txt") + ":" + txtNum);
    word.setText(MsgUtil.getMessage("resource.word") + ":" + wordNum);
    ppt.setText(MsgUtil.getMessage("resource.ppt") + ":" + pptNum);
    excel.setText(MsgUtil.getMessage("resource.excel") + ":" + excelNum);
    pdf.setText(MsgUtil.getMessage("resource.pdf") + ":" + pdfNum);
}
Also used : Data(javafx.scene.chart.PieChart.Data) PieChart(javafx.scene.chart.PieChart) Node(javafx.scene.Node) Data(javafx.scene.chart.PieChart.Data)

Example 10 with Data

use of javafx.scene.chart.PieChart.Data in project VocabHunter by VocabHunter.

the class ProgressController method buildChartResults.

private void buildChartResults(final ProgressModel model) {
    Data known = slice(PROGRESS_SLICE_KNOWN, model.knownProperty());
    Data unknown = slice(PROGRESS_SLICE_UNKNOWN, model.unknownProperty());
    Data unmarked = slice(PROGRESS_SLICE_UNMARKED, model.unseenUnfilteredProperty());
    Data filtered = slice(PROGRESS_SLICE_FILTERED, model.unseenFilteredProperty());
    chartResults.setData(FXCollections.observableArrayList(known, unknown, unmarked, filtered));
    bindValueLabel(labelValueKnown, model.knownProperty());
    bindPercentLabel(labelPercentKnown, model.knownPercentProperty());
    bindValueLabel(labelValueUnknown, model.unknownProperty());
    bindPercentLabel(labelPercentUnknown, model.unknownPercentProperty());
    bindValueLabel(labelValueUnseenUnfiltered, model.unseenUnfilteredProperty());
    bindPercentLabel(labelPercentUnseenUnfiltered, model.unseenUnfilteredPercentProperty());
    bindValueLabel(labelValueFiltered, model.unseenFilteredProperty());
    bindPercentLabel(labelPercentFiltered, model.unseenFilteredPercentProperty());
}
Also used : Data(javafx.scene.chart.PieChart.Data)

Aggregations

Data (javafx.scene.chart.PieChart.Data)11 Node (javafx.scene.Node)5 PieChart (javafx.scene.chart.PieChart)5 ContextMenu (javafx.scene.control.ContextMenu)2 MenuItem (javafx.scene.control.MenuItem)2 Region (javafx.scene.layout.Region)2 LibraryAnswerAction (com.cas.sim.tis.action.LibraryAnswerAction)1 AnswerState (com.cas.sim.tis.consts.AnswerState)1 Question (com.cas.sim.tis.entity.Question)1 AttachedTextValuePieChart (com.kyj.fx.voeditor.visual.component.chart.AttachedTextValuePieChart)1 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)1 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1