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));
}
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));
}
}
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());
}
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());
}
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();
}
Aggregations