{
model.beginUpdate();
try
{
double scale = view.getScale();
mxPoint tr = view.getTranslate();
// Prepares a hashtable for faster cell lookups
Set<Object> hash = new HashSet<Object>();
for (int i = 0; i < cells.length; i++)
{
hash.add(cells[i]);
}
for (int i = 0; i < cells.length; i++)
{
if (model.isEdge(cells[i]))
{
mxGeometry geo = model.getGeometry(cells[i]);
if (geo != null)
{
mxCellState state = view.getState(cells[i]);
mxCellState pstate = view.getState(model
.getParent(cells[i]));
if (state != null && pstate != null)
{
geo = (mxGeometry) geo.clone();
double dx = -pstate.getOrigin().getX();
double dy = -pstate.getOrigin().getY();
Object src = model.getTerminal(cells[i], true);
if (src != null
&& isCellDisconnectable(cells[i], src,
true))
{
while (src != null && !hash.contains(src))
{
src = model.getParent(src);
}
if (src == null)
{
mxPoint pt = state.getAbsolutePoint(0);
geo.setTerminalPoint(
new mxPoint(pt.getX() / scale
- tr.getX() + dx, pt
.getY()
/ scale
- tr.getY() + dy), true);
model.setTerminal(cells[i], null, true);
}
}
Object trg = model.getTerminal(cells[i], false);
if (trg != null
&& isCellDisconnectable(cells[i], trg,
false))
{
while (trg != null && !hash.contains(trg))
{
trg = model.getParent(trg);
}
if (trg == null)
{
int n = state.getAbsolutePointCount() - 1;
mxPoint pt = state.getAbsolutePoint(n);
geo.setTerminalPoint(
new mxPoint(pt.getX() / scale
- tr.getX() + dx, pt
.getY()
/ scale
- tr.getY() + dy),
false);
model.setTerminal(cells[i], null, false);