Search in sources :

Example 56 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class ViewDot method setPathTriangle.

/**
 * Creates a triangle (one of the possibles shapes of a dot).
 */
private void setPathTriangle() {
    final IPoint tl = model.getLazyTopLeftPoint();
    final double dec = model.getDiametre() / IDot.THICKNESS_O_STYLE_FACTOR;
    final IPoint br = model.getLazyBottomRightPoint();
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo((br.getX() + tl.getX()) / 2d, tl.getY() - 1.5 * dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(tl.getX() - 0.3 * dec, br.getY() - 3d * dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(br.getX() + 0.3 * dec, br.getY() - 3d * dec));
    path.getElements().add(ViewFactory.INSTANCE.createClosePath());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 57 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class ViewDot method setPathDiamond.

/**
 * Creates a diamond (one of the possibles shapes of a dot).
 */
private void setPathDiamond() {
    final IPoint tl = model.getLazyTopLeftPoint();
    final IPoint br = model.getLazyBottomRightPoint();
    final double dec = model.getDiametre() / IDot.THICKNESS_O_STYLE_FACTOR;
    // This diamond is a golden diamond
    // cf. http://mathworld.wolfram.com/GoldenRhombus.html
    final double midY = (tl.getY() + br.getY()) / 2d;
    final double a = Math.abs(tl.getX() - br.getX()) / (2d * Math.sin(IShape.GOLDEN_ANGLE));
    final double p = 2d * a * Math.cos(IShape.GOLDEN_ANGLE);
    final double x1 = br.getX() - dec - 0.5 * dec;
    final double x3 = tl.getX() + dec + 0.5 * dec;
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo((x1 + x3) / 2d, midY + p / 2d - dec - 0.5 * dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(x1, midY));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo((x1 + x3) / 2d, midY - p / 2d + dec + 0.5 * dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(x3, midY));
    path.getElements().add(ViewFactory.INSTANCE.createClosePath());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 58 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class ViewDot method setPathOTime.

private void setPathOTime() {
    final IPoint centre = model.getPosition();
    final IPoint br = model.getLazyBottomRightPoint();
    final IPoint tl = model.getLazyTopLeftPoint();
    final double dec = model.getGeneralGap();
    final double tlx = tl.getX();
    final double tly = tl.getY();
    final double brx = br.getX();
    final double bry = br.getY();
    setPathOLikeDot(model.getOGap());
    IPoint p1 = ShapeFactory.INST.createPoint((tlx + brx) / 2d, tly + dec * 2d);
    IPoint p2 = ShapeFactory.INST.createPoint((tlx + brx) / 2d, bry - dec * 2d);
    p1 = p1.rotatePoint(centre, Math.PI / 4d);
    p2 = p2.rotatePoint(centre, Math.PI / 4d);
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo(p1.getX(), p1.getY()));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(p2.getX(), p2.getY()));
    p1.setPoint(tlx + dec * 2d, (tly + bry) / 2d);
    p2.setPoint(brx - dec * 2d, (tly + bry) / 2d);
    p1 = p1.rotatePoint(centre, Math.PI / 4d);
    p2 = p2.rotatePoint(centre, Math.PI / 4d);
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo(p1.getX(), p1.getY()));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(p2.getX(), p2.getY()));
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 59 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class ViewDot method setPathPlus.

private void setPathPlus() {
    final double plusGap = model.getPlusGap();
    final IPoint br = model.getLazyBottomRightPoint();
    final IPoint tl = model.getLazyTopLeftPoint();
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo((tl.getX() + br.getX()) / 2d, tl.getY() - plusGap));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo((tl.getX() + br.getX()) / 2d, br.getY() + plusGap));
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo(tl.getX() - plusGap, (tl.getY() + br.getY()) / 2d));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(br.getX() + plusGap, (tl.getY() + br.getY()) / 2d));
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Example 60 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class ViewDot method setPathPentagon.

/**
 * Creates a pentagon (one of the possibles shapes of a dot)
 */
private void setPathPentagon() {
    final double dec = model.getDiametre() / IDot.THICKNESS_O_STYLE_FACTOR;
    final IPoint tl = model.getLazyTopLeftPoint();
    final IPoint br = model.getLazyBottomRightPoint();
    final double yCenter = (tl.getY() + br.getY()) / 2d - dec;
    final double xCenter = (tl.getX() + br.getX()) / 2d;
    final double dist = Math.abs(tl.getY() - br.getY()) / 2d + dec;
    final double c1 = 0.25 * (Math.sqrt(5d) - 1d) * dist;
    final double s1 = Math.sin(2 * Math.PI / 5d) * dist;
    final double c2 = 0.25 * (Math.sqrt(5d) + 1d) * dist;
    final double s2 = Math.sin(4 * Math.PI / 5d) * dist;
    path.getElements().add(ViewFactory.INSTANCE.createMoveTo(xCenter, tl.getY() - dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(s1 + xCenter, -c1 + yCenter + dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(s2 + xCenter, c2 + yCenter + dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(-s2 + xCenter, c2 + yCenter + dec));
    path.getElements().add(ViewFactory.INSTANCE.createLineTo(-s1 + xCenter, -c1 + yCenter + dec));
    path.getElements().add(ViewFactory.INSTANCE.createClosePath());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Aggregations

IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)191 Test (org.junit.Test)45 HelperTest (net.sf.latexdraw.HelperTest)25 Theory (org.junit.experimental.theories.Theory)21 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)15 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)11 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)11 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)10 ILine (net.sf.latexdraw.models.interfaces.shape.ILine)10 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)9 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)9 ArrayList (java.util.ArrayList)8 MathUtils (net.sf.latexdraw.models.MathUtils)8 Collections (java.util.Collections)7 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)7 Arrays (java.util.Arrays)6 Cursor (javafx.scene.Cursor)6 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)6 IModifiablePointsShape (net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape)6 Inject (net.sf.latexdraw.util.Inject)6