mxCell edge = null;
//Retrieve edge Shape and Parent
String shapeConnect = connect.getAttribute(mxVdxConstants.FROM_SHEET);
mxVdxShape edgeShape = edgeShapeMap.get(new PageShapeIDKey(pageNumber,
shapeConnect));
edgeShapeMap.remove(new PageShapeIDKey(pageNumber, shapeConnect));
if (edgeShape != null)
{
Object parent = parentsMap.get(new PageShapeIDKey(pageNumber,
edgeShape.getId()));
//Get Parent Height
double parentHeight = pageHeight;
mxCell parentCell = (mxCell) parent;
if (parentCell != null)
{
mxGeometry parentGeometry = parentCell.getGeometry();
if (parentGeometry != null)
{
parentHeight = parentGeometry.getHeight();
parentHeight += pageHeight - actualPageHeight;
}
}
//Get beginXY and endXY coordinates.
mxPoint beginXY = edgeShape.getBeginXY(parentHeight);
beginXY = calculateAbsolutePoint((mxCell) parent, graph, beginXY);
mxPoint endXY = edgeShape.getEndXY(parentHeight);
endXY = calculateAbsolutePoint((mxCell) parent, graph, endXY);
//Declare variables.
mxCell source = null;
mxCell target = null;
mxPoint fromConstraint = null;
mxPoint toConstraint = null;
//Defines text label
String textLabel = edgeShape.getTextLabel();
String from = connect.getAttribute(mxVdxConstants.TO_SHEET);
mxVdxShape fromShape = vertexShapeMap.get(new PageShapeIDKey(
pageNumber, from));
//If the source is not defined.
if (connect.getAttribute(mxVdxConstants.FROM_CELL).equals(
mxVdxConstants.END_X)
|| fromShape == null)
{
//Only one side connected.
source = (mxCell) graph.insertVertex(parent, null, null,
beginXY.getX(), beginXY.getY(), 0, 0);
fromConstraint = new mxPoint(0, 0);
sigConnect = connect;
}
else
{
//Define Source vertex of the edge.
source = vertexMap.get(new PageShapeIDKey(pageNumber, from));
//Get dimentions of vertex
mxPoint dimentionFrom = fromShape.getDimentions();
//Get From shape origin and begin/end of edge in absolutes values.
double height = pageHeight;
if ((source.getParent() != null)
&& (source.getParent().getGeometry() != null))
{
height = source.getParent().getGeometry().getHeight();
height += pageHeight - actualPageHeight;
}
mxPoint originFrom = fromShape.getOriginPoint(height);
mxPoint absOriginFrom = calculateAbsolutePoint(
(mxCell) source.getParent(), graph, originFrom);
//Determines From Constraints (Connection point) of the edge.
fromConstraint = new mxPoint(
(beginXY.getX() - absOriginFrom.getX())
/ dimentionFrom.getX(),
(beginXY.getY() - absOriginFrom.getY())
/ dimentionFrom.getY());
}
//If is connected in both sides.
if (sigConnect != null)
{
String to = sigConnect.getAttribute(mxVdxConstants.TO_SHEET);
mxVdxShape toShape = vertexShapeMap.get(new PageShapeIDKey(
pageNumber, to));
if (toShape != null)
{
target = vertexMap.get(new PageShapeIDKey(pageNumber, to));
mxPoint dimentionTo = toShape.getDimentions();
//Get To shape origin.
double height = pageHeight;
if ((target.getParent() != null)
&& (target.getParent().getGeometry() != null))
{
height = target.getParent().getGeometry().getHeight();
height += pageHeight - actualPageHeight;
}
mxPoint originTo = toShape.getOriginPoint(height);
mxPoint absOriginTo = calculateAbsolutePoint(
(mxCell) target.getParent(), graph, originTo);
//Determines To Constraints (Connection point) of the edge.