use of com.ramussoft.pb.data.negine.NSectorBorder 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;
}
use of com.ramussoft.pb.data.negine.NSectorBorder in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method fillFromOwners.
private static void fillFromOwners(Function function, DataPlugin dataPlugin) {
Function par = (Function) function.getParent();
if (par == null)
return;
Vector<Sector> ends = new Vector<Sector>();
Vector<Sector> starts = new Vector<Sector>();
for (Sector sector : par.getSectors()) {
NSectorBorder start = sector.getStart();
if (function.equals(start.getFunction()) && start.getCrosspoint() != null) {
if (start.getCrosspoint().isDLevel()) {
for (Sector sector2 : start.getCrosspoint().getOppozite(sector)) starts.add(sector2);
}
}
NSectorBorder end = sector.getEnd();
if (function.equals(end.getFunction()) && end.getCrosspoint() != null) {
if (end.getCrosspoint().isDLevel()) {
for (Sector sector2 : end.getCrosspoint().getOppozite(sector)) ends.add(sector2);
}
}
}
if (ends.size() == 0 && starts.size() == 0)
return;
HashSet<Row> owners = new HashSet<Row>();
boolean[] hasFunctionOwners = new boolean[] { false };
for (Sector sector : starts) fillStartFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
for (Sector sector : ends) fillEndFromOwners(sector, owners, dataPlugin, hasFunctionOwners);
if (!hasFunctionOwners[0] && owners.size() == 0)
return;
Stream stream = (Stream) dataPlugin.findRowByGlobalId(function.getLink());
if (stream == null) {
if (owners.size() > 0) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
function.setLink(stream.getElement().getId());
stream.setRows(owners.toArray(new Row[owners.size()]));
}
} else {
stream.setRows(owners.toArray(new Row[owners.size()]));
}
}
use of com.ramussoft.pb.data.negine.NSectorBorder in project ramus by Vitaliy-Yakovchuk.
the class ArrowTunnelDialog method showModal.
public void showModal(final PaintSector sector) {
this.sector = sector;
NSectorBorder sb;
boolean show;
if (sector.isSelEnd()) {
sb = sector.getSector().getEnd();
show = sector.getSector().getEnd().getFunction() != null;
} else {
sb = sector.getSector().getStart();
show = sector.getSector().getStart().getFunction() != null;
}
jRadioButton.setVisible(show);
if (!show) {
gridLayout3.setRows(2);
jPanel1.removeAll();
jPanel1.add(jRadioButton1, null);
jPanel1.add(jRadioButton2, null);
} else {
gridLayout3.setRows(3);
jPanel1.removeAll();
jPanel1.add(jRadioButton1, null);
jPanel1.add(jRadioButton, null);
jPanel1.add(jRadioButton2, null);
}
if (sb.getTunnelSoft() == Crosspoint.TUNNEL_SOFT) {
if (show)
jRadioButton.setSelected(true);
else
jRadioButton2.setSelected(true);
} else if (sb.getTunnelSoft() == Crosspoint.TUNNEL_SIMPLE_SOFT)
jRadioButton2.setSelected(true);
else
jRadioButton1.setSelected(true);
pack();
setVisible(true);
Options.saveOptions("arrow_border_dialog", this);
}
use of com.ramussoft.pb.data.negine.NSectorBorder in project ramus by Vitaliy-Yakovchuk.
the class ArrowTunnelDialog method tunnelIt.
protected void tunnelIt() {
NSectorBorder crosspoint;
boolean start;
if (sector.isSelStart()) {
crosspoint = sector.getSector().getStart();
start = true;
} else if (sector.isSelEnd()) {
crosspoint = sector.getSector().getEnd();
start = false;
} else
return;
if (jRadioButton.isSelected())
crosspoint.setTunnelSoft(Crosspoint.TUNNEL_SOFT);
else if (jRadioButton2.isSelected())
crosspoint.setTunnelSoft(Crosspoint.TUNNEL_SIMPLE_SOFT);
else {
SectorRefactor.fixOwners(movingArea.getRefactor().createSectorOnIn(sector, start), movingArea.getDataPlugin());
}
}
Aggregations