use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class LCircleArc method getArrowLine.
@Override
public ILine getArrowLine(final int index) {
final IArrow arrow = getArrowAt(index);
if (arrow == null) {
return null;
}
// Computing the angle to use for the second point of the line:
// the length of the arrow and the radius are used to compute the angle that separates the two points of the line.
final double gap = Math.asin(Math.max(-1d, Math.min(1d, arrow.getArrowShapeLength() / getRadius())));
if (index == 0) {
final IPoint sp = getStartPoint();
final IPoint ep = getPointOnArc(getAngleStart() < getAngleEnd() ? getAngleStart() + gap : getAngleStart() - gap);
return ShapeFactory.INST.createLine(sp, ep);
}
// For sure index == 1 here.
final IPoint sp = getEndPoint();
final IPoint ep = getPointOnArc(getAngleEnd() < getAngleStart() ? getAngleEnd() + gap : getAngleEnd() - gap);
return ShapeFactory.INST.createLine(sp, ep);
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow 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.IArrow in project latexdraw by arnobl.
the class TestIArrow method testCopyArrow.
@Test
public void testCopyArrow() {
setArrowParams();
final IArrow arrow2 = new LArrow(arrowable);
arrow2.copy(arrow);
assertArrowEquals(arrow2);
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class SVGShape method setSVGArrow.
protected static void setSVGArrow(final IArrowableSingleShape shape, final SVGElement parent, final int arrowPos, final boolean isShadow, final SVGDocument doc, final SVGDefsElement defs) {
final IArrow arrow = shape.getArrowAt(arrowPos);
if (arrow.getArrowStyle() != ArrowStyle.NONE) {
// NON-NLS
final String arrowName = "arrow" + arrowPos + (isShadow ? "Shad-" : "-") + shape.hashCode();
final SVGElement arrowSVG = new SVGArrow(arrow).toSVG(doc, isShadow);
arrowSVG.setAttribute(SVGAttributes.SVG_ID, arrowName);
defs.appendChild(arrowSVG);
parent.setAttribute(arrowPos == 0 ? SVGAttributes.SVG_MARKER_START : SVGAttributes.SVG_MARKER_END, SVG_URL_TOKEN_BEGIN + arrowName + ')');
}
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class GenericViewArrow method updatePathBarEnd.
default void updatePathBarEnd(final boolean isShadow) {
final IArrow arrow = getArrow();
final double width = arrow.getBarShapedArrowWidth();
createMoveTo(0d, -width / 2d);
createLineTo(0d, width / 2d);
setPathStrokeWidth(createFullThickBinding());
setPathStroke(createLineOrShadColBinding(isShadow));
}
Aggregations