Search in sources :

Example 6 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class MatrixProjectionStreams method getLeft.

/**
 * Повертає набір класифікаторів пов’язаних з елементом класифікатора
 * потоків, атрибут обов’язково має бети елементом класифікатора потоків.
 */
public Vector<Row> getLeft(final Row row) {
    final Row[] rows = ((Stream) row).getAdded();
    final Vector<Row> res = new Vector<Row>();
    for (final Row row2 : rows) res.add(row2);
    return res;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 7 with Stream

use of com.ramussoft.pb.Stream 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 8 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class NFunction method getOwners.

public Row[] getOwners() {
    Function function = (Function) getParentRow();
    if (function.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
        if (function != null) {
            List<Row> res = new ArrayList<Row>();
            int c = function.getChildCount();
            for (int i = 0; i < c; i++) {
                Function function2 = (Function) function.getChildAt(i);
                if (function2.getType() == Function.TYPE_DFDS_ROLE && this.equals(function2.getOwner())) {
                    Stream stream = (Stream) dataPlugin.findRowByGlobalId(function2.getLink());
                    if (stream != null) {
                        for (Row row : stream.getAdded()) if (!res.contains(row))
                            res.add(row);
                    }
                }
            }
            Row[] rows = res.toArray(new Row[res.size()]);
            RowFactory.sortByName(rows);
            return rows;
        }
    }
    String s = dataPlugin.getProperty(DataPlugin.PROPERTY_OUNERS);
    if (s == null)
        s = "";
    final StringTokenizer st = new StringTokenizer(s);
    final Vector<GlobalId> ids = new Vector<GlobalId>();
    while (st.hasMoreTokens()) {
        ids.add(GlobalId.convert(st.nextToken()));
    }
    final MatrixProjection projection = dataPlugin.getProjection(MatrixProjection.TYPE_IDEF0, "BOTTOM");
    final Vector left = projection.getLeft(this);
    final Vector<Row> res = new Vector<Row>();
    Row[] rows;
    for (int i = 0; i < left.size(); i++) {
        final Stream r = (Stream) left.get(i);
        if ((rows = r.getAdded()).length == 0)
            addRow(res, ids, r);
        else
            for (final Row element2 : rows) addRow(res, ids, element2);
    }
    rows = res.toArray(new Row[res.size()]);
    RowFactory.sortByName(rows);
    return rows;
}
Also used : MatrixProjection(com.ramussoft.pb.MatrixProjection) ArrayList(java.util.ArrayList) GlobalId(com.ramussoft.pb.types.GlobalId) Function(com.ramussoft.pb.Function) StringTokenizer(java.util.StringTokenizer) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 9 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class AbstractSector method removeFromParent.

public void removeFromParent(Row[] rows, boolean start) {
    final Vector<Sector> v = new Vector<Sector>();
    if (start)
        getParents(getStart().getCrosspoint(), v);
    else
        getParents(getEnd().getCrosspoint(), v);
    for (int i = 0; i < v.size(); i++) {
        final AbstractSector s = (AbstractSector) v.get(i);
        final Stream ps = s.getStream();
        if (ps != null) {
            final Vector<Sector> v1 = new Vector<Sector>();
            if (s.getStart().getBorderType() < 0 && !start)
                s.getChilds(s.getStart().getCrosspoint(), v1);
            if (s.getEnd().getBorderType() < 0 && start)
                s.getChilds(s.getEnd().getCrosspoint(), v1);
            // v1.remove(this);
            for (int j = 0; j < v1.size(); j++) {
                final Sector s1 = v1.get(j);
                if (!equals(s1)) {
                    final Stream stream = s1.getStream();
                    if (stream != null) {
                        final Row[] rs = stream.getAdded();
                        rows = RowFactory.removeRows(rows, rs);
                        final Row[] add = RowFactory.removeRows(rs, ps.getAdded());
                        if (add.length > 0)
                            ps.addRows(add);
                    }
                }
            }
            if (rows.length > 0) {
                ps.removeRows(rows);
                s.removeFromParent(rows, start);
            }
        }
    }
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) NStream(com.ramussoft.pb.data.negine.NStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 10 with Stream

use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.

the class AbstractSector method getStreams.

/**
 * Повертає масив потоків пов’язаних з масивом секторів.
 *
 * @param sectors Масив секторів, з якого буде виділений масив потоків.
 * @return Масив потоків, виділений з масиву секторів.
 */
protected Stream[] getStreams(final Sector[] sectors) {
    final Vector<Stream> v = new Vector<Stream>();
    for (final Sector element : sectors) if (element.getStream() != null)
        if (v.indexOf(element.getStream()) < 0)
            v.add(element.getStream());
    final Stream[] streams = new Stream[v.size()];
    for (int i = 0; i < v.size(); i++) streams[i] = v.get(i);
    return streams;
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) NStream(com.ramussoft.pb.data.negine.NStream) Stream(com.ramussoft.pb.Stream) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Aggregations

Stream (com.ramussoft.pb.Stream)51 Row (com.ramussoft.pb.Row)30 Function (com.ramussoft.pb.Function)21 Sector (com.ramussoft.pb.Sector)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 NSector (com.ramussoft.pb.data.negine.NSector)14 Vector (java.util.Vector)13 InputStream (java.io.InputStream)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Crosspoint (com.ramussoft.pb.Crosspoint)9 NFunction (com.ramussoft.pb.data.negine.NFunction)9 OutputStream (java.io.OutputStream)7 NStream (com.ramussoft.pb.data.negine.NStream)6 ArrayList (java.util.ArrayList)6 FloatPoint (com.dsoft.pb.types.FloatPoint)4 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)4 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)4 IOException (java.io.IOException)4 FRectangle (com.dsoft.pb.types.FRectangle)3