Search in sources :

Example 6 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSFunction method onEndBoundsChange.

@Override
public void onEndBoundsChange() {
    FRectangle oldRec = function.getBounds();
    if (oldRec.equals(myBounds))
        return;
    final SectorRefactor refactor = movingArea.getRefactor();
    ((NRow) function).startUserTransaction();
    onProcessEndBoundsChange();
    refactor.setUndoPoint();
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) FRectangle(com.dsoft.pb.types.FRectangle) NRow(com.ramussoft.pb.data.negine.NRow)

Example 7 with FRectangle

use of com.dsoft.pb.types.FRectangle 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 8 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class DFDSRole method replaceFunction.

private void replaceFunction(NSectorBorder border, PaintSector paintSector, List<PaintSector> list, Point point, int functionType, DFDSFunction function, SectorRefactor refactor, boolean start) {
    FRectangle bounds = function.getBounds();
    FRectangle thisBounds = this.function.getBounds();
    border.setFunctionA(function.getFunction());
    border.commit();
    if (!list.contains(paintSector))
        list.add(paintSector);
    double p;
    double inPos = 0;
    switch(functionType) {
        case MovingText.LEFT:
            point.setX(bounds.getX());
            p = (point.getY() - thisBounds.getY()) / thisBounds.getHeight();
            point.setY(bounds.getY() + bounds.getHeight() * p);
            inPos = point.getY();
            break;
        case MovingText.RIGHT:
            point.setX(bounds.getRight());
            p = (point.getY() - thisBounds.getY()) / thisBounds.getHeight();
            point.setY(bounds.getY() + bounds.getHeight() * p);
            inPos = point.getY();
            break;
        case MovingText.TOP:
            p = (point.getX() - thisBounds.getX()) / thisBounds.getWidth();
            point.setX(bounds.getX() + bounds.getWidth() * p);
            point.setY(bounds.getY());
            inPos = point.getX();
            break;
        case MovingText.BOTTOM:
            p = (point.getX() - thisBounds.getX()) / thisBounds.getWidth();
            point.setX(bounds.getX() + bounds.getWidth() * p);
            point.setY(bounds.getBottom());
            inPos = point.getX();
            break;
    }
    refactor.createPartIn(border.getCrosspoint(), function.getFunction(), functionType, inPos, !start);
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle)

Example 9 with FRectangle

use of com.dsoft.pb.types.FRectangle 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 10 with FRectangle

use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.

the class NFunction method setDefaultValues.

public void setDefaultValues() {
    boolean inTransaction = false;
    if (engine instanceof Journaled) {
        inTransaction = ((Journaled) engine).isUserTransactionStarted();
        if (!inTransaction)
            ((Journaled) engine).startUserTransaction();
    }
    setSectorData(new byte[0]);
    setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
    setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
    setBounds(new FRectangle(IDEFPanel.DEFAULT_X, IDEFPanel.DEFAULT_Y, IDEFPanel.DEFAULT_WIDTH * 1.2, IDEFPanel.DEFAULT_HEIGHT * 1.2));
    setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 10)));
    setStatus(new Status());
    if (engine instanceof Journaled)
        if (!inTransaction)
            ((Journaled) engine).commitUserTransaction();
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Journaled(com.ramussoft.common.journal.Journaled) FRectangle(com.dsoft.pb.types.FRectangle) Font(java.awt.Font)

Aggregations

FRectangle (com.dsoft.pb.types.FRectangle)39 FloatPoint (com.dsoft.pb.types.FloatPoint)11 NFunction (com.ramussoft.pb.data.negine.NFunction)11 Rectangle2D (java.awt.geom.Rectangle2D)10 Function (com.ramussoft.pb.Function)9 Point (com.ramussoft.pb.idef.elements.Point)7 BasicStroke (java.awt.BasicStroke)6 Stroke (java.awt.Stroke)6 Line2D (java.awt.geom.Line2D)6 ArrayList (java.util.ArrayList)6 Crosspoint (com.ramussoft.pb.Crosspoint)5 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)5 Row (com.ramussoft.pb.Row)4 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)4 Font (java.awt.Font)4 MemoryData (com.dsoft.utils.DataLoader.MemoryData)3 Stream (com.ramussoft.pb.Stream)3 DFDSFunction (com.ramussoft.pb.dfds.visual.DFDSFunction)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 Status (com.dsoft.pb.idef.elements.Status)2