Search in sources :

Example 16 with Function

use of com.ramussoft.pb.Function 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 17 with Function

use of com.ramussoft.pb.Function 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 18 with Function

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

the class AbstractDataPlugin method indexOfFunction.

public int indexOfFunction(final Function function) {
    if (((NFunction) function).isBase())
        return 0;
    class X {

        private int count = 0;

        private Function f;

        public int getIndex(final Function f) {
            this.f = f;
            calc(getBaseFunction(f));
            return count;
        }

        private boolean calc(final Function base) {
            final Enumeration cs = base.children();
            while (cs.hasMoreElements()) {
                final Function c = (Function) cs.nextElement();
                if (c.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
                    continue;
                if (c.equals(f)) {
                    count++;
                    return true;
                }
                if (c.isHaveRealChilds()) {
                    count++;
                    if (calc(c))
                        return true;
                }
            }
            return false;
        }
    }
    return new X().getIndex(function);
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Enumeration(java.util.Enumeration) NFunction(com.ramussoft.pb.data.negine.NFunction)

Example 19 with Function

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

the class AbstractDataPlugin method getFastMatrixProjectionIDEF0.

public FastMatrixProjection getFastMatrixProjectionIDEF0(final int type, Function function) {
    // if (idef0s[type] == null) {
    Function base = function;
    while (base.getParentRow() != null) {
        base = (Function) base.getParentRow();
    }
    idef0s[type] = new FastMatrixProjection(this, type, -1, base);
    // }
    return idef0s[type];
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) FastMatrixProjection(com.ramussoft.pb.print.xml.FastMatrixProjection)

Example 20 with Function

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

the class IDLImporter method importFromIDL.

public void importFromIDL(InputStream in) throws IOException {
    Vector<Row> streams = plugin.getRecChilds(plugin.getBaseStream(), true);
    for (Row r : streams) {
        Stream stream = (Stream) r;
        if (!stream.isEmptyName()) {
            this.streams.put(stream.getName(), stream);
        }
    }
    reader = new InputStreamReader(in, encoding);
    length = reader.read(buff);
    while (true) {
        String line = readLine();
        if (line == null)
            return;
        switch(position) {
            case KIT:
                if (starts(MODELC, line)) {
                    String name = valueOf(line);
                    try {
                        base.setName(name);
                    } catch (Exception e) {
                    }
                    plugin.getBaseFunctionQualifier().setName(name);
                    plugin.getEngine().updateQualifier(plugin.getBaseFunctionQualifier());
                    loadFonts(line);
                } else if (starts(PROJECT_NAME, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectName(name);
                } else if (starts(AUTHOR, line)) {
                    String name = valueOf(line);
                    plugin.getBaseFunction().getProjectOptions().setProjectAutor(name);
                } else if (starts(DIAGRAM_GRAPHICC, line)) {
                    position = DIAGRAM_GRAPHIC;
                    String name = line.substring(DIAGRAM_GRAPHICC.length() + 1);
                    Function f = getFunction(name);
                    functions.add(f);
                    boxes.clear();
                    segments.clear();
                }
                break;
            case DIAGRAM_GRAPHIC:
                if (starts(TITLE, line)) {
                    String name = valueOf(line);
                    try {
                        getFunction().setName(name);
                    } catch (Exception e) {
                    }
                } else if (starts(STATUS, line)) {
                    String name = line.substring(STATUS.length() + 1);
                    int typeOf = Status.typeOf(name);
                    Status status = getFunction().getStatus();
                    status.setType(typeOf);
                    if (typeOf < 0) {
                        status.setOtherName(name);
                        status.setType(Status.OTHER);
                    }
                    getFunction().setStatus(getFunction().getStatus());
                } else if (starts(BOXC, line)) {
                    box = new Box();
                    box.index = Integer.parseInt(getLastWord(line));
                    boxes.add(box);
                    position = BOX;
                } else if (starts(ENDDIAGRAM, line)) {
                    position = KIT;
                    createSegments();
                    functions.remove(functions.size() - 1);
                } else if (starts("ARROWSEG", line)) {
                    position = ARROWSEG;
                    seg = new Arrowseg();
                    seg.index = Integer.parseInt(line.substring("ARROWSEG".length() + 1));
                    segments.add(seg);
                }
                break;
            case BOX:
                if (starts(NAME, line)) {
                    String name = valueOf(line);
                    box.name = name;
                } else if (starts(BOX_COORDINATES, line)) {
                    box.coordinates = line.substring(BOX_COORDINATES.length() + 1);
                } else if (starts(DETAIL_REFERENCE, line)) {
                    box.reference = line.substring(DETAIL_REFERENCE.length() + 1);
                } else if (starts(ENDBOX, line)) {
                    addBox();
                    position = DIAGRAM_GRAPHIC;
                }
                break;
            case ARROWSEG:
                if (starts(SOURCE, line)) {
                    seg.source = line.substring(SOURCE.length() + 1);
                } else if (starts(PATH, line)) {
                    seg.path = line.substring(PATH.length() + 1);
                } else if (starts(LABAL_COORDINATES, line)) {
                    seg.coordinates = line.substring(LABAL_COORDINATES.length() + 1);
                } else if (starts(LABEL, line)) {
                    seg.label = valueOf(line);
                } else if (starts(SQUIGGLE_COORDINATES, line)) {
                    seg.squiggleCoordinates = line.substring(SQUIGGLE_COORDINATES.length() + 1);
                } else if (starts(SINK, line)) {
                    seg.sink = line.substring(SINK.length() + 1);
                } else if (starts("ENDSEG", line)) {
                    position = DIAGRAM_GRAPHIC;
                }
                break;
        }
    }
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) InputStreamReader(java.io.InputStreamReader) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row) IOException(java.io.IOException)

Aggregations

Function (com.ramussoft.pb.Function)96 NFunction (com.ramussoft.pb.data.negine.NFunction)50 Row (com.ramussoft.pb.Row)36 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)27 Crosspoint (com.ramussoft.pb.Crosspoint)25 Sector (com.ramussoft.pb.Sector)25 Stream (com.ramussoft.pb.Stream)21 FloatPoint (com.dsoft.pb.types.FloatPoint)19 NSector (com.ramussoft.pb.data.negine.NSector)18 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)17 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)17 Vector (java.util.Vector)17 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)15 IOException (java.io.IOException)13 FRectangle (com.dsoft.pb.types.FRectangle)11 Point (com.ramussoft.pb.idef.elements.Point)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 ArrayList (java.util.ArrayList)10 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)8