Search in sources :

Example 1 with PaintSector

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

the class DFDSFunction method onProcessEndBoundsChange.

@Override
public void onProcessEndBoundsChange() {
    FRectangle oldRec = function.getBounds();
    myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
    FRectangle newRect = new FRectangle(myBounds);
    function.setBounds(newRect);
    final SectorRefactor refactor = movingArea.getRefactor();
    MemoryData memoryData = new MemoryData();
    List<PaintSector> list = new ArrayList<PaintSector>();
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        PaintSector sector = refactor.getSector(i);
        try {
            setAddedSectorPos(oldRec, sector, list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
    setAddedRolesPos(oldRec, newRect);
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NFunction(com.ramussoft.pb.data.negine.NFunction) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 2 with PaintSector

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

the class DFDSRole method onProcessEndBoundsChange.

@Override
public void onProcessEndBoundsChange() {
    final FRectangle oldRec = function.getBounds();
    myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
    List<PaintSector> list = new ArrayList<PaintSector>();
    final SectorRefactor refactor = movingArea.getRefactor();
    boolean sectorReplaced = false;
    DFDSFunction function = movingArea.findDFDSFunction(this.getBounds());
    if (function != null) {
        getFunction().setOwner(function.getFunction());
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector ps = refactor.getSector(i);
            Function function2 = ps.getSector().getStart().getFunction();
            if (function2 != null && function2.equals(this.function)) {
                replaceFunction(ps.getSector().getStart(), ps, list, ps.getStartPoint(), ps.getSector().getStart().getFunctionType(), function, refactor, true);
            }
            Function function3 = ps.getSector().getEnd().getFunction();
            if (function3 != null && function3.equals(this.function)) {
                replaceFunction(ps.getSector().getEnd(), ps, list, ps.getEndPoint(), ps.getSector().getEnd().getFunctionType(), function, refactor, false);
            }
        }
        function.justifyRoles();
        sectorReplaced = true;
    } else {
        if (this.getFunction().getOwner() != null) {
            DFDSFunction function2 = movingArea.findDFDSFunction(this.getFunction().getOwner());
            if (function2 != null && function2.getBounds().intersects(this.getBounds())) {
                function2.justifyRoles();
            } else
                this.function.setBounds(new FRectangle(myBounds));
        } else
            this.function.setBounds(new FRectangle(myBounds));
    }
    MemoryData memoryData = new MemoryData();
    if (!sectorReplaced) {
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector sector = refactor.getSector(i);
            setAddedSectorPos(oldRec, sector, list);
        }
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) this.function).getEngine());
    long l = this.function.getLink();
    if (l >= 0l) {
        Stream stream = (Stream) movingArea.getDataPlugin().findRowByGlobalId(l);
        if (stream != null) {
            Row[] rows = stream.getAdded();
            RectangleVisualOptions ops = new RectangleVisualOptions();
            ops.bounds = this.function.getBounds();
            ops.background = this.function.getBackground();
            ops.font = this.function.getFont();
            ops.foreground = this.function.getForeground();
            for (Row row : rows) if (row != null) {
                IDEF0Plugin.setDefaultRectangleVisualOptions(movingArea.getDataPlugin().getEngine(), row.getElement(), ops);
            }
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) NFunction(com.ramussoft.pb.data.negine.NFunction) ArrayList(java.util.ArrayList) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 3 with PaintSector

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

the class UserTemplate method recRemove.

private static void recRemove(PaintSector ps, List<PaintSector> paintSectors) {
    boolean remed;
    do {
        remed = false;
        for (int i = 0; i < paintSectors.size(); i++) {
            PaintSector s = paintSectors.get(i);
            if (hasCross(s, ps.getStart())) {
                remed = true;
                recRemove(paintSectors.remove(i), paintSectors);
                break;
            }
            if (hasCross(s, ps.getEnd())) {
                remed = true;
                recRemove(paintSectors.remove(i), paintSectors);
                break;
            }
        }
    } while (remed);
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 4 with PaintSector

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

the class UserTemplate method remove.

private static boolean remove(List<PaintSector> paintSectors, int i, List<Function> functions, DataPlugin dataPlugin) {
    PaintSector ps = paintSectors.get(i);
    if (hasFunction(functions, ((NSector) ps.getSector()).getStart().getFunction()) && hasFunction(functions, ((NSector) ps.getSector()).getEnd().getFunction()))
        return false;
    paintSectors.remove(i);
    recRemove(ps, paintSectors);
    return true;
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector)

Example 5 with PaintSector

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

the class IDLExporter method printSegments.

protected void printSegments(Function f) throws IOException {
    MovingArea movingArea = new MovingArea(dataPlugin, f);
    movingArea.setActiveFunction(f);
    SectorRefactor sr = movingArea.getRefactor();
    for (int i = 0; i < sr.getSectorsCount(); i++) {
        PaintSector ps = sr.getSector(i);
        writer.p1("ARROWSEG " + (i + 1));
        writer.right();
        writer.p1("SOURCE " + getName(ps.getSector().getStart(), f, ps.getSector(), sr, ps.getPoint(0)));
        StringBuffer path = new StringBuffer();
        path.append("PATH ");
        for (int j = 0; j < ps.getPointCount(); j++) {
            Point point = ps.getPoint(j);
            path.append(toCoortinate(point.getX(), point.getY()));
        }
        writer.p1(path.toString());
        String s = ps.getAlternativeText();
        if ("".equals(s))
            s = ps.getSector().getName();
        if ((s != null) && (s.length() > 0)) {
            MovingLabel text = ps.getText();
            if (text != null) {
                final PStringBounder nb = new PStringBounder(null);
                nb.setFont(text.getFont());
                final PStringBounder.Tokanizer tokanizer = nb.getTokanizer(s, text.getBounds().getWidth(), 0);
                StringBuffer sb = new StringBuffer();
                if (tokanizer.hasMoreData())
                    sb.append(tokanizer.getNext());
                while (tokanizer.hasMoreData()) {
                    sb.append("<CR>");
                    sb.append(tokanizer.getNext());
                }
                writer.p2("LABEL {0}", "{LWI I 0 " + toByteTextIndex(text.getColor()) + " " + toByteTextIndex(text.getColor()) + " }" + sb.toString());
                writer.p1("LABEL COORDINATES " + toCoortinate(ps.getText().getBounds().getX(), ps.getText().getBounds().getCenter().getY()));
                if (ps.isShowTilda()) {
                    writer.p1("SQUIGGLE COORDINATES " + toCoortinate(ps.getTildaOPoint()) + " " + toCoortinate(ps.getTildaPoint()));
                }
            } else
                writer.p2("LABEL {0}", s);
        }
        writer.p1("SINK " + getName(ps.getSector().getEnd(), f, ps.getSector(), sr, ps.getPoint(ps.getPointCount() - 1)));
        writer.left();
        writer.p1("ENDSEG");
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) PStringBounder(com.ramussoft.pb.print.PStringBounder) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Aggregations

PaintSector (com.ramussoft.pb.idef.elements.PaintSector)32 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)15 FloatPoint (com.dsoft.pb.types.FloatPoint)14 Crosspoint (com.ramussoft.pb.Crosspoint)12 Function (com.ramussoft.pb.Function)12 Point (com.ramussoft.pb.idef.elements.Point)12 Row (com.ramussoft.pb.Row)10 MemoryData (com.dsoft.utils.DataLoader.MemoryData)9 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)9 ArrayList (java.util.ArrayList)8 Stream (com.ramussoft.pb.Stream)7 NFunction (com.ramussoft.pb.data.negine.NFunction)7 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)6 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)5 Sector (com.ramussoft.pb.Sector)4 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)4 IOException (java.io.IOException)4 Vector (java.util.Vector)4 FRectangle (com.dsoft.pb.types.FRectangle)3 NSector (com.ramussoft.pb.data.negine.NSector)3