Search in sources :

Example 1 with Color

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

the class SVGBezierCurve method produceShowPointsLines.

private void produceShowPointsLines(@NotNull final SVGDocument doc, @NotNull final SVGGElement showPts, final double thick) {
    final double blackDash = shape.getDashSepBlack();
    final double whiteDash = shape.getDashSepWhite();
    final Color col = shape.getLineColour();
    final boolean isClosed = !shape.isOpened();
    final int size = shape.getNbPoints();
    final double doubleSep = shape.getDbleBordSep();
    final boolean hasDble = shape.hasDbleBord();
    for (int i = 3; i < size; i += 2) {
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getPtAt(i - 1), shape.getSecondCtrlPtAt(i - 1), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getSecondCtrlPtAt(i - 1), shape.getFirstCtrlPtAt(i), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getFirstCtrlPtAt(i), shape.getPtAt(i), blackDash, whiteDash, hasDble, 1., doubleSep));
    }
    for (int i = 2; i < size; i += 2) {
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getPtAt(i - 1), shape.getSecondCtrlPtAt(i - 1), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getSecondCtrlPtAt(i - 1), shape.getFirstCtrlPtAt(i), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getFirstCtrlPtAt(i), shape.getPtAt(i), blackDash, whiteDash, hasDble, 1., doubleSep));
    }
    if (isClosed) {
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getPtAt(-1), shape.getSecondCtrlPtAt(-1), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getSecondCtrlPtAt(-1), shape.getSecondCtrlPtAt(0), blackDash, whiteDash, hasDble, 1., doubleSep));
        showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getSecondCtrlPtAt(0), shape.getPtAt(0), blackDash, whiteDash, hasDble, 1., doubleSep));
    }
    showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getPtAt(0), shape.getFirstCtrlPtAt(0), blackDash, whiteDash, hasDble, 1., doubleSep));
    showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getFirstCtrlPtAt(0), shape.getFirstCtrlPtAt(1), blackDash, whiteDash, hasDble, 1., doubleSep));
    showPts.appendChild(getShowPointsLine(doc, thick, col, shape.getFirstCtrlPtAt(1), shape.getPtAt(1), blackDash, whiteDash, hasDble, 1., doubleSep));
}
Also used : Color(net.sf.latexdraw.model.api.shape.Color) Point(net.sf.latexdraw.model.api.shape.Point)

Example 2 with Color

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

the class SVGBezierCurve method produceShowPointsDots.

/**
 * Companion method of getShowPointsElement
 */
private void produceShowPointsDots(@NotNull final SVGDocument doc, @NotNull final SVGGElement showPts, final double thick) {
    final Arrow arrow1 = shape.getArrowAt(0);
    final Arrow arrow2 = shape.getArrowAt(-1);
    final double rad = (PSTricksConstants.DEFAULT_ARROW_DOTSIZE_DIM * Shape.PPC + PSTricksConstants.DEFAULT_ARROW_DOTSIZE_NUM * thick * 2d) / 2d;
    final int size = shape.getNbPoints();
    final Color col = shape.getLineColour();
    final boolean isClosed = !shape.isOpened();
    if (!arrow1.hasStyle() || isClosed) {
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getPtAt(0), col));
    }
    if (!arrow2.hasStyle() || isClosed) {
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getPtAt(-1), col));
    }
    for (int i = 1; i < size - 1; i++) {
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getPtAt(i), col));
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getSecondCtrlPtAt(i), col));
    }
    for (int i = 0; i < size; i++) {
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getFirstCtrlPtAt(i), col));
    }
    if (isClosed) {
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getSecondCtrlPtAt(-1), col));
        showPts.appendChild(SVGShape.getShowPointsDot(doc, rad, shape.getSecondCtrlPtAt(0), col));
    }
}
Also used : Arrow(net.sf.latexdraw.model.api.shape.Arrow) Color(net.sf.latexdraw.model.api.shape.Color) Point(net.sf.latexdraw.model.api.shape.Point)

Example 3 with Color

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

the class TestDviPsColors method testGetColorNameOK.

@Test
void testGetColorNameOK() {
    final Color c2 = ShapeFactory.INST.createColor(218d / 255d, 29d / 255d, 78d / 255d, 1d);
    final Optional<String> nameColour = DviPsColors.INSTANCE.addUserColour(c2);
    assertEquals(nameColour.orElseThrow(), DviPsColors.INSTANCE.getColourName(c2).orElseThrow());
}
Also used : Color(net.sf.latexdraw.model.api.shape.Color) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with Color

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

the class TestDviPsColors method testAddUserColor.

@Test
void testAddUserColor() {
    final Color c2 = ShapeFactory.INST.createColor(18d / 255d, 29d / 255d, 78d / 255d, 1d);
    final Optional<String> nameColour = DviPsColors.INSTANCE.addUserColour(c2);
    assertEquals(nameColour.orElseThrow(), DviPsColors.INSTANCE.getColourName(c2).orElseThrow());
}
Also used : Color(net.sf.latexdraw.model.api.shape.Color) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with Color

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

the class PSTTextView method getCode.

@Override
@NotNull
public String getCode(@NotNull final Point origin, final float ppc) {
    final StringBuilder rot = getRotationHeaderCode(ppc, origin);
    final StringBuilder code = new StringBuilder();
    if (rot != null) {
        code.append(rot);
    }
    final String colorName;
    final Color lineCol = shape.getLineColour();
    if (PSTricksConstants.DEFAULT_LINE_COLOR.equals(lineCol)) {
        colorName = null;
    } else {
        colorName = getColourName(shape.getLineColour());
        addColour(colorName);
    }
    final String tokenPosition = shape.getTextPosition().getLatexToken();
    if (tokenPosition.isEmpty()) {
        // NON-NLS
        code.append("\\rput(");
    } else {
        // NON-NLS
        code.append("\\rput[").append(shape.getTextPosition().getLatexToken()).append(']').append('(');
    }
    code.append(MathUtils.INST.getCutNumberFloat((shape.getX() - origin.getX()) / ppc)).append(',');
    code.append(MathUtils.INST.getCutNumberFloat((origin.getY() - shape.getY()) / ppc)).append(')').append('{');
    if (colorName != null) {
        // NON-NLS
        code.append("\\textcolor{").append(colorName).append('}').append('{');
    }
    code.append(shape.getText()).append('}');
    if (colorName != null) {
        code.append('}');
    }
    if (rot != null) {
        code.append('}');
    }
    return code.toString();
}
Also used : Color(net.sf.latexdraw.model.api.shape.Color) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Color (net.sf.latexdraw.model.api.shape.Color)10 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Point (net.sf.latexdraw.model.api.shape.Point)3 NotNull (org.jetbrains.annotations.NotNull)2 Font (javafx.scene.text.Font)1 Text (javafx.scene.text.Text)1 Arrow (net.sf.latexdraw.model.api.shape.Arrow)1 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)1 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)1