Search in sources :

Example 31 with Sector

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

the class SectorRefactor method createNewSector.

/**
 * Створює новий сектор по переданим точкам, новостворений сектор можна
 * отримати методом getSector().
 */
public void createNewSector() {
    Stream stream = null;
    boolean start = true;
    PaintSector fromSector = null;
    if (pointA.pin != null) {
        fromSector = pointA.pin.getSector();
        if (fromSector.getEnd() == null) {
            return;
        }
        if (pointB.pin != null) {
            final Sector s = pointB.pin.getSector().getSector();
            if (s.isConnectedOnFunction(fromSector.getSector()))
                return;
        }
        stream = fromSector.getStream();
    }
    if (pointB.pin != null) {
        fromSector = pointB.pin.getSector();
        if (fromSector.getStart() == null) {
            return;
        }
        if (stream == null) {
            stream = fromSector.getStream();
            start = false;
        }
    }
    Sector s1 = createMiss(pointA);
    Sector s2 = createMiss(pointB);
    final Sector s = getDataPlugin().createSector();
    s.setFunction(function);
    copyToSectorBorder(s.getStart(), pointA);
    s.getStart().setCrosspointA(pointA.crosspoint);
    s.getStart().commit();
    copyToSectorBorder(s.getEnd(), pointB);
    s.getEnd().setCrosspointA(pointB.crosspoint);
    s.getEnd().commit();
    final PaintSector sector = new PaintSector(s, pointA.point, pointB.point, movingArea);
    addSector(sector);
    if (stream != null && fromSector != null) {
        s.setStream(cloneStream(stream, movingArea.dataPlugin, s), ReplaceStreamType.CHILDREN);
        s.loadRowAttributes(fromSector.getSector(), start);
        s.setVisualAttributes(fromSector.getSector().getVisualAttributes());
    }
    if (fromSector != null) {
        if (s1 != null)
            s1.setVisualAttributes(fromSector.getSector().getVisualAttributes());
        if (s2 != null)
            s2.setVisualAttributes(fromSector.getSector().getVisualAttributes());
    }
    if (fromSector == null && stream == null && (pointA.sector != null || pointB.sector != null)) {
        PaintSector ps = pointA.sector;
        if (ps == null)
            ps = pointB.sector;
        if (s1 != null)
            s1.setVisualAttributes(ps.getSector().getVisualAttributes());
        if (s2 != null)
            s2.setVisualAttributes(ps.getSector().getVisualAttributes());
        if (ps.getStream() != null)
            s.setStream(ps.getStream(), ReplaceStreamType.CHILDREN);
    }
    sector.tryRemovePin(movingArea);
    sector.savePointOrdinates();
    // sector.saveVisual();
    lightSaveToFunction();
    this.sector = sector;
}
Also used : 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)

Example 32 with Sector

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

the class SectorRefactor method copyOwnersFrom.

public static void copyOwnersFrom(Function function, DataPlugin dataPlugin) {
    Function par = (Function) function.getParent();
    HashSet<Function> roles = new HashSet<Function>();
    for (Sector sector : par.getSectors()) {
        if (function.equals(sector.getStart().getFunction())) {
            getEndRoles(sector, roles, dataPlugin);
            getStartRoles(sector, roles, dataPlugin);
        }
        if (function.equals(sector.getEnd().getFunction())) {
            getStartRoles(sector, roles, dataPlugin);
            getEndRoles(sector, roles, dataPlugin);
        }
    }
    Stream stream = (Stream) dataPlugin.findRowByGlobalId(function.getLink());
    Row[] owners;
    if (stream == null)
        owners = new Row[] {};
    else
        owners = stream.getAdded();
    for (Function function2 : roles) {
        stream = (Stream) dataPlugin.findRowByGlobalId(function2.getLink());
        if (stream == null) {
            if (owners.length > 0) {
                stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                function2.setLink(stream.getElement().getId());
                stream.setRows(owners);
            }
        } else {
            stream.setRows(owners);
        }
    }
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) 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) HashSet(java.util.HashSet)

Example 33 with Sector

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

the class SectorRefactor method createPartOut.

/**
 * Метод свторює сектор зверху на функціональному блоці.
 *
 * @param point        Точка на краю активного функціоналоноко блоку (констук якого
 *                     показується).
 * @param function     Активний функціональний блок.
 * @param functionType Край, на якому знаходиться тока.
 */
private Sector createPartOut(final Crosspoint point, final Function function, final int functionType, final double outPos, boolean start) {
    if (functionType < 0) {
        JOptionPane.showMessageDialog(null, "Не виправлена " + "помилка тунулювання.");
        return null;
    }
    final Function par = (Function) function.getParent();
    if (par == null)
        return null;
    // PerspectivePoint ppPoint = null;
    final Sector sector = getDataPlugin().createSector();
    sector.setFunction(par);
    /*	if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
			ppPoint = new PerspectivePoint();
			ppPoint.x = function.getBounds().getX() + outPos
					/ movingArea.CLIENT_WIDTH * function.getBounds().getWidth();
			ppPoint.y = outPos;
			ppPoint.borderType = functionType;
			createBorderPoints(ppPoint, par);
		}*/
    final Crosspoint op = getDataPlugin().createCrosspoint();
    if (start) {
        sector.getStart().setCrosspointA(point);
        sector.getStart().setFunctionA(function);
        sector.getStart().setFunctionTypeA(functionType);
        sector.getEnd().setCrosspointA(op);
        /*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
				sector.getEnd().setFunctionA(ppPoint.function);
				sector.getEnd().setFunctionTypeA(
						MovingPanel.getOpposite(functionType));
			} else*/
        sector.getEnd().setBorderTypeA(functionType);
    } else {
        sector.getEnd().setCrosspointA(point);
        sector.getEnd().setFunctionA(function);
        sector.getEnd().setFunctionTypeA(functionType);
        sector.getStart().setCrosspointA(op);
        /*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
				sector.getStart().setFunctionA(ppPoint.function);
				sector.getStart().setFunctionTypeA(
						MovingPanel.getOpposite(functionType));
			} else*/
        sector.getStart().setBorderTypeA(functionType);
    }
    sector.getStart().commit();
    sector.getEnd().commit();
    PaintSector.save(createOutPaintPart(sector, outPos), new DataLoader.MemoryData(), movingArea.getDataPlugin().getEngine());
    return sector;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) DataLoader(com.dsoft.utils.DataLoader) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 34 with Sector

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

the class PaintSector method getRemoved.

private void getRemoved(final Sector sector, final Vector<PaintSector> resRemove) {
    final PaintSector ps = movingArea.getRefactor().getPaintSector(sector);
    if (ps == null || resRemove.indexOf(ps) >= 0)
        return;
    resRemove.add(ps);
    Crosspoint c;
    c = sector.getStart().getCrosspoint();
    if (c != null && c.isOne(sector)) {
        final Sector[] sectors = c.getIns();
        for (final Sector s : sectors) getRemoved(s, resRemove);
    }
    c = sector.getEnd().getCrosspoint();
    if (c != null && c.isOne(sector)) {
        final Sector[] sectors = c.getOuts();
        for (final Sector s : sectors) getRemoved(s, resRemove);
    }
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 35 with Sector

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

the class PaintSector method remove.

/**
 * Метод який видаляє сектор.
 */
public void remove() {
    List<Sector> sectors = new ArrayList<Sector>();
    Crosspoint start = getStart();
    if (start != null) {
        for (Sector s : start.getIns()) if (s != getSector())
            sectors.add(s);
        for (Sector s : start.getOuts()) if (s != getSector())
            sectors.add(s);
    }
    Crosspoint end = getEnd();
    if (end != null) {
        for (Sector s : end.getIns()) if (s != getSector())
            sectors.add(s);
        for (Sector s : end.getOuts()) if (s != getSector())
            sectors.add(s);
    }
    final Vector<PaintSector> resRemove = new Vector<PaintSector>();
    getRemoved(getSector(), resRemove);
    if (!resRemove.contains(this))
        resRemove.add(this);
    for (int i = 0; i < resRemove.size(); i++) resRemove.get(i).removeX();
    for (Sector sector : sectors) SectorRefactor.fixOwners(sector, movingArea.dataPlugin);
}
Also used : Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) AbstractSector(com.ramussoft.pb.data.AbstractSector) ArrayList(java.util.ArrayList) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) Vector(java.util.Vector) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

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