Search in sources :

Example 21 with Sector

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

the class IDLImporter method createSegment.

private void createSegment(Arrowseg seg, MovingArea area) {
    SectorRefactor sr = area.getRefactor();
    Sector s = plugin.createSector();
    Function f = getFunction();
    s.setFunction(f);
    PaintSector ps = new PaintSector();
    ps.setSector(s);
    ps.setMovingArea(area);
    sr.addSector(ps);
    seg.sector = ps;
    ArrayList<FloatPoint> list = new ArrayList<FloatPoint>();
    StringTokenizer st = new StringTokenizer(seg.path, "() ");
    while (st.hasMoreElements()) list.add(toPoint(st.nextToken()));
    seg.pointsList = list;
    String text = seg.getText();
    if ((text != null) && (text.length() > 0)) {
        s.setStream(getStream(text), ReplaceStreamType.CHILDREN);
        if (seg.coordinates != null) {
            MovingLabel label = new MovingLabel(area);
            StringTokenizer st2 = new StringTokenizer(seg.coordinates, "()");
            FloatPoint point = toPoint(st2.nextToken());
            label.getBounds().setX(point.getX());
            label.getBounds().setY(point.getY() - 10);
            label.setText(text);
            ps.setText(label);
            if (seg.squiggleCoordinates != null) {
                ps.setShowTilda(true);
            }
        }
        if (seg.label.startsWith("{")) {
            StringTokenizer st2 = new StringTokenizer(seg.label, " ");
            st2.nextElement();
            st2.nextElement();
            try {
                int font = Integer.parseInt(st2.nextToken());
                if (font < uniqueFonts.size())
                    ps.setFont(uniqueFonts.get(font));
            } catch (Exception e) {
            }
            int color = Integer.parseInt(st2.nextToken());
            if (color < COLORS.length)
                ps.setColor(COLORS[color]);
        }
    }
}
Also used : SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) StringTokenizer(java.util.StringTokenizer) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) FloatPoint(com.dsoft.pb.types.FloatPoint) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ArrayList(java.util.ArrayList) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) IOException(java.io.IOException)

Example 22 with Sector

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

the class AbstractCrosspoint method addSector.

/**
 * Метод додає сектор в кінець масива секторів і повертає новостворений
 * масив секторів. Перевірка на те чи сектор вже присутній в масиві не
 * робиться.
 *
 * @param array  Вхідний масив секторів.
 * @param sector Сектор, який буде доданий до масиву.
 * @return Вихідний масив секторів, який включає всі сектори вхідного масиву
 * і додає елемент в кінець.
 */
protected Sector[] addSector(final Sector[] array, final Sector sector) {
    for (Sector s : array) if (((NSector) s).getElementId() == ((NSector) sector).getElementId())
        return array;
    final Sector[] tmp = new Sector[array.length + 1];
    for (int i = 0; i < array.length; i++) tmp[i] = array[i];
    tmp[array.length] = sector;
    return tmp;
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 23 with Sector

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

the class AbstractCrosspoint method isDLevel.

public boolean isDLevel() {
    Function f = null;
    final Sector[] ins = getIns();
    final Sector[] outs = getOuts();
    if (ins.length == 0 || outs.length == 0)
        return true;
    for (int i = 0; i < ins.length; i++) {
        if (ins[i].getFunction() == null)
            return false;
        if (!ins[i].getFunction().equals(f)) {
            if (f == null)
                f = ins[i].getFunction();
            else
                return true;
        }
    }
    for (int i = 0; i < outs.length; i++) {
        if (outs[i].getFunction() == null)
            return false;
        if (!outs[i].getFunction().equals(f)) {
            if (f == null)
                f = outs[i].getFunction();
            else
                return true;
        }
    }
    return false;
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Function(com.ramussoft.pb.Function) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 24 with Sector

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

the class HTTPParser method addFunction.

private void addFunction(final Row row, final Function function, final Vector<UF> res) {
    if (!function.isHaveChilds()) {
        final Function par = (Function) function.getParent();
        boolean dfd = par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFD;
        final Vector<Sector> sectors = par.getSectors();
        for (int i = 0; i < sectors.size(); i++) {
            final Sector s = sectors.get(i);
            final Stream stream = s.getStream();
            if (stream != null) {
                if (function.equals(s.getStart().getFunction())) {
                    if (RowFactory.isPresent(stream.getAdded(), row)) {
                        final UF uf = new UF(function, s.getStart().getFunctionType());
                        if (res.indexOf(uf) < 0) {
                            res.add(uf);
                            if (dfd)
                                uf.type = MovingPanel.RIGHT;
                        }
                    }
                } else if (function.equals(s.getEnd().getFunction())) {
                    if (RowFactory.isPresent(stream.getAdded(), row)) {
                        final UF uf = new UF(function, s.getEnd().getFunctionType());
                        if (res.indexOf(uf) < 0) {
                            res.add(uf);
                            if (dfd)
                                uf.type = MovingPanel.LEFT;
                        }
                    }
                }
            }
        }
    }
}
Also used : Function(com.ramussoft.pb.Function) MovingFunction(com.ramussoft.pb.idef.visual.MovingFunction) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Stream(com.ramussoft.pb.Stream) InputStream(java.io.InputStream)

Example 25 with Sector

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

the class MovingArea method arrowCopyVisual.

public void arrowCopyVisual() {
    startUserTransaction();
    PaintSector.Pin pin = (PaintSector.Pin) activeObject;
    Stream stream = pin.getSector().getStream();
    Row[] oRows = stream.getAdded();
    byte[] bs = pin.getSector().getSector().getVisualAttributes();
    for (Sector f : dataPlugin.getAllSectors()) if (f.getStream() != null && f.getStream().getAdded() != null) {
        Row[] rows = f.getStream().getAdded();
        boolean b = false;
        for (Row row2 : rows) if (row2 != null) {
            if (b)
                break;
            for (Row row3 : oRows) if (row3.equals(row2)) {
                f.setVisualAttributes(bs);
                b = true;
                break;
            }
        }
    }
    refactor.setUndoPoint();
}
Also used : Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) 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) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row)

Aggregations

Sector (com.ramussoft.pb.Sector)50 NSector (com.ramussoft.pb.data.negine.NSector)40 Crosspoint (com.ramussoft.pb.Crosspoint)29 Function (com.ramussoft.pb.Function)25 NFunction (com.ramussoft.pb.data.negine.NFunction)19 Vector (java.util.Vector)19 Stream (com.ramussoft.pb.Stream)18 Row (com.ramussoft.pb.Row)15 FloatPoint (com.dsoft.pb.types.FloatPoint)10 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 AbstractSector (com.ramussoft.pb.data.AbstractSector)7 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 NStream (com.ramussoft.pb.data.negine.NStream)4 Point (com.ramussoft.pb.idef.elements.Point)4 DataLoader (com.dsoft.utils.DataLoader)3 NCrosspoint (com.ramussoft.pb.data.negine.NCrosspoint)3 DFDFunction (com.ramussoft.pb.dfd.visual.DFDFunction)3