Search in sources :

Example 81 with Function

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

the class MovingArea method checkRemoveLevelFunction.

/**
 * Метод перевіряє, чи правильно розташовані сектори, щоб функціональний
 * блок міг бути видалений.
 *
 * @param context Функціональний блок, який має бути видалений.
 * @return <code>true</code>, якщо функціональний блок може бути видалений,
 * <code>false</code>, якщо функціональний блок не може бути
 * видалений.
 */
private boolean checkRemoveLevelFunction(final Function context) {
    final Function f = (Function) context.getParentRow();
    ((NFunction) f).clearSectorsBuffer();
    final Vector<Sector> sectors = f.getSectors();
    for (int i = 0; i < sectors.size(); i++) {
        final Sector sector = sectors.get(i);
        if (context.equals(sector.getStart().getFunction())) {
            if (sector.getEnd().getBorderType() != sector.getStart().getFunctionType())
                return false;
        } else if (context.equals(sector.getEnd().getFunction())) {
            if (sector.getStart().getBorderType() != sector.getEnd().getFunctionType())
                return false;
        } else
            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) 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) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Example 82 with Function

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

the class MovingArea method removeActiveObject.

/**
 * Метод видаляє активний об’єкт.
 */
public boolean removeActiveObject() {
    if (activeObject instanceof IDEF0Object) {
        Function f = ((IDEF0Object) activeObject).getFunction();
        if (f.isRemoveable()) {
            startUserTransaction();
            if (mouseSelection != null && mouseSelection.contains((IDEF0Object) activeObject)) {
                for (Function function : mouseSelection.getFunctions()) {
                    f = function;
                    removeAddedSectors(f);
                    if (dataPlugin.removeRow(f)) {
                        panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
                        panel.getFrame().refreshActions(panel);
                    }
                }
                mouseSelection = null;
                setPanels();
                refactor.setUndoPoint();
                return true;
            }
            removeAddedSectors(f);
            if (dataPlugin.removeRow(f)) {
                setPanels();
                panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
                panel.getFrame().refreshActions(panel);
                refactor.setUndoPoint();
                return true;
            }
            refactor.setUndoPoint();
        }
        return false;
    } else if (activeObject instanceof PaintSector.Pin) {
        startUserTransaction();
        PaintSector sector = ((PaintSector.Pin) activeObject).getSector();
        sector.remove();
        refactor.setUndoPointSaveAll();
        return true;
    } else if (activeObject instanceof MovingText) {
        startUserTransaction();
        refactor.removeText((MovingText) activeObject);
        refactor.setUndoPoint();
        return true;
    } else {
        if (mouseSelection != null && mouseSelection.getFunctions().size() > 0 && mouseSelection.isRemoveable()) {
            startUserTransaction();
            for (Function function : mouseSelection.getFunctions()) {
                removeAddedSectors(function);
                if (dataPlugin.removeRow(function)) {
                    panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
                    panel.getFrame().refreshActions(panel);
                }
            }
            mouseSelection = null;
            setPanels();
            refactor.setUndoPoint();
            return true;
        }
    }
    return false;
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) 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)

Example 83 with Function

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

the class HTMLHelper method getDiagram.

/*
     *
	 * private static final int IMAGE_WIDTH = 850; private static final int
	 * IMAGE_HEIGHT = 738;
	 */
public String getDiagram(final String sId, final String functionController, final String clasificatorController) {
    if (sId == null)
        return null;
    final Row r = dataPlugin.findRowByGlobalId(GlobalId.convert(sId));
    if (r instanceof Function) {
        final Function function = (Function) r;
        final int imageWidth = IMAGE_WIDTH;
        final int imageHeight = IMAGE_HEIGHT;
        final DiagramHolder htmlStream = new DiagramHolder();
        htmlStream.println("<img border=0 width=" + imageWidth + " height=" + imageHeight + " src=\"" + functionController + "idef0/" + function.getGlobalId().toString() + "\" useMap=#M" + function.getGlobalId().toString() + ">");
        htmlStream.println("<map name=M" + function.getGlobalId().toString() + ">");
        final Vector childs = dataPlugin.getChilds(function, true);
        final MovingArea area = PIDEF0painter.createMovingArea(new Dimension(imageWidth, imageHeight), dataPlugin);
        final SectorRefactor refactor = area.getRefactor();
        for (int i = 0; i < childs.size(); i++) {
            final Function fun = (Function) childs.get(i);
            String where;
            if (fun.isLeaf())
                where = clasificatorController;
            else
                where = functionController + "index/";
            htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + where + fun.getGlobalId().toString() + "\"");
            htmlStream.println(">");
        }
        refactor.loadFromFunction(function, false);
        final int sc = refactor.getSectorsCount();
        for (int i = 0; i < sc; i++) {
            final PaintSector sector = refactor.getSector(i);
            final Stream stream = sector.getStream();
            final MovingLabel text = refactor.getSector(i).getText();
            if (text != null && stream != null) {
                htmlStream.print("<area shape=RECT coords=" + getAreaCoords(text.getBounds(), area) + " href=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
                htmlStream.println(">");
            }
            final int l = sector.getPinCount();
            for (int j = 0; j < l; j++) if (stream != null) {
                final Pin pin = sector.getPin(j);
                htmlStream.print("<area shape=RECT coords=" + getPinCoords(pin, area) + " href=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
                htmlStream.println(">");
            }
        }
        htmlStream.println("<map>");
        return htmlStream.toString();
    }
    return null;
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Dimension(java.awt.Dimension) Function(com.ramussoft.pb.Function) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Example 84 with Function

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

the class FastMatrixProjection method initArrays.

private void initArrays(final Function parent) {
    final Vector sectors = parent.getSectors();
    final Vector childs = dataPlugin.getChilds(parent, true);
    boolean dfd = parent.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFD;
    Function child;
    Sector sector;
    Stream stream;
    Vector v;
    for (int i = 0; i < childs.size(); i++) {
        child = (Function) childs.get(i);
        v = lefts.get(child.getGlobalId());
        if (isOk(child))
            for (int j = 0; j < sectors.size(); j++) {
                sector = (Sector) sectors.get(j);
                stream = sector.getStream();
                if (stream != null) {
                    if (dfd) {
                        if (type == MovingPanel.RIGHT) {
                            if (isEqualsStart(sector, child)) {
                                add(child, sector, stream, v, sector.getStart().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
                            }
                        } else {
                            if (type == MovingPanel.LEFT)
                                if (isEqualsEnd(sector, child, type)) {
                                    add(child, sector, stream, v, sector.getEnd().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
                                }
                        }
                    } else {
                        if (type == MovingPanel.RIGHT) {
                            if (isEqualsStart(sector, child)) {
                                add(child, sector, stream, v, sector.getStart().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
                            }
                        } else if (isEqualsEnd(sector, child, type)) {
                            add(child, sector, stream, v, sector.getEnd().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
                        }
                    }
                }
            }
        initArrays(child);
    }
}
Also used : Function(com.ramussoft.pb.Function) Sector(com.ramussoft.pb.Sector) Stream(com.ramussoft.pb.Stream) Vector(java.util.Vector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 85 with Function

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

the class UserTemplate method createChilds.

public void createChilds(final Function function, final DataPlugin dataPlugin) {
    Hashtable<Long, Long> trans = new Hashtable<Long, Long>();
    final MovingArea ma = new MovingArea(dataPlugin);
    ma.setDataPlugin(dataPlugin);
    ma.setActiveFunction(function);
    final SectorRefactor refactor = ma.getRefactor();
    try {
        final ByteArrayInputStream streamr = new ByteArrayInputStream(data);
        final ObjectInputStream stream = new ObjectInputStream(streamr);
        final MemoryData data = new MemoryData();
        int l = DataLoader.readInteger(stream);
        for (int i = 0; i < l; i++) {
            final Function c = (Function) dataPlugin.createRow(function, true);
            c.setName(functionNames.get(i));
            if (i < functionTypes.size())
                c.setType(functionTypes.get(i));
            if (i < functionLinks.size()) {
                Row r = dataPlugin.findRowByGlobalId(functionLinks.get(i));
                if (r != null) {
                    if (r instanceof Stream) {
                        Stream st = (Stream) r;
                        Stream s = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                        s.setAttachedStatus(st.getAttachedStatus());
                        s.setEmptyName(st.isEmptyName());
                        s.setRows(st.getAdded());
                        c.setLink(s.getElement().getId());
                    }
                }
            }
            final long id = DataLoader.readLong(stream);
            trans.put(id, c.getElement().getId());
            c.setBounds(DataLoader.readFRectangle(stream));
            c.setFont(DataLoader.readFont(stream, data));
            c.setBackground(DataLoader.readColor(stream, data));
            c.setForeground(DataLoader.readColor(stream, data));
        }
        // Read version of
        final int ver = DataLoader.readInteger(stream);
        // Paint
        // Sector format
        l = DataLoader.readInteger(stream);
        HashMap<Sector, List<SectorPointPersistent>> pointsCache = new HashMap<Sector, List<SectorPointPersistent>>();
        HashMap<Long, Long> pointIds = new HashMap<Long, Long>();
        for (int i = 0; i < l; i++) {
            final Sector s = dataPlugin.createSector();
            s.setFunction(function);
            final long id = DataLoader.readLong(stream);
            trans.put(id, ((NSector) s).getElementId());
            final byte[] va = DataLoader.readBytes(stream);
            s.setVisualAttributes(va);
            List<SectorPointPersistent> points = (List) stream.readObject();
            pointsCache.put(s, points);
            normalize(points, dataPlugin.getEngine(), pointIds);
            s.setSectorPointPersistents(points);
            s.setSectorProperties((SectorPropertiesPersistent) stream.readObject());
            // final byte bs[] = DataLoader.readBytes(stream);
            // final ByteArrayInputStream ba = new ByteArrayInputStream(bs);
            final PaintSector ps = PaintSector.loadFromSector(ver, ma, data, dataPlugin, s);
            refactor.addSector(ps);
            Crosspoint c;
            if (DataLoader.readBoolean(stream)) {
                c = getCrosspoint(dataPlugin, trans, stream);
                s.getStart().setCrosspointA(c);
            }
            loadBorder(s.getStart(), stream, trans, dataPlugin, refactor, ps, true);
            s.getStart().commit();
            if (DataLoader.readBoolean(stream)) {
                c = getCrosspoint(dataPlugin, trans, stream);
                s.getEnd().setCrosspointA(c);
            }
            loadBorder(s.getEnd(), stream, trans, dataPlugin, refactor, ps, false);
            s.getEnd().commit();
            if (DataLoader.readBoolean(stream)) {
                int count = DataLoader.readInteger(stream);
                List<Row> rows = new ArrayList<Row>();
                for (int j = 0; j < count; j++) {
                    Row row = loadRow(stream, dataPlugin);
                    if (row != null)
                        rows.add(row);
                }
                if (rows.size() > 0) {
                    Stream stream2 = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                    stream2.setRows(rows.toArray(new Row[rows.size()]));
                    ((NSector) s).setThisStream(stream2);
                }
            }
        }
        setPoints(pointsCache);
        refactor.saveToFunction();
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSector(com.ramussoft.pb.data.negine.NSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) MovingArea(com.ramussoft.pb.idef.visual.MovingArea) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Hashtable(java.util.Hashtable) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) IOException(java.io.IOException) ByteArrayInputStream(java.io.ByteArrayInputStream) MemoryData(com.dsoft.utils.DataLoader.MemoryData) SectorPointPersistent(com.ramussoft.idef0.attribute.SectorPointPersistent) Row(com.ramussoft.pb.Row) ObjectInputStream(java.io.ObjectInputStream)

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