Search in sources :

Example 51 with Row

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

the class SectorRefactor method fillFromOwners.

private static void fillFromOwners(Function function, DataPlugin dataPlugin) {
    Function par = (Function) function.getParent();
    if (par == null)
        return;
    Vector<Sector> ends = new Vector<Sector>();
    Vector<Sector> starts = new Vector<Sector>();
    for (Sector sector : par.getSectors()) {
        NSectorBorder start = sector.getStart();
        if (function.equals(start.getFunction()) && start.getCrosspoint() != null) {
            if (start.getCrosspoint().isDLevel()) {
                for (Sector sector2 : start.getCrosspoint().getOppozite(sector)) starts.add(sector2);
            }
        }
        NSectorBorder end = sector.getEnd();
        if (function.equals(end.getFunction()) && end.getCrosspoint() != null) {
            if (end.getCrosspoint().isDLevel()) {
                for (Sector sector2 : end.getCrosspoint().getOppozite(sector)) ends.add(sector2);
            }
        }
    }
    if (ends.size() == 0 && starts.size() == 0)
        return;
    HashSet<Row> owners = new HashSet<Row>();
    boolean[] hasFunctionOwners = new boolean[] { false };
    for (Sector sector : starts) fillStartFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
    for (Sector sector : ends) fillEndFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
    if (!hasFunctionOwners[0] && owners.size() == 0)
        return;
    Stream stream = (Stream) dataPlugin.findRowByGlobalId(function.getLink());
    if (stream == null) {
        if (owners.size() > 0) {
            stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            function.setLink(stream.getElement().getId());
            stream.setRows(owners.toArray(new Row[owners.size()]));
        }
    } else {
        stream.setRows(owners.toArray(new Row[owners.size()]));
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSectorBorder(com.ramussoft.pb.data.negine.NSectorBorder) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector) HashSet(java.util.HashSet)

Example 52 with Row

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

the class IDEF0ChackedPanel method setFunctionParents.

/**
 * Метод, який виводить в талицю набір тільки тих функцій, що мають дитячі
 * елементи (включно з базовою фунцією "Роботи", якщо вона має дочірні
 * елементи).
 */
public void setFunctionParents(DataPlugin dataPlugin) {
    final Function base = dataPlugin.getBaseFunction();
    final Vector<Function> res = new Vector<Function>();
    if (base.isHaveChilds())
        res.add(base);
    final Vector<Row> v = dataPlugin.getRecChilds(base, true);
    for (int i = 0; i < v.size(); i++) if (((Function) v.get(i)).isHaveRealChilds())
        res.add((Function) v.get(i));
    setFunctions(convert(res));
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 53 with Row

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

the class IDEF0ChackedPanel method setFunctionAll.

/**
 * Метод, який виводить в таблицю набір усіх функцій (включно з базовою
 * фунцією "Роботи").
 */
public void setFunctionAll(DataPlugin dataPlugin) {
    final Function base = dataPlugin.getBaseFunction();
    final Vector<Row> v = dataPlugin.getRecChilds(base, true);
    final Function[] functions = new Function[v.size() + 1];
    functions[0] = base;
    for (int i = 0; i < v.size(); i++) functions[i + 1] = (Function) v.get(i);
    setFunctions(functions);
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Row(com.ramussoft.pb.Row)

Example 54 with Row

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

the class ArrowOptionstDialog method showModal.

public void showModal(final PaintSector sector, MovingArea movingArea) {
    isOk = false;
    Options.loadOptions("select_row", this);
    Options.saveOptions("select_row", this);
    sectorRowsEditor.setSector(sector.getSector());
    sectorNameEditor.setSector(sector.getSector());
    sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
    getColorChooser16().setColor(sector.getColor());
    getJFontChooser().setSelFont(sector.getFont());
    final Stream s = sector.getStream();
    loadFrom(s);
    lineStyleChooser.setStroke(sector.getStroke());
    sectorNameEditor.beforeShow();
    Options.loadOptions("select_row", this);
    setVisible(true);
    if (isOk) {
        ((NSector) sector.getSector()).getDataPlugin().startUserTransaction();
        sector.setFont(getJFontChooser().getSelFont());
        sector.setColor(getColorChooser16().getColor());
        sector.setStroke(lineStyleChooser.getStroke());
        if (lineStyleChooser.isDefaultArrowStyle()) {
            Options.setStroke("DEFAULT_ARROW_STROKE", lineStyleChooser.getStroke());
        }
        sector.copyVisual(Sector.VISUAL_COPY_ADDED);
        sector.setShowText(sectorNameEditor.getBox().isSelected());
        sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
        sector.getSector().setTextAligment(sectorNameEditor.getTextAligment());
        Stream stream = sectorRowsEditor.getStream();
        if (stream == null) {
            stream = sectorNameEditor.findStreamByName();
            if (stream == null) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            }
        }
        final String t = sectorNameEditor.getArrowName();
        if (!t.equals("")) {
            if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
            }
        }
        if (t.equals("")) {
            if (!stream.isEmptyName()) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                stream.setEmptyName(true);
            }
        } else {
            stream.setName(t);
        }
        final Row[] added = stream.getAdded();
        stream.setRows(sectorRowsEditor.getRows());
        sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
        stream = sector.getStream();
        stream.setRows(added);
        saveTo(stream);
        // sector.setStreamAddedByRefactor(false);
        final Row[] rs = sectorRowsEditor.getRows();
        sector.setRows(rs);
        sector.createTexts();
        HashSet<PaintSector> hashSet = new HashSet();
        sector.getConnectedSector(hashSet);
        for (PaintSector sp : hashSet) PaintSector.save(sp, new DataLoader.MemoryData(), dataPlugin.getEngine());
        movingArea.getRefactor().setUndoPoint();
    }
    saveOption();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) HashSet(java.util.HashSet)

Example 55 with Row

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

the class SectorNameEditor method findStreamByName.

public Stream findStreamByName(final String name) {
    if ("".equals(name))
        return null;
    final Vector<Row> streams = dataPlugin.getRecChilds(dataPlugin.getBaseStream(), true);
    final int l = streams.size();
    for (int i = 0; i < l; i++) {
        final Stream s = (Stream) streams.get(i);
        if (name.equals(s.getName()) && !s.isEmptyName())
            return s;
    }
    return null;
}
Also used : Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Aggregations

Row (com.ramussoft.pb.Row)93 Function (com.ramussoft.pb.Function)35 Stream (com.ramussoft.pb.Stream)30 Vector (java.util.Vector)28 NFunction (com.ramussoft.pb.data.negine.NFunction)19 Sector (com.ramussoft.pb.Sector)15 NRow (com.ramussoft.pb.data.negine.NRow)14 Qualifier (com.ramussoft.common.Qualifier)13 Crosspoint (com.ramussoft.pb.Crosspoint)13 NSector (com.ramussoft.pb.data.negine.NSector)13 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ArrayList (java.util.ArrayList)11 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)10 Attribute (com.ramussoft.common.Attribute)9 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)9 IOException (java.io.IOException)9 FloatPoint (com.dsoft.pb.types.FloatPoint)8 Point (com.ramussoft.pb.idef.elements.Point)8 Element (com.ramussoft.common.Element)7