use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LDot method getLazyTopLeftPoint.
@Override
public IPoint getLazyTopLeftPoint() {
final IPoint centre = getPosition();
final double diam = getDiametre();
return ShapeFactory.INST.createPoint(centre.getX() - diam / 2d, centre.getY() - diam / 2d);
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LDot method getBottomLeftPoint.
@Override
public IPoint getBottomLeftPoint() {
final IPoint tl = ShapeFactory.INST.createPoint();
final IPoint br = ShapeFactory.INST.createPoint();
getTopLeftBottomRightPoints(tl, br);
return ShapeFactory.INST.createPoint(tl.getX(), br.getY());
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LEllipse method setCentre.
@Override
public void setCentre(final IPoint centre) {
if (MathUtils.INST.isValidPt(centre)) {
final IPoint gc = getGravityCentre();
translate(centre.getX() - gc.getX(), centre.getY() - gc.getY());
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LGrid method scaleWithRatio.
@Override
public void scaleWithRatio(final double x, final double y, final Position pos, final Rectangle2D bound) {
if (pos == null || bound == null)
return;
final double sx = x / bound.getWidth();
final double sy = y / bound.getHeight();
final double u = getUnit();
switch(pos) {
case WEST:
case SW:
if (u + sx - 1d >= 0.5) {
setUnit(u + sx - 1d);
}
break;
case SOUTH:
if (u + sy - 1d >= 0.5) {
setUnit(u + sy - 1d);
}
break;
case NORTH:
case NW:
if (u + sy - 1d >= 0.5) {
setUnit(u + sy - 1d);
translate(0., -getTopRightPoint().getY() + bound.getY());
}
break;
case NE:
if (u + sy - 1d >= 0.5) {
setUnit(u + sy - 1d);
final IPoint tr = getTopRightPoint();
translate(-tr.getX() + bound.getMaxX(), -tr.getY() + bound.getY());
}
break;
case EAST:
case SE:
if (u + sx - 1d >= 0.5) {
setUnit(u + sx - 1d);
translate(-getTopRightPoint().getX() + bound.getMaxX(), 0d);
}
break;
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LAbstractCtrlPointShape method balance.
@Override
public void balance() {
final int size = getNbPoints();
// Works only with more than 2 points.
if (size < 3) {
return;
}
IPoint ptPrev;
IPoint ptNext;
// Balancing all the points except the first and the last one.
for (int i = 1; i < size - 1; i++) {
ptPrev = points.get(i - 1);
ptNext = points.get(i + 1);
setControlPoints(i, getBalancedPoints(points.get(i), ptPrev, ptNext));
}
// Balancing the first and the last points.
ptPrev = points.get(size - 1);
ptNext = points.get(1);
setControlPoints(0, getBalancedPoints(points.get(0), ptPrev, ptNext));
ptPrev = points.get(size - 2);
ptNext = points.get(0);
setControlPoints(size - 1, getBalancedPoints(points.get(size - 1), ptPrev, ptNext));
}
Aggregations