Search in sources :

Example 1 with DotStyle

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

the class ShapeDotCustomiser method initialize.

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    super.initialize(location, resources);
    mainPane.managedProperty().bind(mainPane.visibleProperty());
    final Map<DotStyle, Image> cache = new EnumMap<>(DotStyle.class);
    // NON-NLS
    cache.put(DotStyle.DOT, new Image("/res/dotStyles/dot.none.png"));
    // NON-NLS
    cache.put(DotStyle.ASTERISK, new Image("/res/dotStyles/dot.asterisk.png"));
    // NON-NLS
    cache.put(DotStyle.BAR, new Image("/res/dotStyles/dot.bar.png"));
    // NON-NLS
    cache.put(DotStyle.DIAMOND, new Image("/res/dotStyles/dot.diamond.png"));
    // NON-NLS
    cache.put(DotStyle.FDIAMOND, new Image("/res/dotStyles/dot.diamondF.png"));
    // NON-NLS
    cache.put(DotStyle.O, new Image("/res/dotStyles/dot.o.png"));
    // NON-NLS
    cache.put(DotStyle.OPLUS, new Image("/res/dotStyles/dot.oplus.png"));
    // NON-NLS
    cache.put(DotStyle.OTIMES, new Image("/res/dotStyles/dot.ocross.png"));
    // NON-NLS
    cache.put(DotStyle.PLUS, new Image("/res/dotStyles/dot.plus.png"));
    // NON-NLS
    cache.put(DotStyle.X, new Image("/res/dotStyles/dot.cross.png"));
    // NON-NLS
    cache.put(DotStyle.TRIANGLE, new Image("/res/dotStyles/dot.triangle.png"));
    // NON-NLS
    cache.put(DotStyle.FTRIANGLE, new Image("/res/dotStyles/dot.triangleF.png"));
    // NON-NLS
    cache.put(DotStyle.PENTAGON, new Image("/res/dotStyles/dot.pentagon.png"));
    // NON-NLS
    cache.put(DotStyle.FPENTAGON, new Image("/res/dotStyles/dot.pentagonF.png"));
    // NON-NLS
    cache.put(DotStyle.SQUARE, new Image("/res/dotStyles/dot.square.png"));
    // NON-NLS
    cache.put(DotStyle.FSQUARE, new Image("/res/dotStyles/dot.squareF.png"));
    initComboBox(dotCB, cache, DotStyle.values());
}
Also used : DotStyle(net.sf.latexdraw.model.api.shape.DotStyle) Image(javafx.scene.image.Image) EnumMap(java.util.EnumMap)

Example 2 with DotStyle

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

the class PSTDotView method getCode.

@Override
@NotNull
public String getCode(@NotNull final Point origin, final float ppc) {
    final double x = shape.getX() - origin.getX();
    final double y = origin.getY() - shape.getY();
    final DotStyle style = shape.getDotStyle();
    final StringBuilder params = getPropertiesCode(ppc);
    final StringBuilder rotation = getRotationHeaderCode(ppc, origin);
    final StringBuilder code = new StringBuilder();
    if (style != DotStyle.DOT) {
        // NON-NLS
        params.append(", dotstyle=").append(style.getPSTToken());
    }
    // NON-NLS
    params.append(", dotsize=").append((float) MathUtils.INST.getCutNumber(shape.getDiametre() / ppc));
    if (rotation != null) {
        code.append(rotation);
    }
    // NON-NLS
    code.append("\\psdots[");
    code.append(params);
    if (shape.isFillable()) {
        // NON-NLS
        code.append(", fillcolor=").append(getColourName(shape.getFillingCol()));
    }
    code.append(']').append('(');
    code.append(MathUtils.INST.getCutNumberFloat(x / ppc)).append(',');
    code.append(MathUtils.INST.getCutNumberFloat(y / ppc)).append(')');
    if (rotation != null) {
        code.append('}');
    }
    return code.toString();
}
Also used : DotStyle(net.sf.latexdraw.model.api.shape.DotStyle) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DotStyle

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

the class TestHandDotStyle method testSelectDotStyleSelection.

@Test
public void testSelectDotStyleSelection() {
    Cmds.of(activateHand, selectionAddDot, selectionAddRec, selectionAddDot, updateIns).execute();
    final DotStyle style = dotCB.getSelectionModel().getSelectedItem();
    Cmds.of(selectNextDotStyle).execute();
    final DotStyle newStyle = dotCB.getSelectionModel().getSelectedItem();
    assertEquals(newStyle, ((Dot) drawing.getSelection().getShapeAt(0).orElseThrow()).getDotStyle());
    assertEquals(newStyle, ((Dot) drawing.getSelection().getShapeAt(2).orElseThrow()).getDotStyle());
    assertNotEquals(style, newStyle);
}
Also used : DotStyle(net.sf.latexdraw.model.api.shape.DotStyle) Test(org.junit.Test)

Aggregations

DotStyle (net.sf.latexdraw.model.api.shape.DotStyle)3 EnumMap (java.util.EnumMap)1 Image (javafx.scene.image.Image)1 NotNull (org.jetbrains.annotations.NotNull)1 Test (org.junit.Test)1