/** {@inheritDoc} */
public void renderInlineParent(InlineParent ip) {
// stuff we only need if a link must be created:
Rectangle ipRect = null;
AbstractAction action = null;
// make sure the rect is determined *before* calling super!
int ipp = currentIPPosition;
int bpp = currentBPPosition + ip.getBlockProgressionOffset();
ipRect = new Rectangle(ipp, bpp, ip.getIPD(), ip.getBPD());
AffineTransform transform = graphicContext.getTransform();
ipRect = transform.createTransformedShape(ipRect).getBounds();
// render contents
super.renderInlineParent(ip);
boolean linkTraitFound = false;
// try INTERNAL_LINK first
Trait.InternalLink intLink = (Trait.InternalLink) ip.getTrait(Trait.INTERNAL_LINK);
if (intLink != null) {
linkTraitFound = true;
String pvKey = intLink.getPVKey();
String idRef = intLink.getIDRef();
boolean pvKeyOK = pvKey != null && pvKey.length() > 0;
boolean idRefOK = idRef != null && idRef.length() > 0;
if (pvKeyOK && idRefOK) {
Integer pageIndex = (Integer)pageIndices.get(pvKey);
action = getGoToActionForID(idRef, (pageIndex != null ? pageIndex.intValue() : -1));
} else {
//Warnings already issued by AreaTreeHandler
}
}
// no INTERNAL_LINK, look for EXTERNAL_LINK
if (!linkTraitFound) {
Trait.ExternalLink extLink = (Trait.ExternalLink) ip.getTrait(Trait.EXTERNAL_LINK);
if (extLink != null) {
String extDest = extLink.getDestination();
if (extDest != null && extDest.length() > 0) {
linkTraitFound = true;
action = new URIAction(extDest, extLink.newWindow());
action = actionSet.put(action);
}
}
}
// warn if link trait found but not allowed, else create link
if (linkTraitFound) {
StructureTreeElement structElem
= (StructureTreeElement) ip.getTrait(Trait.STRUCTURE_TREE_ELEMENT);
action.setStructureTreeElement(structElem);
Link link = new Link(action, ipRect);
this.deferredLinks.add(link);
}
}