Search in sources :

Example 11 with MemoryData

use of com.dsoft.utils.DataLoader.MemoryData in project ramus by Vitaliy-Yakovchuk.

the class MouseSelection method onProcessEndBoundsChange.

public void onProcessEndBoundsChange(MovingArea movingArea, MovingText[] panels, FloatPoint diff) {
    for (MovingText text : panels) if (text instanceof DFDSRole) {
        IDEF0Object idef = (IDEF0Object) text;
        if (contains(text))
            idef.onProcessEndBoundsChange(sectors);
    }
    for (MovingText text : panels) {
        if (!(text instanceof DFDSRole))
            if (contains(text)) {
                if (text instanceof IDEF0Object) {
                    IDEF0Object idef = (IDEF0Object) text;
                    idef.onProcessEndBoundsChange(sectors);
                }
            }
    }
    List<Ordinate> xOrdinates = new ArrayList<Ordinate>();
    List<Ordinate> yOrdinates = new ArrayList<Ordinate>();
    for (PaintSector ps : sectors) {
        for (Point point : ps.getPoints()) {
            boolean has;
            has = false;
            for (Ordinate o : xOrdinates) if (o.getOrdinateId() == point.getXOrdinate().getOrdinateId()) {
                has = true;
                break;
            }
            if (!has)
                xOrdinates.add(point.getXOrdinate());
            has = false;
            for (Ordinate o : yOrdinates) if (o.getOrdinateId() == point.getYOrdinate().getOrdinateId()) {
                has = true;
                break;
            }
            if (!has)
                yOrdinates.add(point.getYOrdinate());
        }
    }
    List<PaintSector> psrs = new ArrayList<PaintSector>();
    psrs.addAll(sectors);
    for (Ordinate xOrdinate : xOrdinates) {
        xOrdinate.setPosition(xOrdinate.getPosition() + diff.getX());
        for (Point point : xOrdinate.getPoints()) if (!psrs.contains(point.getSector()))
            psrs.add(point.getSector());
    }
    for (Ordinate yOrdinate : yOrdinates) {
        yOrdinate.setPosition(yOrdinate.getPosition() + diff.getY());
        for (Point point : yOrdinate.getPoints()) if (!psrs.contains(point.getSector()))
            psrs.add(point.getSector());
    }
    MemoryData data = new MemoryData();
    for (PaintSector paintSector : sectors) {
        Function sFunction = paintSector.getSector().getStart().getFunction();
        if (sFunction != null) {
            switch(paintSector.getSector().getStart().getFunctionType()) {
                case MovingFunction.LEFT:
                    paintSector.getStartPoint().setX(sFunction.getBounds().getLeft());
                    break;
                case MovingFunction.RIGHT:
                    paintSector.getStartPoint().setX(sFunction.getBounds().getRight());
                    break;
                case MovingFunction.TOP:
                    paintSector.getStartPoint().setY(sFunction.getBounds().getTop());
                    break;
                case MovingFunction.BOTTOM:
                    paintSector.getStartPoint().setY(sFunction.getBounds().getBottom());
                    break;
            }
        }
        sFunction = paintSector.getSector().getEnd().getFunction();
        if (sFunction != null) {
            switch(paintSector.getSector().getEnd().getFunctionType()) {
                case MovingFunction.LEFT:
                    paintSector.getEndPoint().setX(sFunction.getBounds().getLeft());
                    break;
                case MovingFunction.RIGHT:
                    paintSector.getEndPoint().setX(sFunction.getBounds().getRight());
                    break;
                case MovingFunction.TOP:
                    paintSector.getEndPoint().setY(sFunction.getBounds().getTop());
                    break;
                case MovingFunction.BOTTOM:
                    paintSector.getEndPoint().setY(sFunction.getBounds().getBottom());
                    break;
            }
        }
    }
    for (MovingText text : panels) {
        if (!(text instanceof DFDSRole))
            if (contains(text)) {
                if (!(text instanceof IDEF0Object)) {
                    text.onProcessEndBoundsChange();
                    if (text instanceof MovingLabel)
                        ((MovingLabel) text).boundsCopy = text.getBounds();
                }
            }
    }
    for (PaintSector ps : psrs) PaintSector.save(ps, data, movingArea.getDataPlugin().getEngine());
}
Also used : DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) ArrayList(java.util.ArrayList) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) Ordinate(com.ramussoft.pb.idef.elements.Ordinate) Function(com.ramussoft.pb.Function) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData)

Aggregations

MemoryData (com.dsoft.utils.DataLoader.MemoryData)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)8 ArrayList (java.util.ArrayList)7 FloatPoint (com.dsoft.pb.types.FloatPoint)6 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 NFunction (com.ramussoft.pb.data.negine.NFunction)4 Point (com.ramussoft.pb.idef.elements.Point)4 FRectangle (com.dsoft.pb.types.FRectangle)3 Crosspoint (com.ramussoft.pb.Crosspoint)3 Function (com.ramussoft.pb.Function)3 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)3 IOException (java.io.IOException)3 DataLoader (com.dsoft.utils.DataLoader)2 Row (com.ramussoft.pb.Row)2 Stream (com.ramussoft.pb.Stream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 List (java.util.List)2 Engine (com.ramussoft.common.Engine)1 RectangleVisualOptions (com.ramussoft.idef0.attribute.RectangleVisualOptions)1