use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class GenericViewArrow method updatePathRightLeftSquaredBracket.
default void updatePathRightLeftSquaredBracket(final boolean isShadow) {
final IArrow arrow = getArrow();
final double halflineWidth = arrow.getShape().getFullThickness() / 2d;
final double lgth = arrow.getBracketShapedArrowLength() + halflineWidth;
final double width = arrow.getBarShapedArrowWidth();
final double y0 = -width / 2d;
final double y1 = width / 2d;
createMoveTo(-lgth, y0 + halflineWidth);
createLineTo(0d, y0 + halflineWidth);
createLineTo(0d, y1 - halflineWidth);
createLineTo(-lgth, y1 - halflineWidth);
setPathFill(null);
setPathStroke(createLineOrShadColBinding(isShadow));
setPathStrokeWidth(createFullThickBinding());
if (arrow.isInverted()) {
setRotation180();
}
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class GenericViewArrow method updatePathRightLeftArrow.
default void updatePathRightLeftArrow(final boolean isShadow) {
final IArrow arrow = getArrow();
final double width = arrow.getArrowShapedWidth();
final double length = arrow.getArrowLength() * width;
final double inset = arrow.getArrowInset() * length;
final double x;
if (arrow.isInverted()) {
x = length;
} else {
x = 0d;
}
updatePathArrow(x, 0d, x - length, -width / 2d, x - length - inset, 0d, x - length, width / 2d);
setPathFill(createLineOrShadColBinding(isShadow));
setPathStroke(createLineOrShadColBinding(isShadow));
if (arrow.isInverted()) {
setRotation180();
}
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class SVGBezierCurve method getShowPointsElement.
/**
* Creates an SVG g element that contains the 'show points' plotting.
* @param doc The owner document.
* @return The created g element or null if the shape has not the 'show points' option activated.
* @since 2.0.0
*/
protected SVGGElement getShowPointsElement(final SVGDocument doc) {
if (!shape.isShowPts() || doc == null) {
return null;
}
final double blackDash = shape.getDashSepBlack();
final double whiteDash = shape.getDashSepWhite();
final boolean hasDble = shape.hasDbleBord();
final Color col = shape.getLineColour();
final boolean isClosed = !shape.isOpened();
final SVGGElement showPts = new SVGGElement(doc);
final IArrow arrow1 = shape.getArrowAt(0);
final IArrow arrow2 = shape.getArrowAt(-1);
final double doubleSep = shape.getDbleBordSep();
final double thick = (hasDble ? shape.getDbleBordSep() + shape.getThickness() * 2. : shape.getThickness()) / 2.;
final double rad = (PSTricksConstants.DEFAULT_ARROW_DOTSIZE_DIM * IShape.PPC + PSTricksConstants.DEFAULT_ARROW_DOTSIZE_NUM * thick * 2.) / 2.;
int i;
final int size = shape.getNbPoints();
showPts.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_SHOW_PTS);
/* Plotting the lines. */
for (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 (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));
// Plotting the dots.
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 (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 (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));
}
return showPts;
}
use of net.sf.latexdraw.models.interfaces.shape.IArrow 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();
IArrow 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.models.interfaces.shape.IArrow in project latexdraw by arnobl.
the class ViewAxes method updatePathAxes.
private void updatePathAxes() {
final IArrow arr0 = model.getArrowAt(1);
final IArrow arr1 = model.getArrowAt(3);
final double arr0Reduction = arr0.getArrowStyle().needsLineReduction() ? arr0.getArrowShapedWidth() : 0d;
final double arr1Reduction = arr1.getArrowStyle().needsLineReduction() ? arr1.getArrowShapedWidth() : 0d;
mainAxes.getElements().add(ViewFactory.INSTANCE.createMoveTo(model.getGridStartX() * IShape.PPC + arr0Reduction, 0d));
mainAxes.getElements().add(ViewFactory.INSTANCE.createLineTo(model.getGridEndX() * IShape.PPC - arr1Reduction, 0d));
mainAxes.getElements().add(ViewFactory.INSTANCE.createMoveTo(0d, -model.getGridStartY() * IShape.PPC - arr0Reduction));
mainAxes.getElements().add(ViewFactory.INSTANCE.createLineTo(0d, -model.getGridEndY() * IShape.PPC + arr1Reduction));
}
Aggregations