Search in sources :

Example 21 with ObservableList

use of javafx.collections.ObservableList in project financial by greatkendy123.

the class ZonghuiService method initTableKaixiaoAndGetSum.

/**
 * 总汇Tab中的开销表赋值
 */
public static String initTableKaixiaoAndGetSum(TableView<ZonghuiKaixiaoInfo> tableZonghuiKaixiao) {
    ObservableList<ZonghuiKaixiaoInfo> obList = FXCollections.observableArrayList();
    Map<String, Map<String, String>> lockedMap = DataConstans.All_Locked_Data_Map;
    String sumOfKaixiao = "0";
    if (lockedMap.size() > 0) {
        Map<String, String> map = lockedMap.get(DataConstans.Index_Table_Id_Map.size() + "");
        List<KaixiaoInfo> KaixiaoInfoList = JSON.parseObject(MoneyService.getJsonString(map, "实时开销"), new TypeReference<List<KaixiaoInfo>>() {
        });
        for (KaixiaoInfo infos : KaixiaoInfoList) {
            obList.add(new ZonghuiKaixiaoInfo(infos.getKaixiaoType(), infos.getKaixiaoMoney()));
        }
        sumOfKaixiao = MoneyService.getJsonString(map, "实时开销总和");
        tableZonghuiKaixiao.getColumns().get(1).setText(sumOfKaixiao);
    }
    tableZonghuiKaixiao.setItems(obList);
    tableZonghuiKaixiao.refresh();
    return sumOfKaixiao;
}
Also used : ZonghuiKaixiaoInfo(com.kendy.entity.ZonghuiKaixiaoInfo) ZonghuiKaixiaoInfo(com.kendy.entity.ZonghuiKaixiaoInfo) KaixiaoInfo(com.kendy.entity.KaixiaoInfo) List(java.util.List) ObservableList(javafx.collections.ObservableList) Map(java.util.Map)

Example 22 with ObservableList

use of javafx.collections.ObservableList in project financial by greatkendy123.

the class TGController method refreshTableTGTeamSum.

/**
 * 刷新托管团队总和数据(合计)
 */
public void refreshTableTGTeamSum() {
    ObservableList<TGTeamInfo> items = tableTGZhanji.getItems();
    // 1 战绩2.5%:
    double zjRate25Sum = items.stream().mapToDouble(info -> NumUtil.getNum(info.getTgZJ25())).sum();
    // 2 战绩未知
    String columnName = tableTGZhanji.getColumns().get(5).getText();
    double zjRateUnknowSum = tableTGZhanji.getItems().stream().mapToDouble(info -> NumUtil.getNum(info.getTgZJUnknow())).sum();
    // 3 保险
    double zjBaoxianSum = items.stream().mapToDouble(info -> NumUtil.getNum(info.getTgBaoxian())).sum() * (-0.975);
    // 4 回保
    double zjHuibaoSum = items.stream().mapToDouble(info -> NumUtil.getNum(info.getTgHuiBao())).sum();
    // 5 总和
    double zjProfitSum = zjRate25Sum - zjRateUnknowSum + zjBaoxianSum - zjHuibaoSum;
    // 6 总人次
    int size = 0;
    if (items != null) {
        size = items.size();
    }
    List<TypeValueInfo> list = new ArrayList<TypeValueInfo>();
    list.add(new TypeValueInfo("战绩2.5%合计", NumUtil.digit2(zjRate25Sum + "")));
    list.add(new TypeValueInfo(columnName + "合计", NumUtil.digit2(zjRateUnknowSum + "")));
    list.add(new TypeValueInfo("保险合计", NumUtil.digit2(zjBaoxianSum + "")));
    list.add(new TypeValueInfo("回保合计", NumUtil.digit2(zjHuibaoSum + "")));
    list.add(new TypeValueInfo("总利润合计", NumUtil.digit2(zjProfitSum + "")));
    list.add(new TypeValueInfo("总人次", size + ""));
    ObservableList<TypeValueInfo> obList = FXCollections.observableArrayList(list);
    tableZJSum.setItems(obList);
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Initializable(javafx.fxml.Initializable) Constants(application.Constants) NumUtil(com.kendy.util.NumUtil) URL(java.net.URL) InputDialog(com.kendy.util.InputDialog) Random(java.util.Random) VBox(javafx.scene.layout.VBox) Huishui(com.kendy.entity.Huishui) Logger(org.apache.log4j.Logger) Parent(javafx.scene.Parent) TabPane(javafx.scene.control.TabPane) AlertType(javafx.scene.control.Alert.AlertType) StringUtil(com.kendy.util.StringUtil) Map(java.util.Map) TGTeamModel(com.kendy.entity.TGTeamModel) WindowEvent(javafx.stage.WindowEvent) MyController(application.MyController) TableView(javafx.scene.control.TableView) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) TgWaizhaiService(com.kendy.service.TgWaizhaiService) TGCompanyModel(com.kendy.entity.TGCompanyModel) FXML(javafx.fxml.FXML) List(java.util.List) TypeReference(com.alibaba.fastjson.TypeReference) CollectUtil(com.kendy.util.CollectUtil) ShowUtil(com.kendy.util.ShowUtil) TGKaixiaoInfo(com.kendy.entity.TGKaixiaoInfo) ProxyTeamInfo(com.kendy.entity.ProxyTeamInfo) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Scene(javafx.scene.Scene) TGCommentInfo(com.kendy.entity.TGCommentInfo) TGExportExcelService(com.kendy.service.TGExportExcelService) ListView(javafx.scene.control.ListView) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TGFwfService(com.kendy.service.TGFwfService) TypeValueInfo(com.kendy.entity.TypeValueInfo) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) TableUtil(com.kendy.util.TableUtil) TGLirunInfo(com.kendy.entity.TGLirunInfo) DataConstans(application.DataConstans) DBUtil(com.kendy.db.DBUtil) TGFwfinfo(com.kendy.entity.TGFwfinfo) Label(javafx.scene.control.Label) TGTeamInfo(com.kendy.entity.TGTeamInfo) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) TeamProxyService(com.kendy.service.TeamProxyService) Main(application.Main) ActionEvent(javafx.event.ActionEvent) JSON(com.alibaba.fastjson.JSON) Stage(javafx.stage.Stage) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) Entity(com.kendy.interfaces.Entity) TypeValueInfo(com.kendy.entity.TypeValueInfo) ArrayList(java.util.ArrayList) TGTeamInfo(com.kendy.entity.TGTeamInfo)

Example 23 with ObservableList

use of javafx.collections.ObservableList in project blue by kunstmusik.

the class ParameterLineView method editPoints.

private void editPoints() {
    TableView<LinePoint> table = new TableView<>();
    TableColumn<LinePoint, Double> xCol = new TableColumn<>("x");
    TableColumn<LinePoint, Double> yCol = new TableColumn<>("y");
    table.getColumns().setAll(xCol, yCol);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setItems(getSelectedLine().getObservableList());
    table.setEditable(true);
    xCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<LinePoint, Double>, ObservableValue<Double>>() {

        @Override
        public ObservableValue<Double> call(TableColumn.CellDataFeatures<LinePoint, Double> param) {
            return new ReadOnlyObjectWrapper<>(param.getValue().getX() * getDuration() + getStartTime());
        }
    });
    xCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    xCol.setOnEditCommit(te -> {
        LinePoint lp = te.getRowValue();
        ObservableList<LinePoint> lpList = getSelectedLine().getObservableList();
        if (getSelectedLine().getLinePoint(0) == lp || getSelectedLine().getLinePoint(getSelectedLine().size() - 1) == lp) {
            return;
        }
        int index = lpList.indexOf(lp);
        double v = (te.getNewValue() - getStartTime()) / getDuration();
        lp.setX(Utils.clamp(lpList.get(index - 1).getX(), v, lpList.get(index + 1).getX()));
    });
    xCol.setEditable(true);
    yCol.setCellValueFactory(new PropertyValueFactory<>("y"));
    yCol.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    yCol.setOnEditCommit(te -> {
        te.getRowValue().setY(Utils.clamp(getSelectedLine().getMin(), te.getNewValue(), getSelectedLine().getMax()));
    });
    yCol.setEditable(true);
    Dialog<ButtonType> d = new Dialog<>();
    d.initOwner(getScene().getWindow());
    d.initModality(Modality.APPLICATION_MODAL);
    d.getDialogPane().setContent(new ScrollPane(table));
    d.getDialogPane().getStylesheets().add(BlueFX.getBlueFxCss());
    d.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
    d.setTitle("Edit Points");
    TableModelListener tml = tme -> {
        repaint();
    };
    getSelectedLine().addTableModelListener(tml);
    Optional<ButtonType> res = d.showAndWait();
    getSelectedLine().removeTableModelListener(tml);
}
Also used : DoubleStringConverter(javafx.util.converter.DoubleStringConverter) NumberUtilities(blue.utility.NumberUtilities) ButtonType(javafx.scene.control.ButtonType) LineList(blue.components.lines.LineList) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) DoubleProperty(javafx.beans.property.DoubleProperty) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableModelListener(javax.swing.event.TableModelListener) LinePoint(blue.components.lines.LinePoint) TableColumn(javafx.scene.control.TableColumn) DragDirection(blue.components.DragDirection) Utils(org.controlsfx.tools.Utils) BlueFX(blue.jfx.BlueFX) ScrollPane(javafx.scene.control.ScrollPane) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Dialog(javafx.scene.control.Dialog) MenuItem(javafx.scene.control.MenuItem) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphicsContext(javafx.scene.canvas.GraphicsContext) Canvas(javafx.scene.canvas.Canvas) Line(blue.components.lines.Line) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) DoubleStringConverter(javafx.util.converter.DoubleStringConverter) ObservableValue(javafx.beans.value.ObservableValue) TableColumn(javafx.scene.control.TableColumn) LinePoint(blue.components.lines.LinePoint) LinePoint(blue.components.lines.LinePoint) Dialog(javafx.scene.control.Dialog) ScrollPane(javafx.scene.control.ScrollPane) TableModelListener(javax.swing.event.TableModelListener) ButtonType(javafx.scene.control.ButtonType) TableView(javafx.scene.control.TableView)

Example 24 with ObservableList

use of javafx.collections.ObservableList in project latexdraw by arnobl.

the class Canvas method updateSelectionBorders.

private void updateSelectionBorders() {
    if (selectionBorder.isDisable())
        return;
    Platform.runLater(() -> {
        final ObservableList<IShape> selection = drawing.getSelection().getShapes();
        if (selection.isEmpty()) {
            selectionBorder.setVisible(false);
        } else {
            final Rectangle2D rec = selection.stream().map(sh -> shapesToViewMap.get(sh)).filter(vi -> vi != null).map(vi -> {
                final Bounds b = vi.getBoundsInParent();
                return (Rectangle2D) new Rectangle2D.Double(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight());
            }).reduce(Rectangle2D::createUnion).orElse(new Rectangle2D.Double());
            selectionBorder.setLayoutX(rec.getMinX());
            selectionBorder.setLayoutY(rec.getMinY());
            selectionBorder.setWidth(rec.getWidth());
            selectionBorder.setHeight(rec.getHeight());
            selectionBorder.setVisible(true);
        }
    });
}
Also used : Change(javafx.collections.ListChangeListener.Change) Point2D(java.awt.geom.Point2D) ShapePropertyCmd(net.sf.latexdraw.commands.shape.ShapePropertyCmd) ShapeFactory(net.sf.latexdraw.models.ShapeFactory) Rectangle2D(java.awt.geom.Rectangle2D) Point(java.awt.Point) Parent(javafx.scene.Parent) ScrollPane(javafx.scene.control.ScrollPane) Document(org.w3c.dom.Document) Map(java.util.Map) IDrawing(net.sf.latexdraw.models.interfaces.shape.IDrawing) Redo(org.malai.command.library.Redo) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Pane(javafx.scene.layout.Pane) Undo(org.malai.command.library.Undo) ShapesCmd(net.sf.latexdraw.commands.ShapesCmd) CmdHandler(org.malai.command.CmdHandler) Undoable(org.malai.undo.Undoable) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) Zoomable(org.malai.properties.Zoomable) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) ViewsSynchroniserHandler(net.sf.latexdraw.view.ViewsSynchroniserHandler) Platform(javafx.application.Platform) List(java.util.List) Duration(javafx.util.Duration) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) StrokeLineCap(javafx.scene.shape.StrokeLineCap) ObservableList(javafx.collections.ObservableList) IOCommand(org.malai.javafx.command.IOCommand) Bounds(javafx.geometry.Bounds) Command(org.malai.command.Command) MouseEvent(javafx.scene.input.MouseEvent) ShapeCmd(net.sf.latexdraw.commands.ShapeCmd) MovePoint(net.sf.latexdraw.commands.shape.MovePoint) HashMap(java.util.HashMap) DoubleProperty(javafx.beans.property.DoubleProperty) MathUtils(net.sf.latexdraw.models.MathUtils) Modifiable(org.malai.properties.Modifiable) CommandsRegistry(org.malai.command.CommandsRegistry) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) LNamespace(net.sf.latexdraw.util.LNamespace) Node(org.w3c.dom.Node) KeyValue(javafx.animation.KeyValue) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) NodeList(org.w3c.dom.NodeList) MagneticGrid(net.sf.latexdraw.view.MagneticGrid) Page(net.sf.latexdraw.util.Page) Preferenciable(org.malai.properties.Preferenciable) ParallelTransition(javafx.animation.ParallelTransition) Cursor(javafx.scene.Cursor) DrawingCmd(net.sf.latexdraw.commands.DrawingCmd) Element(org.w3c.dom.Element) Reinitialisable(org.malai.properties.Reinitialisable) Bounds(javafx.geometry.Bounds) Rectangle2D(java.awt.geom.Rectangle2D) IShape(net.sf.latexdraw.models.interfaces.shape.IShape)

Example 25 with ObservableList

use of javafx.collections.ObservableList in project latexdraw by arnobl.

the class ShortcutsController method initialize.

@SuppressWarnings("unchecked")
@Override
public void initialize(final URL location, final ResourceBundle resources) {
    final String ctrl = KeyEvent.getKeyModifiersText(InputEvent.CTRL_MASK);
    final String shift = KeyEvent.getKeyModifiersText(InputEvent.SHIFT_MASK);
    // $NON-NLS-1$
    final String leftClick = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.8");
    // $NON-NLS-1$
    final String catEdit = LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.89");
    // $NON-NLS-1$
    final String catNav = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.4");
    // $NON-NLS-1$
    final String catTran = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.5");
    // $NON-NLS-1$
    final String catDraw = LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.6");
    // $NON-NLS-1$
    final String catFile = LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.88");
    for (int i = 0, size = table.getColumns().size(); i < size; i++) {
        final int colIndex = i;
        final TableColumn<ObservableList<String>, String> col = (TableColumn<ObservableList<String>, String>) table.getColumns().get(i);
        col.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().get(colIndex)));
    }
    table.getColumns().forEach(col -> col.prefWidthProperty().bind(table.widthProperty().divide(3)));
    // $NON-NLS-1$
    table.getItems().addAll(// $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+C", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.40"), catEdit), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+V", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.43"), catEdit), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+X", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.44"), catEdit), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + "+Z", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.23"), catEdit), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + "+Y", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.22"), catEdit), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+N", LangTool.INSTANCE.getBundle().getString("Res.2"), catFile), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+O", LangTool.INSTANCE.getBundle().getString("FileLoaderSaver.3"), catFile), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + "+S", LangTool.INSTANCE.getBundle().getString("FileLoaderSaver.1"), catFile), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + "+W", LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.18"), catFile), // $NON-NLS-1$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_ADD), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.57"), catNav), // $NON-NLS-1$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_SUBTRACT), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.58"), catNav), // $NON-NLS-1$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DELETE), LangTool.INSTANCE.getBundle().getString("LaTeXDrawFrame.17"), catDraw), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_RIGHT), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.9"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_LEFT), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.10"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_UP), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.11"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(KeyEvent.getKeyText(KeyEvent.VK_DOWN), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.12"), catNav), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + "+U", LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.23"), catTran), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + "+A", LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.25"), catDraw), // $NON-NLS-1$
    FXCollections.observableArrayList(ctrl + '+' + leftClick, LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.26"), catDraw), // $NON-NLS-1$
    FXCollections.observableArrayList(shift + '+' + leftClick, LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.27"), catDraw), // $NON-NLS-1$ //$NON-NLS-2$
    FXCollections.observableArrayList(ctrl + '+' + LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.29"), LangTool.INSTANCE.getBundle().getString("ShortcutsFrame.30"), catDraw));
}
Also used : ObservableList(javafx.collections.ObservableList) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) TableColumn(javafx.scene.control.TableColumn)

Aggregations

ObservableList (javafx.collections.ObservableList)77 List (java.util.List)46 ArrayList (java.util.ArrayList)31 Collectors (java.util.stream.Collectors)29 Map (java.util.Map)28 FXCollections (javafx.collections.FXCollections)28 HashMap (java.util.HashMap)21 Node (javafx.scene.Node)20 TableColumn (javafx.scene.control.TableColumn)20 Label (javafx.scene.control.Label)18 Optional (java.util.Optional)17 ActionEvent (javafx.event.ActionEvent)16 FXML (javafx.fxml.FXML)16 TableView (javafx.scene.control.TableView)16 MouseEvent (javafx.scene.input.MouseEvent)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 Button (javafx.scene.control.Button)15 BorderPane (javafx.scene.layout.BorderPane)15 File (java.io.File)14