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());
}
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());
}
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()));
}
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));
}
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());
}
Aggregations