Search in sources :

Example 6 with Ordinate

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

the class IDEF0Object method setAddedSectorPosWC.

/**
 * Метод організовує зміни в секторі, що виходить або входить в
 * функціональний блок.
 *
 * @param oldRec Старі властивості розмірів функціонального блоку.
 * @param sector Сектор прив’язаний до функціонального блоку.
 */
public boolean setAddedSectorPosWC(final FRectangle oldRec, final PaintSector sector, List<Ordinate> ordinates) {
    boolean res = false;
    final FRectangle currRec = function.getBounds();
    if (function.equals(sector.getSector().getStart().getFunction())) {
        final Point p = sector.getStartPoint();
        if (!p.isMoveable(currRec.getRight(), Ordinate.TYPE_X)) {
            sector.regeneratePoints();
            addOrdinates(sector, ordinates);
        }
        double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
        if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
            if (sector.getPinCount() == 1)
                p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
            p.setY(t);
            sector.regeneratePoints();
            addOrdinates(sector, ordinates);
        } else {
            p.setY(t);
            addOrdinate(ordinates, p.getYOrdinate());
        }
        if (sector.getSector().getStart().getFunctionType() == MovingPanel.RIGHT) {
            p.setX(getX(t, false, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
        } else if (sector.getSector().getStart().getFunctionType() == MovingPanel.LEFT) {
            p.setX(getX(t, true, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
        } else {
            t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
            if (sector.getSector().getStart().getFunctionType() == MovingPanel.TOP) {
                p.setY(getY(t, true, currRec));
            } else {
                p.setY(getY(t, false, currRec));
            }
            addOrdinate(ordinates, p.getYOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_X)) {
                p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
                p.setX(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setX(t);
                addOrdinate(ordinates, p.getXOrdinate());
            }
            fixCuttedEnd(sector);
            return true;
        }
        res = true;
        fixCuttedEnd(sector);
    }
    if (function.equals(sector.getSector().getEnd().getFunction())) {
        final Point p = sector.getEndPoint();
        if (sector.getSector().getEnd().getFunctionType() == MovingPanel.LEFT) {
            if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            }
            final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
            p.setX(getX(t, true, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
                if (sector.getPinCount() == 1)
                    p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
                p.setY(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setY(t);
                addOrdinate(ordinates, p.getYOrdinate());
            }
        } else if (sector.getSector().getEnd().getFunctionType() == MovingPanel.RIGHT) {
            if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            }
            final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
            p.setX(getX(t, false, currRec));
            addOrdinate(ordinates, p.getXOrdinate());
            if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
                if (sector.getPinCount() == 1)
                    p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
                p.setY(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setY(t);
                addOrdinate(ordinates, p.getYOrdinate());
            }
        } else {
            final double t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
            if (sector.getSector().getEnd().getFunctionType() == MovingPanel.TOP) {
                p.setY(getY(t, true, currRec));
                if (!p.isMoveable(currRec.getTop(), Ordinate.TYPE_Y)) {
                    sector.regeneratePoints();
                    addOrdinates(sector, ordinates);
                } else
                    addOrdinate(ordinates, p.getYOrdinate());
            } else {
                p.setY(getY(t, false, currRec));
                if (!p.isMoveable(currRec.getBottom(), Ordinate.TYPE_Y)) {
                    sector.regeneratePoints();
                    addOrdinates(sector, ordinates);
                } else
                    addOrdinate(ordinates, p.getYOrdinate());
            }
            if (!p.isMoveable(t, Ordinate.TYPE_X)) {
                p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
                p.setX(t);
                sector.regeneratePoints();
                addOrdinates(sector, ordinates);
            } else {
                p.setX(t);
                addOrdinate(ordinates, p.getXOrdinate());
            }
        }
        res = true;
        fixCuttedStart(sector);
    }
    sector.tryRemovePin(movingArea);
    return res;
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 7 with Ordinate

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

the class DataLoader method readOrdinate.

public static Ordinate readOrdinate(final InputStream stream, final MemoryData data) throws IOException {
    if (readBoolean(stream)) {
        final Ordinate o = Ordinate.loadFromStream(stream);
        data.ordinates.add(o);
        return o;
    } else {
        return (Ordinate) data.ordinates.get(readInteger(stream));
    }
}
Also used : Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 8 with Ordinate

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

the class DFDFunctionEllipse method mouseClicked.

public void mouseClicked(final FloatPoint point) {
    if (movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) {
        final int type = getTriangle(point);
        final Ordinate x = new Ordinate(Ordinate.TYPE_X);
        final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
        final Point p = new Point(x, y);
        final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
        pp.point = p;
        switch(type) {
            case LEFT:
                {
                    pp.setFunction(getFunction(), LEFT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), true, getBounds()));
                }
                break;
            case TOP:
                {
                    pp.setFunction(getFunction(), TOP);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), true, getBounds()));
                }
                break;
            case BOTTOM:
                {
                    pp.setFunction(getFunction(), BOTTOM);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), false, getBounds()));
                }
                break;
            case RIGHT:
                {
                    pp.setFunction(getFunction(), RIGHT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), false, getBounds()));
                }
                break;
            default:
                return;
        }
        if (movingArea.getPointChangingType() == SectorRefactor.TYPE_START) {
            pp.type = SectorRefactor.TYPE_START;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        } else if (movingArea.getPointChangingType() == SectorRefactor.TYPE_END) {
            pp.type = SectorRefactor.TYPE_END;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 9 with Ordinate

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

the class IDLImporter method setSegment.

private void setSegment(Arrowseg seg, MovingArea area) {
    if (seg.seted)
        return;
    List<Arrowseg> source = loadConnected(seg.source);
    List<Arrowseg> sink = loadConnected(seg.sink);
    if (source != null) {
        for (Arrowseg s : source) {
            if (!s.seted)
                setSegment(s, area);
        }
        Crosspoint c = null;
        for (Arrowseg s : source) {
            if (s.sector.getEnd() != null) {
                c = (NCrosspoint) s.sector.getEnd();
            }
        }
        if (c == null)
            c = dataPlugin.createCrosspoint();
        seg.sector.getSector().getStart().setCrosspointA(c);
        seg.sector.getSector().getStart().commit();
        for (Arrowseg s : source) {
            if (s.sector.getEnd() == null) {
                s.sector.getSector().getEnd().setCrosspointA(c);
                s.sector.getSector().getEnd().commit();
            }
        }
    }
    PaintSector ps = seg.sector;
    Point[] points = new Point[seg.pointsList.size()];
    int type = seg.getFirstPinType();
    Ordinate x = null;
    Ordinate y = null;
    if (source != null) {
        for (Arrowseg arrowseg : source) {
            int sType = arrowseg.getLastPinType();
            if (type == sType) {
                if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_X) {
                    y = arrowseg.sector.getLastPin().getOrdinate();
                    x = arrowseg.sector.getLastPin().getPOrdinate();
                } else {
                    x = arrowseg.sector.getLastPin().getOrdinate();
                    y = arrowseg.sector.getLastPin().getPOrdinate();
                }
            } else {
                if (arrowseg.sector.getLastPin().getType() == Ordinate.TYPE_Y) {
                    x = arrowseg.sector.getLastPin().getOrdinate();
                    y = arrowseg.sector.getLastPin().getPOrdinate();
                } else {
                    y = arrowseg.sector.getLastPin().getOrdinate();
                    x = arrowseg.sector.getLastPin().getPOrdinate();
                }
            }
        }
    }
    if (x == null) {
        x = new Ordinate(Ordinate.TYPE_X);
        x.setPosition(seg.pointsList.get(0).getX());
    }
    if (y == null) {
        y = new Ordinate(Ordinate.TYPE_Y);
        y.setPosition(seg.pointsList.get(0).getY());
    }
    points[0] = new Point(x, y);
    for (int i = 1; i < seg.pointsList.size(); i++) {
        FloatPoint point = seg.pointsList.get(i);
        type = seg.getPinType(i - 1);
        if (type == Ordinate.TYPE_X) {
            x = new Ordinate(Ordinate.TYPE_X);
            x.setPosition(point.getX());
        } else {
            y = new Ordinate(Ordinate.TYPE_Y);
            y.setPosition(point.getY());
        }
        if ((i == seg.pointsList.size() - 1) && (sink != null) && (sink.size() == 1)) {
            Arrowseg s = sink.get(0);
            List<Arrowseg> list = loadConnected(s.source);
            for (Arrowseg arrowseg : list) {
                if (arrowseg.seted) {
                    Point point2 = arrowseg.sector.getLastPin().getEnd();
                    Ordinate xo = point2.getXOrdinate();
                    for (Point point3 : xo.getPoints()) {
                        point3.setXOrdinate(x);
                    }
                    Ordinate yo = point2.getYOrdinate();
                    for (Point point3 : yo.getPoints()) {
                        point3.setYOrdinate(y);
                    }
                }
            }
        }
        points[i] = new Point(x, y);
    }
    ps.setPoints(points);
    if (source == null)
        initCrosspoint(seg.sector.getSector().getStart(), seg.source, area, seg.sector, true, seg);
    if (sink == null) {
        initCrosspoint(seg.sector.getSector().getEnd(), seg.sink, area, seg.sector, false, seg);
    }
    seg.seted = true;
}
Also used : FloatPoint(com.dsoft.pb.types.FloatPoint) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Example 10 with Ordinate

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

the class DFDObject method mouseClicked.

public void mouseClicked(final FloatPoint point) {
    if (movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) {
        final int type = getTriangle(point);
        final Ordinate x = new Ordinate(Ordinate.TYPE_X);
        final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
        final Point p = new Point(x, y);
        final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
        pp.point = p;
        switch(type) {
            case LEFT:
                {
                    pp.setFunction(getFunction(), LEFT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), true, getBounds()));
                }
                break;
            case TOP:
                {
                    pp.setFunction(getFunction(), TOP);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), true, getBounds()));
                }
                break;
            case BOTTOM:
                {
                    pp.setFunction(getFunction(), BOTTOM);
                    x.setPosition(getBounds().getX() + point.getX());
                    y.setPosition(getY(x.getPosition(), false, getBounds()));
                }
                break;
            case RIGHT:
                {
                    pp.setFunction(getFunction(), RIGHT);
                    y.setPosition(getBounds().getY() + point.getY());
                    x.setPosition(getX(y.getPosition(), false, getBounds()));
                }
                break;
            default:
                return;
        }
        if (movingArea.getPointChangingType() == SectorRefactor.TYPE_START) {
            pp.type = SectorRefactor.TYPE_START;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        } else if (movingArea.getPointChangingType() == SectorRefactor.TYPE_END) {
            pp.type = SectorRefactor.TYPE_END;
            movingArea.getRefactor().setPoint(pp);
            movingArea.doSector();
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) Ordinate(com.ramussoft.pb.idef.elements.Ordinate)

Aggregations

Ordinate (com.ramussoft.pb.idef.elements.Ordinate)14 Point (com.ramussoft.pb.idef.elements.Point)12 FloatPoint (com.dsoft.pb.types.FloatPoint)10 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)8 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 Crosspoint (com.ramussoft.pb.Crosspoint)2 Function (com.ramussoft.pb.Function)2 Row (com.ramussoft.pb.Row)2 ArrayList (java.util.ArrayList)2 FRectangle (com.dsoft.pb.types.FRectangle)1 MemoryData (com.dsoft.utils.DataLoader.MemoryData)1 Sector (com.ramussoft.pb.Sector)1 AbstractSector (com.ramussoft.pb.data.AbstractSector)1 NFunction (com.ramussoft.pb.data.negine.NFunction)1 NSector (com.ramussoft.pb.data.negine.NSector)1 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)1 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)1 DFDSRole (com.ramussoft.pb.dfds.visual.DFDSRole)1 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)1 Vector (java.util.Vector)1