Search in sources :

Example 1 with ArrowStyle

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

the class PSTShapeView method getArrowParametersCode.

/**
 * @return The PST code corresponding to the parameter of the style of the given arrow. The style of the
 * given arrow must not be NONE.
 */
private StringBuilder getArrowParametersCode(final IArrow arrow) {
    final StringBuilder code = new StringBuilder();
    final ArrowStyle style = arrow.getArrowStyle();
    if (style.isBar() || style.isRoundBracket() || style.isSquareBracket()) {
        // $NON-NLS-1$
        code.append("tbarsize=").append(MathUtils.INST.getCutNumberFloat(arrow.getTBarSizeDim() / IShape.PPC)).append(PSTricksConstants.TOKEN_CM).append(' ').append(MathUtils.INST.getCutNumberFloat(arrow.getTBarSizeNum()));
        if (style.isSquareBracket())
            // $NON-NLS-1$
            code.append(",bracketlength=").append(MathUtils.INST.getCutNumberFloat(arrow.getBracketNum()));
        else if (style.isRoundBracket())
            // $NON-NLS-1$
            code.append(",rbracketlength=").append(MathUtils.INST.getCutNumberFloat(arrow.getRBracketNum()));
    } else if (style.isArrow())
        // $NON-NLS-1$
        code.append("arrowsize=").append(MathUtils.INST.getCutNumberFloat(arrow.getArrowSizeDim() / IShape.PPC)).append(PSTricksConstants.TOKEN_CM).append(' ').append(MathUtils.INST.getCutNumberFloat(arrow.getArrowSizeNum())).append(// $NON-NLS-1$
        ",arrowlength=").append(MathUtils.INST.getCutNumberFloat(arrow.getArrowLength())).append(",arrowinset=").append(// $NON-NLS-1$
        MathUtils.INST.getCutNumberFloat(arrow.getArrowInset()));
    else
        // $NON-NLS-1$
        code.append("dotsize=").append(MathUtils.INST.getCutNumberFloat(arrow.getDotSizeDim() / IShape.PPC)).append(PSTricksConstants.TOKEN_CM).append(' ').append(MathUtils.INST.getCutNumberFloat(arrow.getDotSizeNum()));
    return code;
}
Also used : ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle)

Example 2 with ArrowStyle

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

the class SVGShape method homogeniseArrowFrom.

/**
 * Copies the parameters of the first arrow to the second arrow (only
 * the parameters of the current style are copied).
 * @param source The arrow that will be copied.
 * @param target The arrow that will be set.
 */
protected void homogeniseArrowFrom(final IArrow source, final IArrow target) {
    if (source == null || target == null)
        return;
    final ArrowStyle style = source.getArrowStyle();
    if (style != null && style != ArrowStyle.NONE) {
        if (style.isBar()) {
            target.setTBarSizeDim(source.getTBarSizeDim());
            target.setTBarSizeNum(source.getTBarSizeNum());
            return;
        }
        if (style.isArrow()) {
            target.setArrowInset(source.getArrowInset());
            target.setArrowLength(source.getArrowLength());
            target.setArrowSizeDim(source.getArrowSizeDim());
            target.setArrowSizeNum(source.getArrowSizeNum());
            return;
        }
        if (style.isRoundBracket()) {
            target.setRBracketNum(source.getRBracketNum());
            target.setTBarSizeDim(source.getTBarSizeDim());
            target.setTBarSizeNum(source.getTBarSizeNum());
            return;
        }
        if (style.isSquareBracket()) {
            target.setBracketNum(source.getBracketNum());
            target.setTBarSizeDim(source.getTBarSizeDim());
            target.setTBarSizeNum(source.getTBarSizeNum());
            return;
        }
        target.setDotSizeDim(source.getDotSizeDim());
        target.setDotSizeNum(source.getDotSizeNum());
    }
}
Also used : ArrowStyle(net.sf.latexdraw.models.interfaces.shape.ArrowStyle)

Example 3 with ArrowStyle

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

the class TestPencilArrowStyle method testSelectRightArrowStyleLEFTROUNDBRACKETPencil.

@Test
public void testSelectRightArrowStyleLEFTROUNDBRACKETPencil() {
    new CompositeGUIVoidCommand(activatePencil, pencilCreatesBezier, updateIns).execute();
    ArrowStyle style = arrowRightCB.getSelectionModel().getSelectedItem();
    selectArrowRightCB.execute(ArrowStyle.LEFT_ROUND_BRACKET);
    ArrowStyle newStyle = arrowRightCB.getSelectionModel().getSelectedItem();
    assertEquals(ArrowStyle.LEFT_ROUND_BRACKET, newStyle);
    assertEquals(newStyle, ((IArrowableSingleShape) pencil.createShapeInstance()).getArrowAt(-1).getArrowStyle());
    assertNotEquals(style, newStyle);
    assertFalse(arrowPane.isVisible());
    assertFalse(dotPane.isVisible());
    assertTrue(barPane.isVisible());
    assertFalse(bracketPane.isVisible());
    assertTrue(rbracketPane.isVisible());
}
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 4 with ArrowStyle

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

the class TestPencilArrowStyle method testSelectLeftArrowStyleRIGHTDBLEARROWPencil.

@Test
public void testSelectLeftArrowStyleRIGHTDBLEARROWPencil() {
    new CompositeGUIVoidCommand(activatePencil, pencilCreatesBezier, updateIns).execute();
    ArrowStyle style = arrowLeftCB.getSelectionModel().getSelectedItem();
    selectArrowLeftCB.execute(ArrowStyle.RIGHT_DBLE_ARROW);
    ArrowStyle newStyle = arrowLeftCB.getSelectionModel().getSelectedItem();
    assertEquals(ArrowStyle.RIGHT_DBLE_ARROW, newStyle);
    assertEquals(newStyle, ((IArrowableSingleShape) pencil.createShapeInstance()).getArrowAt(0).getArrowStyle());
    assertNotEquals(style, newStyle);
    assertTrue(arrowPane.isVisible());
    assertFalse(dotPane.isVisible());
    assertFalse(barPane.isVisible());
    assertFalse(bracketPane.isVisible());
    assertFalse(rbracketPane.isVisible());
}
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 5 with ArrowStyle

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

the class TestPencilArrowStyle method testSelectRightArrowStyleBARINPencil.

@Test
public void testSelectRightArrowStyleBARINPencil() {
    new CompositeGUIVoidCommand(activatePencil, pencilCreatesBezier, updateIns).execute();
    ArrowStyle style = arrowRightCB.getSelectionModel().getSelectedItem();
    selectArrowRightCB.execute(ArrowStyle.BAR_IN);
    ArrowStyle newStyle = arrowRightCB.getSelectionModel().getSelectedItem();
    assertEquals(ArrowStyle.BAR_IN, newStyle);
    assertEquals(newStyle, ((IArrowableSingleShape) pencil.createShapeInstance()).getArrowAt(-1).getArrowStyle());
    assertNotEquals(style, newStyle);
    assertFalse(arrowPane.isVisible());
    assertFalse(dotPane.isVisible());
    assertTrue(barPane.isVisible());
    assertFalse(bracketPane.isVisible());
    assertFalse(rbracketPane.isVisible());
}
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)

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