For a while I have tried to have labels not sit on top of other labels
or nodes with no luck. Whatever I place in value to attempt to
reposition the label does nothing. I have the following in my
positionMidLabel
method.
if (lab instanceof FlowLabel)
{
FlowLabel label = (FlowLabel)lab;
Rectangle labelRectangle = label.getBoundingRect();
Point off = label.getOffset();
Point midpt = label.getMidLabelConnectionPoint(null);
JGoDocument doc = view.getDoc();
JGoListPosition pos = doc.getFirstObjectPos();
while(pos != null)
{
JGoObject obj = doc.getObjectAtPos(pos);
pos = doc.getNextObjectPosAtTop(pos);
if(obj instanceof WorkflowStateNode || obj instanceof FlowLabel)
{
Rectangle compareRect = obj.getBoundingRect();
boolean thisLabel = false;
if(obj instanceof FlowLabel)
{
FlowLabel flowLabel = (FlowLabel)obj;
if(flowLabel == this.getMidLabel())
thisLabel = true;
}
if(!thisLabel && labelRectangle.intersects(compareRect))
{
int position = obtainPosition(compareRect,
labelRectangle);
if(position == Rectangle.OUT_TOP)
{
if (midpt != null)
{
int value =
new Double(((compareRect.getY() + compareRect.getHeight()) -
compareRect.getY()) * 2).intValue();
lab.setSpotLocationOffset(Center, midpt.x , midpt.y + value, off.x,
off.y);
}
}
else if(position == Rectangle.OUT_BOTTOM)
{
…
}
else if(position == Rectangle.OUT_LEFT)
{
…
}
else if(position == Rectangle.OUT_RIGHT)
{
…
}
}
else
{
…
}
}
}
}
else
{
super.positionMidLabel(lab, ax, ay, bx, by);
}