Search in sources :

Example 26 with Function

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

the class IDLImporter method getFunction.

private Function getFunction(String name) {
    Function f = null;
    if (name != null)
        f = hash.get(name);
    if (f == null) {
        Function function = getFunction();
        f = (Function) plugin.createRow(function, true);
        if (name != null)
            hash.put(name, f);
    }
    return f;
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction)

Example 27 with Function

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

the class AbstractCrosspoint method isDLevel.

public boolean isDLevel() {
    Function f = null;
    final Sector[] ins = getIns();
    final Sector[] outs = getOuts();
    if (ins.length == 0 || outs.length == 0)
        return true;
    for (int i = 0; i < ins.length; i++) {
        if (ins[i].getFunction() == null)
            return false;
        if (!ins[i].getFunction().equals(f)) {
            if (f == null)
                f = ins[i].getFunction();
            else
                return true;
        }
    }
    for (int i = 0; i < outs.length; i++) {
        if (outs[i].getFunction() == null)
            return false;
        if (!outs[i].getFunction().equals(f)) {
            if (f == null)
                f = outs[i].getFunction();
            else
                return true;
        }
    }
    return false;
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 28 with Function

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

the class HTTPParser method printIDEF0Model.

private void printIDEF0Model() throws IOException {
    int imageWidth = IMAGE_WIDTH;
    String s = (String) params.get("w");
    if (s != null) {
        try {
            imageWidth = new Integer(s).intValue();
        } catch (final Exception e) {
        }
    }
    int imageHeight = IMAGE_HEIGHT;
    s = (String) params.get("h");
    if (s != null) {
        try {
            imageHeight = new Integer(s).intValue();
        } catch (final Exception e) {
        }
    }
    Row row = loadRowById();
    Row old = row;
    if (row == null || !(row instanceof Function)) {
        printIDEF0Error();
        return;
    }
    row = replaceIDEF0Row(row);
    final Function function = (Function) row;
    String functionType;
    String name = function.getName();
    int iFunctionType = function.getType();
    Row ouner = null;
    if (function.getParent() == null) {
        final Enumeration e = function.children();
        while (e.hasMoreElements()) {
            final Function f = (Function) e.nextElement();
            ouner = f.getOwner();
            iFunctionType = f.getType();
            name = f.getName();
            if (ouner != null)
                break;
        }
    } else
        ouner = function.getOwner();
    switch(iFunctionType) {
        case Function.TYPE_PROCESS_KOMPLEX:
            functionType = RES.getString("functionProcessKomplex");
            break;
        case Function.TYPE_PROCESS:
            functionType = RES.getString("functionProcess");
            break;
        case Function.TYPE_PROCESS_PART:
            functionType = RES.getString("functionProcessPart");
            break;
        case Function.TYPE_ACTION:
            functionType = RES.getString("functionAction");
            break;
        case Function.TYPE_OPERATION:
            functionType = RES.getString("functionOperation");
            break;
        default:
            functionType = "";
            break;
    }
    htmlTitle = functionType + " " + name;
    printStartD();
    if (printVersion) {
    } else {
        if (imageWidth != 800) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=800&h=600\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("800x600");
            htmlStream.println("</a>");
        }
        if (imageWidth != 905) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=905&h=700\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("905x700");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1024) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1024&h=768\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1024x768");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1152) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1152&h=864\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1152x864");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1300) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1300&h=1000\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1300x1000");
            htmlStream.println("</a>");
        }
        if (imageWidth != 1600) {
            htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1600&h=1200\" style=\"color:rgb(0,0,0);\">");
            htmlStream.print("1600x1200");
            htmlStream.println("</a>");
        }
        final Row parent = function.getParentRow();
        htmlStream.println(RES.getString("functionType") + ": <b>" + functionType + "</b>");
        if (parent != null) {
            printStartATeg("idef0/index.html?id=" + parent.getGlobalId().toString());
            htmlStream.println(RES.getString("oneLevelTop"));
            printEndATeg();
            // printStartATeg("idef0/index.html?id="
            // + dataPlugin.getBaseFunction().getGlobalId().toString());
            htmlStream.println(RES.getString("contents"));
            printEndATeg();
        }
        if (ouner != null) {
            printStartATeg("rows/index.html?id=" + ouner.getGlobalId().toString());
            htmlStream.println(RES.getString("ouner") + ": " + ouner.getKod() + ". " + ouner.getName());
            printEndATeg();
        }
        if (old == row) {
            printStartATeg("rows/index.html?id=" + function.getGlobalId().toString());
            htmlStream.println(RES.getString("element"));
            printEndATeg();
        }
        Row top = row;
        while (top.getParentRow() != null) {
            top = top.getParentRow();
        }
        printStartATeg("fullmodel/index.html?id=" + top.getElement().getId());
        htmlStream.println(RES.getString("ExpandedModel"));
        printEndATeg();
    }
    htmlStream.print("<br>");
    htmlStream.println("<img border=0 src=\"" + fromLink + "idef0/" + "model." + getImagesFormatName() + "?id=" + function.getGlobalId().toString() + "&w=" + imageWidth + "&h=" + imageHeight + "\" useMap=#M" + function.getGlobalId().toString() + ">");
    htmlStream.println("<map name=M" + function.getGlobalId().toString() + ">");
    final Vector childs = dataPlugin.getChilds(function, true);
    final MovingArea area = PIDEF0painter.createMovingArea(new Dimension(imageWidth, imageHeight), dataPlugin, function);
    final SectorRefactor refactor = area.getRefactor();
    for (int i = 0; i < childs.size(); i++) {
        final Function fun = (Function) childs.get(i);
        Row row2 = dataPlugin.findRowByGlobalId(fun.getLink());
        String where = "rows";
        if ((row2 == null) && (fun.getType() < Function.TYPE_EXTERNAL_REFERENCE)) {
            row2 = fun;
            if (!fun.isLeaf())
                where = "idef0";
        }
        if (row2 != null) {
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + fromLink + where + "/index.html?id=" + row2.getElement().getId() + "&w=" + imageWidth + "&h=" + imageHeight + (printVersion ? "&printVersion=true" : "") + "\"");
            htmlStream.println(">");
        }
    }
    refactor.loadFromFunction(function, false);
    final int sc = refactor.getSectorsCount();
    for (int i = 0; i < sc; i++) {
        final PaintSector sector = refactor.getSector(i);
        final Stream stream = sector.getStream();
        final MovingLabel text = refactor.getSector(i).getText();
        if (text != null && stream != null) {
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(text.getBounds(), area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "&sectorId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
            htmlStream.println(">");
        }
        final int l = sector.getPinCount();
        for (int j = 0; j < l; j++) if (stream != null) {
            final Pin pin = sector.getPin(j);
            htmlStream.print("<area shape=RECT coords=" + getPinCoords(pin, area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "&sectorId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
            htmlStream.println(">");
        }
    }
    htmlStream.println("<map>");
    printEndD();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Enumeration(java.util.Enumeration) Dimension(java.awt.Dimension) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow) Vector(java.util.Vector)

Example 29 with Function

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

the class HTTPParser method addFunction.

private void addFunction(final Row row, final Function function, final Vector<UF> res) {
    if (!function.isHaveChilds()) {
        final Function par = (Function) function.getParent();
        boolean dfd = par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFD;
        final Vector<Sector> sectors = par.getSectors();
        for (int i = 0; i < sectors.size(); i++) {
            final Sector s = sectors.get(i);
            final Stream stream = s.getStream();
            if (stream != null) {
                if (function.equals(s.getStart().getFunction())) {
                    if (RowFactory.isPresent(stream.getAdded(), row)) {
                        final UF uf = new UF(function, s.getStart().getFunctionType());
                        if (res.indexOf(uf) < 0) {
                            res.add(uf);
                            if (dfd)
                                uf.type = MovingPanel.RIGHT;
                        }
                    }
                } else if (function.equals(s.getEnd().getFunction())) {
                    if (RowFactory.isPresent(stream.getAdded(), row)) {
                        final UF uf = new UF(function, s.getEnd().getFunctionType());
                        if (res.indexOf(uf) < 0) {
                            res.add(uf);
                            if (dfd)
                                uf.type = MovingPanel.LEFT;
                        }
                    }
                }
            }
        }
    }
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream)

Example 30 with Function

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

the class HTMLHelper method getDiagramPicture.

public byte[] getDiagramPicture(final String id) {
    final Row r = dataPlugin.findRowByGlobalId(GlobalId.convert(id));
    if (r instanceof Function) {
        final Function f = (Function) r;
        final PIDEF0painter painter = new PIDEF0painter(f, new Dimension(IMAGE_WIDTH, IMAGE_HEIGHT), dataPlugin);
        final ByteArrayOutputStream stream = new ByteArrayOutputStream();
        try {
            painter.writeToStream(stream, PIDEF0painter.PNG_FORMAT);
        } catch (final IOException e) {
            e.printStackTrace();
        }
        return stream.toByteArray();
    }
    return new byte[] {};
}
Also used : Function(com.ramussoft.pb.Function) PIDEF0painter(com.ramussoft.pb.print.PIDEF0painter) Row(com.ramussoft.pb.Row) Dimension(java.awt.Dimension) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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