Search in sources :

Example 1 with TextPosition

use of net.sf.latexdraw.model.api.shape.TextPosition in project latexdraw by arnobl.

the class ShapeTextCustomiser method initialize.

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    super.initialize(location, resources);
    mainPane.managedProperty().bind(mainPane.visibleProperty());
    final Map<TextPosition, Image> cachePos = new EnumMap<>(TextPosition.class);
    // NON-NLS
    cachePos.put(TextPosition.TOP_LEFT, new Image("/res/textPosTL.png"));
    // NON-NLS
    cachePos.put(TextPosition.TOP, new Image("/res/textPosT.png"));
    // NON-NLS
    cachePos.put(TextPosition.TOP_RIGHT, new Image("/res/textPosTR.png"));
    // NON-NLS
    cachePos.put(TextPosition.RIGHT, new Image("/res/textPosRight.png"));
    // NON-NLS
    cachePos.put(TextPosition.BOT_RIGHT, new Image("/res/textPosBR.png"));
    // NON-NLS
    cachePos.put(TextPosition.BOT, new Image("/res/textPosB.png"));
    // NON-NLS
    cachePos.put(TextPosition.BOT_LEFT, new Image("/res/textPosBL.png"));
    // NON-NLS
    cachePos.put(TextPosition.LEFT, new Image("/res/textPosLeft.png"));
    // NON-NLS
    cachePos.put(TextPosition.CENTER, new Image("/res/textPosCentre.png"));
    initComboBox(textPos, cachePos, TextPosition.values());
}
Also used : TextPosition(net.sf.latexdraw.model.api.shape.TextPosition) Image(javafx.scene.image.Image) EnumMap(java.util.EnumMap)

Example 2 with TextPosition

use of net.sf.latexdraw.model.api.shape.TextPosition in project latexdraw by arnobl.

the class ShapeTextCustomiser method updateOnTextPropShape.

private void updateOnTextPropShape(final Group shape) {
    final TextPosition tp = shape.getTextPosition();
    textPos.getSelectionModel().select(tp);
    // Otherwise it means that this field is currently being edited and must not be updated.
    if (!packagesField.isFocused()) {
        packagesField.setText(latexData.getPackages());
    }
    // Updating the log field.
    shape.getShapes().stream().filter(sh -> sh instanceof Text && canvas.getViewFromShape(sh).orElse(null) instanceof ViewText && ((ViewText) canvas.getViewFromShape(sh).orElseThrow()).getCompilationData().isPresent()).findFirst().ifPresent(txt -> {
        final ViewText view = (ViewText) canvas.getViewFromShape(txt).orElseThrow();
        final Future<?> currentCompil = view.getCurrentCompilation();
        if (currentCompil != null) {
            try {
                currentCompil.get();
            } catch (final InterruptedException ex) {
                Thread.currentThread().interrupt();
                BadaboomCollector.INSTANCE.add(ex);
            } catch (final ExecutionException ex) {
                BadaboomCollector.INSTANCE.add(ex);
            }
        }
        logField.setText(view.getCompilationData().orElse(""));
    });
}
Also used : ViewText(net.sf.latexdraw.view.jfx.ViewText) TextPosition(net.sf.latexdraw.model.api.shape.TextPosition) ViewText(net.sf.latexdraw.view.jfx.ViewText) Text(net.sf.latexdraw.model.api.shape.Text) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

TextPosition (net.sf.latexdraw.model.api.shape.TextPosition)2 EnumMap (java.util.EnumMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Image (javafx.scene.image.Image)1 Text (net.sf.latexdraw.model.api.shape.Text)1 ViewText (net.sf.latexdraw.view.jfx.ViewText)1