@Override public void seriesLegendLabelCustomAction(Data t, Node u) { u.setOnMouseEntered(ev -> { u.setCursor(Cursor.HAND); }); u.setOnMouseExited(ev -> { u.setCursor(Cursor.DEFAULT); }); u.setOnMouseClicked(ev -> { ListView<RuleViolation> lvViolation = this.checkedListComposite.getLvViolation(); ObservableList<RuleViolation> items = lvViolation.getItems(); ObservableList<RuleViolation> violationList = this.checkedListComposite.getViolationList(); List<RuleViolation> collect = violationList.stream().filter(ruleViolationFilter()) .filter(v -> ValueUtil.equals(t.getName(), ValueUtil.getSimpleFileName(v.getFilename()))).collect(Collectors.toList()); items.setAll(collect); }); }
@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; }
public void dataOnMouseClick(MouseEvent e, Data d) { if (e.getClickCount() == 1 && e.getButton() == MouseButton.PRIMARY) { contextMenu.hide(); // Long long1 = collectedTable.get(d.getName()); ObservableList<GargoyleSVNLogEntryPath> list = FXCollections.observableArrayList(supplier.getCollectedTable().get(d.getName())); if (!list.isEmpty()) { GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath = list.get(0); BorderPane borderPane = new BorderPane(); borderPane.setTop(new Label(gargoyleSVNLogEntryPath.getPath())); ListView<GargoyleSVNLogEntryPath> createHistoryListView = supplier.createHistoryListView(list); borderPane.setCenter(createHistoryListView); borderPane.setBottom(new Label(String.valueOf(list.size()) + " ea")); FxUtil.showPopOver(d.getNode(), borderPane); } } else if (e.getClickCount() == 1 && e.getButton() == MouseButton.SECONDARY) { Node owner = d.getNode(); if (!contextMenu.isShowing()) { contextMenu.setUserData(d); contextMenu.show(owner, e.getScreenX(), e.getScreenY()); } } }
@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); }
@Override public void build() { Optional<Integer> reduce = observableHashMap.values().stream().reduce((a, b) -> a + b); reduce.ifPresent(size ->{ total.set(size); //Summary observableHashMap.entrySet().forEach(v -> { String name = v.getKey().toString(); Integer value = v.getValue(); dataList.add(new Data(name, value)); }); }); // Integer size = reduce.get(); }
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; }
private void buildChartResults(final ProgressModel model) { Data known = slice("Marked as\nKnown", model.knownProperty()); Data unknown = slice("Marked as\nUnknown", model.unknownProperty()); Data unmarked = slice("Unmarked", model.unseenUnfilteredProperty()); Data filtered = 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()); }
static ObservableList<Data> convertNewData(long totalSpace, ObservableList<Map<String, Object>> items) { ObservableList<Data> charItmes = FXCollections.observableArrayList(); for (Map<String, Object> m : items) { long value = Long.valueOf(m.get("value").toString(), 10); long percent = value * 100 / totalSpace; String key = m.get("key").toString().replace("(byte)", ""); Data e = new Data(key, percent); charItmes.add(e); } return charItmes; }
@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; }
@Override public void chartGraphicsCustomAction(Data data, Node node) { node.setOnMouseClicked(ev -> { ListView<RuleViolation> lvViolation = this.checkedListComposite.getLvViolation(); ObservableList<RuleViolation> violationList = this.checkedListComposite.getViolationList(); ObservableList<RuleViolation> items = lvViolation.getItems(); List<RuleViolation> collect = violationList.stream().filter(ruleViolationFilter()) .filter(v -> ValueUtil.equals(data.getName(), ValueUtil.getSimpleFileName(v.getFilename()))) .collect(Collectors.toList()); items.setAll(collect); }); }
protected Object createObject(double width, double height) { ObservableList<Data> data = FXCollections.<Data>observableArrayList(); for (int i = 0; i < 10; i++) { data.add(new Data("Data item " + i, i * 100)); } PieChart chart = new PieChart(data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("PieChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
public PieChart getNewChart() { data = FXCollections.<Data>observableArrayList(); //Don't change numbers here. for (int i = 0; i < 4; i++) { data.add(new Data("Data item " + i, 100)); } PieChart chart = new PieChart(data); chart.setTitle("PieChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
/** * this method's database for processing the view about user information * * @param protocol * @param packetSize * @return */ public boolean AddQueryDataSet(String protocol, double packetSize) { for (int i = 0; i < queryDataSet.size(); i++) if (queryDataSet.get(i).getName().equals(protocol)) { queryDataSet.get(i).setPieValue( queryDataSet.get(i).getPieValue() + packetSize * Settings.nOnePacketStringSize); return true; } Platform.runLater(() -> { queryDataSet.add(new Data(protocol, packetSize * Settings.nOnePacketStringSize)); }); return false; }
private void buildChartProgress(final ProgressModel model) { Data done = slice("Marked as\nKnown/Unknown", model.markedProperty()); Data remaining = slice("Unmarked", model.unseenUnfilteredProperty()); chartProgress.setData(FXCollections.observableArrayList( done, remaining )); bindValueLabel(labelValueDone, model.markedProperty()); bindPercentLabel(labelPercentDone, model.markedPercentVisibleProperty()); bindValueLabel(labelValueRemaining, model.unseenUnfilteredProperty()); bindPercentLabel(labelPercentRemaining, model.unseenUnfilteredPercentVisibleProperty()); }
private void showErlangMemory() { ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); showPieChart(data); ErlangMemoryThread emThread; emThread = new ErlangMemoryThread(data); emThread.start(); }
private void populatePieData(final Map<Object, Object> erlangMemory) { for (Entry<Object, Object> entry : erlangMemory.entrySet()) { long kb = (long) (Double.parseDouble(entry.getValue().toString()) / 1024); String label = entry.getKey().toString() + " (" + kb + " KB)"; pieData.add(new Data(label, kb)); } }
@FXML public void initialize() { createContextMenu(); Collection<SVNLogEntry> allLogs = supplier.getAllLogs(); LOGGER.debug("Log Count : {}", allLogs.size()); String dateString = supplier.getStart().toDateString(); String dateString2 = supplier.getEnd().toDateString(); piChartChagendCode .setTitle(String.format("Chaned Code Count ( Rank %d )\n%s ~ %s", supplier.getRankSize(), dateString, dateString2)); // collectedTable = supplier.createStream(allLogs).collect(Collectors.groupingBy(v -> v.getPath())); Map<String, Long> collect = supplier.createStream(allLogs) .collect(Collectors.groupingBy(v -> v.getPath(), LinkedHashMap::new, Collectors.counting())); dataList = collect.entrySet().stream().sorted((o1, o2) -> { return -Long.compare(o1.getValue(), o2.getValue()); }).map(v -> new Data(v.getKey(), v.getValue())).limit(supplier.getRankSize()).collect(Collectors.toList()); piChartChagendCode.getData().addAll(dataList); Set<Node> lookupAll = piChartChagendCode.lookupAll(".chart-pie-label"); for (Data d : piChartChagendCode.getData()) { Node node = d.getNode(); Tooltip.install(node, new Tooltip(String.format("Source Code : %s\nModify Count:%d", d.getName(), (int) d.getPieValue()))); node.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> { dataOnMouseClick(e, d); e.consume(); }); /*animation effect. */ node.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, ev -> { Platform.runLater(() -> node.setStyle("-fx-background-color:derive(-fx-color,-5%);")); }); /*animation effect. */ node.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, ev -> { Platform.runLater(() -> node.setStyle(null)); }); } lookupAll.stream().map(v -> (Text) v).forEach(v -> { String text = v.getText(); String displayText = text; int count = supplier.getCollectedTable().get(displayText).size(); int textLength = displayText.length(); if (textLength > 15) { displayText = "... "+ displayText.substring(textLength-15); Tooltip.install(v, new Tooltip(text)); // text = text.substring(lastIndexOf, textLength); } displayText = displayText.concat(" [").concat(String.valueOf(count)).concat("]"); v.setText(displayText); }); // Platform.runLater(() -> { // this.getScene().addEventFilter(KeyEvent.KEY_PRESSED, this::sceneOnKeyPressed); // }); }
public AddDataNode(List<Data> data) { this.data = data; }
@Override protected TestNode setup() { super.setup(); setupPieChartCSSPages(); setupDouble(Pages.LabelLineLength.name(), LENGTH_D); setupBoolean(Pages.LabelsVisible.name()); setupDouble(Pages.StartAngle.name(), START_ANGLE_D); setupBoolean(Pages.Clockwise.name()); ObservableList<Data> data = FXCollections.<Data>observableArrayList(); data.add(new Data("New item", 500)); TestNode add_data_node = new AddDataNode(data); pageSetup(Pages.AddData.name(), add_data_node); TestNode remove_data_node = new RemoveDataNode(); pageSetup(Pages.RemoveData.name(), remove_data_node); return rootTestNode; }
public ErlangMemoryThread(ObservableList<PieChart.Data> thePieData) { pieData = thePieData; setName("Erlang Memory Thread"); setDaemon(true); }
@FXML private void onHeapPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getHeapSize(); }); showPieChart("Process Heap", data); }
@FXML private void onStackPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getStackSize(); }); showPieChart("Process Stack", data); }
@FXML private void onTotalHeapPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getTotalHeapSize(); }); showPieChart("Total Heap", data); }
/** * get the query data set. observableList<Data> * * @return */ public ObservableList<Data> getQueryDataSet() { return queryDataSet; }