use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.
the class SVGAxes method createArrows.
private void createArrows(final SVGElement elt, final SVGDocument document) {
if (shape.getAxesStyle().supportsArrows() && shape.getNbArrows() == 4) {
final double posX = shape.getPosition().getX();
final double posY = shape.getPosition().getY();
final IArrow arr0 = shape.getArrowAt(1);
final IArrow arr1 = shape.getArrowAt(3);
final double arr0Reduction = arr0.getArrowStyle().needsLineReduction() ? arr0.getArrowShapedWidth() : 0.;
final double arr1Reduction = arr1.getArrowStyle().needsLineReduction() ? arr1.getArrowShapedWidth() : 0.;
final IPolyline xLine = ShapeFactory.INST.createPolyline(Arrays.asList(ShapeFactory.INST.createPoint(posX + shape.getGridStartX() * IShape.PPC + arr0Reduction, posY), ShapeFactory.INST.createPoint(posX + shape.getGridEndX() * IShape.PPC - arr1Reduction, posY)));
final IPolyline yLine = ShapeFactory.INST.createPolyline(Arrays.asList(ShapeFactory.INST.createPoint(posX, posY - shape.getGridStartY() * IShape.PPC - arr0Reduction), ShapeFactory.INST.createPoint(posX, posY - shape.getGridEndY() * IShape.PPC + arr1Reduction)));
xLine.getArrowAt(0).copy(arr0);
xLine.getArrowAt(1).copy(arr1);
yLine.getArrowAt(0).copy(shape.getArrowAt(0));
yLine.getArrowAt(1).copy(shape.getArrowAt(2));
final SVGElement eltX = new SVGPolylines(xLine).toSVG(document);
final SVGElement eltY = new SVGPolylines(yLine).toSVG(document);
final String transform = "translate(" + MathUtils.INST.format.format(-shape.getPosition().getX()) + ',' + MathUtils.INST.format.format(-shape.getPosition().getY()) + ')';
eltX.setAttribute(SVGAttributes.SVG_TRANSFORM, transform);
eltY.setAttribute(SVGAttributes.SVG_TRANSFORM, transform);
elt.appendChild(eltX);
elt.appendChild(eltY);
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.
the class TestCanvasCreation method testDrawPolylines.
@Test
public void testDrawPolylines() {
pencil.setCurrentChoice(EditionChoice.LINES);
final Point2D pos = point(canvas).query();
moveTo(pos).clickOn(MouseButton.PRIMARY).moveBy(-20d, -100d).clickOn(MouseButton.PRIMARY).moveBy(-100d, 50d).clickOn(MouseButton.SECONDARY).sleep(SLEEP);
assertEquals(1, drawing.size());
assertTrue(drawing.getShapeAt(0) instanceof IPolyline);
final IPolyline sh = (IPolyline) drawing.getShapeAt(0);
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), sh.getPtAt(0).getX(), 1d);
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY(), sh.getPtAt(0).getY(), 1d);
assertEquals(3, sh.getNbPoints());
}
use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.
the class LShapeFactory method createPolylineFrom.
@Override
public IPolyline createPolylineFrom(final IPolyline sh, final IPoint pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd))
return null;
final List<IPoint> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final IPolyline copy = createPolyline(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.
the class PSTLatexdrawListener method createLine.
/**
* Creates and initialises a polyline shape.
*/
private IPolyline createLine(final boolean hasStar, final List<IPoint> points, final PSTContext ctx, final boolean qObject) {
final IPolyline line = ShapeFactory.INST.createPolyline(points);
setShapeParameters(line, ctx);
setArrows(line, ctx);
if (qObject) {
line.setHasShadow(false);
line.setHasDbleBord(false);
line.setFillingStyle(FillingStyle.NONE);
line.setArrowStyle(ArrowStyle.NONE, 0);
line.setArrowStyle(ArrowStyle.NONE, -1);
}
if (hasStar) {
setShapeForStar(line);
}
return line;
}
use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.
the class PlotViewHelper method updateLine.
public IPolyline updateLine(final IPlot shape, final double posX, final double posY, final double minX, final double maxX, final double step) {
final IPolyline pl = ShapeFactory.INST.createPolyline(fillPoints(shape, posX, posY, minX, maxX, step));
pl.copy(shape);
return pl;
}
Aggregations