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;
}
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);
}
}
}
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;
}
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);
}
}
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);
}
Aggregations