Search in sources :

Example 1 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class PaintSector method removeX.

private void removeX() {
    if (rec)
        return;
    rec = true;
    for (final Point element : points) element.remove();
    movingArea.getRefactor().removeSector(this);
    Crosspoint start = getStart();
    Crosspoint end = getEnd();
    sector.remove();
    synchronized (movingArea.getDataPlugin()) {
        ((NSector) sector).clearMe();
    }
    removeAther(start);
    removeAther(end);
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) FloatPoint(com.dsoft.pb.types.FloatPoint) NCrosspoint(com.ramussoft.pb.data.negine.NCrosspoint) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 2 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method changeSector.

/**
 * Змінює сектор переданий методом setSector(Sector sector).
 *
 * @return <code>true</code>, якщо зміна відбулась,<br>
 * <code>false</code>, якщо зміна не відбулась.
 */
public boolean changeSector() {
    Crosspoint crosspoint;
    final PerspectivePoint point = getLastPoint();
    if (point.functionType == -1 && point.borderType == -1) {
        if (point.pin.getSector().getStart() == null || point.pin.getSector().getEnd() == null || point.pin.getSector().equals(sector))
            return false;
    }
    Sector inner = sector.getSector();
    for (PaintSector s : sectors) if (s.getSector().equals(inner)) {
        this.sector = s;
        break;
    }
    lastC = null;
    NSectorBorder sb;
    if (point.type == TYPE_START) {
        sb = sector.getSector().getStart();
        crosspoint = sector.getStart();
        pointB = new PerspectivePoint();
        pointB.x = sector.getEndPoint().getX();
        pointB.y = sector.getEndPoint().getY();
    } else {
        sb = sector.getSector().getEnd();
        crosspoint = sector.getEnd();
        pointA = new PerspectivePoint();
        pointA.x = sector.getStartPoint().getX();
        pointA.y = sector.getStartPoint().getY();
    }
    List<Sector> oldConnectedSectors = new ArrayList<Sector>();
    if (crosspoint != null) {
        for (Sector s : crosspoint.getIns()) if (s != sector.getSector())
            oldConnectedSectors.add(s);
        for (Sector s : crosspoint.getOuts()) if (s != sector.getSector())
            oldConnectedSectors.add(s);
    }
    Sector s = null;
    boolean createMiss = true;
    if (point.function != null) {
        Function oldF = sb.getFunction();
        if (oldF != null && oldF.equals(point.function)) {
            if (function.getDecompositionType() >= 0 || point.function.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
                createMiss = false;
            else {
                createMiss = point.functionType != sb.getFunctionType();
            }
        }
    }
    if (createMiss)
        s = createMiss(point);
    else
        point.crosspoint = sb.getCrosspoint();
    if (s != null)
        s.setVisualAttributes(sector.getSector().getVisualAttributes());
    if (type == TYPE_START) {
        copyToSectorBorder(sb, pointA);
        sector.setStart(point.crosspoint, point.point, createMiss);
        sector.getSector().getStart().commit();
    } else {
        copyToSectorBorder(sector.getSector().getEnd(), pointB);
        sector.setEnd(point.crosspoint, point.point, createMiss);
        sector.getSector().getEnd().commit();
    }
    if (sector.getStream() != null) {
        if (lastC != null)
            lastC.setStream(cloneStream(sector.getStream(), movingArea.dataPlugin, lastC), ReplaceStreamType.CHILDREN);
    }
    sector.setCorrectRows();
    sector.regeneratePoints();
    sector.tryRemovePin(movingArea);
    Hashtable<Long, Sector> sectorHash = movingArea.getDataPlugin().getSectorHash();
    for (Sector sector : oldConnectedSectors) {
        if (sectorHash.get(((NSector) sector).getElementId()) != null) {
            fixOwners(sector, getDataPlugin());
        }
    }
    saveToFunction();
    return true;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSectorBorder(com.ramussoft.pb.data.negine.NSectorBorder) NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) ArrayList(java.util.ArrayList) Crosspoint(com.ramussoft.pb.Crosspoint)

Example 3 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method fixNoNameBug.

private void fixNoNameBug(Crosspoint crosspoint, Sector sector) {
    if (crosspoint != null) {
        if (crosspoint.isDLevel()) {
            Sector[] oppozite = crosspoint.getOppozite(sector);
            if (oppozite.length == 1) {
                Sector opp = oppozite[0];
                Stream s = opp.getStream();
                ((NSector) sector).setThisStream(s);
            }
        }
    }
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) 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 4 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class SectorRefactor method createSectorOnIn.

public Sector createSectorOnIn(final Crosspoint point, final SectorBorder border, final PaintSector sector, boolean start) {
    Function function = border.getFunction();
    int borderType = border.getBorderType();
    if (function != null && function.getType() == Function.TYPE_DFDS_ROLE) {
        function = null;
        borderType = MovingText.getOpposite(border.getFunctionType());
    }
    double pos;
    Sector s;
    Point bPoint;
    Function par = sector.getFunction();
    if (start)
        bPoint = sector.getStartPoint();
    else
        bPoint = sector.getEndPoint();
    if (function != null) {
        if ((border.getFunctionType() == MovingPanel.RIGHT) || (border.getFunctionType() == MovingPanel.LEFT))
            pos = bPoint.getY() / movingArea.CLIENT_HEIGHT * par.getBounds().getHeight() + par.getBounds().getY();
        else
            pos = bPoint.getX() / movingArea.CLIENT_WIDTH * par.getBounds().getWidth() + par.getBounds().getX();
        s = createPartIn(point, function, border.getFunctionType(), pos, !start);
    } else {
        if ((borderType == MovingPanel.RIGHT) || (borderType == MovingPanel.LEFT))
            pos = bPoint.getY() / movingArea.CLIENT_HEIGHT * par.getBounds().getHeight() + par.getBounds().getY();
        else
            pos = sector.getStartPoint().getX() / movingArea.CLIENT_WIDTH * par.getBounds().getWidth() + par.getBounds().getX();
        s = createPartOut(point, this.function, borderType, pos, !start);
    }
    if (s != null) {
        s.setStream(cloneStream(sector.getSector().getStream(), movingArea.dataPlugin, s), ReplaceStreamType.CHILDREN);
        ((NSector) s).storeData();
        s.setVisualAttributes(s.getVisualAttributes());
    }
    return s;
}
Also used : Function(com.ramussoft.pb.Function) NFunction(com.ramussoft.pb.data.negine.NFunction) NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) FloatPoint(com.dsoft.pb.types.FloatPoint)

Example 5 with NSector

use of com.ramussoft.pb.data.negine.NSector in project ramus by Vitaliy-Yakovchuk.

the class AbstractSector method setRows.

public void setRows(final Row[] rows) {
    synchronized (dataPlugin) {
        sRec = true;
        if (getStream() != null) {
            final Row[] dels = RowFactory.removeRows(getStream().getAdded(), rows);
            if (dels.length > 0)
                removeFromParent(dels);
            getStream().setRows(rows);
        }
        final Vector<Sector> v = new Vector();
        getRecParents(v);
        final Sector[] sectors = toArray(v);
        final Stream[] streams = getStreams(sectors);
        for (final Stream element : streams) element.addRows(rows);
        for (Sector s : sectors) {
            if (s.getStream() == null) {
                Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                stream.addRows(rows);
                ((NSector) s).setThisStream(stream);
            }
        }
        sRec = false;
    }
}
Also used : NSector(com.ramussoft.pb.data.negine.NSector) Sector(com.ramussoft.pb.Sector) NSector(com.ramussoft.pb.data.negine.NSector) NStream(com.ramussoft.pb.data.negine.NStream) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) Vector(java.util.Vector)

Aggregations

NSector (com.ramussoft.pb.data.negine.NSector)11 Crosspoint (com.ramussoft.pb.Crosspoint)6 Sector (com.ramussoft.pb.Sector)6 Function (com.ramussoft.pb.Function)4 NFunction (com.ramussoft.pb.data.negine.NFunction)4 FloatPoint (com.dsoft.pb.types.FloatPoint)3 Row (com.ramussoft.pb.Row)3 Stream (com.ramussoft.pb.Stream)3 NCrosspoint (com.ramussoft.pb.data.negine.NCrosspoint)3 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)3 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)2 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 DataLoader (com.dsoft.utils.DataLoader)1 MemoryData (com.dsoft.utils.DataLoader.MemoryData)1 Attribute (com.ramussoft.common.Attribute)1 AttributeEditorView (com.ramussoft.gui.attribute.AttributeEditorView)1 SectorPointPersistent (com.ramussoft.idef0.attribute.SectorPointPersistent)1