use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class AbstractSector method setStream.
public void setStream(final Stream stream, ReplaceStreamType type) {
synchronized (dataPlugin) {
if (sRec)
return;
if (rec || stream == null)
return;
sRec = true;
if (stream != null) {
final Vector<Sector> v = new Vector<Sector>();
if (!stream.isEmptyName()) {
v.add(this);
getNullStreamedSectors(v);
addPart(v, getStart().getCrosspoint());
addPart(v, getEnd().getCrosspoint());
if (type.equals(ReplaceStreamType.SIMPLE)) {
getStreamChilds(v);
for (int i = v.size() - 1; i >= 0; i--) {
Sector s = v.get(i);
((AbstractSector) s).getStreamChilds(v);
}
} else if (type.equals(ReplaceStreamType.CHILDREN)) {
for (int i = v.size() - 1; i >= 0; i--) {
Sector s = v.get(i);
((AbstractSector) s).getRecEndChilds(v);
}
} else if (type.equals(ReplaceStreamType.ALL)) {
for (int i = v.size() - 1; i >= 0; i--) {
Sector s = v.get(i);
((AbstractSector) s).getConnected(v);
}
}
for (Sector s : v) ((AbstractSector) s).setThisStream(stream);
} else {
getStreamChilds(v);
addPart(v, getStart().getCrosspoint());
addPart(v, getEnd().getCrosspoint());
for (final Sector s : v) {
setPersonalStream(s, stream);
}
}
v.clear();
getConnected(v);
for (Sector s : v) if (s.getStream() != null) {
Row[] rows2 = s.getStream().getAdded();
Row[] rows = stream.getAdded();
boolean changed = false;
for (int i = 0; i < rows2.length; i++) {
Row r2 = rows2[i];
for (Row r : rows) if (r.getElement().getId() == r2.getElement().getId()) {
rows2[i] = r;
changed = true;
}
}
if (changed) {
s.getStream().addRows(rows2);
((NStream) s.getStream()).saveAdded();
}
}
}
setThisStream(stream);
sRec = false;
}
}
use of com.ramussoft.pb.Sector 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;
}
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class AbstractSector method afterCreate.
public void afterCreate() {
final Vector<Sector> v = new Vector<Sector>();
getParents(v);
for (int i = 0; i < v.size(); i++) if (v.get(i).getStream() != null) {
setStream(v.get(i).getStream(), ReplaceStreamType.CHILDREN);
}
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class AbstractSector method toArray.
public static Sector[] toArray(final Vector v) {
final int n = v.size();
final Sector[] res = new Sector[n];
for (int i = 0; i < n; i++) res[i] = (Sector) v.get(i);
return res;
}
use of com.ramussoft.pb.Sector in project ramus by Vitaliy-Yakovchuk.
the class MatrixProjectionIDEF0 method getLeft.
/**
* Метод повертає вектор елементів класифікатора потоків, які пов’язані з
* відповідним елементом класифікатора робіт.
*/
public Vector<Row> getLeft(final Row row) {
Function parent;
if ((parent = (Function) row.getParentRow()) == null)
return new Vector<Row>();
final Vector<Row> res = new Vector<Row>();
final Function f = (Function) row;
final Vector sectors = parent.getSectors();
Sector sector;
Stream stream;
final int l = sectors.size();
for (int i = 0; i < l; i++) {
sector = (Sector) sectors.get(i);
if ((stream = sector.getStream()) != null) {
if (type == MovingPanel.RIGHT) {
if (f.equals(sector.getStart().getFunction()))
res.add(stream);
} else {
if (f.equals(sector.getEnd().getFunction()) && sector.getEnd().getFunctionType() == type)
res.add(stream);
}
}
}
return res;
}
Aggregations