Search in sources :

Example 21 with Function

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

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

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

the class MatrixProjectionIDEF0 method getLeft.

/**
 * Метод повертає вектор елементів класифікатора потоків, які пов’язані з
 * відповідним елементом класифікатора робіт.
 */
public Vector<Row> getLeft(final Row row) {
    Function parent;
    if ((parent = (Function) row.getParentRow()) == null)
        return new Vector<Row>();
    final Vector<Row> res = new Vector<Row>();
    final Function f = (Function) row;
    final Vector sectors = parent.getSectors();
    Sector sector;
    Stream stream;
    final int l = sectors.size();
    for (int i = 0; i < l; i++) {
        sector = (Sector) sectors.get(i);
        if ((stream = sector.getStream()) != null) {
            if (type == MovingPanel.RIGHT) {
                if (f.equals(sector.getStart().getFunction()))
                    res.add(stream);
            } else {
                if (f.equals(sector.getEnd().getFunction()) && sector.getEnd().getFunctionType() == type)
                    res.add(stream);
            }
        }
    }
    return res;
}
Also used : Function(com.ramussoft.pb.Function) Sector(com.ramussoft.pb.Sector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 24 with Function

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

the class IDLExporter method export.

public void export(OutputStream out) throws IOException {
    loadFonts();
    writer = new IDLWriter(out, encoding);
    writer.p1("KIT");
    writer.right();
    writer.p1("IDL VERSION 1.2.8");
    writer.p2("TITLE {0}", base.getName());
    final ProjectOptions projectOptions = base.getProjectOptions();
    writer.p2("AUTHOR {0}", projectOptions.getProjectAutor());
    writer.p1("CREATION DATE " + format.format(new Date()));
    writer.p2("PROJECT NAME {0}", projectOptions.getProjectName());
    writer.println();
    writer.println("MODEL {0}", q(base.getName()));
    writer.right();
    writer.println("{LWI");
    printFonts();
    writer.println("D 0 0 0 0 0 1 0 0 2");
    writer.println("G 0 1");
    writer.println("T " + q(Status.STATUS_NAMES[base.getStatus().getType()].toUpperCase()));
    writer.println("R 77");
    writer.println("M 0 }");
    writer.left();
    writer.println(" ;");
    writer.right();
    writer.p2("AUTHOR {0}", projectOptions.getProjectAutor());
    writer.p2("PROJECT NAME {0}", projectOptions.getProjectName());
    rec(new FunctionCallback() {

        @Override
        public void call(Function f) throws IOException {
            String code = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) f);
            writer.p1("DIAGRAM GRAPHIC " + code);
            writer.right();
            writer.p1("CREATION DATE " + format.format(projectOptions.getDateCreateDate()));
            writer.p1("REVISION DATE " + format.format(projectOptions.getDateChangeDate()));
            writer.p2("TITLE {0}", f.getName());
            writer.p2("STATUS " + Status.STATUS_NAMES[f.getStatus().getType()].toUpperCase());
            writer.println();
            for (int i = 0; i < f.getChildCount(); i++) {
                Function child = (Function) f.getChildAt(i);
                int j = i;
                if (!f.equals(base))
                    j++;
                writer.p1("BOX " + j);
                writer.right();
                int textColot = toByteTextIndex(child.getForeground());
                int bkColot = toByteIndex(child.getBackground());
                writer.p2("NAME {0}", "{LWI I " + uniqueFonts.indexOf(child.getFont()) + " " + textColot + " " + bkColot + " " + textColot + "}" + child.getName());
                String lb = toCoortinate(child.getBounds().getLeft(), child.getBounds().getBottom());
                String rt = toCoortinate(child.getBounds().getRight(), child.getBounds().getTop());
                writer.p1("BOX COORDINATES " + lb + " " + rt);
                writer.p1("DETAIL REFERENCE N " + MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) child));
                writer.left();
                writer.p1("ENDBOX");
            }
            printSegments(f);
            writer.left();
            writer.p1("ENDDIAGRAM");
        }
    }, true);
    writer.left();
    writer.p1("ENDMODEL");
    writer.left();
    writer.p1("ENDKIT");
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) IOException(java.io.IOException) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions) Date(java.util.Date)

Example 25 with Function

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

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