use of com.dsoft.pb.types.FloatPoint 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.dsoft.pb.types.FloatPoint in project ramus by Vitaliy-Yakovchuk.
the class MovingPanel method mouseDragged.
public void mouseDragged(final FloatPoint point) {
if (!canMove)
return;
final FloatPoint add = point.minus(pressedPoint);
if (xt == 2)
pressedPoint.setX(point.getX());
if (yt == 2)
pressedPoint.setY(point.getY());
switch(state) {
case STATE_MOVE:
move(add);
break;
case STATE_RESIZE_BOTTOM:
{
moveBottomWall(add.getY());
moveRightWall(0);
}
break;
case STATE_RESIZE_TOP:
{
moveTopWall(add.getY());
moveRightWall(0);
}
break;
case STATE_RESIZE_LEFT:
{
moveLeftWall(add.getX());
moveBottomWall(0);
}
break;
case STATE_RESIZE_RIGHT:
{
moveRightWall(add.getX());
moveBottomWall(0);
}
break;
case STATE_RESIZE_BOTTOM_LEFT:
{
moveBottomWall(add.getY());
moveLeftWall(add.getX());
}
break;
case STATE_RESIZE_LEFT_TOP:
{
moveTopWall(add.getY());
moveLeftWall(add.getX());
}
break;
case STATE_RESIZE_TOP_RIGHT:
{
moveTopWall(add.getY());
moveRightWall(add.getX());
}
break;
case STATE_RESIZE_RIGHT_BOTTOM:
{
moveBottomWall(add.getY());
moveRightWall(add.getX());
}
break;
}
onBoundsChange();
}
use of com.dsoft.pb.types.FloatPoint in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method mouseClicked.
/**
* @see com.ramussoft.pb.idef.visual.MovingPanel#mouseClicked(com.dsoft.pb.types.FloatPoint)
*/
@Override
public void mouseClicked(final FloatPoint point) {
super.mouseClicked(point);
if (movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) {
if (movingArea.getPointChangingType() == SectorRefactor.TYPE_START) {
if (getTriangle(point) == RIGHT) {
final Ordinate x = new Ordinate(Ordinate.TYPE_X);
final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
final Point p = new Point(x, y);
x.setPosition(getBounds().getRight());
y.setPosition(getBounds().getY() + point.getY());
final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
pp.point = p;
pp.x = p.getX();
pp.y = p.getY();
pp.setFunction(getFunction(), RIGHT);
pp.type = SectorRefactor.TYPE_START;
movingArea.getRefactor().setPoint(pp);
movingArea.doSector();
}
} else {
final int type = getTriangle(point);
if (type == -1 || type == RIGHT)
return;
final Ordinate x = new Ordinate(Ordinate.TYPE_X);
final Ordinate y = new Ordinate(Ordinate.TYPE_Y);
final Point p = new Point(x, y);
final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
pp.point = p;
switch(type) {
case LEFT:
{
pp.setFunction(getFunction(), LEFT);
x.setPosition(getBounds().getLeft());
y.setPosition(getBounds().getY() + point.getY());
}
break;
case TOP:
{
pp.setFunction(getFunction(), TOP);
x.setPosition(getBounds().getX() + point.getX());
y.setPosition(getBounds().getTop());
}
break;
case BOTTOM:
{
pp.setFunction(getFunction(), BOTTOM);
x.setPosition(getBounds().getX() + point.getX());
y.setPosition(getBounds().getBottom());
}
break;
}
pp.x = x.getPosition();
pp.y = y.getPosition();
pp.type = SectorRefactor.TYPE_END;
movingArea.getRefactor().setPoint(pp);
movingArea.doSector();
}
}
}
use of com.dsoft.pb.types.FloatPoint in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method getTriangle.
protected int getTriangle(final FloatPoint point) {
int res = -1;
FloatPoint l = getLocation();
for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
GeneralPath gp = getTrianglePath(type);
double y = point.getY() + l.getY();
double x = point.getX() + l.getX();
if (gp.contains(new Point2D.Double(x, y))) {
res = type;
break;
}
}
if (isShowRight() ^ res == Point.RIGHT)
res = -1;
return res;
}
use of com.dsoft.pb.types.FloatPoint in project ramus by Vitaliy-Yakovchuk.
the class MouseSelection method onProcessEndBoundsChange.
public void onProcessEndBoundsChange(MovingArea movingArea, MovingText[] panels, FloatPoint diff) {
for (MovingText text : panels) if (text instanceof DFDSRole) {
IDEF0Object idef = (IDEF0Object) text;
if (contains(text))
idef.onProcessEndBoundsChange(sectors);
}
for (MovingText text : panels) {
if (!(text instanceof DFDSRole))
if (contains(text)) {
if (text instanceof IDEF0Object) {
IDEF0Object idef = (IDEF0Object) text;
idef.onProcessEndBoundsChange(sectors);
}
}
}
List<Ordinate> xOrdinates = new ArrayList<Ordinate>();
List<Ordinate> yOrdinates = new ArrayList<Ordinate>();
for (PaintSector ps : sectors) {
for (Point point : ps.getPoints()) {
boolean has;
has = false;
for (Ordinate o : xOrdinates) if (o.getOrdinateId() == point.getXOrdinate().getOrdinateId()) {
has = true;
break;
}
if (!has)
xOrdinates.add(point.getXOrdinate());
has = false;
for (Ordinate o : yOrdinates) if (o.getOrdinateId() == point.getYOrdinate().getOrdinateId()) {
has = true;
break;
}
if (!has)
yOrdinates.add(point.getYOrdinate());
}
}
List<PaintSector> psrs = new ArrayList<PaintSector>();
psrs.addAll(sectors);
for (Ordinate xOrdinate : xOrdinates) {
xOrdinate.setPosition(xOrdinate.getPosition() + diff.getX());
for (Point point : xOrdinate.getPoints()) if (!psrs.contains(point.getSector()))
psrs.add(point.getSector());
}
for (Ordinate yOrdinate : yOrdinates) {
yOrdinate.setPosition(yOrdinate.getPosition() + diff.getY());
for (Point point : yOrdinate.getPoints()) if (!psrs.contains(point.getSector()))
psrs.add(point.getSector());
}
MemoryData data = new MemoryData();
for (PaintSector paintSector : sectors) {
Function sFunction = paintSector.getSector().getStart().getFunction();
if (sFunction != null) {
switch(paintSector.getSector().getStart().getFunctionType()) {
case MovingFunction.LEFT:
paintSector.getStartPoint().setX(sFunction.getBounds().getLeft());
break;
case MovingFunction.RIGHT:
paintSector.getStartPoint().setX(sFunction.getBounds().getRight());
break;
case MovingFunction.TOP:
paintSector.getStartPoint().setY(sFunction.getBounds().getTop());
break;
case MovingFunction.BOTTOM:
paintSector.getStartPoint().setY(sFunction.getBounds().getBottom());
break;
}
}
sFunction = paintSector.getSector().getEnd().getFunction();
if (sFunction != null) {
switch(paintSector.getSector().getEnd().getFunctionType()) {
case MovingFunction.LEFT:
paintSector.getEndPoint().setX(sFunction.getBounds().getLeft());
break;
case MovingFunction.RIGHT:
paintSector.getEndPoint().setX(sFunction.getBounds().getRight());
break;
case MovingFunction.TOP:
paintSector.getEndPoint().setY(sFunction.getBounds().getTop());
break;
case MovingFunction.BOTTOM:
paintSector.getEndPoint().setY(sFunction.getBounds().getBottom());
break;
}
}
}
for (MovingText text : panels) {
if (!(text instanceof DFDSRole))
if (contains(text)) {
if (!(text instanceof IDEF0Object)) {
text.onProcessEndBoundsChange();
if (text instanceof MovingLabel)
((MovingLabel) text).boundsCopy = text.getBounds();
}
}
}
for (PaintSector ps : psrs) PaintSector.save(ps, data, movingArea.getDataPlugin().getEngine());
}
Aggregations