Search in sources :

Example 11 with Function

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

the class DFDSFunction method justifyRoles.

public void justifyRoles(List<Function> roles1) {
    FRectangle bounds = getBounds();
    List<Function> roles = new ArrayList<Function>();
    for (Function role : roles1) if (bounds.intersects(role.getBounds()))
        roles.add(role);
    List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
    lines.add(new ArrayList<FRectangle>());
    List<double[]> maxHights = new ArrayList<double[]>();
    maxHights.add(new double[] { 0 });
    int line = 0;
    double x = bounds.getX() + 2;
    double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
    for (Function role : roles) {
        FRectangle rectangle = role.getBounds();
        if (x + rectangle.getWidth() > maxX) {
            line++;
            lines.add(new ArrayList<FRectangle>());
            x = bounds.getX() + 2;
            maxHights.add(new double[] { 0 });
        }
        List<FRectangle> list = lines.get(line);
        FRectangle rect = role.getBounds();
        list.add(rect);
        rect.setX(x);
        if (rect.getHeight() > maxHights.get(line)[0])
            maxHights.get(line)[0] = rect.getHeight();
        x += rect.getWidth() + 3;
    }
    double d = maxHights.get(line)[0];
    double y = bounds.getBottom() - d - 2;
    for (int i = line; i >= 0; --i) {
        List<FRectangle> rectangles = lines.get(i);
        for (FRectangle rectangle : rectangles) rectangle.setY(y);
        if (i > 0)
            y -= maxHights.get(i - 1)[0];
    }
    int i = 0;
    for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
        roles.get(i).setBounds(new FRectangle(rectangle));
        i++;
    }
}
Also used : DFDFunction(com.ramussoft.pb.dfd.visual.DFDFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) FRectangle(com.dsoft.pb.types.FRectangle) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 12 with Function

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

the class DFDSRole method setStream.

public void setStream(Stream stream, ReplaceStreamType replaceStreamType) {
    function.setLink((stream == null) ? -1 : stream.getElement().getId());
    Function function = (Function) this.function.getOwner();
    if (function != null) {
        HashSet<Sector> toUpdate = new HashSet<Sector>();
        for (Sector sector : ((Function) this.function.getParent()).getSectors()) {
            if (function.equals(sector.getStart().getFunction()) || function.equals(sector.getEnd().getFunction()))
                if (!toUpdate.contains(sector))
                    toUpdate.add(sector);
        }
        for (Sector sector : toUpdate) SectorRefactor.fixOwners(sector, movingArea.dataPlugin);
    } else {
        SectorRefactor.copyOwnersFrom(this.function, movingArea.dataPlugin);
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) HashSet(java.util.HashSet)

Example 13 with Function

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

the class DFDSRole method onProcessEndBoundsChange.

@Override
public void onProcessEndBoundsChange() {
    final FRectangle oldRec = function.getBounds();
    myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
    List<PaintSector> list = new ArrayList<PaintSector>();
    final SectorRefactor refactor = movingArea.getRefactor();
    boolean sectorReplaced = false;
    DFDSFunction function = movingArea.findDFDSFunction(this.getBounds());
    if (function != null) {
        getFunction().setOwner(function.getFunction());
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector ps = refactor.getSector(i);
            Function function2 = ps.getSector().getStart().getFunction();
            if (function2 != null && function2.equals(this.function)) {
                replaceFunction(ps.getSector().getStart(), ps, list, ps.getStartPoint(), ps.getSector().getStart().getFunctionType(), function, refactor, true);
            }
            Function function3 = ps.getSector().getEnd().getFunction();
            if (function3 != null && function3.equals(this.function)) {
                replaceFunction(ps.getSector().getEnd(), ps, list, ps.getEndPoint(), ps.getSector().getEnd().getFunctionType(), function, refactor, false);
            }
        }
        function.justifyRoles();
        sectorReplaced = true;
    } else {
        if (this.getFunction().getOwner() != null) {
            DFDSFunction function2 = movingArea.findDFDSFunction(this.getFunction().getOwner());
            if (function2 != null && function2.getBounds().intersects(this.getBounds())) {
                function2.justifyRoles();
            } else
                this.function.setBounds(new FRectangle(myBounds));
        } else
            this.function.setBounds(new FRectangle(myBounds));
    }
    MemoryData memoryData = new MemoryData();
    if (!sectorReplaced) {
        for (int i = 0; i < refactor.getSectorsCount(); i++) {
            PaintSector sector = refactor.getSector(i);
            setAddedSectorPos(oldRec, sector, list);
        }
    }
    for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) this.function).getEngine());
    long l = this.function.getLink();
    if (l >= 0l) {
        Stream stream = (Stream) movingArea.getDataPlugin().findRowByGlobalId(l);
        if (stream != null) {
            Row[] rows = stream.getAdded();
            RectangleVisualOptions ops = new RectangleVisualOptions();
            ops.bounds = this.function.getBounds();
            ops.background = this.function.getBackground();
            ops.font = this.function.getFont();
            ops.foreground = this.function.getForeground();
            for (Row row : rows) if (row != null) {
                IDEF0Plugin.setDefaultRectangleVisualOptions(movingArea.getDataPlugin().getEngine(), row.getElement(), ops);
            }
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) NFunction(com.ramussoft.pb.data.negine.NFunction) ArrayList(java.util.ArrayList) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) FRectangle(com.dsoft.pb.types.FRectangle) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) MemoryData(com.dsoft.utils.DataLoader.MemoryData) RectangleVisualOptions(com.ramussoft.idef0.attribute.RectangleVisualOptions) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Example 14 with Function

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

the class AbstractClassicTemplate method createInsOuts.

private void createInsOuts(final Function function, final MovingArea movingArea) {
    Function f = (Function) function.getChildAt(0);
    createStartxBorderPoint(movingArea, 10, getY(f), LEFT);
    createInPoint(movingArea, f, LEFT, f.getBounds().getLeft(), getY(f));
    for (int i = 1; i < function.getChildCount(); i++) {
        final Function sF = (Function) function.getChildAt(i);
        createOutPoint(movingArea, f);
        createInPoint(movingArea, sF, LEFT, sF.getBounds().getLeft(), getY(sF));
        f = sF;
    }
    createOutPoint(movingArea, f);
    createRightBorderPoint(movingArea, getY(f));
}
Also used : Function(com.ramussoft.pb.Function) Point(com.ramussoft.pb.idef.elements.Point)

Example 15 with Function

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

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