Vector<Object> celle = new Vector<Object>();
for (int x = 0; x < celletmp.length; x++) {
if (!(celletmp[x] == vertex) && !((vertex.getChildren()).contains(celletmp[x])) && !(celletmp[x] == edge)) {
Object[] listEdgesIn = null;
Object[] listEdgesOut = null;
GraphModel graphmodel = mediator.getGraph().getModel();
listEdgesIn = DefaultGraphModel.getEdges(graphmodel, vertex, true);
listEdgesOut = DefaultGraphModel.getEdges(graphmodel, vertex, false);
boolean edgeIn = false;
boolean edgeOut = false;
for (Object element : listEdgesIn) {
if (celletmp[x] instanceof JmtEdge && element.equals(celletmp[x])) {
edgeIn = true;
}
}
for (Object element : listEdgesOut) {
if (celletmp[x] instanceof JmtEdge && element.equals(celletmp[x])) {
edgeIn = true;
}
}
if ((listEdgesIn.length == 0 && listEdgesOut.length == 0) || (!edgeIn && !edgeOut)) {
if (celletmp[x] instanceof JmtEdge) {
JmtEdgeView viewtmp = (JmtEdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(((celletmp[x])), false);
if (((JmtEdge) celletmp[x]).intersects(viewtmp, newRett)) {
celle.add(celletmp[x]);
}
} else {
celle.add(celletmp[x]);
}
}
}
}
Object[] celletmp3 = (mediator.getGraph()).getDescendants(mediator.getGraph().getRoots(newRettDown));
Vector<Object> celle2 = new Vector<Object>();
for (int x = 0; x < celletmp3.length; x++) {
if (!(celletmp3[x] == vertex) && !((vertex.getChildren()).contains(celletmp3[x])) && !(celletmp3[x] == edge)) {
if (celletmp3[x] instanceof JmtEdge) {
JmtEdgeView viewtmp = (JmtEdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(((celletmp3[x])), false);
if (((handledEdges.size() == 0) || (handledEdges.size() > 0 && !handledEdges.contains(celletmp3[x])))
&& ((JmtEdge) celletmp3[x]).intersects(viewtmp, newRettDown)) {
celle2.add(celletmp3[x]);
}
} else {
celle2.add(celletmp3[x]);
}
}
}
if (celle.size() > 0 && celle2.size() == 0) {
if (((int) newRettDown.getMinX() < 20) || ((int) newRettDown.getMinY() < 0)) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
return new Point((int) newRettDown.getMinX(), (int) newRettDown.getMinY());
} else if (celle.size() == 0) {
if (((int) newRettUp.getMinX() < 20) || ((int) newRettUp.getMinY() < 0)) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
return new Point((int) newRettUp.getMinX(), (int) newRettUp.getMinY());
} else if (celle.size() > 0 && celle2.size() > 0) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
pointBack = new Point((int) vertexMinX, pointYToMove);
} //END IF to move the vertex UP
//BEGIN IF to move the vertex RIGHT
else if (!down && !up && !left && right) {
int pointXToMove = (int) (tmp.getX() + 12);
Rectangle newRett = new Rectangle(pointXToMove, (int) vertexMinY, (int) vertexWidth, (int) vertexHeight);
Object[] celletmp = (mediator.getGraph()).getDescendants(mediator.getGraph().getRoots(newRett));
Vector<Object> celle = new Vector<Object>();
for (int x = 0; x < celletmp.length; x++) {//BEGIN FOR
if (!(celletmp[x] == vertex) && !((vertex.getChildren()).contains(celletmp[x])) && !(celletmp[x] == edge)) {
Object[] listEdgesIn = null;
Object[] listEdgesOut = null;
GraphModel graphmodel = mediator.getGraph().getModel();
listEdgesIn = DefaultGraphModel.getEdges(graphmodel, vertex, true);
listEdgesOut = DefaultGraphModel.getEdges(graphmodel, vertex, false);
boolean edgeIn = false;
boolean edgeOut = false;
for (Object element : listEdgesIn) {
if (celletmp[x] instanceof JmtEdge && element.equals(celletmp[x])) {
edgeIn = true;
}
}
for (Object element : listEdgesOut) {
if (celletmp[x] instanceof JmtEdge && element.equals(celletmp[x])) {
edgeIn = true;
}
}
if ((listEdgesIn.length == 0 && listEdgesOut.length == 0) || (!edgeIn && !edgeOut)) {
if (!(celletmp[x] == vertex) && !((vertex.getChildren()).contains(celletmp[x])) && !(celletmp[x] == edge)) {
if (celletmp[x] instanceof JmtEdge) {
JmtEdgeView viewtmp = (JmtEdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(((celletmp[x])), false);
if (((handledEdges.size() == 0) || (handledEdges.size() > 0 && !handledEdges.contains(celletmp[x])))
&& ((JmtEdge) celletmp[x]).intersects(viewtmp, newRett)) {
celle.add(celletmp[x]);
}
} else {
celle.add(celletmp[x]);
}
}
}
}
}//END FOR
Object[] celletmp3 = (mediator.getGraph()).getDescendants(mediator.getGraph().getRoots(newRettLeft));
Vector<Object> celle3 = new Vector<Object>();
for (int x = 0; x < celletmp3.length; x++) {
if (!(celletmp3[x] == vertex) && !((vertex.getChildren()).contains(celletmp3[x])) && !(celletmp3[x] == edge)) {
if (celletmp3[x] instanceof JmtEdge) {
JmtEdgeView viewtmp = (JmtEdgeView) (mediator.getGraph().getGraphLayoutCache()).getMapping(((celletmp3[x])), false);
if (((handledEdges.size() == 0) || (handledEdges.size() > 0 && !handledEdges.contains(celletmp3[x])))
&& ((JmtEdge) celletmp3[x]).intersects(viewtmp, newRettLeft)) {
celle3.add(celletmp3[x]);
}
} else {
celle3.add(celletmp3[x]);
}
}
}
if (celle.size() > 0 && celle3.size() == 0) {
if (((int) cellBound.getMinX() < 20) || ((int) cellBound.getMinY() < 0)) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
return new Point((int) newRettLeft.getMinX(), (int) newRettLeft.getMinY());
} else if (celle.size() == 0) {
if (((int) cellBound.getMinX() < 20) || ((int) cellBound.getMinY() < 0)) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
return new Point((int) newRett.getMinX(), (int) newRett.getMinY());
} else if (celle.size() > 0 && celle3.size() > 0) {
return new Point((int) cellBound.getMinX(), (int) cellBound.getMinY());
}
pointBack = new Point(pointXToMove, (int) vertexMinY);
}//END IF to move the vertex RIGHT
//BEGIN IF to move the vertex LEFT
else if (!down && !up && left && !right) {
int pointXToMove = (int) (vertexMaxX - tmp.getX());
int point2XToMove = (int) (vertexMinX - pointXToMove) - 12;
if (point2XToMove < 0) {
point2XToMove = (int) (tmp.getX() + 12);
}
Rectangle newRett = new Rectangle(point2XToMove, (int) vertexMinY, (int) vertexWidth, (int) vertexHeight);
Object[] celletmp = (mediator.getGraph()).getDescendants(mediator.getGraph().getRoots(newRett));
Vector<Object> celle = new Vector<Object>();
for (int x = 0; x < celletmp.length; x++) {
if (!(celletmp[x] == vertex) && !((vertex.getChildren()).contains(celletmp[x])) && !(celletmp[x] == edge)) {
Object[] listEdgesIn = null;
Object[] listEdgesOut = null;
GraphModel graphmodel = mediator.getGraph().getModel();
listEdgesIn = DefaultGraphModel.getEdges(graphmodel, vertex, true);
listEdgesOut = DefaultGraphModel.getEdges(graphmodel, vertex, false);
boolean edgeIn = false;
boolean edgeOut = false;
for (Object element : listEdgesIn) {