Search in sources :

Example 1 with Data

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

the class ScmCommitComposite method load.

public void load() {
    try {
        scmHistoryWalk();
        getBarChartDayOfMonthCategory().setLabel("기간별 커밋 통계");
        getLineChartDayOfWeekCategory().setLabel("요일별 커밋 통계");
        getBarChartDayOfMonthCategory().getCategories().add(SERIES_LABEL);
        getLineChartDayOfWeekCategory().getCategories().add(SERIES_LABEL);
        Color lineColor = Color.GREEN;
        double strokeWidth = 1;
        String cssStyleClassName = ".chart-series-line";
        {
            /*start Desing css.*/
            BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
            String style = "-fx-bar-fill: ".concat(FxUtil.toWebString(lineColor)).concat(";");
            for (Node n : barChartDayOfMonth.lookupAll(".default-color0.chart-bar")) {
                n.setStyle(style);
            }
            //				barChartDayOfMonth.setStyle(
            //						".chart-legend-item-syCmbol chart-bar series0 bar-legend-symbol default-color0{- fx-background-color:green;}");
            /*end Desing css.*/
            /*start Popover*/
            //무조건 1개의 시리즈만 처리하므로 인덱스에서 바로 가져옴.
            ObservableList<Data<String, Long>> dataArr = getBarChartDayOfMonth().getData().get(0).getData();
            for (Data<String, Long> d : dataArr) {
                d.getNode().setOnMouseClicked(ev -> {
                    if (ev.getClickCount() == 1 && ev.getButton() == MouseButton.PRIMARY)
                        createPopOver(d);
                });
            }
            barChartDayOfMonth.setMinWidth(BarChart.USE_COMPUTED_SIZE);
            barChartDayOfMonth.requestLayout();
        /*end Popover*/
        }
        {
            LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
            lineChartDayOfWeek.setStyle(".chart-series-line .series0 .default-color0{- fx-background-color:green;}");
            Set<Node> lookupAll = lineChartDayOfWeek.lookupAll(".chart-line-symbol");
            StringBuffer sb = new StringBuffer();
            sb.append("-fx-background-color: " + FxUtil.toRgbString(lineColor) + ", white;");
            sb.append(" -fx-background-insets: 0, 2;");
            sb.append("-fx-background-radius: 5px;");
            sb.append("-fx-padding: 5px;");
            for (Node n : lookupAll) {
                n.setStyle(sb.toString());
            }
            String style = "-fx-stroke: " + FxUtil.toRgbString(lineColor) + "; -fx-stroke-width: " + strokeWidth + ";";
            for (Node seriesLine : lineChartDayOfWeek.lookupAll(cssStyleClassName)) {
                seriesLine.setStyle(style);
            }
        }
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
    }
}
Also used : MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) SimpleDateFormat(java.text.SimpleDateFormat) XYChart(javafx.scene.chart.XYChart) LinkedHashMap(java.util.LinkedHashMap) LineChart(javafx.scene.chart.LineChart) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SVNException(org.tmatesoft.svn.core.SVNException) Data(javafx.scene.chart.XYChart.Data) Collection(java.util.Collection) Node(javafx.scene.Node) Set(java.util.Set) MasterSlaveChartComposite(com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) TreeMap(java.util.TreeMap) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Set(java.util.Set) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Data(javafx.scene.chart.XYChart.Data) SVNException(org.tmatesoft.svn.core.SVNException) ObservableList(javafx.collections.ObservableList) BarChart(javafx.scene.chart.BarChart) LineChart(javafx.scene.chart.LineChart)

Example 2 with Data

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

the class SVNViewer method svnTreeViewOnAction.

public void svnTreeViewOnAction(SVNItem item) {
    if (!item.isDir()) {
        lastSelectedSVNItem.set(item);
        tbRevision.getItems().clear();
        LineChart<String, String> lineHist = new LineChart<>(new CategoryAxis(), new CategoryAxis());
        //			lineHist.setRotate(90d);
        //			lineHist.scaleXProperty().set(0.7);
        //			lineHist.scaleYProperty().set(0.7);
        lineHist.autosize();
        lineHist.setLegendVisible(false);
        List<SVNLogEntry> logs = item.getManager().log(item.getPath());
        tbRevision.getItems().addAll(logs.stream().sorted(sortUpper).collect(Collectors.toList()));
        // 시리즈 생성
        ObservableList<Data<String, String>> observableArrayList = FXCollections.observableArrayList();
        logs.stream().sorted(sortLower).forEach(entry -> {
            Date date = entry.getDate();
            String dateString = DateUtil.getDateString(date.getTime(), "yy-MM-dd HH:mm");
            Data<String, String> data = new Data<>(dateString, entry.getAuthor());
            setDataNode(entry, data);
            data.getNode().setOnMouseClicked(e -> {
                if (e.getClickCount() == 2 && e.getButton() == MouseButton.PRIMARY) {
                    String path = item.path;
                    long revision = entry.getRevision();
                    String content = item.getManager().cat(path, String.valueOf(revision));
                    BorderPane pane = new BorderPane(FxUtil.createJavaTextArea(content));
                    pane.setTop(new Label(item.getManager().fromPrettySVNLogConverter().apply(entry)));
                    FxUtil.showPopOver(data.getNode(), pane);
                }
            });
            data.getNode().setOnMouseEntered(ev -> {
                data.getNode().setBlendMode(BlendMode.GREEN);
            });
            data.getNode().setOnMouseExited(ev -> {
                data.getNode().setBlendMode(null);
            });
            observableArrayList.add(data);
        });
        Series<String, String> series = new Series<>("Commitors.", observableArrayList);
        lineHist.getData().add(series);
        borChart.setCenter(lineHist);
        String cat = item.getManager().cat(item.getPath());
        //			String simpleName = item.getSimpleName();
        javaTextAre.setContent(cat);
        tabPaneSVN.getSelectionModel().select(tabHistChart);
    }
}
Also used : BorderPane(javafx.scene.layout.BorderPane) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) Label(javafx.scene.control.Label) Data(javafx.scene.chart.XYChart.Data) Date(java.util.Date) Series(javafx.scene.chart.XYChart.Series) CategoryAxis(javafx.scene.chart.CategoryAxis) LineChart(javafx.scene.chart.LineChart)

Example 3 with Data

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

the class ScmCommitComposite method scmHistoryWalk.

private void scmHistoryWalk() throws SVNException {
    List<GagoyleDate> periodDaysByWeek = DateUtil.getPeriodDaysByWeek(supplier.getWeekSize());
    Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
    //		supplier.createStream(allLogs);
    TreeMap<String, Long> dayOfMonths = allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN.format(v.getDate()), () -> new TreeMap<>(), Collectors.counting()));
    Map<String, Long> dayOfWeeks = new LinkedHashMap<>();
    //초기값 세팅. [중요한건 정렬순서를 유지해아하므로. 초기값을 넣어준것.]
    for (GagoyleDate d : DateUtil.getPeriodDaysByWeek()) {
        String eee = FxSVNHistoryDataSupplier.EEE_PATTERN.format(d.toDate());
        dayOfWeeks.put(eee, new Long(0));
    }
    //실제값 add
    dayOfWeeks.putAll(allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.EEE_PATTERN.format(v.getDate()), Collectors.counting())));
    {
        BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
        ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN, periodDaysByWeek, dayOfMonths, true);
        Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
        barChartDayOfMonth.getData().add(series);
    }
    {
        LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
        ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.EEE_PATTERN, DateUtil.getPeriodDaysByWeek(), dayOfWeeks, false);
        Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
        lineChartDayOfWeek.getData().add(series);
    }
}
Also used : MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) SimpleDateFormat(java.text.SimpleDateFormat) XYChart(javafx.scene.chart.XYChart) LinkedHashMap(java.util.LinkedHashMap) LineChart(javafx.scene.chart.LineChart) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SVNException(org.tmatesoft.svn.core.SVNException) Data(javafx.scene.chart.XYChart.Data) Collection(java.util.Collection) Node(javafx.scene.Node) Set(java.util.Set) MasterSlaveChartComposite(com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) TreeMap(java.util.TreeMap) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) Series(javafx.scene.chart.XYChart.Series) ObservableList(javafx.collections.ObservableList) BarChart(javafx.scene.chart.BarChart) LineChart(javafx.scene.chart.LineChart)

Example 4 with Data

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

the class ScheduleTimeLineComposite method initialize.

@FXML
public void initialize() {
    Monitors.addListener(this);
    Main.addPrimaryStageCloseListener(this);
    chartTimeLine.setVerticalGridLinesVisible(false);
    ObservableList<Series<String, Number>> data = chartTimeLine.getData();
    // allJvmProcessSeries = new Series<String, Number>();
    // allJvmProcessSeries.setName("All JVM Process");
    // data.add(allJvmProcessSeries);
    passBatchProcessSeries = new Series<String, Number>();
    passBatchProcessSeries.setName("Java Process");
    data.add(passBatchProcessSeries);
    // monitorService.setOnRunning(ev ->{
    // System.err.println("running~~~~~~~~~~~~~~~~~~~");
    // });
    // monitorService.setOnScheduled(ev ->{
    // System.err.println("service schedule.....");
    // });
    monitorService = new Service<Void>() {

        @Override
        protected Task<Void> createTask() {
            return new Task<Void>() {

                @Override
                protected Void call() throws Exception {
                    Thread.sleep(1000);
                    String mmss = format.format(new Date());
                    updateMessage(mmss);
                    return null;
                }
            };
        }
    };
    monitorService.messageProperty().addListener((oba, oldval, newval) -> {
        if (newval == null || newval.isEmpty())
            return;
        ObservableList<Data<String, Number>> seriesData = passBatchProcessSeries.getData();
        Data<String, Number> e = new Data<String, Number>(newval, Monitors.getActivedJavaProcessCount());
        e.setNode(new Rectangle(1, 1));
        seriesData.add(e);
        if (seriesData.size() > CHART_SHOWING_ITEM_COUNT) {
            seriesData.remove(0);
        }
    });
    monitorService.setOnSucceeded(ev -> {
        if (running.get()) {
            monitorService.restart();
            onTickTock();
        }
    });
    monitorService.start();
}
Also used : Task(javafx.concurrent.Task) Rectangle(javafx.scene.shape.Rectangle) Data(javafx.scene.chart.XYChart.Data) Date(java.util.Date) Series(javafx.scene.chart.XYChart.Series) FXML(javafx.fxml.FXML)

Example 5 with Data

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

the class SliderLineChartExam method start.

@Override
public void start(Stage primaryStage) throws Exception {
    SliderLineChartComposite<Person> loadRoot1 = null;
    RangeSliderLineChartComposite<Person> loadRoot2 = null;
    try {
        List<Person> arrayList = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            arrayList.add(new Person(i + "", i));
        }
        loadRoot1 = new SliderLineChartComposite<Person>() {

            @Override
            public Data<String, Number> converter(Person t) {
                return new Data<>(t.name, t.age);
            }
        };
        loadRoot1.getItems().addAll(arrayList);
        loadRoot2 = new RangeSliderLineChartComposite<Person>() {

            @Override
            public Data<String, Number> converter(Person t) {
                return new Data<>(t.name, t.age);
            }
        };
        loadRoot2.getItems().addAll(arrayList);
        primaryStage.setScene(new Scene(new SplitPane(loadRoot1, loadRoot2)));
        primaryStage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
//		System.out.println(loadRoot1 == loadRoot2);
}
Also used : ArrayList(java.util.ArrayList) Data(javafx.scene.chart.XYChart.Data) SplitPane(javafx.scene.control.SplitPane) Scene(javafx.scene.Scene)

Aggregations

Data (javafx.scene.chart.XYChart.Data)5 Series (javafx.scene.chart.XYChart.Series)4 LineChart (javafx.scene.chart.LineChart)3 Label (javafx.scene.control.Label)3 BorderPane (javafx.scene.layout.BorderPane)3 SVNLogEntry (org.tmatesoft.svn.core.SVNLogEntry)3 MasterSlaveChartComposite (com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite)2 GagoyleDate (com.kyj.fx.voeditor.visual.framework.model.GagoyleDate)2 DateUtil (com.kyj.fx.voeditor.visual.util.DateUtil)2 FxCollectors (com.kyj.fx.voeditor.visual.util.FxCollectors)2 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Collection (java.util.Collection)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 Collectors (java.util.stream.Collectors)2