Search in sources :

Example 11 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class IDEFPanel method modelProperties.

private void modelProperties() {
    Qualifier qualifier = ((NFunction) movingArea.getActiveFunction()).getQualifier();
    if (qualifier.isSystem()) {
        qualifier = dataPlugin.getBaseFunctionQualifier();
    }
    ModelPropertiesDialog dialog = new ModelPropertiesDialog(framework, qualifier, dataPlugin.getEngine(), dataPlugin.getAccessRules());
    dialog.setVisible(true);
}
Also used : ModelPropertiesDialog(com.ramussoft.idef0.ModelPropertiesDialog) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier)

Example 12 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method loadFromFunction.

/**
 * Метод, який завантажує секторну структуру функціонального блоку, якщо
 * інформація вже раніше була завантажена з функціонального блоку, то вона
 * автоматично в нього зберігається.
 *
 * @param function Функціональний блок, з якого завантажаться дані.
 * @param save     Параметр, який вказує, чи зберігати останню завантажену
 *                 функцію.
 */
public void loadFromFunction(final Function function, final boolean save) {
    if (save && this.function != null)
        saveToFunction(this.function);
    sectors.clear();
    texts.clear();
    this.function = function;
    if (function == null)
        return;
    ((NFunction) function).clearSectorsBuffer();
    final byte[] bs = function.getSectorData();
    if (bs == null)
        return;
    final ByteArrayInputStream in = new ByteArrayInputStream(bs);
    try {
        final DataLoader.MemoryData memoryData = new DataLoader.MemoryData();
        // read version
        final int ver = DataLoader.readInteger(in);
        this.loadVersion = ver;
        if (ver < 2 && ver > 0) {
            int n = DataLoader.readInteger(in);
            for (int i = 0; i < n; i++) {
                final PaintSector sector = PaintSector.loadFromStream(in, ver, movingArea, memoryData, getDataPlugin());
                if (sector != null)
                    addSector(sector);
            }
        } else {
            for (Sector sector : function.getSectors()) {
                final PaintSector paintSector = PaintSector.loadFromSector(ver, movingArea, memoryData, getDataPlugin(), sector);
                if (paintSector != null) {
                    if (sector.getCreateState() == Sector.STATE_IN)
                        createInPaintPart(sector);
                    else if (sector.getCreateState() == Sector.STATE_OUT)
                        createOutPaintPart(sector);
                    else
                        addSector(paintSector);
                }
            }
        }
        int n = DataLoader.readInteger(in);
        for (int i = 0; i < n; i++) {
            final MovingText text = movingArea.createText();
            text.setFont(DataLoader.readFont(in, memoryData));
            text.setColor(DataLoader.readColor(in, memoryData));
            text.setBounds(DataLoader.readFRectangle(in));
            text.setText(DataLoader.readString(in));
            texts.add(text);
        }
        in.close();
        HashSet<PaintSector> hashSet = new HashSet<PaintSector>();
        for (int i = 0; i < getSectorsCount(); i++) {
            getSector(i).createTexts(hashSet);
        }
    } catch (final IOException e) {
        e.printStackTrace();
    }
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) IOException(java.io.IOException) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint) DataLoader(com.dsoft.utils.DataLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) MovingText(com.ramussoft.pb.idef.visual.MovingText) HashSet(java.util.HashSet)

Example 13 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class ArrowPainter method paintLink.

public void paintLink(Graphics2D g, FloatPoint point, int type, Function inner, Function outer) {
    long innerQ = ((NFunction) inner).getQualifierId();
    long outerQ = ((NFunction) outer).getQualifierId();
    String text = MovingFunction.getIDEF0Kod((com.ramussoft.database.common.Row) outer);
    String letter = outer.getProjectOptions().getDeligate().getModelLetter();
    if (outer.getParentRow().getName().equals("F_BASE_FUNCTIONS")) {
        if (letter == null)
            text = "A-0";
        else
            text = letter + "-0";
    }
    if (innerQ != outerQ) {
        if (letter == null || "A".equals(letter))
            text = movingArea.getDataPlugin().getEngine().getQualifier(outerQ).getName() + "/" + text;
    }
    tunnelLength = movingArea.getIDoubleOrdinate(TUNNEL_LENGTH) * 1;
    g.setStroke(ArrowPainter.THIN_STROKE);
    g.setStroke(new BasicStroke(0.5f));
    double x = movingArea.getIDoubleOrdinate(point.getX());
    double y = movingArea.getIDoubleOrdinate(point.getY());
    double helf = tunnelLength / 2;
    switch(type) {
        case MovingPanel.BOTTOM:
            {
                g.draw(new Ellipse2D.Double(x - helf, y, tunnelLength, tunnelLength));
                boolean left = point.getX() < movingArea.CLIENT_WIDTH / 2;
                if (!left) {
                    movingArea.paintText(g, text, new FRectangle(point.getX() + TUNNEL_LENGTH, 0, movingArea.CLIENT_WIDTH - point.getX() - TUNNEL_WIDTH * 10, movingArea.CLIENT_HEIGHT), Line.LEFT_ALIGN, true);
                } else {
                    movingArea.paintText(g, text, new FRectangle(0, 0, point.getX() - TUNNEL_LENGTH, movingArea.CLIENT_HEIGHT), Line.RIGHT_ALIGN, true);
                }
            }
            break;
        case MovingPanel.TOP:
            {
                g.draw(new Ellipse2D.Double(x - helf, y - tunnelLength, tunnelLength, tunnelLength));
                boolean left = point.getX() < movingArea.CLIENT_WIDTH / 2;
                if (!left) {
                    movingArea.paintText(g, text, new FRectangle(point.getX() + TUNNEL_LENGTH, 0, movingArea.CLIENT_WIDTH - point.getX() - TUNNEL_WIDTH * 10, movingArea.CLIENT_HEIGHT), Line.LEFT_ALIGN, 2, true);
                } else {
                    movingArea.paintText(g, text, new FRectangle(0, 0, point.getX() - TUNNEL_LENGTH, movingArea.CLIENT_HEIGHT), Line.RIGHT_ALIGN, 2, true);
                }
            }
            break;
        case MovingPanel.RIGHT:
            {
                g.draw(new Ellipse2D.Double(x, y - helf, tunnelLength, tunnelLength));
                boolean top = point.getY() < movingArea.CLIENT_HEIGHT / 2;
                if (!top) {
                    movingArea.paintText(g, text, new FRectangle(2, point.getY() + tunnelLength / 2, movingArea.CLIENT_WIDTH * 0.20, movingArea.CLIENT_HEIGHT - point.getY() - tunnelLength / 2), Line.LEFT_ALIGN, 0, true);
                } else {
                    movingArea.paintText(g, text, new FRectangle(2, 0, movingArea.CLIENT_WIDTH * 0.20, point.getY() - tunnelLength / 2), Line.LEFT_ALIGN, 2, true);
                }
            }
            break;
        case MovingPanel.LEFT:
            {
                g.draw(new Ellipse2D.Double(x - tunnelLength, y - helf, tunnelLength, tunnelLength));
                boolean top = point.getY() < movingArea.CLIENT_HEIGHT / 2;
                if (!top) {
                    movingArea.paintText(g, text, new FRectangle(movingArea.CLIENT_WIDTH * 0.80, point.getY() + tunnelLength / 2, movingArea.CLIENT_WIDTH * 0.20 - 2, movingArea.CLIENT_HEIGHT - point.getY() - tunnelLength / 2), Line.RIGHT_ALIGN, 0, true);
                } else {
                    movingArea.paintText(g, text, new FRectangle(movingArea.CLIENT_WIDTH * 0.80, 0, movingArea.CLIENT_WIDTH * 0.20 - 2, point.getY() - tunnelLength / 2), Line.RIGHT_ALIGN, 2, true);
                }
            }
            break;
    }
}
Also used : BasicStroke(java.awt.BasicStroke) NFunction(com.ramussoft.pb.data.negine.NFunction) FRectangle(com.dsoft.pb.types.FRectangle)

Example 14 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class ModelParaleler method loadFromParalel.

public void loadFromParalel(boolean importAll, List<Qualifier> selected) {
    List<Attribute> tAttrs = toEngine.getAttributes();
    List<Attribute> fAttrs = fromEngine.getAttributes();
    for (Attribute f : fAttrs) for (Attribute t : tAttrs) if ((f.getName().equals(t.getName())) && (f.getAttributeType().equals(t.getAttributeType())))
        attrHash.put(f.getId(), t);
    List<Qualifier> fList = fromEngine.getQualifiers();
    List<Qualifier> tList = toEngine.getQualifiers();
    for (Qualifier f : fList) if (!IDEF0Plugin.isFunction(f))
        for (Qualifier t : tList) if (!IDEF0Plugin.isFunction(t))
            if (f.getName().equals(t.getName()))
                qHash.put(f.getId(), t);
    Vector<Row> fRows = fromDataPlugin.getRecChilds(null, false);
    Vector<Row> tRows = toDataPlugin.getRecChilds(null, false);
    for (Row f : fRows) for (Row t : tRows) if (f.getName().equals(t.getName())) {
        rowHash.put(f.getElement().getId(), t);
        Vector<Row> fCRows = fromDataPlugin.getRecChilds(f, true);
        Vector<Row> tCRows = toDataPlugin.getRecChilds(t, true);
        for (Row fc : fCRows) for (Row tc : tCRows) if (fc.getName().equals(tc.getName()))
            rowHash.put(fc.getElement().getId(), tc);
    }
    if (importAll) {
        createAllRows();
    }
    for (Qualifier qualifier : selected) {
        fromDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, fromEngine, fromDataPlugin.getAccessRules());
        Qualifier baseFunction = toEngine.createQualifier();
        baseFunction.setName(qualifier.getName());
        IDEF0Plugin.installFunctionAttributes(baseFunction, toEngine);
        toDataPlugin = NDataPluginFactory.getDataPlugin(baseFunction, toEngine, toDataPlugin.getAccessRules());
        base = toDataPlugin.getBaseFunction();
        List<Attribute> list = getAttributes(qualifier.getAttributes());
        for (Attribute a : list) if (baseFunction.getAttributes().indexOf(a) < 0)
            baseFunction.getAttributes().add(a);
        Attribute forName = fromEngine.getAttribute(qualifier.getAttributeForName());
        if (forName != null)
            baseFunction.setAttributeForName(getAttribute(forName).getId());
        toEngine.updateQualifier(baseFunction);
        if (fromDataPlugin.getBaseFunction().getChildCount() > 0) {
            function = (Function) fromDataPlugin.getBaseFunction().getChildAt(0);
            Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
            childs.add(0, function);
            for (Row row : childs) {
                NFunction dest = (NFunction) getRow(row);
                showMessageAnimation(dest.toString());
            }
            NFunction func = (NFunction) getRow(function);
            createSectorsOnUpperLevel(func);
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 15 with NFunction

use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.

the class DFDSNamePanel method compile.

private void compile(DFDSName name) {
    Row row = dataPlugin.findRowByGlobalId(element.getId());
    if (row instanceof Function) {
        Function function = (NFunction) row;
        dataPlugin.compileDFDSName(name, function);
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Row(com.ramussoft.pb.Row)

Aggregations

NFunction (com.ramussoft.pb.data.negine.NFunction)24 Function (com.ramussoft.pb.Function)10 Row (com.ramussoft.pb.Row)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 FRectangle (com.dsoft.pb.types.FRectangle)7 Attribute (com.ramussoft.common.Attribute)7 Qualifier (com.ramussoft.common.Qualifier)7 Point (com.ramussoft.pb.idef.elements.Point)7 Crosspoint (com.ramussoft.pb.Crosspoint)6 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)6 NSector (com.ramussoft.pb.data.negine.NSector)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Element (com.ramussoft.common.Element)4 Sector (com.ramussoft.pb.Sector)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Engine (com.ramussoft.common.Engine)3 DataPlugin (com.ramussoft.pb.DataPlugin)3 PerspectivePoint (com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint)3