use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class DFDSFunction method justifyRoles.
public void justifyRoles(List<Function> roles1) {
FRectangle bounds = getBounds();
List<Function> roles = new ArrayList<Function>();
for (Function role : roles1) if (bounds.intersects(role.getBounds()))
roles.add(role);
List<List<FRectangle>> lines = new ArrayList<List<FRectangle>>();
lines.add(new ArrayList<FRectangle>());
List<double[]> maxHights = new ArrayList<double[]>();
maxHights.add(new double[] { 0 });
int line = 0;
double x = bounds.getX() + 2;
double maxX = bounds.getX() + bounds.getWidth() * ROLES_PERCENT;
for (Function role : roles) {
FRectangle rectangle = role.getBounds();
if (x + rectangle.getWidth() > maxX) {
line++;
lines.add(new ArrayList<FRectangle>());
x = bounds.getX() + 2;
maxHights.add(new double[] { 0 });
}
List<FRectangle> list = lines.get(line);
FRectangle rect = role.getBounds();
list.add(rect);
rect.setX(x);
if (rect.getHeight() > maxHights.get(line)[0])
maxHights.get(line)[0] = rect.getHeight();
x += rect.getWidth() + 3;
}
double d = maxHights.get(line)[0];
double y = bounds.getBottom() - d - 2;
for (int i = line; i >= 0; --i) {
List<FRectangle> rectangles = lines.get(i);
for (FRectangle rectangle : rectangles) rectangle.setY(y);
if (i > 0)
y -= maxHights.get(i - 1)[0];
}
int i = 0;
for (List<FRectangle> list : lines) for (FRectangle rectangle : list) {
roles.get(i).setBounds(new FRectangle(rectangle));
i++;
}
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class DFDSRole method setStream.
public void setStream(Stream stream, ReplaceStreamType replaceStreamType) {
function.setLink((stream == null) ? -1 : stream.getElement().getId());
Function function = (Function) this.function.getOwner();
if (function != null) {
HashSet<Sector> toUpdate = new HashSet<Sector>();
for (Sector sector : ((Function) this.function.getParent()).getSectors()) {
if (function.equals(sector.getStart().getFunction()) || function.equals(sector.getEnd().getFunction()))
if (!toUpdate.contains(sector))
toUpdate.add(sector);
}
for (Sector sector : toUpdate) SectorRefactor.fixOwners(sector, movingArea.dataPlugin);
} else {
SectorRefactor.copyOwnersFrom(this.function, movingArea.dataPlugin);
}
}
use of com.ramussoft.pb.Function 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.Function in project ramus by Vitaliy-Yakovchuk.
the class AbstractClassicTemplate method createInsOuts.
private void createInsOuts(final Function function, final MovingArea movingArea) {
Function f = (Function) function.getChildAt(0);
createStartxBorderPoint(movingArea, 10, getY(f), LEFT);
createInPoint(movingArea, f, LEFT, f.getBounds().getLeft(), getY(f));
for (int i = 1; i < function.getChildCount(); i++) {
final Function sF = (Function) function.getChildAt(i);
createOutPoint(movingArea, f);
createInPoint(movingArea, sF, LEFT, sF.getBounds().getLeft(), getY(sF));
f = sF;
}
createOutPoint(movingArea, f);
createRightBorderPoint(movingArea, getY(f));
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class SimpleTemplate method createChilds.
public void createChilds(final Function function, final DataPlugin dataPlugin) {
final MovingArea movingArea = new MovingArea(dataPlugin);
movingArea.setDataPlugin(dataPlugin);
movingArea.setActiveFunction(function);
movingArea.setArrowAddingState();
assert count > 0;
// Відступ зправа/зліва
final double x = 80;
// Відступ знизу/звурху
final double y = 80;
final double width = movingArea.MOVING_AREA_WIDTH - x * 2 - IDEFPanel.DEFAULT_WIDTH;
final double height = movingArea.CLIENT_HEIGHT - y * 2 - IDEFPanel.DEFAULT_HEIGHT;
for (int i = 0; i < count; i++) {
final Function f = (Function) dataPlugin.createRow(function, true);
final FRectangle rect = new FRectangle(f.getBounds());
rect.setX(x + width / (count - 1) * i);
rect.setY(y + height / (count - 1) * i);
f.setBounds(rect);
}
}
Aggregations