use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LRectangularShape method mirrorVertical.
@Override
public void mirrorVertical(final double y) {
super.mirrorVertical(y);
if (getHeight() < 0d) {
final IPoint tmp = ShapeFactory.INST.createPoint(points.get(0));
points.get(0).setPoint(points.get(3));
points.get(3).setPoint(tmp);
tmp.setPoint(points.get(1));
points.get(1).setPoint(points.get(2));
points.get(2).setPoint(tmp);
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LShape method addToRotationAngle.
@Override
public void addToRotationAngle(final IPoint gravCentre, final double angle) {
if (MathUtils.INST.isValidCoord(angle)) {
setRotationAngle(getRotationAngle() + angle);
if (gravCentre != null) {
final IPoint gravityCentre = getGravityCentre();
final IPoint rotatedGC = gravityCentre.rotatePoint(gravCentre, angle);
translate(rotatedGC.getX() - gravityCentre.getX(), rotatedGC.getY() - gravityCentre.getY());
}
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LShape method scaleSetPointsWithRatio.
protected void scaleSetPointsWithRatio(final List<IPoint> pts, final double prevWidth, final double prevHeight, final Position pos, final Rectangle2D bound) {
final double s = Math.max(prevWidth / bound.getWidth(), prevHeight / bound.getHeight());
final IPoint refPt = pos.getReferencePoint(bound);
final double refX = refPt.getX();
final double refY = refPt.getY();
for (final IPoint pt : pts) {
if (!MathUtils.INST.equalsDouble(pt.getX(), refX))
pt.setX(refX + (pt.getX() - refX) * s);
if (!MathUtils.INST.equalsDouble(pt.getY(), refY))
pt.setY(refY + (pt.getY() - refY) * s);
}
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LShape method scaleSetPoints.
protected void scaleSetPoints(final List<IPoint> pts, final double prevWidth, final double prevHeight, final Position pos, final Rectangle2D bound) {
final double sx = prevWidth / bound.getWidth();
final double sy = prevHeight / bound.getHeight();
final boolean xScale = pos.isEast() || pos.isWest();
final boolean yScale = pos.isNorth() || pos.isSouth();
final IPoint refPt = pos.getReferencePoint(bound);
final double refX = refPt.getX();
final double refY = refPt.getY();
pts.forEach(pt -> {
if (xScale && !MathUtils.INST.equalsDouble(pt.getX(), refX))
pt.setX(refX + (pt.getX() - refX) * sx);
if (yScale && !MathUtils.INST.equalsDouble(pt.getY(), refY))
pt.setY(refY + (pt.getY() - refY) * sy);
});
}
use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.
the class LShapeFactory method createPolygonFrom.
@Override
public IPolygon createPolygonFrom(final IPolygon sh, final IPoint pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd))
return null;
final List<IPoint> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final IPolygon copy = createPolygon(pts);
copy.copy(sh);
return copy;
}
Aggregations