use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class NFunction method getOwners.
public Row[] getOwners() {
Function function = (Function) getParentRow();
if (function.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
if (function != null) {
List<Row> res = new ArrayList<Row>();
int c = function.getChildCount();
for (int i = 0; i < c; i++) {
Function function2 = (Function) function.getChildAt(i);
if (function2.getType() == Function.TYPE_DFDS_ROLE && this.equals(function2.getOwner())) {
Stream stream = (Stream) dataPlugin.findRowByGlobalId(function2.getLink());
if (stream != null) {
for (Row row : stream.getAdded()) if (!res.contains(row))
res.add(row);
}
}
}
Row[] rows = res.toArray(new Row[res.size()]);
RowFactory.sortByName(rows);
return rows;
}
}
String s = dataPlugin.getProperty(DataPlugin.PROPERTY_OUNERS);
if (s == null)
s = "";
final StringTokenizer st = new StringTokenizer(s);
final Vector<GlobalId> ids = new Vector<GlobalId>();
while (st.hasMoreTokens()) {
ids.add(GlobalId.convert(st.nextToken()));
}
final MatrixProjection projection = dataPlugin.getProjection(MatrixProjection.TYPE_IDEF0, "BOTTOM");
final Vector left = projection.getLeft(this);
final Vector<Row> res = new Vector<Row>();
Row[] rows;
for (int i = 0; i < left.size(); i++) {
final Stream r = (Stream) left.get(i);
if ((rows = r.getAdded()).length == 0)
addRow(res, ids, r);
else
for (final Row element2 : rows) addRow(res, ids, element2);
}
rows = res.toArray(new Row[res.size()]);
RowFactory.sortByName(rows);
return rows;
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class NFunction method setOwner.
public void setOwner(final Row owner) {
Function ow = null;
if (getType() == Function.TYPE_DFDS_ROLE) {
ow = (Function) owner;
if (ow == null)
ow = (Function) getOwner();
}
if (owner == null) {
setObject(OWNER_ID, null);
} else {
setObject(OWNER_ID, ((NRow) owner).getElementId());
}
Function function = (Function) getParent();
if (function.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
HashSet<Sector> toUpdate = new HashSet<Sector>();
if (getType() == Function.TYPE_DFDS_ROLE) {
if (ow != null) {
for (Sector sector : function.getSectors()) {
if (ow.equals(sector.getStart().getFunction()) || ow.equals(sector.getEnd().getFunction()))
if (!toUpdate.contains(sector))
toUpdate.add(sector);
}
}
} else {
for (Sector sector : function.getSectors()) {
if (this.equals(sector.getStart().getFunction()) || this.equals(sector.getEnd().getFunction()))
if (!toUpdate.contains(sector))
toUpdate.add(sector);
}
}
for (Sector sector : toUpdate) SectorRefactor.fixOwners(sector, getDataPlugin());
}
for (Attribute attribute : engine.getQualifier(getElement().getQualifierId()).getAttributes()) if (attribute.getAttributeType().equals(DFDSNamePlugin.type)) {
DFDSName dfdsName = (DFDSName) engine.getAttribute(getElement(), attribute);
if (dfdsName != null)
dataPlugin.compileDFDSName(dfdsName, this);
}
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class AbstractDataPlugin method indexOfFunction.
public int indexOfFunction(final Function function) {
if (((NFunction) function).isBase())
return 0;
class X {
private int count = 0;
private Function f;
public int getIndex(final Function f) {
this.f = f;
calc(getBaseFunction(f));
return count;
}
private boolean calc(final Function base) {
final Enumeration cs = base.children();
while (cs.hasMoreElements()) {
final Function c = (Function) cs.nextElement();
if (c.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
continue;
if (c.equals(f)) {
count++;
return true;
}
if (c.isHaveRealChilds()) {
count++;
if (calc(c))
return true;
}
}
return false;
}
}
return new X().getIndex(function);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class AbstractDataPlugin method getFastMatrixProjectionIDEF0.
public FastMatrixProjection getFastMatrixProjectionIDEF0(final int type, Function function) {
// if (idef0s[type] == null) {
Function base = function;
while (base.getParentRow() != null) {
base = (Function) base.getParentRow();
}
idef0s[type] = new FastMatrixProjection(this, type, -1, base);
// }
return idef0s[type];
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class IDLImporter method importFromIDL.
public void importFromIDL(InputStream in) throws IOException {
Vector<Row> streams = plugin.getRecChilds(plugin.getBaseStream(), true);
for (Row r : streams) {
Stream stream = (Stream) r;
if (!stream.isEmptyName()) {
this.streams.put(stream.getName(), stream);
}
}
reader = new InputStreamReader(in, encoding);
length = reader.read(buff);
while (true) {
String line = readLine();
if (line == null)
return;
switch(position) {
case KIT:
if (starts(MODELC, line)) {
String name = valueOf(line);
try {
base.setName(name);
} catch (Exception e) {
}
plugin.getBaseFunctionQualifier().setName(name);
plugin.getEngine().updateQualifier(plugin.getBaseFunctionQualifier());
loadFonts(line);
} else if (starts(PROJECT_NAME, line)) {
String name = valueOf(line);
plugin.getBaseFunction().getProjectOptions().setProjectName(name);
} else if (starts(AUTHOR, line)) {
String name = valueOf(line);
plugin.getBaseFunction().getProjectOptions().setProjectAutor(name);
} else if (starts(DIAGRAM_GRAPHICC, line)) {
position = DIAGRAM_GRAPHIC;
String name = line.substring(DIAGRAM_GRAPHICC.length() + 1);
Function f = getFunction(name);
functions.add(f);
boxes.clear();
segments.clear();
}
break;
case DIAGRAM_GRAPHIC:
if (starts(TITLE, line)) {
String name = valueOf(line);
try {
getFunction().setName(name);
} catch (Exception e) {
}
} else if (starts(STATUS, line)) {
String name = line.substring(STATUS.length() + 1);
int typeOf = Status.typeOf(name);
Status status = getFunction().getStatus();
status.setType(typeOf);
if (typeOf < 0) {
status.setOtherName(name);
status.setType(Status.OTHER);
}
getFunction().setStatus(getFunction().getStatus());
} else if (starts(BOXC, line)) {
box = new Box();
box.index = Integer.parseInt(getLastWord(line));
boxes.add(box);
position = BOX;
} else if (starts(ENDDIAGRAM, line)) {
position = KIT;
createSegments();
functions.remove(functions.size() - 1);
} else if (starts("ARROWSEG", line)) {
position = ARROWSEG;
seg = new Arrowseg();
seg.index = Integer.parseInt(line.substring("ARROWSEG".length() + 1));
segments.add(seg);
}
break;
case BOX:
if (starts(NAME, line)) {
String name = valueOf(line);
box.name = name;
} else if (starts(BOX_COORDINATES, line)) {
box.coordinates = line.substring(BOX_COORDINATES.length() + 1);
} else if (starts(DETAIL_REFERENCE, line)) {
box.reference = line.substring(DETAIL_REFERENCE.length() + 1);
} else if (starts(ENDBOX, line)) {
addBox();
position = DIAGRAM_GRAPHIC;
}
break;
case ARROWSEG:
if (starts(SOURCE, line)) {
seg.source = line.substring(SOURCE.length() + 1);
} else if (starts(PATH, line)) {
seg.path = line.substring(PATH.length() + 1);
} else if (starts(LABAL_COORDINATES, line)) {
seg.coordinates = line.substring(LABAL_COORDINATES.length() + 1);
} else if (starts(LABEL, line)) {
seg.label = valueOf(line);
} else if (starts(SQUIGGLE_COORDINATES, line)) {
seg.squiggleCoordinates = line.substring(SQUIGGLE_COORDINATES.length() + 1);
} else if (starts(SINK, line)) {
seg.sink = line.substring(SINK.length() + 1);
} else if (starts("ENDSEG", line)) {
position = DIAGRAM_GRAPHIC;
}
break;
}
}
}
Aggregations