public PieChart fillChartPiePopBovinos() { HashMap<String, Integer> data = dataForChartEdadesySexo(); int total = 0; Set<String> keySet = data.keySet(); for (String key : keySet) { total = total + data.get(key); } ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); System.out.println("total=" + total); int percent; double di; for (String key : keySet) { di = (double) data.get(key) / (double) total; percent = (int) (di * 100); pieChartData.add(new PieChart.Data(key, percent)); } final PieChart chart = new PieChart(pieChartData); chart.setTitle("Población de Bovinos"); // set it to pane return (chart); }
public void load3(Event event) { f.clear(); String extra; String[] extra1; HashMap<String, Integer> h = new HashMap<String, Integer>(); try { BufferedReader x = new BufferedReader(new FileReader("./src/Expenses.txt")); extra = x.readLine(); extra = x.readLine(); extra = x.readLine(); while ((extra = x.readLine()) != null) { extra1 = extra.split(" "); if (h.containsKey(extra1[0])) { h.put(extra1[0], h.get(extra1[0]) + Integer.parseInt(extra1[1])); } h.put(extra1[0], Integer.parseInt(extra1[1])); } Set<String> keys = h.keySet(); for (String key : keys) { f.add(new PieChart.Data(key, h.get(key))); } x.close(); chr.setData(f); } catch (IOException ex) { ex.printStackTrace(); } }
@Override public void start(Stage primaryStage) { PieChart pieChart = new PieChart(); pieChart.setData(getPieData()); final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); final StackedBarChart<String, Number> sbc = new StackedBarChart<>(xAxis, yAxis); ObservableList<Series<String, Number>> barData = createBarData(getPieData()); // simulate client code that re-orders/filters the data FXCollections.shuffle(barData); sbc.setData(barData); primaryStage.setTitle("Correlated Charts"); Scene scene = new Scene(new HBox(pieChart, sbc)); primaryStage.setScene(scene); primaryStage.show(); }
@Override public void initialize(URL url, ResourceBundle rb) { Sql.loadSql(); total.setText("$" + expenseTotal); name.setCellValueFactory(new PropertyValueFactory<Expense, String>("name")); name.setCellFactory(TextFieldTableCell.<String>forTableColumn()); vendor.setCellValueFactory(new PropertyValueFactory<Expense, String>("vendor")); vendor.setCellFactory(TextFieldTableCell.<String>forTableColumn()); date.setCellValueFactory(new PropertyValueFactory<Expense, String>("date")); date.setCellFactory(TextFieldTableCell.<String>forTableColumn()); cost.setCellValueFactory(new PropertyValueFactory<Expense, Double>("cost")); cost.setCellFactory( TextFieldTableCell.forTableColumn( new StringConverter<Double>() { @Override public String toString(Double object) { return object.toString(); } @Override public Double fromString(String string) { return Double.parseDouble(string); } })); add.setOnAction(e -> Action.addExpense()); delete.setOnAction(e -> Action.deleteExpense()); if (tableList.size() > 0) emptyLabel.setText(""); table.setItems(tableList); pieChart.setData(pieChartList); }
/** initializes the PieChart */ private void initializePieChart() { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("To Keep", 100), new PieChart.Data("To Remove", 0)); pieChartSubsToRemove.setData(pieChartData); }
@Override public void initialize(URL location, ResourceBundle resources) { // Set measurement result into scene domainName.setText(StaticVars.currentDomainName); domainNameLabel.setText(StaticVars.currentLabel); domainNameResponseTime.setText(StaticVars.currentResponseTime + " second(s)"); domainNameDateMeasured.setText(String.valueOf(StaticVars.currentDate)); if (StaticVars.methodType == 1) { labelSiteComposition.setVisible(false); chartCompositionDangerousity.setVisible(false); } else { if (StaticVars.currentLabel.equals("normal")) { labelSiteComposition.setVisible(false); chartCompositionDangerousity.setVisible(false); } else { if (!StaticVars.currentLabel.equals("malicious (unknown type)") && !StaticVars.currentLabel.equals("unknown")) { Triplet<Double, Double, Double> compositionDangerousity = StaticVars.currentComposition; ObservableList<PieChart.Data> pieChartElements = FXCollections.observableArrayList(); pieChartElements.addAll( new PieChart.Data("Malware", compositionDangerousity.getValue0()), new PieChart.Data("Phishing", compositionDangerousity.getValue1()), new PieChart.Data("Spamming", compositionDangerousity.getValue2())); chartCompositionDangerousity.setData(pieChartElements); chartCompositionDangerousity.setLegendSide(Side.RIGHT); chartCompositionDangerousity.setLabelLineLength(10); } else { labelSiteComposition.setVisible(false); chartCompositionDangerousity.setVisible(false); } } } // Save this reputation result into eksternal file historySitesReputation thisResultReputation = new historySitesReputation(); thisResultReputation.setCompositionDangerousity(StaticVars.currentComposition); thisResultReputation.setLabelNormality(StaticVars.currentLabel); thisResultReputation.setResponseTime(Long.parseLong(StaticVars.currentResponseTime)); thisResultReputation.setMeasureDate(StaticVars.currentDate); switch (StaticVars.reputationType) { case 1: thisResultReputation.setReputationType("DNS"); break; case 2: thisResultReputation.setReputationType("Spesific"); break; case 3: thisResultReputation.setReputationType("Trust"); break; case 4: thisResultReputation.setReputationType("DNS+Spesific"); break; case 5: thisResultReputation.setReputationType("DNS+Trust"); break; case 6: thisResultReputation.setReputationType("Spesific+Trust"); break; case 7: thisResultReputation.setReputationType("DNS+Spesific+Trust"); break; } switch (StaticVars.methodType) { case 1: thisResultReputation.setMethodType("supervised"); break; case 2: thisResultReputation.setMethodType("unsupervised"); break; case 3: thisResultReputation.setMethodType("hybrid"); break; } List<Pair<String, historySitesReputation>> oldHistoryReputation = reputationResultController.loadHistoryReputation(); Pair<String, historySitesReputation> addedHistoryReputation = new Pair<String, historySitesReputation>( StaticVars.currentDomainName, thisResultReputation); oldHistoryReputation.add(addedHistoryReputation); reputationResultController.saveHistoryReputation(oldHistoryReputation); }
public WeightCoverageChart() { weightA.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set( 0, new PieChart.Data("A " + weightA.doubleValue() + "kgs", (weightA.doubleValue()))); } }); weightB.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(1, new PieChart.Data("B", (weightB.doubleValue()))); } }); weightC.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(2, new PieChart.Data("C", (weightC.doubleValue()))); } }); weightD.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(3, new PieChart.Data("D", (weightD.doubleValue()))); } }); weightE.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(4, new PieChart.Data("E", (weightE.doubleValue()))); } }); weightF.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(5, new PieChart.Data("F", (weightF.doubleValue()))); } }); weightG.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(6, new PieChart.Data("G", (weightG.doubleValue()))); } }); weightH.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(7, new PieChart.Data("H", (weightH.doubleValue()))); } }); weightI.addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { pieData.set(8, new PieChart.Data("I", (weightI.doubleValue()))); } }); this.setCache(true); pie.setData(pieData); Rectangle pieBG = RectangleBuilder.create() .cache(true) .x(pie.getTranslateX() + 127) .y(pie.getTranslateY() + 84) .fill(Color.rgb(50, 50, 50)) .id("envelopeBG") .width(265) .height(245) .arcWidth(5) .arcHeight(5) .build(); Group group = new Group(); group.getChildren().addAll(pieBG, pie); getChildren().add(group); }
public void assignSampleData(FXOMObject startObject) { assert startObject != null; final Object sceneGraphObject = startObject.getSceneGraphObject(); final AbstractSampleData currentData = sampleDataMap.get(startObject); final AbstractSampleData newData; if (sceneGraphObject == null) { // startObject is unresolved newData = null; } else { final Class<?> sceneGraphClass = sceneGraphObject.getClass(); if (sceneGraphClass == ChoiceBox.class) { final ChoiceBox<?> choiceBox = (ChoiceBox) sceneGraphObject; if (choiceBox.getItems().isEmpty()) { if (currentData instanceof ChoiceBoxSampleData) { newData = currentData; } else { newData = new ChoiceBoxSampleData(); } } else { newData = null; } } else if (sceneGraphClass == ComboBox.class) { final ComboBox<?> comboBox = (ComboBox) sceneGraphObject; if (comboBox.getItems().isEmpty()) { if (currentData instanceof ComboBoxSampleData) { newData = currentData; } else { newData = new ComboBoxSampleData(); } } else { newData = null; } } else if (sceneGraphClass == ListView.class) { final ListView<?> listView = (ListView) sceneGraphObject; if (listView.getItems().isEmpty()) { if (currentData instanceof ListViewSampleData) { newData = currentData; } else { newData = new ListViewSampleData(); } } else { newData = null; } } else if (sceneGraphClass == TreeView.class) { final TreeView<?> treeView = (TreeView) sceneGraphObject; if (treeView.getRoot() == null) { if (currentData instanceof TreeViewSampleData) { newData = currentData; } else { newData = new TreeViewSampleData(); } } else { newData = null; } } else if (sceneGraphClass == TableView.class) { final TableView<?> treeView = (TableView) sceneGraphObject; if (TableViewSampleData.canApplyTo(treeView)) { if (currentData instanceof TableViewSampleData) { newData = currentData; } else { newData = new TableViewSampleData(); } } else { newData = null; } } else if (sceneGraphClass == TreeTableView.class) { final TreeTableView<?> treeTableView = (TreeTableView) sceneGraphObject; if (treeTableView.getRoot() == null) { if (currentData instanceof TreeTableViewSampleData) { newData = currentData; } else { newData = new TreeTableViewSampleData(); } } else { newData = null; } } else if (sceneGraphClass == PieChart.class) { final PieChart pieChart = (PieChart) sceneGraphObject; if (pieChart.getData().isEmpty()) { if (currentData instanceof PieChartSampleData) { newData = currentData; } else { newData = new PieChartSampleData(); } } else { newData = null; } } else if (XYChartSampleData.isKnownXYChart(sceneGraphObject)) { final XYChart<?, ?> xyChart = (XYChart) sceneGraphObject; if (xyChart.getData().isEmpty()) { if (currentData instanceof XYChartSampleData) { newData = currentData; } else { newData = new XYChartSampleData(); } } else { newData = null; } } else { newData = null; } } if (newData == null) { if (currentData != null) { sampleDataMap.remove(startObject); } } else { newData.applyTo(sceneGraphObject); sampleDataMap.put(startObject, newData); } if (startObject instanceof FXOMInstance) { final FXOMInstance fxomInstance = (FXOMInstance) startObject; for (FXOMProperty p : fxomInstance.getProperties().values()) { if (p instanceof FXOMPropertyC) { final FXOMPropertyC pc = (FXOMPropertyC) p; for (FXOMObject v : pc.getValues()) { assignSampleData(v); } } } } else if (startObject instanceof FXOMCollection) { final FXOMCollection fxomCollection = (FXOMCollection) startObject; for (FXOMObject i : fxomCollection.getItems()) { assignSampleData(i); } } }