Search in sources :

Example 1 with UpdateTemplates

use of net.sf.latexdraw.command.UpdateTemplates in project latexdraw by arnobl.

the class TemplateManager method configureBindings.

@Override
protected void configureBindings() {
    buttonBinder().toProduce(() -> new UpdateTemplates(templatePane, svgGen, true)).on(updateTemplates).bind();
    nodeBinder().usingInteraction(DnD::new).toProduce(i -> new LoadTemplate(svgGen, drawing, new File((String) i.getSrcObject().orElseThrow().getUserData()), statusController.getProgressBar(), statusController.getLabel(), app)).on(templatePane).first(c -> templatePane.setCursor(Cursor.CLOSED_HAND)).then((i, c) -> {
        final Node srcObj = i.getSrcObject().orElseThrow();
        final Point3D pt3d = i.getTgtObject().orElseThrow().sceneToLocal(srcObj.localToScene(i.getTgtLocalPoint())).subtract(Canvas.ORIGIN.getX() + srcObj.getLayoutX(), Canvas.ORIGIN.getY() + srcObj.getLayoutY(), 0d);
        c.setPosition(ShapeFactory.INST.createPoint(pt3d));
    }).when(i -> i.getSrcObject().orElse(null) instanceof ImageView && i.getSrcObject().get().getUserData() instanceof String && i.getTgtObject().orElse(null) instanceof Canvas).endOrCancel(i -> templatePane.setCursor(Cursor.MOVE)).bind();
}
Also used : Button(javafx.scene.control.Button) Initializable(javafx.fxml.Initializable) Drawing(net.sf.latexdraw.model.api.shape.Drawing) Point3D(javafx.geometry.Point3D) URL(java.net.URL) Bindings(javafx.beans.binding.Bindings) Command(io.github.interacto.command.Command) ShapeFactory(net.sf.latexdraw.model.ShapeFactory) Inject(net.sf.latexdraw.util.Inject) ResourceBundle(java.util.ResourceBundle) JfxInstrument(io.github.interacto.jfx.instrument.JfxInstrument) FontPosture(javafx.scene.text.FontPosture) Canvas(net.sf.latexdraw.view.jfx.Canvas) UpdateTemplates(net.sf.latexdraw.command.UpdateTemplates) Label(javafx.scene.control.Label) TitledPane(javafx.scene.control.TitledPane) Node(javafx.scene.Node) Font(javafx.scene.text.Font) LoadTemplate(net.sf.latexdraw.command.LoadTemplate) File(java.io.File) Objects(java.util.Objects) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) FlowPane(javafx.scene.layout.FlowPane) ImageView(javafx.scene.image.ImageView) SVGDocumentGenerator(net.sf.latexdraw.view.svg.SVGDocumentGenerator) JfxUI(io.github.interacto.jfx.ui.JfxUI) NotNull(org.jetbrains.annotations.NotNull) DnD(io.github.interacto.jfx.interaction.library.DnD) Point3D(javafx.geometry.Point3D) Node(javafx.scene.Node) Canvas(net.sf.latexdraw.view.jfx.Canvas) LoadTemplate(net.sf.latexdraw.command.LoadTemplate) ImageView(javafx.scene.image.ImageView) UpdateTemplates(net.sf.latexdraw.command.UpdateTemplates) File(java.io.File)

Example 2 with UpdateTemplates

use of net.sf.latexdraw.command.UpdateTemplates in project latexdraw by arnobl.

the class TemplateManager method initialize.

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    mainPane.managedProperty().bind(mainPane.visibleProperty());
    emptyLabel.managedProperty().bind(emptyLabel.visibleProperty());
    emptyLabel.visibleProperty().bind(Bindings.createBooleanBinding(() -> templatePane.getChildren().isEmpty(), templatePane.getChildren()));
    emptyLabel.setFont(Font.font(emptyLabel.getFont().getFamily(), FontPosture.ITALIC, emptyLabel.getFont().getSize()));
    Command.executeAndFlush(new UpdateTemplates(templatePane, svgGen, false));
    setActivated(true);
    templatePane.setCursor(Cursor.MOVE);
}
Also used : UpdateTemplates(net.sf.latexdraw.command.UpdateTemplates)

Aggregations

UpdateTemplates (net.sf.latexdraw.command.UpdateTemplates)2 Command (io.github.interacto.command.Command)1 JfxInstrument (io.github.interacto.jfx.instrument.JfxInstrument)1 DnD (io.github.interacto.jfx.interaction.library.DnD)1 JfxUI (io.github.interacto.jfx.ui.JfxUI)1 File (java.io.File)1 URL (java.net.URL)1 Objects (java.util.Objects)1 ResourceBundle (java.util.ResourceBundle)1 Bindings (javafx.beans.binding.Bindings)1 FXML (javafx.fxml.FXML)1 Initializable (javafx.fxml.Initializable)1 Point3D (javafx.geometry.Point3D)1 Cursor (javafx.scene.Cursor)1 Node (javafx.scene.Node)1 Button (javafx.scene.control.Button)1 Label (javafx.scene.control.Label)1 TitledPane (javafx.scene.control.TitledPane)1 ImageView (javafx.scene.image.ImageView)1 FlowPane (javafx.scene.layout.FlowPane)1