Search in sources :

Example 1 with SectorRefactor

use of com.ramussoft.pb.idef.elements.SectorRefactor 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 SectorRefactor

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

the class DFDSFunction method onEndBoundsChange.

@Override
public void onEndBoundsChange() {
    FRectangle oldRec = function.getBounds();
    if (oldRec.equals(myBounds))
        return;
    final SectorRefactor refactor = movingArea.getRefactor();
    ((NRow) function).startUserTransaction();
    onProcessEndBoundsChange();
    refactor.setUndoPoint();
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) NRow(com.ramussoft.pb.data.negine.NRow)

Example 3 with SectorRefactor

use of com.ramussoft.pb.idef.elements.SectorRefactor 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 4 with SectorRefactor

use of com.ramussoft.pb.idef.elements.SectorRefactor 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)

Example 5 with SectorRefactor

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

the class IDLImporter method createSegment.

private void createSegment(Arrowseg seg, MovingArea area) {
    SectorRefactor sr = area.getRefactor();
    Sector s = plugin.createSector();
    Function f = getFunction();
    s.setFunction(f);
    PaintSector ps = new PaintSector();
    ps.setSector(s);
    ps.setMovingArea(area);
    sr.addSector(ps);
    seg.sector = ps;
    ArrayList<FloatPoint> list = new ArrayList<FloatPoint>();
    StringTokenizer st = new StringTokenizer(seg.path, "() ");
    while (st.hasMoreElements()) list.add(toPoint(st.nextToken()));
    seg.pointsList = list;
    String text = seg.getText();
    if ((text != null) && (text.length() > 0)) {
        s.setStream(getStream(text), ReplaceStreamType.CHILDREN);
        if (seg.coordinates != null) {
            MovingLabel label = new MovingLabel(area);
            StringTokenizer st2 = new StringTokenizer(seg.coordinates, "()");
            FloatPoint point = toPoint(st2.nextToken());
            label.getBounds().setX(point.getX());
            label.getBounds().setY(point.getY() - 10);
            label.setText(text);
            ps.setText(label);
            if (seg.squiggleCoordinates != null) {
                ps.setShowTilda(true);
            }
        }
        if (seg.label.startsWith("{")) {
            StringTokenizer st2 = new StringTokenizer(seg.label, " ");
            st2.nextElement();
            st2.nextElement();
            try {
                int font = Integer.parseInt(st2.nextToken());
                if (font < uniqueFonts.size())
                    ps.setFont(uniqueFonts.get(font));
            } catch (Exception e) {
            }
            int color = Integer.parseInt(st2.nextToken());
            if (color < COLORS.length)
                ps.setColor(COLORS[color]);
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) StringTokenizer(java.util.StringTokenizer) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) FloatPoint(com.dsoft.pb.types.FloatPoint) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ArrayList(java.util.ArrayList) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) IOException(java.io.IOException)

Aggregations

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