Search in sources :

Example 1 with MovingArea

use of com.ramussoft.pb.idef.visual.MovingArea in project ramus by Vitaliy-Yakovchuk.

the class DetailedTemplate method createChilds.

@Override
public synchronized void createChilds(final Function function, final DataPlugin dataPlugin) {
    final MovingArea movingArea = new MovingArea(dataPlugin);
    movingArea.setDataPlugin(dataPlugin);
    movingArea.setActiveFunction(function);
    movingArea.setArrowAddingState();
    super.createChilds(function, dataPlugin, movingArea);
    for (int num = 0; num < count; num++) {
        createSimpleArrow(function, movingArea, num, TOP);
        createSimpleArrow(function, movingArea, num, BOTTOM);
    }
    movingArea.getRefactor().saveToFunction();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea)

Example 2 with MovingArea

use of com.ramussoft.pb.idef.visual.MovingArea in project ramus by Vitaliy-Yakovchuk.

the class SimpleTemplate method createChilds.

public void createChilds(final Function function, final DataPlugin dataPlugin) {
    final MovingArea movingArea = new MovingArea(dataPlugin);
    movingArea.setDataPlugin(dataPlugin);
    movingArea.setActiveFunction(function);
    movingArea.setArrowAddingState();
    assert count > 0;
    // Відступ зправа/зліва
    final double x = 80;
    // Відступ знизу/звурху
    final double y = 80;
    final double width = movingArea.MOVING_AREA_WIDTH - x * 2 - IDEFPanel.DEFAULT_WIDTH;
    final double height = movingArea.CLIENT_HEIGHT - y * 2 - IDEFPanel.DEFAULT_HEIGHT;
    for (int i = 0; i < count; i++) {
        final Function f = (Function) dataPlugin.createRow(function, true);
        final FRectangle rect = new FRectangle(f.getBounds());
        rect.setX(x + width / (count - 1) * i);
        rect.setY(y + height / (count - 1) * i);
        f.setBounds(rect);
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) Function(com.ramussoft.pb.Function) FRectangle(com.dsoft.pb.types.FRectangle)

Example 3 with MovingArea

use of com.ramussoft.pb.idef.visual.MovingArea in project ramus by Vitaliy-Yakovchuk.

the class IDLExporter method printSegments.

protected void printSegments(Function f) throws IOException {
    MovingArea movingArea = new MovingArea(dataPlugin, f);
    movingArea.setActiveFunction(f);
    SectorRefactor sr = movingArea.getRefactor();
    for (int i = 0; i < sr.getSectorsCount(); i++) {
        PaintSector ps = sr.getSector(i);
        writer.p1("ARROWSEG " + (i + 1));
        writer.right();
        writer.p1("SOURCE " + getName(ps.getSector().getStart(), f, ps.getSector(), sr, ps.getPoint(0)));
        StringBuffer path = new StringBuffer();
        path.append("PATH ");
        for (int j = 0; j < ps.getPointCount(); j++) {
            Point point = ps.getPoint(j);
            path.append(toCoortinate(point.getX(), point.getY()));
        }
        writer.p1(path.toString());
        String s = ps.getAlternativeText();
        if ("".equals(s))
            s = ps.getSector().getName();
        if ((s != null) && (s.length() > 0)) {
            MovingLabel text = ps.getText();
            if (text != null) {
                final PStringBounder nb = new PStringBounder(null);
                nb.setFont(text.getFont());
                final PStringBounder.Tokanizer tokanizer = nb.getTokanizer(s, text.getBounds().getWidth(), 0);
                StringBuffer sb = new StringBuffer();
                if (tokanizer.hasMoreData())
                    sb.append(tokanizer.getNext());
                while (tokanizer.hasMoreData()) {
                    sb.append("<CR>");
                    sb.append(tokanizer.getNext());
                }
                writer.p2("LABEL {0}", "{LWI I 0 " + toByteTextIndex(text.getColor()) + " " + toByteTextIndex(text.getColor()) + " }" + sb.toString());
                writer.p1("LABEL COORDINATES " + toCoortinate(ps.getText().getBounds().getX(), ps.getText().getBounds().getCenter().getY()));
                if (ps.isShowTilda()) {
                    writer.p1("SQUIGGLE COORDINATES " + toCoortinate(ps.getTildaOPoint()) + " " + toCoortinate(ps.getTildaPoint()));
                }
            } else
                writer.p2("LABEL {0}", s);
        }
        writer.p1("SINK " + getName(ps.getSector().getEnd(), f, ps.getSector(), sr, ps.getPoint(ps.getPointCount() - 1)));
        writer.left();
        writer.p1("ENDSEG");
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) PStringBounder(com.ramussoft.pb.print.PStringBounder) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Example 4 with MovingArea

use of com.ramussoft.pb.idef.visual.MovingArea 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 5 with MovingArea

use of com.ramussoft.pb.idef.visual.MovingArea in project ramus by Vitaliy-Yakovchuk.

the class SectorCorrector method run.

public void run(Engine engine, AccessRules accessRules) {
    ((Journaled) engine).startUserTransaction();
    log("Loading data");
    List<Qualifier> list = IDEF0Plugin.getBaseQualifiers(engine);
    for (Qualifier q : list) {
        DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(q, engine, accessRules);
        Vector<Row> v = dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true);
        for (Row r : v) {
            if (r.getChildCount() == 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                while (sr.getSectorsCount() > 0) {
                    sr.getSector(0).remove();
                }
                sr.saveToFunction();
                log("Function " + r + " clean");
            }
        }
        for (Row r : v) {
            if (r.getChildCount() != 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                for (int i = 0; i < sr.getSectorsCount(); i++) {
                    PaintSector ps = sr.getSector(i);
                    if ((ps.getSector().getStart().getFunction() != null) && (ps.getSector().getStart().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, true);
                    if ((ps.getSector().getEnd().getFunction() != null) && (ps.getSector().getEnd().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, false);
                }
                log("Function " + r + " done");
            }
        }
    }
    ((Journaled) engine).commitUserTransaction();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) Journaled(com.ramussoft.common.journal.Journaled) Function(com.ramussoft.pb.Function) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin)

Aggregations

MovingArea (com.ramussoft.pb.idef.visual.MovingArea)16 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)9 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)9 Function (com.ramussoft.pb.Function)8 Row (com.ramussoft.pb.Row)6 Stream (com.ramussoft.pb.Stream)3 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Crosspoint (com.ramussoft.pb.Crosspoint)2 NSector (com.ramussoft.pb.data.negine.NSector)2 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)2 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)2 Dimension (java.awt.Dimension)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Vector (java.util.Vector)2 FRectangle (com.dsoft.pb.types.FRectangle)1 FloatPoint (com.dsoft.pb.types.FloatPoint)1 DataLoader (com.dsoft.utils.DataLoader)1