Search in sources :

Example 1 with Color

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

the class TestDviPsColors method testAddUserColor.

@SuppressWarnings("all")
@Test
public void testAddUserColor() {
    Color c2 = ShapeFactory.INST.createColor(18d / 255d, 29d / 255d, 78d / 255d, 1d);
    Optional<String> nameColour = DviPsColors.INSTANCE.addUserColour(c2);
    assertEquals(nameColour.get(), DviPsColors.INSTANCE.getColourName(c2).get());
}
Also used : Color(net.sf.latexdraw.models.interfaces.shape.Color) Test(org.junit.Test)

Example 2 with Color

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

the class PSTShapeView method getFillingGrad.

/**
 * @return The PST code of the filling with parameter "gradient".
 * @since 3.0
 */
private StringBuilder getFillingGrad() {
    final Color gradStartCol = shape.getGradColStart();
    final Color gradEndCol = shape.getGradColEnd();
    final float gradMidPt = MathUtils.INST.getCutNumberFloat(shape.getGradMidPt());
    final float gradAngle = MathUtils.INST.getCutNumberFloat(shape.getGradAngle());
    // $NON-NLS-1$
    final StringBuilder code = new StringBuilder("fillstyle=gradient, gradlines=2000");
    if (!gradStartCol.equals(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR))
        // $NON-NLS-1$
        code.append(", gradbegin=").append(getColourName(gradStartCol));
    if (!gradEndCol.equals(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR))
        // $NON-NLS-1$
        code.append(", gradend=").append(getColourName(gradEndCol));
    if (!MathUtils.INST.equalsDouble(gradMidPt, PSTricksConstants.DEFAULT_GRADIENT_MID_POINT))
        // $NON-NLS-1$
        code.append(", gradmidpoint=").append(gradMidPt);
    if (!MathUtils.INST.equalsDouble(toDegrees(gradAngle), PSTricksConstants.DEFAULT_GRADIENT_ANGLE))
        // $NON-NLS-1$
        code.append(", gradangle=").append(MathUtils.INST.getCutNumberFloat(toDegrees(gradAngle)));
    return code;
}
Also used : Color(net.sf.latexdraw.models.interfaces.shape.Color)

Example 3 with Color

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

the class PSTShapeView method getFillingHatchings.

/**
 * @return The PST code of the filling with parameter "hlines" or "vlines" etc.
 * @since 3.0
 */
private StringBuilder getFillingHatchings(final float ppc) {
    final Color hatchingsCol = shape.getHatchingsCol();
    final StringBuilder code = new StringBuilder();
    switch(shape.getFillingStyle()) {
        case CLINES:
        case CLINES_PLAIN:
            // $NON-NLS-1$
            code.append("fillstyle=crosshatch");
            break;
        case HLINES:
        case HLINES_PLAIN:
            // $NON-NLS-1$
            code.append("fillstyle=hlines");
            break;
        default:
            // $NON-NLS-1$
            code.append("fillstyle=vlines");
            break;
    }
    if (shape.isFilled())
        code.append('*');
    // $NON-NLS-1$
    code.append(", hatchwidth=");
    code.append(MathUtils.INST.getCutNumberFloat(shape.getHatchingsWidth() / ppc));
    // $NON-NLS-1$
    code.append(", hatchangle=").append(MathUtils.INST.getCutNumberFloat(Math.toDegrees(shape.getHatchingsAngle())));
    // $NON-NLS-1$
    code.append(", hatchsep=");
    code.append(MathUtils.INST.getCutNumberFloat(shape.getHatchingsSep() / ppc));
    if (!hatchingsCol.equals(PSTricksConstants.DEFAULT_HATCHING_COLOR))
        // $NON-NLS-1$
        code.append(", hatchcolor=").append(getColourName(hatchingsCol));
    return code;
}
Also used : Color(net.sf.latexdraw.models.interfaces.shape.Color)

Example 4 with Color

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

the class PSTShapeView method getLineCode.

/**
 * @param ppc The number of pixels per centimetre.
 * @return The PSTricks code of the line style.
 * @since 1.7
 */
protected StringBuilder getLineCode(final float ppc) {
    final StringBuilder code = new StringBuilder();
    final Color linesColor = shape.getLineColour();
    // $NON-NLS-1$
    code.append("linecolor=").append(getColourName(linesColor));
    // $NON-NLS-1$
    if (shape.isThicknessable())
        code.append(", linewidth=").append(MathUtils.INST.getCutNumberFloat(shape.getThickness() / ppc));
    // $NON-NLS-1$
    if (linesColor.getO() < 1.0)
        code.append(", strokeopacity=").append(MathUtils.INST.getCutNumberFloat(linesColor.getO()));
    switch(shape.getLineStyle()) {
        case DOTTED:
            // $NON-NLS-1$
            code.append(", linestyle=");
            code.append(PSTricksConstants.LINE_DOTTED_STYLE);
            // $NON-NLS-1$
            code.append(", dotsep=");
            code.append(MathUtils.INST.getCutNumberFloat(shape.getDotSep() / ppc));
            code.append(PSTricksConstants.TOKEN_CM);
            break;
        case DASHED:
            // $NON-NLS-1$
            code.append(", linestyle=");
            code.append(PSTricksConstants.LINE_DASHED_STYLE);
            // $NON-NLS-1$
            code.append(", dash=");
            code.append(MathUtils.INST.getCutNumberFloat(shape.getDashSepBlack() / ppc));
            code.append(PSTricksConstants.TOKEN_CM).append(' ');
            code.append(MathUtils.INST.getCutNumberFloat(shape.getDashSepWhite() / ppc));
            code.append(PSTricksConstants.TOKEN_CM);
            break;
        case SOLID:
    }
    return code;
}
Also used : Color(net.sf.latexdraw.models.interfaces.shape.Color)

Example 5 with Color

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

the class PSTShapeView method getFillingPlain.

/**
 * @return The PST code of the filling with parameter "plain".
 * @since 3.0
 */
private StringBuilder getFillingPlain() {
    final Color interiorColor = shape.getFillingCol();
    // $NON-NLS-1$
    final StringBuilder code = new StringBuilder("fillstyle=solid");
    if (!interiorColor.equals(PSTricksConstants.DEFAULT_INTERIOR_COLOR))
        // $NON-NLS-1$
        code.append(",fillcolor=").append(getColourName(interiorColor));
    // $NON-NLS-1$
    if (interiorColor.getO() < 1.0)
        code.append(", opacity=").append(MathUtils.INST.getCutNumberFloat(interiorColor.getO()));
    return code;
}
Also used : Color(net.sf.latexdraw.models.interfaces.shape.Color)

Aggregations

Color (net.sf.latexdraw.models.interfaces.shape.Color)21 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)4 Test (org.junit.Test)3 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)2 Font (javafx.scene.text.Font)1 Text (javafx.scene.text.Text)1 IArrow (net.sf.latexdraw.models.interfaces.shape.IArrow)1 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)1 SVGTextElement (net.sf.latexdraw.parsers.svg.SVGTextElement)1 SVGTransform (net.sf.latexdraw.parsers.svg.SVGTransform)1 SVGTransformList (net.sf.latexdraw.parsers.svg.SVGTransformList)1