Search in sources :

Example 21 with Stream

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

the class MovingArea method arrowCopyVisual.

public void arrowCopyVisual() {
    startUserTransaction();
    PaintSector.Pin pin = (PaintSector.Pin) activeObject;
    Stream stream = pin.getSector().getStream();
    Row[] oRows = stream.getAdded();
    byte[] bs = pin.getSector().getSector().getVisualAttributes();
    for (Sector f : dataPlugin.getAllSectors()) if (f.getStream() != null && f.getStream().getAdded() != null) {
        Row[] rows = f.getStream().getAdded();
        boolean b = false;
        for (Row row2 : rows) if (row2 != null) {
            if (b)
                break;
            for (Row row3 : oRows) if (row3.equals(row2)) {
                f.setVisualAttributes(bs);
                b = true;
                break;
            }
        }
    }
    refactor.setUndoPoint();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 22 with Stream

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

the class MovingArea method joinArrows.

public void joinArrows() {
    List<Row> rows = mouseSelection.getSelectedArrowsAddedRows();
    Row[] array = rows.toArray(new Row[rows.size()]);
    startUserTransaction();
    List<MovingLabel> pss = new ArrayList<MovingLabel>();
    for (int i = 1; i < mouseSelection.getLabels().size(); i++) pss.add(mouseSelection.getLabels().get(i));
    mouseSelection.getLabels().removeAll(pss);
    for (MovingLabel ml : pss) ml.getSector().remove();
    PaintSector sector = mouseSelection.getLabels().get(0).getSector();
    Stream stream = sector.getStream();
    if (stream == null) {
        stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
        stream.setRows(array);
        sector.setStream(stream, ReplaceStreamType.SIMPLE);
    }
    sector.setRows(array);
    sector.createTexts();
    HashSet<PaintSector> hashSet = new HashSet();
    sector.getConnectedSector(hashSet);
    for (PaintSector sp : hashSet) PaintSector.save(sp, new DataLoader.MemoryData(), dataPlugin.getEngine());
    getRefactor().setUndoPoint();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData) ArrayList(java.util.ArrayList) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) HashSet(java.util.HashSet)

Example 23 with Stream

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

the class MovingArea method removeLevel.

/**
 * Метод, який видяляє рівень з функціонального блоку
 */
public void removeLevel() {
    final Function f = ((MovingFunction) getActiveObject()).getFunction();
    if (f.getChildCount() != 1) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionHaveNotOneChild"));
        return;
    }
    Vector<Row> childs = dataPlugin.getChilds(f, true);
    if (childs.size() != 1)
        return;
    final Function c = (Function) childs.get(0);
    if (f.isLocked() || c.isLocked()) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionIsLocked"));
        return;
    }
    if (!checkRemoveLevelFunction(c)) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.removingLevelSectorError"));
        return;
    }
    if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("MovingArea.removingLevelWarning"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
        return;
    f.lock();
    c.lock();
    startUserTransaction();
    Vector<Sector> sectors = new Vector<Sector>(f.getSectors());
    for (int i = 0; i < sectors.size(); i++) {
        final Sector sector = sectors.get(i);
        Crosspoint opp;
        Crosspoint crosspoint;
        if (c.equals(sector.getStart().getFunction())) {
            opp = sector.getStart().getCrosspoint();
            crosspoint = sector.getEnd().getCrosspoint();
        } else {
            opp = sector.getEnd().getCrosspoint();
            crosspoint = sector.getStart().getCrosspoint();
        }
        Sector o = null;
        final Sector[] os = opp.getOppozite(sector);
        for (final Sector s : os) o = s;
        class X {

            int createState;

            double createPos;

            Stream stream;

            byte[] visual;

            int sBorderType;

            int eBorderType;
        }
        X x = null;
        if (o != null && (o.getStart().getCrosspoint() == null || o.getEnd().getCrosspoint() == null)) {
            x = new X();
            x.createState = o.getCreateState();
            x.createPos = o.getCreatePos();
            x.stream = o.getStream();
            x.visual = o.getVisualAttributes();
            x.sBorderType = o.getStart().getBorderType();
            x.eBorderType = o.getEnd().getBorderType();
        }
        sector.remove();
        if (x != null) {
            o = dataPlugin.createSector();
            o.setCreateState(x.createState, x.createPos);
            ((AbstractSector) o).setThisStream(x.stream);
            o.setVisualAttributes(x.visual);
            o.setFunction(c);
            o.getStart().setBorderTypeA(x.sBorderType);
            o.getEnd().setBorderTypeA(x.eBorderType);
            o.getStart().commit();
            o.getEnd().commit();
        }
        if (o != null) {
            if (c.equals(sector.getStart().getFunction())) {
                o.getEnd().setCrosspointA(crosspoint);
                o.getEnd().commit();
            } else {
                o.getStart().setCrosspointA(crosspoint);
                o.getEnd().commit();
            }
        }
    }
    sectors = new Vector<Sector>(c.getSectors());
    for (int i = 0; i < sectors.size(); i++) {
        final Sector sector = sectors.get(i);
        sector.setFunction(f);
    }
    f.setSectorData(c.getSectorData());
    c.setSectorData(new byte[0]);
    childs = dataPlugin.getChilds(c, true);
    for (int i = 0; i < childs.size(); i++) {
        final Function c1 = (Function) childs.get(i);
        c1.setParentRow(f);
    }
    c.unlock();
    if (!dataPlugin.removeRow(c)) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.cantRemoveFunctionByRemovingLevel"));
    }
    f.unlock();
    if (panel != null)
        panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
    commitUserTransaction();
}
Also used : PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) Crosspoint(com.ramussoft.pb.Crosspoint) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) DFDSFunction(com.ramussoft.pb.dfds.visual.DFDSFunction) Function(com.ramussoft.pb.Function) DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) AbstractSector(com.ramussoft.pb.data.AbstractSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 24 with Stream

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

the class SectorRefactor method cloneStream.

public static Stream cloneStream(final Stream stream, DataPlugin dataPlugin, Sector sector) {
    if (stream == null)
        return null;
    if (!stream.isEmptyName())
        return stream;
    final Stream res = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
    res.setRows(stream.getAdded());
    res.setEmptyName(true);
    return res;
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Stream(com.ramussoft.pb.Stream)

Example 25 with Stream

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

Aggregations

Stream (com.ramussoft.pb.Stream)51 Row (com.ramussoft.pb.Row)30 Function (com.ramussoft.pb.Function)21 Sector (com.ramussoft.pb.Sector)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 NSector (com.ramussoft.pb.data.negine.NSector)14 Vector (java.util.Vector)13 InputStream (java.io.InputStream)11 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Crosspoint (com.ramussoft.pb.Crosspoint)9 NFunction (com.ramussoft.pb.data.negine.NFunction)9 OutputStream (java.io.OutputStream)7 NStream (com.ramussoft.pb.data.negine.NStream)6 ArrayList (java.util.ArrayList)6 FloatPoint (com.dsoft.pb.types.FloatPoint)4 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)4 MovingFunction (com.ramussoft.pb.idef.visual.MovingFunction)4 IOException (java.io.IOException)4 FRectangle (com.dsoft.pb.types.FRectangle)3