Search in sources :

Example 71 with Function

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

the class IDLExporter method loadFonts.

private void loadFonts() throws IOException {
    addFont(new Font("Arial", 0, 13));
    addFont(new Font("Arial", 0, 24));
    addFont(new Font("Courier New", 0, 11));
    rec(new FunctionCallback() {

        @Override
        public void call(Function f) {
            addFont(f.getFont());
            SectorRefactor sr = new SectorRefactor(new MovingArea(dataPlugin));
            sr.loadFromFunction(f, false);
            for (int i = 0; i < sr.getSectorsCount(); i++) {
                PaintSector ps = sr.getSector(i);
                addFont(ps.getFont());
            }
        }
    }, false);
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Font(java.awt.Font)

Example 72 with Function

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

the class MovingArea method addLevel.

/**
 * Метод, який додає рівень до активного функціонального блоку на моделі,
 * контекст функціонального блоку заміняється на новий функціональний блок з
 * контекстом, який мав активний функціональний блок.
 */
public synchronized void addLevel() {
    final Function f = ((MovingFunction) getActiveObject()).getFunction();
    if (f.isLocked()) {
        JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionIsLocked"));
        return;
    }
    if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("MovingArea.addingLevelWarning"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
        return;
    f.lock();
    final Vector<Row> childs = dataPlugin.getChilds(f, true);
    final Function n = (Function) dataPlugin.createRow(f, true);
    n.setSectorData(f.getSectorData());
    n.setBounds(f.getBounds());
    n.setBackground(f.getBackground());
    n.setForeground(f.getForeground());
    n.setName(f.getName());
    n.setDecompositionType(f.getDecompositionType());
    n.setType(f.getType());
    f.setName(f.getName() + " (" + ResourceLoader.getString("MovingArea.context") + ")");
    n.setFont(f.getFont());
    f.setSectorData(new byte[0]);
    final SectorRefactor r = new SectorRefactor(this);
    // .getBounds().getHeight()));
    for (int i = 0; i < childs.size(); i++) {
        final Function c = (Function) childs.get(i);
        c.setParentRow(n);
    }
    Vector srs = new Vector(f.getSectors());
    for (int i = 0; i < srs.size(); i++) {
        final Sector sector = (Sector) srs.get(i);
        sector.setFunction(n);
    // System.out.println(sector.getFunction());
    }
    final Function p = (Function) f.getParent();
    srs = p.getSectors();
    final int[] cnts = new int[4];
    final double[] poses = new double[4];
    final double[] hs = new double[4];
    for (int i = 0; i < cnts.length; i++) cnts[i] = 0;
    for (int i = 0; i < srs.size(); i++) {
        final Sector sector = (Sector) srs.get(i);
        if (f.equals(sector.getStart().getFunction())) {
            cnts[MovingPanel.RIGHT]++;
        }
        if (f.equals(sector.getEnd().getFunction())) {
            cnts[sector.getEnd().getFunctionType()]++;
        }
    }
    for (int i = 0; i < cnts.length; i++) {
        if (cnts[i] > 0) {
            if (i == MovingPanel.LEFT || i == MovingPanel.RIGHT)
                hs[i] = n.getBounds().getHeight() / cnts[i];
            else
                hs[i] = n.getBounds().getWidth() / cnts[i];
        }
        poses[i] = hs[i] / 2.0d;
    }
    for (int i = 0; i < srs.size(); i++) {
        final Sector sector = (Sector) srs.get(i);
        if (f.equals(sector.getStart().getFunction())) {
            final Crosspoint c = sector.getStart().getCrosspoint();
            final Sector[] ss = c.getOppozite(sector);
            Sector so = null;
            for (final Sector element : ss) {
                so = element;
            }
            final Sector s = dataPlugin.createSector();
            ((AbstractSector) s).setThisStream(SectorRefactor.cloneStream(sector.getStream(), dataPlugin, s));
            s.setVisualAttributes(sector.getVisualAttributes());
            s.setFunction(f);
            final Ordinate x1 = new Ordinate(Ordinate.TYPE_X);
            final Ordinate x2 = new Ordinate(Ordinate.TYPE_X);
            x1.setPosition(n.getBounds().getX() + n.getBounds().getWidth());
            x2.setPosition(getDoubleWidth() - PART_SPACE);
            final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
            y.setPosition(n.getBounds().getY() + poses[MovingPanel.RIGHT]);
            poses[MovingPanel.RIGHT] += hs[MovingPanel.RIGHT];
            final Point p1 = new Point(x1, y);
            final Point p2 = new Point(x2, y);
            final PaintSector ps = new PaintSector(s, p1, p2, this);
            r.addSector(ps);
            final Crosspoint cp = dataPlugin.createCrosspoint();
            if (so != null) {
                so.getEnd().setCrosspointA(cp);
                so.getEnd().commit();
            }
            s.getEnd().setCrosspointA(c);
            s.getStart().setCrosspointA(cp);
            s.getStart().setFunctionA(n);
            s.getStart().setFunctionTypeA(MovingPanel.RIGHT);
            s.getEnd().setBorderTypeA(MovingPanel.RIGHT);
            s.getStart().commit();
            s.getEnd().commit();
        }
        if (f.equals(sector.getEnd().getFunction())) {
            final int et = sector.getEnd().getFunctionType();
            final Crosspoint c = sector.getEnd().getCrosspoint();
            final Sector[] ss = c.getOppozite(sector);
            Sector so = null;
            for (final Sector element : ss) {
                so = element;
                so.setFunction(n);
            }
            final Sector s = dataPlugin.createSector();
            ((AbstractSector) s).setThisStream(SectorRefactor.cloneStream(sector.getStream(), dataPlugin, s));
            s.setVisualAttributes(sector.getVisualAttributes());
            s.setFunction(f);
            if (et == MovingPanel.LEFT) {
                final Ordinate x1 = new Ordinate(Ordinate.TYPE_X);
                final Ordinate x2 = new Ordinate(Ordinate.TYPE_X);
                x2.setPosition(n.getBounds().getX());
                x1.setPosition(PART_SPACE);
                final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
                y.setPosition(n.getBounds().getY() + poses[et]);
                final Point p1 = new Point(x1, y);
                final Point p2 = new Point(x2, y);
                final PaintSector ps = new PaintSector(s, p1, p2, this);
                r.addSector(ps);
            } else if (et == MovingPanel.TOP) {
                final Ordinate y1 = new Ordinate(Ordinate.TYPE_Y);
                final Ordinate y2 = new Ordinate(Ordinate.TYPE_Y);
                y2.setPosition(n.getBounds().getY());
                y1.setPosition(PART_SPACE);
                final Ordinate x = new Ordinate(Ordinate.TYPE_X);
                x.setPosition(n.getBounds().getX() + poses[et]);
                final Point p1 = new Point(x, y1);
                final Point p2 = new Point(x, y2);
                final PaintSector ps = new PaintSector(s, p1, p2, this);
                r.addSector(ps);
            } else if (et == MovingPanel.BOTTOM) {
                final Ordinate y1 = new Ordinate(Ordinate.TYPE_Y);
                final Ordinate y2 = new Ordinate(Ordinate.TYPE_Y);
                y2.setPosition(n.getBounds().getY() + n.getBounds().getHeight());
                y1.setPosition(PART_SPACE + getDoubleHeight());
                final Ordinate x = new Ordinate(Ordinate.TYPE_X);
                x.setPosition(n.getBounds().getX() + poses[et]);
                final Point p1 = new Point(x, y1);
                final Point p2 = new Point(x, y2);
                final PaintSector ps = new PaintSector(s, p1, p2, this);
                r.addSector(ps);
            }
            poses[et] += hs[et];
            final Crosspoint cp = dataPlugin.createCrosspoint();
            if (so != null) {
                so.getStart().setCrosspointA(cp);
                so.setFunction(n);
                so.getStart().commit();
            }
            s.getStart().setCrosspointA(c);
            s.getEnd().setCrosspointA(cp);
            s.getEnd().setFunctionA(n);
            s.getEnd().setFunctionTypeA(et);
            s.getStart().setBorderTypeA(et);
            s.getStart().commit();
            s.getEnd().commit();
        }
    }
    r.saveToFunction(f);
    if (panel != null)
        panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
    ((NFunction) f).clearSectorsBuffer();
    f.unlock();
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) NFunction(com.ramussoft.pb.data.negine.NFunction) 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) PerspectivePoint(com.ramussoft.pb.idef.elements.SectorRefactor.PerspectivePoint) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) 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) Ordinate(com.ramussoft.pb.idef.elements.Ordinate) 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) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 73 with Function

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

the class MovingArea method createLevel.

public void createLevel() {
    if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("MovingArea.addingLevelWarning"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
        return;
    final SectorRefactor r = new SectorRefactor(this);
    r.loadFromFunction(activeFunction, false);
    startUserTransaction();
    Function f = activeFunction;
    final Vector<Row> childs = dataPlugin.getChilds(f, true);
    NFunction n = (NFunction) dataPlugin.createRow(f, true);
    n.setSectorData(f.getSectorData());
    n.setBounds(f.getBounds());
    n.setBackground(f.getBackground());
    n.setForeground(f.getForeground());
    n.setName(f.getName());
    n.setDecompositionType(f.getDecompositionType());
    n.setType(f.getType());
    // f.setName(f.getName() + " ("
    // + ResourceLoader.getString("MovingArea.context") + ")");
    n.setFont(f.getFont());
    f.setSectorData(new byte[0]);
    for (int i = 0; i < childs.size(); i++) {
        final Function c = (Function) childs.get(i);
        c.setParentRow(n);
    }
    for (int i = 0; i < r.getSectorsCount(); i++) r.getSector(i).getSector().setFunction(n);
    ((NFunction) f).clearSectorsBuffer();
    commitUserTransaction();
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) 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) NFunction(com.ramussoft.pb.data.negine.NFunction) 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)

Example 74 with Function

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

the class MovingArea method createFunctionalObject.

public Function createFunctionalObject(final double dX, final double dY, int type, Function activeFunction) {
    final Function function = (Function) dataPlugin.createFunction(activeFunction, type);
    function.setBounds(new FRectangle(dX, dY, function.getBounds().getWidth(), function.getBounds().getHeight()));
    function.setCreateDate(new Date());
    function.setSystemRevDate(new Date());
    if (type == Function.TYPE_DATA_STORE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(rect.getHeight() / 2);
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_DATA_STORE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_DATA_STORE_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_DATA_STORE_TEXT_COLOR", Color.black));
    } else if (type == Function.TYPE_EXTERNAL_REFERENCE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(12);
        rect.setWidth(20);
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_EXTERNAL_REFERENCE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_EXTERNAL_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_EXTERNAL_TEXT_COLOR", Color.black));
    } else if (type == Function.TYPE_DFDS_ROLE) {
        FRectangle rect = function.getBounds();
        rect.setHeight(Options.getInteger("DEFAULT_DFDS_ROLE_HEIGHT", 12));
        rect.setWidth(Options.getInteger("DEFAULT_DFDS_ROLE_WIDTH", 20));
        function.setBounds(rect);
        function.setFont(Options.getFont("DEFAULT_DFDS_ROLE_FONT", new Font("Dialog", Font.BOLD, 8)));
        function.setBackground(Options.getColor("DEFAULT_DFDS_ROLE_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULT_DFDS_ROLE_TEXT_COLOR", Color.black));
    } else {
        function.setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 12)));
        function.setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
        function.setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
    }
    return function;
}
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) FRectangle(com.dsoft.pb.types.FRectangle) Date(java.util.Date) Font(java.awt.Font)

Example 75 with Function

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

the class MovingArea method silentRefresh.

public void silentRefresh(Function function) {
    bImage = null;
    Object object = getActiveObject();
    Function function2 = null;
    if (object instanceof IDEF0Object) {
        function2 = ((IDEF0Object) object).getFunction();
    }
    activeFunction = function;
    refactor.loadFromFunction(getActiveFunction(), false);
    panel.setMovingActiveFunction(function);
    setPanels();
    if (!(this.activeObject instanceof PaintSector.Pin))
        this.activeObject = null;
    this.pressedPanel = null;
    repaintAsync();
    if (function2 != null)
        for (MovingText text : panels) {
            if (text instanceof IDEF0Object) {
                if (((IDEF0Object) text).getFunction().equals(function2)) {
                    this.pressedPanel = text;
                    text.focusGained(true);
                    setActiveObject(text, true);
                    break;
                }
            }
        }
}
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) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) DFDObject(com.ramussoft.pb.dfd.visual.DFDObject)

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