use of com.ramussoft.idef0.attribute.RectangleVisualOptions 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.idef0.attribute.RectangleVisualOptions in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method getDefaultRectangleVisualOptions.
/**
* Can return null if there is no visual options
*/
public static RectangleVisualOptions getDefaultRectangleVisualOptions(Engine engine, Element element) {
if (hasVisualAttributes(engine, element)) {
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = (FRectangle) engine.getAttribute(element, getAttribute(engine, F_BOUNDS));
if (ops.bounds == null)
return null;
ops.background = (Color) engine.getAttribute(element, getAttribute(engine, F_BACKGROUND));
ops.foreground = (Color) engine.getAttribute(element, getAttribute(engine, F_FOREGROUND));
ops.font = (Font) engine.getAttribute(element, getAttribute(engine, F_FONT));
return ops;
}
return null;
}
use of com.ramussoft.idef0.attribute.RectangleVisualOptions in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method setActiveFunction.
/**
* Задає значення активного на блоку (того який являється базовим для
* решти).
*
* @param activeFunction Значення активної функції.
*/
public void setActiveFunction(final Function activeFunction) {
synchronized (backgroundPaintlock) {
bImage = null;
}
String size = activeFunction.getPageSize();
initSize(size);
if (panel != null) {
cancelAdding();
panel.setMovingAreaSize(zoom);
}
if (activeFunction.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
return;
textPaintCache.clear();
if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS) {
DropTarget dropTarget = new DropTarget();
this.setDropTarget(dropTarget);
try {
dropTarget.addDropTargetListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetDropEvent event) {
if (event.getTransferable().isDataFlavorSupported(RowTreeTable.rowsListFlavor)) {
try {
event.acceptDrop(event.getSourceActions());
Rows rows = (Rows) event.getTransferable().getTransferData(RowTreeTable.rowsListFlavor);
FloatPoint point = toPoint(event.getLocation().x, event.getLocation().y);
Function owner = null;
for (MovingPanel panel : panels) if (panel instanceof DFDSFunction && panel.contain(point)) {
owner = ((DFDSFunction) panel).getFunction();
}
startUserTransaction();
Function function = createFunctionalObject(getDoubleOrdinate(event.getLocation().getX()), getDoubleOrdinate(event.getLocation().getY()), Function.TYPE_DFDS_ROLE, activeFunction);
RectangleVisualOptions ops = IDEF0Plugin.getDefaultRectangleVisualOptions(dataPlugin.getEngine(), rows.get(0).getElement());
if (ops != null) {
FRectangle rect = function.getBounds();
rect.setHeight(ops.bounds.getHeight());
rect.setWidth(ops.bounds.getWidth());
function.setBounds(rect);
function.setFont(ops.font);
function.setBackground(ops.background);
function.setForeground(ops.foreground);
}
Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
Row[] rows2 = new Row[rows.size()];
for (int i = 0; i < rows2.length; i++) rows2[i] = dataPlugin.findRowByGlobalId(rows.get(i).getElementId());
stream.setRows(rows2);
function.setLink(stream.getElement().getId());
if (owner != null) {
function.setOwner(owner);
DFDSFunction function2 = findDFDSFunction(owner);
List<Function> roles = getRoles(function2);
if (!roles.contains(function))
roles.add(function);
if (function2 != null)
function2.justifyRoles(roles);
}
commitUserTransaction();
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else
event.rejectDrop();
}
});
} catch (TooManyListenersException e) {
e.printStackTrace();
}
} else
this.setDropTarget(null);
if (rec)
return;
rec = true;
if (panel != null) {
boolean locked;
if (activeFunction.equals(lockedFunction))
locked = true;
else
locked = activeFunction.lock();
refactor.loadFromFunction(activeFunction, false);
if (!activeFunction.equals(lockedFunction)) {
if (lockedFunction != null)
lockedFunction.unlock();
if (locked)
lockedFunction = activeFunction;
else
lockedFunction = null;
}
panel.setMovingActiveFunction(activeFunction);
if (getState() == END_POINT_ADDING)
setState(START_POINT_ADDING);
if ((getState() == END_POINT_CHANGING) || (getState() == START_POINT_CHANGING) || (getState() == FUNCTION_ADDING_STATE) || (getState() == TEXT_ADDING_STATE))
cancelAdding();
} else
refactor.loadFromFunction(activeFunction, false);
boolean updateListeneres = this.activeFunction != activeFunction;
this.activeFunction = activeFunction;
if (panel != null) {
panel.getFrame().propertyChange(MChangeListener.REFRESH_FUNCTION_IN_TREE, activeFunction);
}
setPanels();
if (panel != null) {
setActiveObject(null);
final java.awt.Point mp = getMousePosition();
if (mp != null)
moveMoveListener.mouseMoved(new MouseEvent(this, 0, 0, 0, mp.x, mp.y, 0, false));
}
functionIndex = dataPlugin.indexOfFunction(activeFunction);
if (functionIndex < 0)
functionIndex = 0;
rec = false;
if (updateListeneres) {
ActiveFunctionEvent event = new ActiveFunctionEvent(activeFunction);
for (ActiveFunctionListener l : getActiveFunctionListeners()) l.activeFunctionChanged(event);
}
if (panel != null) {
panel.getFrame().refreshActions(panel);
}
}
use of com.ramussoft.idef0.attribute.RectangleVisualOptions in project ramus by Vitaliy-Yakovchuk.
the class DFDSRoleOptionsDialog method onOk.
@Override
protected void onOk() {
if (!isCanOk()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
return;
}
if (!isOkStreamName()) {
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
}
DFDSRole role = (DFDSRole) object;
Journaled journaled = (Journaled) dataPlugin.getEngine();
journaled.startUserTransaction();
Function function = object.getFunction();
function.setFont(fontChooser.getSelFont());
function.setBackground(backgroundColorChooser.getColor());
function.setForeground(foregroundColorChooser.getColor());
role.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
Stream stream = sectorRowsEditor.getStream();
if (stream == null) {
stream = sectorNameEditor.findStreamByName();
if (stream == null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
final String t = sectorNameEditor.getArrowName();
if (!t.equals("")) {
if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
if (t.equals("")) {
if (!stream.isEmptyName()) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream.setEmptyName(true);
}
} else {
stream.setName(t);
}
stream.setRows(sectorRowsEditor.getRows());
role.setStream(stream, ReplaceStreamType.SIMPLE);
// sector.setStreamAddedByRefactor(false);
final Row[] rs = sectorRowsEditor.getRows();
role.setRows(rs);
if (rs != null) {
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = function.getBounds();
ops.background = function.getBackground();
ops.font = function.getFont();
ops.foreground = function.getForeground();
for (Row row : rs) if (row != null) {
IDEF0Plugin.setDefaultRectangleVisualOptions(dataPlugin.getEngine(), row.getElement(), ops);
}
}
journaled.commitUserTransaction();
setVisible(false);
}
Aggregations