Search in sources :

Example 11 with Stream

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

the class AbstractSector method splitStream.

/**
 * Метод призначений для розбивання потоку при розбитті сектору. Може
 * повертати переданий параметр.
 *
 * @param stream
 * @return
 */
protected Stream splitStream(final Stream stream) {
    if (stream == null)
        return null;
    if (!stream.isEmptyName())
        return stream;
    final Stream res = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
    res.setRows(stream.getAdded());
    return res;
}
Also used : NStream(com.ramussoft.pb.data.negine.NStream) Stream(com.ramussoft.pb.Stream)

Example 12 with Stream

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

Example 13 with Stream

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

the class NDataPlugin method createRow.

public Row createRow(final Row parent, boolean element, final GlobalId globalId) {
    assert parent == null && !element || parent != null;
    if (parent instanceof Stream) {
        return (Row) streamsRowSet.createRow(baseStream);
    }
    if (parent instanceof Function)
        throw new RuntimeException("Method can not be called to create functions!");
    Row res;
    if (!element) {
        res = (Row) qualifiers.createRow((com.ramussoft.database.common.Row) parent);
    } else {
        com.ramussoft.database.common.Row row = qualifiers.findRow(((com.ramussoft.database.common.Row) parent).getElementId());
        if (row != null) {
            long qId = (Long) engine.getAttribute(row.getElement(), qualifierId);
            RowSet rowSet = getRowSet(qId);
            res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
        } else {
            RowSet rowSet = findRowSetByRowId(((com.ramussoft.database.common.Row) parent).getElementId());
            res = (Row) rowSet.createRow((com.ramussoft.database.common.Row) parent);
        }
    }
    return res;
}
Also used : Function(com.ramussoft.pb.Function) RowSet(com.ramussoft.database.common.RowSet) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row)

Example 14 with Stream

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

the class NDataPlugin method replaceParent.

private Row replaceParent(Row row, final boolean element) {
    if ((!row.isElement()) && (element) && (!(row instanceof Stream)) && (!(row instanceof Function))) {
        long id = (Long) ((com.ramussoft.database.common.Row) row).getAttribute(qualifierId);
        RowSet rs = getRowSet(id);
        row = (Row) rs.getRoot();
    }
    return row;
}
Also used : Function(com.ramussoft.pb.Function) RowSet(com.ramussoft.database.common.RowSet) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream)

Example 15 with Stream

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

the class AbstractSector method setRows.

public void setRows(final Row[] rows) {
    synchronized (dataPlugin) {
        sRec = true;
        if (getStream() != null) {
            final Row[] dels = RowFactory.removeRows(getStream().getAdded(), rows);
            if (dels.length > 0)
                removeFromParent(dels);
            getStream().setRows(rows);
        }
        final Vector<Sector> v = new Vector();
        getRecParents(v);
        final Sector[] sectors = toArray(v);
        final Stream[] streams = getStreams(sectors);
        for (final Stream element : streams) element.addRows(rows);
        for (Sector s : sectors) {
            if (s.getStream() == null) {
                Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                stream.addRows(rows);
                ((NSector) s).setThisStream(stream);
            }
        }
        sRec = false;
    }
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) 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)

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