Search in sources :

Example 6 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class TestSvg method start.

@Override
public void start(Stage primaryStage) throws Exception {
    SVGHelper.loadGlyphsFont(TestSvg.class.getResource("/svg/iconfont.svg"));
    SVGHelper.getAllGlyphsIDs().forEach(System.out::println);
    // 
    SVGGlyph svgGlyph = null;
    svgGlyph = new SVGGlyph("iconfont.svg.excel", Color.RED, 64);
    svgGlyph.setSizeForWidth(64);
    Button btn1 = new Button("文字1", svgGlyph);
    // 
    svgGlyph = new SVGGlyph("iconfont.svg.excelwenjian", Color.AQUA, 32);
    svgGlyph.setSizeForWidth(32);
    svgGlyph.setRotate(45);
    Button btn2 = new Button("文字2", svgGlyph);
    // 
    svgGlyph = new SVGGlyph("iconfont.svg.wui-f-excel", Color.BLANCHEDALMOND, 16);
    svgGlyph.setSizeForWidth(16);
    Button btn3 = new Button("文字3", svgGlyph);
    VBox vb = new VBox(btn1, btn2, btn3);
    primaryStage.setScene(new Scene(vb));
    primaryStage.show();
}
Also used : SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 7 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class TypicalCaseMenu method getLeftContent.

@Override
public Region getLeftContent() {
    VBox vb = new VBox(10);
    Button create = createMenu(MsgUtil.getMessage("menu.button.new"), new SVGGlyph("iconfont.svg.new", Color.WHITE, 32));
    create.setOnMouseClicked(e -> newCase());
    Button open = createMenu(MsgUtil.getMessage("menu.button.open"), new SVGGlyph("iconfont.svg.open", Color.WHITE, 32));
    open.setOnMouseClicked(e -> showCaseDialog());
    Button save = createMenu(MsgUtil.getMessage("menu.button.save"), new SVGGlyph("iconfont.svg.save", Color.WHITE, 32));
    save.setOnMouseClicked(e -> saveCase());
    HBox menu = new HBox(22, create, open, save);
    menu.setAlignment(Pos.CENTER);
    // 菜单
    vb.getChildren().add(menu);
    vb.getChildren().add(new ElecCompTree(elecComp -> typicalCase3D.selectedElecComp(elecComp)));
    return vb;
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) PageController(com.cas.sim.tis.view.controller.PageController) Node(javafx.scene.Node) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) Font(javafx.scene.text.Font) TypicalCase(com.cas.sim.tis.entity.TypicalCase) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) AlertUtil(com.cas.sim.tis.util.AlertUtil) Region(javafx.scene.layout.Region) AlertType(javafx.scene.control.Alert.AlertType) TextInputDialog(javafx.scene.control.TextInputDialog) ILeftContent(com.cas.sim.tis.view.control.ILeftContent) Optional(java.util.Optional) SpringUtil(com.cas.sim.tis.util.SpringUtil) Dialog(com.cas.sim.tis.view.control.imp.dialog.Dialog) MsgUtil(com.cas.sim.tis.util.MsgUtil) TypicalCaseSelectDialog(com.cas.sim.tis.view.control.imp.preparation.TypicalCaseSelectDialog) ContentDisplay(javafx.scene.control.ContentDisplay) HBox(javafx.scene.layout.HBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Button(javafx.scene.control.Button) VBox(javafx.scene.layout.VBox)

Example 8 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method createQuizTable.

private void createQuizTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("icon");
    icon.setText("");
    icon.setMaxWidth(25);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    quizs.getColumns().addAll(id, icon, name);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        PreparationQuiz preparationQuiz = SpringUtil.getBean(PreparationQuizAction.class).findQuizById((Integer) rid);
        int type = preparationQuiz.getType();
        if (PreparationQuizType.LIBRARY.getType() == type) {
            openLibrary(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.BROKEN_CASE.getType() == type) {
            openBrokenCase(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.FREE.getType() == type) {
            openFreeMode();
        }
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    quizs.getColumns().add(view);
    if (RoleConst.TEACHER == Session.get(Session.KEY_LOGIN_ROLE, -1)) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(PreparationResourceAction.class).detele((Integer) rid);
                    loadResources();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        quizs.getColumns().add(delete);
    }
}
Also used : Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) PreparationInfo(com.cas.sim.tis.vo.PreparationInfo) PreparationResource(com.cas.sim.tis.entity.PreparationResource) TypicalCase(com.cas.sim.tis.entity.TypicalCase) PreviewQuestionPaper(com.cas.sim.tis.view.control.imp.question.PreviewQuestionPaper) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) ElecCompAction(com.cas.sim.tis.action.ElecCompAction) ElecComp(com.cas.sim.tis.entity.ElecComp) Map(java.util.Map) HBox(javafx.scene.layout.HBox) RoleConst(com.cas.sim.tis.consts.RoleConst) IContent(com.cas.sim.tis.view.control.IContent) Recongnize3D(com.cas.sim.tis.view.control.imp.jme.Recongnize3D) Table(com.cas.sim.tis.view.control.imp.table.Table) Preparation(com.cas.sim.tis.entity.Preparation) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) PreparationQuizType(com.cas.sim.tis.consts.PreparationQuizType) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) Session(com.cas.sim.tis.consts.Session) FXML(javafx.fxml.FXML) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) FlowPane(javafx.scene.layout.FlowPane) CatalogAction(com.cas.sim.tis.action.CatalogAction) ResourceAction(com.cas.sim.tis.action.ResourceAction) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) ButtonType(javafx.scene.control.ButtonType) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D) Function(java.util.function.Function) BrokenCase(com.cas.sim.tis.entity.BrokenCase) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) PreparationAction(com.cas.sim.tis.action.PreparationAction) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) User(com.cas.sim.tis.entity.User) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AlertUtil(com.cas.sim.tis.util.AlertUtil) PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction) ResourceType(com.cas.sim.tis.consts.ResourceType) Dialog(com.cas.sim.tis.view.control.imp.dialog.Dialog) BrokenCaseAction(com.cas.sim.tis.action.BrokenCaseAction) Catalog(com.cas.sim.tis.entity.Catalog) PreparationQuizAction(com.cas.sim.tis.action.PreparationQuizAction) UserAction(com.cas.sim.tis.action.UserAction) Function(java.util.function.Function) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) ResourceType(com.cas.sim.tis.consts.ResourceType)

Example 9 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceList method createTable.

private void createTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("type");
    icon.setText("");
    icon.setMaxWidth(25);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    // 日期
    Column<Date> date = new Column<>();
    date.setAlignment(Pos.CENTER);
    date.setKey("createDate");
    date.setText(type.getDateLabel());
    date.setMaxWidth(160);
    date.setCellFactory(Cell.forTableColumn(new StringConverter<Date>() {

        @Override
        public String toString(Date date) {
            return DateUtil.date2Str(date, DateUtil.DATE_TIME_PAT_SHOW_);
        }

        @Override
        public Date fromString(String string) {
            return null;
        }
    }));
    table.getColumns().addAll(id, icon, name, date);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        SpringUtil.getBean(ResourceAction.class).browsed((Integer) rid);
        ResourceAction action = SpringUtil.getBean(ResourceAction.class);
        Resource resource = action.findResourceByID((Integer) rid);
        // 跳转到查看页面
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new ResourceViewer(resource), PageLevel.Level2);
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    table.getColumns().add(view);
    if (type.isEditable()) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(ResourceAction.class).detele((Integer) rid);
                    pagination.reload();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        table.getColumns().add(delete);
    }
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) StringUtil(com.cas.util.StringUtil) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) PaginationBar(com.cas.sim.tis.view.control.imp.pagination.PaginationBar) Data(javafx.scene.chart.PieChart.Data) HBox(javafx.scene.layout.HBox) ResourceConsts(com.cas.sim.tis.consts.ResourceConsts) TextField(javafx.scene.control.TextField) IContent(com.cas.sim.tis.view.control.IContent) Table(com.cas.sim.tis.view.control.imp.table.Table) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) UUID(java.util.UUID) PageInfo(com.github.pagehelper.PageInfo) FXML(javafx.fxml.FXML) PieChart(javafx.scene.chart.PieChart) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) GUIState(de.felixroske.jfxsupport.GUIState) ResourceAction(com.cas.sim.tis.action.ResourceAction) Cell(com.cas.sim.tis.view.control.imp.table.Cell) ObservableList(javafx.collections.ObservableList) SearchBox(com.cas.sim.tis.view.control.imp.SearchBox) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) FileUtil(com.cas.util.FileUtil) Function(java.util.function.Function) ArrayList(java.util.ArrayList) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Node(javafx.scene.Node) DecimalFormat(java.text.DecimalFormat) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) StringConverter(javafx.util.StringConverter) File(java.io.File) AlertUtil(com.cas.sim.tis.util.AlertUtil) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) DateUtil(com.cas.util.DateUtil) ResourceType(com.cas.sim.tis.consts.ResourceType) FTPUtils(com.cas.sim.tis.util.FTPUtils) Resource(com.cas.sim.tis.entity.Resource) ResourceType(com.cas.sim.tis.consts.ResourceType) StringConverter(javafx.util.StringConverter) Date(java.util.Date) Function(java.util.function.Function) PageController(com.cas.sim.tis.view.controller.PageController) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) ResourceAction(com.cas.sim.tis.action.ResourceAction)

Example 10 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class DrawingController method maximize.

public void maximize() {
    if (this.stage.isMaximized()) {
        max.setGraphic(new SVGGlyph("iconfont.svg.revert", Color.web("#A2CBF3"), 10));
        maxTip.setText(MsgUtil.getMessage("button.revert"));
    } else {
        max.setGraphic(new SVGGlyph("iconfont.svg.max", Color.web("#A2CBF3"), 10));
        maxTip.setText(MsgUtil.getMessage("button.maximize"));
    }
}
Also used : SVGGlyph(com.cas.sim.tis.svg.SVGGlyph)

Aggregations

SVGGlyph (com.cas.sim.tis.svg.SVGGlyph)12 ResourceAction (com.cas.sim.tis.action.ResourceAction)5 FXML (javafx.fxml.FXML)5 Button (javafx.scene.control.Button)5 VBox (javafx.scene.layout.VBox)5 AlertUtil (com.cas.sim.tis.util.AlertUtil)4 MsgUtil (com.cas.sim.tis.util.MsgUtil)4 SpringUtil (com.cas.sim.tis.util.SpringUtil)4 PageController (com.cas.sim.tis.view.controller.PageController)4 Pos (javafx.geometry.Pos)4 Node (javafx.scene.Node)4 AlertType (javafx.scene.control.Alert.AlertType)4 HBox (javafx.scene.layout.HBox)4 Region (javafx.scene.layout.Region)4 JSONArray (com.alibaba.fastjson.JSONArray)3 ResourceType (com.cas.sim.tis.consts.ResourceType)3 Resource (com.cas.sim.tis.entity.Resource)3 IContent (com.cas.sim.tis.view.control.IContent)3 IOException (java.io.IOException)3 BrokenCaseAction (com.cas.sim.tis.action.BrokenCaseAction)2