Search in sources :

Example 41 with Function

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

the class ProjectOptionsPanel method update.

private void update(Function function, boolean updateFonts, boolean updateZoom, double percent, GUIFramework framework) {
    if (!updateFonts && !updateZoom)
        return;
    long id = -1l;
    if (!dataPlugin.getBaseFunction().equals(function)) {
        id = function.getElement().getId();
    }
    framework.propertyChanged(IDEF0TabView.CLOSE, id);
    SectorRefactor sectorRefactor = new SectorRefactor(new MovingArea(dataPlugin, function));
    sectorRefactor.updatePageSize(updateFonts, updateZoom, percent, function);
    Vector<Row> v = dataPlugin.getChilds(function, true);
    for (Row row : v) {
        Function function2 = (Function) row;
        update(function2, updateFonts, updateZoom, percent, framework);
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Function(com.ramussoft.pb.Function) Row(com.ramussoft.pb.Row)

Example 42 with Function

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

Example 43 with Function

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

the class ExportToImagesDialog method onOk.

@Override
protected void onOk() {
    final File dir = new File(directory.getText());
    if (dir.exists()) {
        if (!dir.isDirectory()) {
            JOptionPane.showMessageDialog(this, MessageFormat.format(ResourceLoader.getString("FileIsNotADirectory"), directory.getText()));
        } else {
            for (File file : dir.listFiles()) {
                if (file.isFile()) {
                    if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("DirectoryIsNotEmpty"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
                        return;
                    break;
                }
            }
        }
    } else {
        if (!dir.mkdirs()) {
            JOptionPane.showMessageDialog(this, ResourceLoader.getString("CanNotCreateADirectory"));
        }
    }
    final BusyDialog dialog = new BusyDialog(this, ResourceLoader.getString("ExportingBusy"));
    Thread export = new Thread("Export-to-images") {

        @Override
        public void run() {
            int i = 0;
            int[] js = chackedPanel.getSelected();
            for (Function f : chackedPanel.getSelectedFunctions()) {
                try {
                    String prefix = Integer.toString(js[i] + 1);
                    while (prefix.length() < 2) prefix = "0" + prefix;
                    exportToFile(dir, f, prefix + "_");
                    i++;
                } catch (IOException e) {
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            dialog.setVisible(false);
                        }
                    });
                    JOptionPane.showMessageDialog(ExportToImagesDialog.this, e.getLocalizedMessage());
                    if (Metadata.DEBUG)
                        e.printStackTrace();
                    return;
                }
            }
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    dialog.setVisible(false);
                }
            });
            Options.setString(LAST_IMG_EXPORT_DIRECTORY, directory.getText());
            ExportToImagesDialog.super.onOk();
        }
    };
    export.start();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            if (ExportToImagesDialog.this.isVisible())
                dialog.setVisible(true);
        }
    });
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) IOException(java.io.IOException) BusyDialog(com.ramussoft.gui.common.BusyDialog) File(java.io.File)

Example 44 with Function

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

the class IDEF0ChackedPanel method setFunctionParents.

/**
 * Метод, який виводить в талицю набір тільки тих функцій, що мають дитячі
 * елементи (включно з базовою фунцією "Роботи", якщо вона має дочірні
 * елементи).
 */
public void setFunctionParents(DataPlugin dataPlugin) {
    final Function base = dataPlugin.getBaseFunction();
    final Vector<Function> res = new Vector<Function>();
    if (base.isHaveChilds())
        res.add(base);
    final Vector<Row> v = dataPlugin.getRecChilds(base, true);
    for (int i = 0; i < v.size(); i++) if (((Function) v.get(i)).isHaveRealChilds())
        res.add((Function) v.get(i));
    setFunctions(convert(res));
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 45 with Function

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

the class IDEF0ChackedPanel method setFunctionAll.

/**
 * Метод, який виводить в таблицю набір усіх функцій (включно з базовою
 * фунцією "Роботи").
 */
public void setFunctionAll(DataPlugin dataPlugin) {
    final Function base = dataPlugin.getBaseFunction();
    final Vector<Row> v = dataPlugin.getRecChilds(base, true);
    final Function[] functions = new Function[v.size() + 1];
    functions[0] = base;
    for (int i = 0; i < v.size(); i++) functions[i + 1] = (Function) v.get(i);
    setFunctions(functions);
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Row(com.ramussoft.pb.Row)

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