use of com.dsoft.pb.types.FRectangle 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.dsoft.pb.types.FRectangle 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.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.
the class DFDSRole method replaceFunction.
private void replaceFunction(NSectorBorder border, PaintSector paintSector, List<PaintSector> list, Point point, int functionType, DFDSFunction function, SectorRefactor refactor, boolean start) {
FRectangle bounds = function.getBounds();
FRectangle thisBounds = this.function.getBounds();
border.setFunctionA(function.getFunction());
border.commit();
if (!list.contains(paintSector))
list.add(paintSector);
double p;
double inPos = 0;
switch(functionType) {
case MovingText.LEFT:
point.setX(bounds.getX());
p = (point.getY() - thisBounds.getY()) / thisBounds.getHeight();
point.setY(bounds.getY() + bounds.getHeight() * p);
inPos = point.getY();
break;
case MovingText.RIGHT:
point.setX(bounds.getRight());
p = (point.getY() - thisBounds.getY()) / thisBounds.getHeight();
point.setY(bounds.getY() + bounds.getHeight() * p);
inPos = point.getY();
break;
case MovingText.TOP:
p = (point.getX() - thisBounds.getX()) / thisBounds.getWidth();
point.setX(bounds.getX() + bounds.getWidth() * p);
point.setY(bounds.getY());
inPos = point.getX();
break;
case MovingText.BOTTOM:
p = (point.getX() - thisBounds.getX()) / thisBounds.getWidth();
point.setX(bounds.getX() + bounds.getWidth() * p);
point.setY(bounds.getBottom());
inPos = point.getX();
break;
}
refactor.createPartIn(border.getCrosspoint(), function.getFunction(), functionType, inPos, !start);
}
use of com.dsoft.pb.types.FRectangle 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);
}
}
use of com.dsoft.pb.types.FRectangle in project ramus by Vitaliy-Yakovchuk.
the class NFunction method setDefaultValues.
public void setDefaultValues() {
boolean inTransaction = false;
if (engine instanceof Journaled) {
inTransaction = ((Journaled) engine).isUserTransactionStarted();
if (!inTransaction)
((Journaled) engine).startUserTransaction();
}
setSectorData(new byte[0]);
setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
setBounds(new FRectangle(IDEFPanel.DEFAULT_X, IDEFPanel.DEFAULT_Y, IDEFPanel.DEFAULT_WIDTH * 1.2, IDEFPanel.DEFAULT_HEIGHT * 1.2));
setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 10)));
setStatus(new Status());
if (engine instanceof Journaled)
if (!inTransaction)
((Journaled) engine).commitUserTransaction();
}
Aggregations