use of com.ramussoft.pb.idef.elements.SectorRefactor in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method onProcessEndBoundsChange.
@Override
public void onProcessEndBoundsChange() {
FRectangle oldRec = function.getBounds();
myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
FRectangle newRect = new FRectangle(myBounds);
function.setBounds(newRect);
final SectorRefactor refactor = movingArea.getRefactor();
MemoryData memoryData = new MemoryData();
List<PaintSector> list = new ArrayList<PaintSector>();
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector sector = refactor.getSector(i);
try {
setAddedSectorPos(oldRec, sector, list);
} catch (Exception e) {
e.printStackTrace();
}
}
for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) function).getEngine());
setAddedRolesPos(oldRec, newRect);
}
use of com.ramussoft.pb.idef.elements.SectorRefactor in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method onEndBoundsChange.
@Override
public void onEndBoundsChange() {
FRectangle oldRec = function.getBounds();
if (oldRec.equals(myBounds))
return;
final SectorRefactor refactor = movingArea.getRefactor();
((NRow) function).startUserTransaction();
onProcessEndBoundsChange();
refactor.setUndoPoint();
}
use of com.ramussoft.pb.idef.elements.SectorRefactor in project ramus by Vitaliy-Yakovchuk.
the class DFDSRole method onProcessEndBoundsChange.
@Override
public void onProcessEndBoundsChange() {
final FRectangle oldRec = function.getBounds();
myBounds.setTransformNetBounds(MovingArea.NET_LENGTH);
List<PaintSector> list = new ArrayList<PaintSector>();
final SectorRefactor refactor = movingArea.getRefactor();
boolean sectorReplaced = false;
DFDSFunction function = movingArea.findDFDSFunction(this.getBounds());
if (function != null) {
getFunction().setOwner(function.getFunction());
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector ps = refactor.getSector(i);
Function function2 = ps.getSector().getStart().getFunction();
if (function2 != null && function2.equals(this.function)) {
replaceFunction(ps.getSector().getStart(), ps, list, ps.getStartPoint(), ps.getSector().getStart().getFunctionType(), function, refactor, true);
}
Function function3 = ps.getSector().getEnd().getFunction();
if (function3 != null && function3.equals(this.function)) {
replaceFunction(ps.getSector().getEnd(), ps, list, ps.getEndPoint(), ps.getSector().getEnd().getFunctionType(), function, refactor, false);
}
}
function.justifyRoles();
sectorReplaced = true;
} else {
if (this.getFunction().getOwner() != null) {
DFDSFunction function2 = movingArea.findDFDSFunction(this.getFunction().getOwner());
if (function2 != null && function2.getBounds().intersects(this.getBounds())) {
function2.justifyRoles();
} else
this.function.setBounds(new FRectangle(myBounds));
} else
this.function.setBounds(new FRectangle(myBounds));
}
MemoryData memoryData = new MemoryData();
if (!sectorReplaced) {
for (int i = 0; i < refactor.getSectorsCount(); i++) {
PaintSector sector = refactor.getSector(i);
setAddedSectorPos(oldRec, sector, list);
}
}
for (PaintSector ps : list) PaintSector.save(ps, memoryData, ((NFunction) this.function).getEngine());
long l = this.function.getLink();
if (l >= 0l) {
Stream stream = (Stream) movingArea.getDataPlugin().findRowByGlobalId(l);
if (stream != null) {
Row[] rows = stream.getAdded();
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = this.function.getBounds();
ops.background = this.function.getBackground();
ops.font = this.function.getFont();
ops.foreground = this.function.getForeground();
for (Row row : rows) if (row != null) {
IDEF0Plugin.setDefaultRectangleVisualOptions(movingArea.getDataPlugin().getEngine(), row.getElement(), ops);
}
}
}
}
use of com.ramussoft.pb.idef.elements.SectorRefactor in project ramus by Vitaliy-Yakovchuk.
the class IDLExporter method printSegments.
protected void printSegments(Function f) throws IOException {
MovingArea movingArea = new MovingArea(dataPlugin, f);
movingArea.setActiveFunction(f);
SectorRefactor sr = movingArea.getRefactor();
for (int i = 0; i < sr.getSectorsCount(); i++) {
PaintSector ps = sr.getSector(i);
writer.p1("ARROWSEG " + (i + 1));
writer.right();
writer.p1("SOURCE " + getName(ps.getSector().getStart(), f, ps.getSector(), sr, ps.getPoint(0)));
StringBuffer path = new StringBuffer();
path.append("PATH ");
for (int j = 0; j < ps.getPointCount(); j++) {
Point point = ps.getPoint(j);
path.append(toCoortinate(point.getX(), point.getY()));
}
writer.p1(path.toString());
String s = ps.getAlternativeText();
if ("".equals(s))
s = ps.getSector().getName();
if ((s != null) && (s.length() > 0)) {
MovingLabel text = ps.getText();
if (text != null) {
final PStringBounder nb = new PStringBounder(null);
nb.setFont(text.getFont());
final PStringBounder.Tokanizer tokanizer = nb.getTokanizer(s, text.getBounds().getWidth(), 0);
StringBuffer sb = new StringBuffer();
if (tokanizer.hasMoreData())
sb.append(tokanizer.getNext());
while (tokanizer.hasMoreData()) {
sb.append("<CR>");
sb.append(tokanizer.getNext());
}
writer.p2("LABEL {0}", "{LWI I 0 " + toByteTextIndex(text.getColor()) + " " + toByteTextIndex(text.getColor()) + " }" + sb.toString());
writer.p1("LABEL COORDINATES " + toCoortinate(ps.getText().getBounds().getX(), ps.getText().getBounds().getCenter().getY()));
if (ps.isShowTilda()) {
writer.p1("SQUIGGLE COORDINATES " + toCoortinate(ps.getTildaOPoint()) + " " + toCoortinate(ps.getTildaPoint()));
}
} else
writer.p2("LABEL {0}", s);
}
writer.p1("SINK " + getName(ps.getSector().getEnd(), f, ps.getSector(), sr, ps.getPoint(ps.getPointCount() - 1)));
writer.left();
writer.p1("ENDSEG");
}
}
use of com.ramussoft.pb.idef.elements.SectorRefactor in project ramus by Vitaliy-Yakovchuk.
the class IDLImporter method createSegment.
private void createSegment(Arrowseg seg, MovingArea area) {
SectorRefactor sr = area.getRefactor();
Sector s = plugin.createSector();
Function f = getFunction();
s.setFunction(f);
PaintSector ps = new PaintSector();
ps.setSector(s);
ps.setMovingArea(area);
sr.addSector(ps);
seg.sector = ps;
ArrayList<FloatPoint> list = new ArrayList<FloatPoint>();
StringTokenizer st = new StringTokenizer(seg.path, "() ");
while (st.hasMoreElements()) list.add(toPoint(st.nextToken()));
seg.pointsList = list;
String text = seg.getText();
if ((text != null) && (text.length() > 0)) {
s.setStream(getStream(text), ReplaceStreamType.CHILDREN);
if (seg.coordinates != null) {
MovingLabel label = new MovingLabel(area);
StringTokenizer st2 = new StringTokenizer(seg.coordinates, "()");
FloatPoint point = toPoint(st2.nextToken());
label.getBounds().setX(point.getX());
label.getBounds().setY(point.getY() - 10);
label.setText(text);
ps.setText(label);
if (seg.squiggleCoordinates != null) {
ps.setShowTilda(true);
}
}
if (seg.label.startsWith("{")) {
StringTokenizer st2 = new StringTokenizer(seg.label, " ");
st2.nextElement();
st2.nextElement();
try {
int font = Integer.parseInt(st2.nextToken());
if (font < uniqueFonts.size())
ps.setFont(uniqueFonts.get(font));
} catch (Exception e) {
}
int color = Integer.parseInt(st2.nextToken());
if (color < COLORS.length)
ps.setColor(COLORS[color]);
}
}
}
Aggregations