Search in sources :

Example 36 with Function

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

the class MovingArea method copyDFDSVisual.

protected void copyDFDSVisual() {
    startUserTransaction();
    DFDSRole role = (DFDSRole) activeObject;
    VisualPanelImpl panelImpl = new VisualPanelImpl(role);
    Stream stream = role.getStream();
    Row[] oRows = stream.getAdded();
    for (Row row : dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true)) if (row instanceof Function) {
        final Function f = (Function) row;
        if (f.getType() == Function.TYPE_DFDS_ROLE && f.getElement().getId() != role.getFunction().getElement().getId()) {
            long l = f.getLink();
            if (l >= 0) {
                Stream s = (Stream) dataPlugin.findRowByGlobalId(l);
                if (s != null && s.getAdded() != null) {
                    Row[] rows = s.getAdded();
                    boolean b = false;
                    for (Row row2 : rows) if (row2 != null) {
                        if (b)
                            break;
                        for (Row row3 : oRows) if (row3.equals(row2)) {
                            panelImpl.copyTo(new VisualPanel() {

                                @Override
                                public void setForegroundA(Color foreground) {
                                    f.setForeground(foreground);
                                }

                                @Override
                                public void setFontA(Font font) {
                                    f.setFont(font);
                                }

                                @Override
                                public void setBoundsA(FRectangle bounds) {
                                    f.setBounds(bounds);
                                }

                                @Override
                                public void setBackgroundA(Color background) {
                                    f.setBackground(background);
                                }

                                @Override
                                public Color getForegroundA() {
                                    return f.getForeground();
                                }

                                @Override
                                public Font getFontA() {
                                    return f.getFont();
                                }

                                @Override
                                public FRectangle getBoundsA() {
                                    return f.getBounds();
                                }

                                @Override
                                public Color getBackgroundA() {
                                    return f.getBackground();
                                }
                            }, copyOptions.copyBK, copyOptions.copyFK, copyOptions.copyFont, copyOptions.copySize);
                            b = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    commitUserTransaction();
}
Also used : DFDSRole(com.ramussoft.pb.dfds.visual.DFDSRole) 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) FRectangle(com.dsoft.pb.types.FRectangle) Color(java.awt.Color) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Font(java.awt.Font)

Example 37 with Function

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

the class MovingArea method down.

/**
 * Мотод показує контекстну діаграму активного функціонального блоку, якщо
 * на поточній діаграмі всього один функціональний блок то показується його
 * контекстна діаграма.
 */
public void down() {
    Function function = null;
    if (activeFunction.getRealChildCount() == 1)
        function = ((Function) activeFunction).getRealChildAt(0);
    else if (activeObject instanceof MovingFunction) {
        function = ((MovingFunction) activeObject).getFunction();
    }
    if ((function != null) && (function.getType() < Function.TYPE_EXTERNAL_REFERENCE)) {
        if (function.getRealChildCount() == 0) {
            if (panel.isReadOnly())
                return;
            panel.getFramework().setOpenDynamikViewEvent(panel.getView().getOpenAction());
            ContextMasterDialog contextMasterDialog = panel.getContextMasterDialog();
            contextMasterDialog.setDecompositionType(activeFunction.getDecompositionType());
            final Template model = contextMasterDialog.showModal();
            panel.getFramework().setOpenDynamikViewEvent(null);
            int type = contextMasterDialog.getDecompositionType();
            if (model != null) {
                startUserTransaction();
                function.setDecompositionType(type);
                refactor.saveToFunction();
                model.createChilds(function, dataPlugin);
                setActiveFunction(function);
                refactor.fixNoNameBug();
                refactor.saveToFunction();
                if (isUserTransactionStarted())
                    commitUserTransaction();
            }
        } else
            setActiveFunction(function);
        panel.getJPanel3().repaint();
    }
    pressedPanel = null;
}
Also used : 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) ContextMasterDialog(com.ramussoft.pb.idef.frames.ContextMasterDialog) 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) UserTemplate(com.ramussoft.pb.dmaster.UserTemplate) Template(com.ramussoft.pb.dmaster.Template)

Example 38 with Function

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

the class MovingArea method canAddOnContext.

private boolean canAddOnContext() {
    if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFD || activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS)
        return true;
    if (getActiveFunction() == dataPlugin.getBaseFunction()) {
        Function function = getActiveFunction();
        int cc = function.getChildCount();
        if (cc == 0)
            return true;
        for (int i = 0; i < cc; i++) {
            Function c = (Function) function.getChildAt(i);
            if (c.getType() < Function.TYPE_EXTERNAL_REFERENCE)
                return false;
        }
    }
    return true;
}
Also used : 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) 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)

Example 39 with Function

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

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

the class IDEFPanel method setFunctionType.

protected void setFunctionType(final int type) {
    movingArea.startUserTransaction();
    final Function function = ((MovingFunction) movingArea.getActiveObject()).getFunction();
    function.setType(type);
    switch(type) {
        case Function.TYPE_ACTION:
            {
                getJRadioButtonMenuItemAction().setSelected(true);
                frame.getJMenuItemAction().setSelected(true);
            }
            break;
        case Function.TYPE_OPERATION:
            {
                getJRadioButtonMenuItemOperation().setSelected(true);
                frame.getJMenuItemOperation().setSelected(true);
            }
            break;
        case Function.TYPE_PROCESS_PART:
            {
                getJRadioButtonMenuItemProcessPart().setSelected(true);
                frame.getJMenuItemProcessPart().setSelected(true);
            }
            break;
        case Function.TYPE_PROCESS:
            {
                getJRadioButtonMenuItemProcess().setSelected(true);
                frame.getJMenuItemProcess().setSelected(true);
            }
            break;
        case Function.TYPE_PROCESS_KOMPLEX:
            {
                getJRadioButtonMenuItemKomplex().setSelected(true);
                frame.getJMenuItemKomplex().setSelected(true);
            }
            break;
    }
    movingArea.commitUserTransaction();
}
Also used : MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction)

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