Search in sources :

Example 1 with SplitSectorType

use of com.ramussoft.pb.idef.elements.PaintSector.SplitSectorType in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method createMiss.

private Sector createMiss(final PerspectivePoint point) {
    if (point.functionType >= 0) {
        point.crosspoint = getDataPlugin().createCrosspoint();
        double inPos;
        if (point.functionType == MovingPanel.LEFT || point.functionType == MovingPanel.RIGHT)
            inPos = point.point.getY();
        else
            inPos = point.point.getX();
        return createPartIn(point.crosspoint, point.function, point.functionType, inPos, point.type == TYPE_END);
    } else if (point.borderType == -1) {
        // Tochka na inshomu sektory
        final PaintSector.Pin pin = point.pin;
        final double x = point.x;
        final double y = point.y;
        double oX;
        double oY;
        double opX;
        double opY;
        final boolean start = point.type == TYPE_START;
        if (start) {
            oX = pointA.x;
            oY = pointA.y;
            opX = pointB.getX();
            opY = pointB.getY();
        } else {
            opX = pointA.getX();
            opY = pointA.getY();
            oX = pointB.x;
            oY = pointB.y;
        }
        final Point p = new Point();
        if (pin.isNearStart(x, y) && pin.isFirst()) {
            final Crosspoint crosspoint = pin.getSector().getStart();
            if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
                final int type = pin.getStart().isCanConnected(opX, opY);
                if (type >= 0) {
                    p.setType(type);
                    p.setXOrdinate(pin.getStart().getXOrdinate());
                    p.setYOrdinate(pin.getStart().getYOrdinate());
                    point.crosspoint = crosspoint;
                    point.point = p;
                    return null;
                }
            }
        } else if (pin.isNearEnd(x, y) && pin.isEnd()) {
            final Crosspoint crosspoint = pin.getSector().getEnd();
            if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
                final int type = pin.getEnd().isCanConnected(opX, opY);
                if (type >= 0) {
                    p.setType(type);
                    p.setXOrdinate(pin.getEnd().getXOrdinate());
                    p.setYOrdinate(pin.getEnd().getYOrdinate());
                    point.crosspoint = crosspoint;
                    point.point = p;
                    return null;
                }
            }
        }
        final PaintSector sector = pin.getSector();
        final SplitSectorType sst = sector.splitSector(pin, new FloatPoint(point.x, point.y), oX, oY, opX, opY, start);
        final PaintSector aSector = sst.paintSector;
        point.crosspoint = sector.getEnd();
        point.point = new Point(sector.getEndPoint().getXOrdinate(), sector.getEndPoint().getYOrdinate());
        point.point.setType(sst.type);
        tryRemoveText(aSector);
        tryRemoveText(sector);
        addSector(aSector);
    } else {
        // TOCHKA NA KRAU
        createBorderPoints(point, function);
    }
    return null;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) SplitSectorType(com.ramussoft.pb.idef.elements.PaintSector.SplitSectorType) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Aggregations

FloatPoint (com.dsoft.pb.types.FloatPoint)1 Crosspoint (com.ramussoft.pb.Crosspoint)1 SplitSectorType (com.ramussoft.pb.idef.elements.PaintSector.SplitSectorType)1