Search in sources :

Example 11 with Sector

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

the class NFunction method setOwner.

public void setOwner(final Row owner) {
    Function ow = null;
    if (getType() == Function.TYPE_DFDS_ROLE) {
        ow = (Function) owner;
        if (ow == null)
            ow = (Function) getOwner();
    }
    if (owner == null) {
        setObject(OWNER_ID, null);
    } else {
        setObject(OWNER_ID, ((NRow) owner).getElementId());
    }
    Function function = (Function) getParent();
    if (function.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
        HashSet<Sector> toUpdate = new HashSet<Sector>();
        if (getType() == Function.TYPE_DFDS_ROLE) {
            if (ow != null) {
                for (Sector sector : function.getSectors()) {
                    if (ow.equals(sector.getStart().getFunction()) || ow.equals(sector.getEnd().getFunction()))
                        if (!toUpdate.contains(sector))
                            toUpdate.add(sector);
                }
            }
        } else {
            for (Sector sector : function.getSectors()) {
                if (this.equals(sector.getStart().getFunction()) || this.equals(sector.getEnd().getFunction()))
                    if (!toUpdate.contains(sector))
                        toUpdate.add(sector);
            }
        }
        for (Sector sector : toUpdate) SectorRefactor.fixOwners(sector, getDataPlugin());
    }
    for (Attribute attribute : engine.getQualifier(getElement().getQualifierId()).getAttributes()) if (attribute.getAttributeType().equals(DFDSNamePlugin.type)) {
        DFDSName dfdsName = (DFDSName) engine.getAttribute(getElement(), attribute);
        if (dfdsName != null)
            dataPlugin.compileDFDSName(dfdsName, this);
    }
}
Also used : Function(com.ramussoft.pb.Function) Attribute(com.ramussoft.common.Attribute) Sector(com.ramussoft.pb.Sector) DFDSName(com.ramussoft.idef0.attribute.DFDSName) HashSet(java.util.HashSet)

Example 12 with Sector

use of com.ramussoft.pb.Sector 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 13 with Sector

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

the class AbstractSector method getConnectedOnFunction.

/**
 * Метод повертає масив під’єднаних до точки секторів, при чому всі сектори
 * знаходяться на одному функціональному блоці.
 *
 * @param crosspoint Точка перетену секторів.
 * @return Масив секторів, що під’єднані до точки.
 */
private void getConnectedOnFunction(final Crosspoint crosspoint, final Vector<Sector> v) {
    if (crosspoint == null)
        return;
    final Vector<Sector> ss = new Vector<Sector>();
    crosspoint.getSectors(ss);
    int i;
    final int n = ss.size();
    final int oLen = v.size();
    Sector s;
    for (i = 0; i < n; i++) if ((s = ss.get(i)).getFunction().equals(getFunction()))
        if (v.indexOf(s) < 0)
            v.add(s);
    final int len = v.size();
    for (i = oLen; i < len; i++) ((AbstractSector) v.get(i)).getConnectedOnFunction(v);
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 14 with Sector

use of com.ramussoft.pb.Sector 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)

Example 15 with Sector

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

the class AbstractSector method getStreamedAllSectors.

private void getStreamedAllSectors(final Crosspoint point, final Vector<Sector> v, final boolean equalByAdded) {
    if (point == null)
        return;
    final Vector<Sector> srs = new Vector<Sector>();
    getChilds(point, srs);
    for (final Sector s : srs) if (v.indexOf(s) < 0) {
        if (s.getStream() == null)
            v.add(s);
        else if ((equalByAdded) && (s.getStream().isEmptyName()) && (equalsStreamsByAdded(s.getStream(), getStream())))
            v.add(s);
        else if (s.getStream().equals(this.getStream()))
            v.add(s);
    }
    srs.clear();
    getParents(point, srs);
    for (final Sector s : srs) if (v.indexOf(s) < 0) {
        if (s.getStream() == null)
            v.add(s);
        else if ((equalByAdded) && (s.getStream().isEmptyName()) && (equalsStreamsByAdded(s.getStream(), getStream())))
            v.add(s);
    }
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Vector(java.util.Vector)

Aggregations

Sector (com.ramussoft.pb.Sector)50 NSector (com.ramussoft.pb.data.negine.NSector)40 Crosspoint (com.ramussoft.pb.Crosspoint)29 Function (com.ramussoft.pb.Function)25 NFunction (com.ramussoft.pb.data.negine.NFunction)19 Vector (java.util.Vector)19 Stream (com.ramussoft.pb.Stream)18 Row (com.ramussoft.pb.Row)15 FloatPoint (com.dsoft.pb.types.FloatPoint)10 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 AbstractSector (com.ramussoft.pb.data.AbstractSector)7 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 NStream (com.ramussoft.pb.data.negine.NStream)4 Point (com.ramussoft.pb.idef.elements.Point)4 DataLoader (com.dsoft.utils.DataLoader)3 NCrosspoint (com.ramussoft.pb.data.negine.NCrosspoint)3 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)3