Search in sources :

Example 36 with ArrowStyle

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

the class PSTShapeView method getArrowsStyleCode.

/**
 * @return The PST code corresponding to the style of the arrows (e.g. {|->}).
 * @since 3.0
 */
protected StringBuilder getArrowsStyleCode() {
    final StringBuilder code;
    if (shape instanceof IArrowableSingleShape) {
        final IArrowableSingleShape arr = (IArrowableSingleShape) shape;
        final ArrowStyle style1 = arr.getArrowStyle(0);
        final ArrowStyle style2 = arr.getArrowStyle(-1);
        if (style1 == ArrowStyle.NONE && style2 == ArrowStyle.NONE)
            code = null;
        else
            code = new StringBuilder().append('{').append(style1.getPSTToken()).append('-').append(style2.getPSTToken()).append('}');
    } else
        code = null;
    return code;
}
Also used : IArrowableSingleShape(net.sf.latexdraw.models.interfaces.shape.IArrowableSingleShape) ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle)

Example 37 with ArrowStyle

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

the class TestHandArrowStyle method testSelectRightArrowStyleHand.

@Test
public void testSelectRightArrowStyleHand() {
    new CompositeGUIVoidCommand(selectionAddBezier, selectionAddBezier, activateHand, updateIns).execute();
    ArrowStyle style = arrowRightCB.getSelectionModel().getSelectedItem();
    selectArrowRightCB.execute(ArrowStyle.ROUND_IN);
    ArrowStyle newStyle = arrowRightCB.getSelectionModel().getSelectedItem();
    assertEquals(ArrowStyle.ROUND_IN, newStyle);
    assertEquals(newStyle, ((IArrowableSingleShape) drawing.getSelection().getShapeAt(0)).getArrowAt(-1).getArrowStyle());
    assertEquals(newStyle, ((IArrowableSingleShape) drawing.getSelection().getShapeAt(1)).getArrowAt(-1).getArrowStyle());
    assertNotEquals(style, newStyle);
}
Also used : CompositeGUIVoidCommand(net.sf.latexdraw.instruments.CompositeGUIVoidCommand) IArrowableSingleShape(net.sf.latexdraw.models.interfaces.shape.IArrowableSingleShape) ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle) Test(org.junit.Test)

Example 38 with ArrowStyle

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

the class TestHandArrowStyle method testSelectLeftArrowStyleHand.

@Test
public void testSelectLeftArrowStyleHand() {
    new CompositeGUIVoidCommand(selectionAddBezier, selectionAddBezier, activateHand, updateIns).execute();
    ArrowStyle style = arrowLeftCB.getSelectionModel().getSelectedItem();
    selectArrowLeftCB.execute(ArrowStyle.BAR_IN);
    ArrowStyle newStyle = arrowLeftCB.getSelectionModel().getSelectedItem();
    assertEquals(ArrowStyle.BAR_IN, newStyle);
    assertEquals(newStyle, ((IArrowableSingleShape) drawing.getSelection().getShapeAt(0)).getArrowAt(0).getArrowStyle());
    assertEquals(newStyle, ((IArrowableSingleShape) drawing.getSelection().getShapeAt(1)).getArrowAt(0).getArrowStyle());
    assertNotEquals(style, newStyle);
}
Also used : CompositeGUIVoidCommand(net.sf.latexdraw.instruments.CompositeGUIVoidCommand) IArrowableSingleShape(net.sf.latexdraw.models.interfaces.shape.IArrowableSingleShape) ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle) Test(org.junit.Test)

Example 39 with ArrowStyle

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

the class ShapeArrowCustomiser method update.

@Override
protected void update(final IGroup shape) {
    if (shape.isTypeOf(IArrowable.class)) {
        setActivated(true);
        final IArrow arr1 = shape.getArrowAt(0);
        final IArrow arr2 = shape.getArrowAt(-1);
        final ArrowStyle arrStyle1 = arr1.getArrowStyle();
        final ArrowStyle arrStyle2 = arr2.getArrowStyle();
        arrowLeftCB.setValue(arrStyle1);
        arrowRightCB.setValue(arrStyle2);
        final boolean isArrow = arrStyle1.isArrow() || arrStyle2.isArrow();
        final boolean isDot = arrStyle1.isCircleDisk() || arrStyle2.isCircleDisk();
        final boolean isBar = arrStyle1.isBar() || arrStyle2.isBar();
        final boolean isSBracket = arrStyle1.isSquareBracket() || arrStyle2.isSquareBracket();
        final boolean isRBracket = arrStyle1.isRoundBracket() || arrStyle2.isRoundBracket();
        // Updating the visibility of the widgets.
        arrowPane.setVisible(isArrow);
        dotPane.setVisible(isDot);
        barPane.setVisible(isBar || isSBracket || isRBracket);
        bracketPane.setVisible(isSBracket);
        rbracketPane.setVisible(isRBracket);
        // Updating the value of the widgets.
        if (isArrow) {
            arrowInset.getValueFactory().setValue(arr1.getArrowInset());
            arrowLength.getValueFactory().setValue(arr1.getArrowLength());
            arrowSizeDim.getValueFactory().setValue(arr1.getArrowSizeDim());
            arrowSizeNum.getValueFactory().setValue(arr1.getArrowSizeNum());
        }
        if (isDot) {
            dotSizeNum.getValueFactory().setValue(arr1.getDotSizeNum());
            dotSizeDim.getValueFactory().setValue(arr1.getDotSizeDim());
        }
        if (isBar || isSBracket || isRBracket) {
            tbarsizeDim.getValueFactory().setValue(arr1.getTBarSizeDim());
            tbarsizeNum.getValueFactory().setValue(arr1.getTBarSizeNum());
        }
        if (isSBracket) {
            bracketNum.getValueFactory().setValue(arr1.getBracketNum());
        }
        if (isRBracket) {
            rbracketNum.getValueFactory().setValue(arr1.getRBracketNum());
        }
    } else {
        setActivated(false);
    }
}
Also used : ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle) IArrow(net.sf.latexdraw.models.interfaces.shape.IArrow)

Example 40 with ArrowStyle

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

the class ShapeArrowCustomiser method initialize.

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    mainPane.managedProperty().bind(mainPane.visibleProperty());
    dotPane.managedProperty().bind(dotPane.visibleProperty());
    arrowPane.managedProperty().bind(arrowPane.visibleProperty());
    barPane.managedProperty().bind(barPane.visibleProperty());
    bracketPane.managedProperty().bind(bracketPane.visibleProperty());
    rbracketPane.managedProperty().bind(rbracketPane.visibleProperty());
    final Map<ArrowStyle, Image> cacheLeft = new EnumMap<>(ArrowStyle.class);
    // NON-NLS
    cacheLeft.put(ArrowStyle.NONE, new Image("/res/arrowStyles/line.none.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.BAR_END, new Image("/res/arrowStyles/line.barEnd.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.BAR_IN, new Image("/res/arrowStyles/line.barIn.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.CIRCLE_END, new Image("/res/arrowStyles/line.circle.end.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.CIRCLE_IN, new Image("/res/arrowStyles/line.circle.in.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.DISK_END, new Image("/res/arrowStyles/line.disk.end.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.DISK_IN, new Image("/res/arrowStyles/line.disk.in.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.LEFT_ARROW, new Image("/res/arrowStyles/line.arrow.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.RIGHT_ARROW, new Image("/res/arrowStyles/line.rarrow.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.LEFT_ROUND_BRACKET, new Image("/res/arrowStyles/line.arc.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.RIGHT_ROUND_BRACKET, new Image("/res/arrowStyles/line.arc.r.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.LEFT_SQUARE_BRACKET, new Image("/res/arrowStyles/line.bracket.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.RIGHT_SQUARE_BRACKET, new Image("/res/arrowStyles/line.bracket.r.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.LEFT_DBLE_ARROW, new Image("/res/arrowStyles/line.dbleArrow.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.RIGHT_DBLE_ARROW, new Image("/res/arrowStyles/line.rdbleArrow.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.ROUND_IN, new Image("/res/arrowStyles/line.roundIn.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.ROUND_END, new Image("/res/arrowStyles/line.roundEnd.left.png"));
    // NON-NLS
    cacheLeft.put(ArrowStyle.SQUARE_END, new Image("/res/arrowStyles/lineEnd.left.png"));
    initComboBox(arrowLeftCB, cacheLeft, ArrowStyle.values());
    final Map<ArrowStyle, Image> cacheRight = new EnumMap<>(ArrowStyle.class);
    // NON-NLS
    cacheRight.put(ArrowStyle.NONE, new Image("/res/arrowStyles/line.none.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.BAR_END, new Image("/res/arrowStyles/line.barEnd.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.BAR_IN, new Image("/res/arrowStyles/line.barIn.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.CIRCLE_END, new Image("/res/arrowStyles/line.circle.end.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.CIRCLE_IN, new Image("/res/arrowStyles/line.circle.in.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.DISK_END, new Image("/res/arrowStyles/line.disk.end.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.DISK_IN, new Image("/res/arrowStyles/line.disk.in.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.RIGHT_ARROW, new Image("/res/arrowStyles/line.arrow.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.LEFT_ARROW, new Image("/res/arrowStyles/line.rarrow.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.RIGHT_ROUND_BRACKET, new Image("/res/arrowStyles/line.arc.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.LEFT_ROUND_BRACKET, new Image("/res/arrowStyles/line.arc.r.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.RIGHT_SQUARE_BRACKET, new Image("/res/arrowStyles/line.bracket.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.LEFT_SQUARE_BRACKET, new Image("/res/arrowStyles/line.bracket.r.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.RIGHT_DBLE_ARROW, new Image("/res/arrowStyles/line.dbleArrow.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.LEFT_DBLE_ARROW, new Image("/res/arrowStyles/line.rdbleArrow.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.ROUND_IN, new Image("/res/arrowStyles/line.roundIn.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.ROUND_END, new Image("/res/arrowStyles/line.roundEnd.right.png"));
    // NON-NLS
    cacheRight.put(ArrowStyle.SQUARE_END, new Image("/res/arrowStyles/lineEnd.right.png"));
    initComboBox(arrowRightCB, cacheRight, ArrowStyle.values());
}
Also used : ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle) Image(javafx.scene.image.Image) EnumMap(java.util.EnumMap)

Aggregations

ArrowStyle (net.sf.latexdraw.models.interfaces.shape.ArrowStyle)40 IArrowableSingleShape (net.sf.latexdraw.models.interfaces.shape.IArrowableSingleShape)36 CompositeGUIVoidCommand (net.sf.latexdraw.instruments.CompositeGUIVoidCommand)34 Test (org.junit.Test)34 EnumMap (java.util.EnumMap)1 Image (javafx.scene.image.Image)1 IArrow (net.sf.latexdraw.models.interfaces.shape.IArrow)1