use of net.sf.latexdraw.model.api.shape.Arrow in project latexdraw by arnobl.
the class ShapeArrowCustomiser method update.
@Override
protected void update(final Group shape) {
if (shape.isTypeOf(Arrowable.class)) {
setActivated(true);
final Arrow arr1 = shape.getArrowAt(0);
final Arrow arr2 = shape.getArrowAt(-1);
final ArrowStyle arrStyle1 = arr1.getArrowStyle();
final ArrowStyle arrStyle2 = arr2.getArrowStyle();
arrowLeftCB.setValue(arrStyle1);
arrowRightCB.setValue(arrStyle2);
// Updating the value of the widgets.
updateArrowWidgets(arr1, arrStyle2);
updateArrowDotWidgets(arr1, arrStyle2);
updateArrowBarWidgets(arr1, arrStyle2);
updateArrowSBracketWidgets(arr1, arrStyle2);
updateArrowRBracketWidgets(arr1, arrStyle2);
} else {
setActivated(false);
}
}
use of net.sf.latexdraw.model.api.shape.Arrow 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.Arrow in project latexdraw by arnobl.
the class ViewArrowableTraitArc method clipPath.
@Override
protected void clipPath(final Arc arc) {
if (!model.getArcStyle().supportArrow()) {
arc.setClip(null);
return;
}
final double width = Math.max(arc.getRadiusX() * 2d, 1d);
double sAngle = model.getAngleStart();
double eAngle = model.getAngleEnd();
Arrow arr = model.getArrowAt(1);
final double gap = Math.atan(arr.getArrowShapeLength() / width);
if (arr.getArrowStyle().isReducingShape()) {
if (eAngle > sAngle) {
eAngle -= gap;
} else {
eAngle += gap;
}
}
arr = model.getArrowAt(0);
if (arr.getArrowStyle().isReducingShape()) {
if (eAngle > sAngle) {
sAngle += gap;
} else {
sAngle -= gap;
}
}
sAngle = Math.toDegrees(sAngle % (2d * Math.PI));
eAngle = Math.toDegrees(eAngle % (2d * Math.PI));
if (MathUtils.INST.equalsDouble(sAngle, eAngle)) {
eAngle += 0.1;
}
final Arc clip = new Arc(arc.getCenterX(), arc.getCenterY(), arc.getRadiusX(), arc.getRadiusY(), sAngle, eAngle - sAngle);
clip.setType(arc.getType());
clip.setStrokeWidth(arc.getStrokeWidth());
arc.setClip(clip);
}
use of net.sf.latexdraw.model.api.shape.Arrow in project latexdraw by arnobl.
the class TestArrow method testCopyArrow.
@Test
public void testCopyArrow() {
setArrowParams();
final Arrow arrow2 = new ArrowImpl(arrowable);
arrow2.copy(arrow);
assertArrowEquals(arrow2);
}
use of net.sf.latexdraw.model.api.shape.Arrow in project latexdraw by arnobl.
the class CircleArcImpl method getArrowLine.
@Override
public Line getArrowLine(final int index) {
final Arrow 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 Point sp = getStartPoint();
final Point ep = getPointOnArc(getAngleStart() < getAngleEnd() ? getAngleStart() + gap : getAngleStart() - gap);
return ShapeFactory.INST.createLine(sp, ep);
}
// For sure index == 1 here.
final Point sp = getEndPoint();
final Point ep = getPointOnArc(getAngleEnd() < getAngleStart() ? getAngleEnd() + gap : getAngleEnd() - gap);
return ShapeFactory.INST.createLine(sp, ep);
}
Aggregations