Ejemplo n.º 1
0
 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();
  }
Ejemplo n.º 3
0
  @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);
 }