Search in sources :

Example 1 with FillingStyle

use of net.sf.latexdraw.models.interfaces.shape.FillingStyle in project latexdraw by arnobl.

the class ShapeFillingCustomiser method update.

@Override
protected void update(final IGroup shape) {
    if (shape.isInteriorStylable()) {
        setActivated(true);
        final FillingStyle style = shape.getFillingStyle();
        final boolean isFillable = style.isFilled();
        final boolean hatchings = style.isHatchings();
        final boolean gradient = style.isGradient();
        // Updating the visibility of the widgets.
        gradientPane.setVisible(gradient);
        hatchingsPane.setVisible(hatchings);
        fillPane.setVisible(isFillable);
        fillStyleCB.getSelectionModel().select(style);
        if (isFillable) {
            fillColButton.setValue(shape.getFillingCol().toJFX());
        }
        if (hatchings) {
            hatchColButton.setValue(shape.getHatchingsCol().toJFX());
            hatchAngleField.getValueFactory().setValue(Math.toDegrees(shape.getHatchingsAngle()));
            hatchSepField.getValueFactory().setValue(shape.getHatchingsSep());
            hatchWidthField.getValueFactory().setValue(shape.getHatchingsWidth());
        } else if (gradient) {
            gradStartColButton.setValue(shape.getGradColStart().toJFX());
            gradEndColButton.setValue(shape.getGradColEnd().toJFX());
            gradAngleField.getValueFactory().setValue(Math.toDegrees(shape.getGradAngle()));
            gradMidPtField.getValueFactory().setValue(shape.getGradMidPt());
        }
    } else {
        setActivated(false);
    }
}
Also used : FillingStyle(net.sf.latexdraw.models.interfaces.shape.FillingStyle)

Example 2 with FillingStyle

use of net.sf.latexdraw.models.interfaces.shape.FillingStyle in project latexdraw by arnobl.

the class TestPencilFillingStyle method testSelectFillingPlainPencil.

@Test
public void testSelectFillingPlainPencil() {
    new CompositeGUIVoidCommand(activatePencil, pencilCreatesRec, updateIns).execute();
    FillingStyle style = fillStyleCB.getSelectionModel().getSelectedItem();
    selectStyle.execute(FillingStyle.PLAIN);
    FillingStyle newStyle = fillStyleCB.getSelectionModel().getSelectedItem();
    assertEquals(newStyle, pencil.createShapeInstance().getFillingStyle());
    assertNotEquals(style, newStyle);
}
Also used : CompositeGUIVoidCommand(net.sf.latexdraw.instruments.CompositeGUIVoidCommand) FillingStyle(net.sf.latexdraw.models.interfaces.shape.FillingStyle) Test(org.junit.Test)

Example 3 with FillingStyle

use of net.sf.latexdraw.models.interfaces.shape.FillingStyle in project latexdraw by arnobl.

the class TestHandFillingStyle method testSelectFillingPlainHand.

@Test
public void testSelectFillingPlainHand() {
    new CompositeGUIVoidCommand(activateHand, selectionAddDot, selectionAddRec, selectionAddBezier, updateIns).execute();
    FillingStyle style = fillStyleCB.getSelectionModel().getSelectedItem();
    selectStyle.execute(FillingStyle.PLAIN);
    FillingStyle newStyle = fillStyleCB.getSelectionModel().getSelectedItem();
    assertEquals(newStyle, drawing.getSelection().getShapeAt(1).getFillingStyle());
    assertEquals(newStyle, drawing.getSelection().getShapeAt(2).getFillingStyle());
    assertNotEquals(style, newStyle);
}
Also used : CompositeGUIVoidCommand(net.sf.latexdraw.instruments.CompositeGUIVoidCommand) FillingStyle(net.sf.latexdraw.models.interfaces.shape.FillingStyle) Test(org.junit.Test)

Example 4 with FillingStyle

use of net.sf.latexdraw.models.interfaces.shape.FillingStyle in project latexdraw by arnobl.

the class ShapeFillingCustomiser method initialize.

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    mainPane.managedProperty().bind(mainPane.visibleProperty());
    fillPane.managedProperty().bind(fillPane.visibleProperty());
    hatchingsPane.managedProperty().bind(hatchingsPane.visibleProperty());
    gradientPane.managedProperty().bind(gradientPane.visibleProperty());
    final Map<FillingStyle, Image> cache = new EnumMap<>(FillingStyle.class);
    // NON-NLS
    cache.put(FillingStyle.NONE, new Image("/res/hatch/hatch.none.png"));
    // NON-NLS
    cache.put(FillingStyle.PLAIN, new Image("/res/hatch/hatch.solid.png"));
    // NON-NLS
    cache.put(FillingStyle.CLINES, new Image("/res/hatch/hatch.cross.png"));
    // NON-NLS
    cache.put(FillingStyle.CLINES_PLAIN, new Image("/res/hatch/hatchf.cross.png"));
    // NON-NLS
    cache.put(FillingStyle.HLINES, new Image("/res/hatch/hatch.horiz.png"));
    // NON-NLS
    cache.put(FillingStyle.HLINES_PLAIN, new Image("/res/hatch/hatchf.horiz.png"));
    // NON-NLS
    cache.put(FillingStyle.VLINES, new Image("/res/hatch/hatch.vert.png"));
    // NON-NLS
    cache.put(FillingStyle.VLINES_PLAIN, new Image("/res/hatch/hatchf.vert.png"));
    // NON-NLS
    cache.put(FillingStyle.GRAD, new Image("/res/hatch/gradient.png"));
    initComboBox(fillStyleCB, cache, FillingStyle.values());
}
Also used : Image(javafx.scene.image.Image) FillingStyle(net.sf.latexdraw.models.interfaces.shape.FillingStyle) EnumMap(java.util.EnumMap)

Aggregations

FillingStyle (net.sf.latexdraw.models.interfaces.shape.FillingStyle)4 CompositeGUIVoidCommand (net.sf.latexdraw.instruments.CompositeGUIVoidCommand)2 Test (org.junit.Test)2 EnumMap (java.util.EnumMap)1 Image (javafx.scene.image.Image)1