Program: 67786
Project: 67786
Buggy source:
/** 
 * Renders all marker lines (and labels at requested positions) associated with every axis in the plot Note that marker lines are drawn immediately (not rendered as deferred) at the appropriate Z-order
 * @param oaxa
 * @param boPlotClientArea
 * @throws ChartException
 */
private final void renderMarkerLines() throws ChartException {
  PlotWithAxes pwa=(PlotWithAxes)getComputations();
  Bounds boPlotClientArea=pwa.getPlotBounds();
  Axis ax;
  OneAxis[] oaxa=getAllOneAxes();
  int iLineCount, iAxisCount=oaxa.length;
  MarkerLine ml;
  LineRenderEvent lre;
  DataElement deValue;
  AutoScale asc;
  double dCoordinate=0;
  int iOrientation;
  final IDeviceRenderer idr=getDevice();
  final AbstractScriptHandler<?> sh=getRunTimeContext().getScriptHandler();
  final Location loStart=goFactory.createLocation(0,0);
  final Location loEnd=goFactory.createLocation(0,0);
  Anchor anc;
  TextRenderEvent tre=null;
  Label la=null;
  double dOriginalAngle=0;
  final boolean bTransposed=((ChartWithAxes)getModel()).isTransposed();
  final Bounds boText=goFactory.createBounds(0,0,0,0);
  for (int i=0; i < iAxisCount; i++) {
    ax=oaxa[i].getModelAxis();
    iOrientation=ax.getOrientation().getValue();
    if (bTransposed) {
      iOrientation=(iOrientation == Orientation.HORIZONTAL) ? Orientation.VERTICAL : Orientation.HORIZONTAL;
    }
    asc=oaxa[i].getScale();
    EList<MarkerLine> el=ax.getMarkerLines();
    iLineCount=el.size();
    for (int j=0; j < iLineCount; j++) {
      ml=el.get(j);
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_MARKER_LINE,ax,ml,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_MARKER_LINE,ml);
      deValue=ml.getValue();
      if (deValue == null) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{ml},Messages.getResourceBundle(getRunTimeContext().getULocale()));
      }
      la=goFactory.copyOf(ml.getLabel());
      if (la.getCaption().getValue() != null && !IConstants.UNDEFINED_STRING.equals(la.getCaption().getValue()) && la.getCaption().getValue().length() > 0) {
        la.getCaption().setValue(oaxa[i].getRunTimeContext().externalizedMessage(la.getCaption().getValue()));
      }
 else {
        try {
          la.getCaption().setValue(ValueFormatter.format(deValue,ml.getFormatSpecifier(),oaxa[i].getRunTimeContext().getULocale(),null));
        }
 catch (        ChartException dfex) {
          throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,dfex);
        }
      }
      if (isDimension3D()) {
        return;
      }
      try {
        dCoordinate=Methods.getLocation(asc,deValue);
      }
 catch (      Exception ex) {
        logger.log(ILogger.WARNING,Messages.getString("String_Node_Str",new Object[]{deValue,ml},getRunTimeContext().getULocale()));
        continue;
      }
      lre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),LineRenderEvent.class);
      if (iOrientation == Orientation.HORIZONTAL) {
        if (dCoordinate > boPlotClientArea.getLeft() + boPlotClientArea.getWidth()) {
          dCoordinate=boPlotClientArea.getLeft() + boPlotClientArea.getWidth();
        }
        if (dCoordinate < boPlotClientArea.getLeft()) {
          dCoordinate=boPlotClientArea.getLeft();
        }
        loStart.set(dCoordinate,boPlotClientArea.getTop());
        loEnd.set(dCoordinate,boPlotClientArea.getTop() + boPlotClientArea.getHeight());
      }
 else {
        if (dCoordinate < boPlotClientArea.getTop()) {
          dCoordinate=boPlotClientArea.getTop();
        }
        if (dCoordinate > boPlotClientArea.getTop() + boPlotClientArea.getHeight()) {
          dCoordinate=boPlotClientArea.getTop() + boPlotClientArea.getHeight();
        }
        loStart.set(boPlotClientArea.getLeft(),dCoordinate);
        loEnd.set(boPlotClientArea.getLeft() + boPlotClientArea.getWidth(),dCoordinate);
      }
      if (pwa.getDimension() == IConstants.TWO_5_D) {
        if (iOrientation == Orientation.HORIZONTAL) {
          loStart.translate(0,pwa.getSeriesThickness());
          loEnd.translate(0,pwa.getSeriesThickness());
        }
 else {
          loStart.translate(-pwa.getSeriesThickness(),0);
          loEnd.translate(-pwa.getSeriesThickness(),0);
        }
      }
      lre.setStart(loStart);
      lre.setEnd(loEnd);
      lre.setLineAttributes(ml.getLineAttributes());
      idr.drawLine(lre);
      if (la.isVisible()) {
        anc=switchAnchor(ml.getLabelAnchor());
        if (bTransposed) {
          dOriginalAngle=la.getCaption().getFont().getRotation();
          try {
            la.getCaption().getFont().setRotation(pwa.getTransposedAngle(dOriginalAngle));
            anc=ChartUtil.transposeAnchor(anc);
          }
 catch (          IllegalArgumentException uiex) {
            throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,uiex);
          }
        }
        BoundingBox bb=null;
        try {
          bb=cComp.computeBox(idr.getDisplayServer(),IConstants.LEFT,la,0,0);
        }
 catch (        IllegalArgumentException uiex) {
          throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,uiex);
        }
        boText.set(0,0,bb.getWidth(),bb.getHeight());
        if (iOrientation == Orientation.VERTICAL) {
          if (anc != null) {
switch (anc.getValue()) {
case Anchor.NORTH:
case Anchor.NORTH_EAST:
case Anchor.NORTH_WEST:
              boText.setTop(loStart.getY() - boText.getHeight());
            break;
case Anchor.SOUTH:
case Anchor.SOUTH_EAST:
case Anchor.SOUTH_WEST:
          boText.setTop(loStart.getY());
        break;
default :
      boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
    break;
}
switch (anc.getValue()) {
case Anchor.NORTH_EAST:
case Anchor.SOUTH_EAST:
case Anchor.EAST:
  boText.setLeft(loEnd.getX() - boText.getWidth());
break;
case Anchor.NORTH_WEST:
case Anchor.SOUTH_WEST:
case Anchor.WEST:
boText.setLeft(loStart.getX());
break;
default :
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
break;
}
}
 else {
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
}
}
 else {
if (anc != null) {
switch (anc.getValue()) {
case Anchor.NORTH:
case Anchor.NORTH_EAST:
case Anchor.NORTH_WEST:
boText.setTop(loStart.getY());
break;
case Anchor.SOUTH:
case Anchor.SOUTH_EAST:
case Anchor.SOUTH_WEST:
boText.setTop(loEnd.getY() - boText.getHeight());
break;
default :
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
break;
}
switch (anc.getValue()) {
case Anchor.NORTH_EAST:
case Anchor.SOUTH_EAST:
case Anchor.EAST:
boText.setLeft(loStart.getX());
break;
case Anchor.NORTH_WEST:
case Anchor.SOUTH_WEST:
case Anchor.WEST:
boText.setLeft(loEnd.getX() - boText.getWidth());
break;
default :
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
break;
}
}
 else {
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
}
}
tre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),TextRenderEvent.class);
tre.setBlockBounds(boText);
tre.setBlockAlignment(null);
tre.setLabel(la);
tre.setAction(TextRenderEvent.RENDER_TEXT_IN_BLOCK);
getDeferredCache().addLabel(tre);
}
if (isInteractivityEnabled()) {
Trigger tg;
EList<Trigger> elTriggers=ml.getTriggers();
if (!elTriggers.isEmpty()) {
final InteractionEvent iev=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),InteractionEvent.class);
iev.setCursor(ml.getCursor());
for (int t=0; t < elTriggers.size(); t++) {
tg=goFactory.copyOf(elTriggers.get(t));
processTrigger(tg,StructureSource.createMarkerLine(ml));
iev.addTrigger(tg);
}
Location[] loaHotspot=new Location[4];
if (iOrientation == Orientation.HORIZONTAL) {
loaHotspot[0]=goFactory.createLocation(loStart.getX() - IConstants.LINE_EXPAND_SIZE,loStart.getY());
loaHotspot[1]=goFactory.createLocation(loStart.getX() + IConstants.LINE_EXPAND_SIZE,loStart.getY());
loaHotspot[2]=goFactory.createLocation(loEnd.getX() + IConstants.LINE_EXPAND_SIZE,loEnd.getY());
loaHotspot[3]=goFactory.createLocation(loEnd.getX() - IConstants.LINE_EXPAND_SIZE,loEnd.getY());
}
 else {
loaHotspot[0]=goFactory.createLocation(loStart.getX(),loStart.getY() - IConstants.LINE_EXPAND_SIZE);
loaHotspot[1]=goFactory.createLocation(loEnd.getX(),loEnd.getY() - IConstants.LINE_EXPAND_SIZE);
loaHotspot[2]=goFactory.createLocation(loEnd.getX(),loEnd.getY() + IConstants.LINE_EXPAND_SIZE);
loaHotspot[3]=goFactory.createLocation(loStart.getX(),loStart.getY() + IConstants.LINE_EXPAND_SIZE);
}
final PolygonRenderEvent pre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),PolygonRenderEvent.class);
pre.setPoints(loaHotspot);
iev.setHotSpot(pre);
idr.enableInteraction(iev);
}
}
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_MARKER_LINE,ax,ml,getRunTimeContext().getScriptContext());
getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_MARKER_LINE,ml);
}
}
}

Fixed version (ground truth):
/** 
 * Renders all marker lines (and labels at requested positions) associated with every axis in the plot Note that marker lines are drawn immediately (not rendered as deferred) at the appropriate Z-order
 * @param oaxa
 * @param boPlotClientArea
 * @throws ChartException
 */
private final void renderMarkerLines() throws ChartException {
  PlotWithAxes pwa=(PlotWithAxes)getComputations();
  Bounds boPlotClientArea=pwa.getPlotBounds();
  Axis ax;
  OneAxis[] oaxa=getAllOneAxes();
  int iLineCount, iAxisCount=oaxa.length;
  MarkerLine ml;
  LineRenderEvent lre;
  DataElement deValue;
  AutoScale asc;
  double dCoordinate=0;
  int iOrientation;
  final IDeviceRenderer idr=getDevice();
  final AbstractScriptHandler<?> sh=getRunTimeContext().getScriptHandler();
  final Location loStart=goFactory.createLocation(0,0);
  final Location loEnd=goFactory.createLocation(0,0);
  Anchor anc;
  TextRenderEvent tre=null;
  Label la=null;
  double dOriginalAngle=0;
  final boolean bTransposed=((ChartWithAxes)getModel()).isTransposed();
  final Bounds boText=goFactory.createBounds(0,0,0,0);
  for (int i=0; i < iAxisCount; i++) {
    ax=oaxa[i].getModelAxis();
    iOrientation=ax.getOrientation().getValue();
    if (bTransposed) {
      iOrientation=(iOrientation == Orientation.HORIZONTAL) ? Orientation.VERTICAL : Orientation.HORIZONTAL;
    }
    asc=oaxa[i].getScale();
    EList<MarkerLine> el=ax.getMarkerLines();
    iLineCount=el.size();
    for (int j=0; j < iLineCount; j++) {
      ml=el.get(j);
      ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_MARKER_LINE,ax,ml,getRunTimeContext().getScriptContext());
      getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_MARKER_LINE,ml);
      deValue=ml.getValue();
      if (deValue == null) {
        throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{ml},Messages.getResourceBundle(getRunTimeContext().getULocale()));
      }
      la=goFactory.copyOf(ml.getLabel());
      if (la.getCaption().getValue() != null && !IConstants.UNDEFINED_STRING.equals(la.getCaption().getValue()) && la.getCaption().getValue().length() > 0) {
        la.getCaption().setValue(oaxa[i].getRunTimeContext().externalizedMessage(la.getCaption().getValue()));
      }
 else {
        try {
          la.getCaption().setValue(ValueFormatter.format(deValue,getValidMarkerLineFormat(ml),oaxa[i].getRunTimeContext().getULocale(),null));
        }
 catch (        ChartException dfex) {
          throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,dfex);
        }
      }
      if (isDimension3D()) {
        return;
      }
      try {
        dCoordinate=Methods.getLocation(asc,deValue);
      }
 catch (      Exception ex) {
        logger.log(ILogger.WARNING,Messages.getString("String_Node_Str",new Object[]{deValue,ml},getRunTimeContext().getULocale()));
        continue;
      }
      lre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),LineRenderEvent.class);
      if (iOrientation == Orientation.HORIZONTAL) {
        if (dCoordinate > boPlotClientArea.getLeft() + boPlotClientArea.getWidth()) {
          dCoordinate=boPlotClientArea.getLeft() + boPlotClientArea.getWidth();
        }
        if (dCoordinate < boPlotClientArea.getLeft()) {
          dCoordinate=boPlotClientArea.getLeft();
        }
        loStart.set(dCoordinate,boPlotClientArea.getTop());
        loEnd.set(dCoordinate,boPlotClientArea.getTop() + boPlotClientArea.getHeight());
      }
 else {
        if (dCoordinate < boPlotClientArea.getTop()) {
          dCoordinate=boPlotClientArea.getTop();
        }
        if (dCoordinate > boPlotClientArea.getTop() + boPlotClientArea.getHeight()) {
          dCoordinate=boPlotClientArea.getTop() + boPlotClientArea.getHeight();
        }
        loStart.set(boPlotClientArea.getLeft(),dCoordinate);
        loEnd.set(boPlotClientArea.getLeft() + boPlotClientArea.getWidth(),dCoordinate);
      }
      if (pwa.getDimension() == IConstants.TWO_5_D) {
        if (iOrientation == Orientation.HORIZONTAL) {
          loStart.translate(0,pwa.getSeriesThickness());
          loEnd.translate(0,pwa.getSeriesThickness());
        }
 else {
          loStart.translate(-pwa.getSeriesThickness(),0);
          loEnd.translate(-pwa.getSeriesThickness(),0);
        }
      }
      lre.setStart(loStart);
      lre.setEnd(loEnd);
      lre.setLineAttributes(ml.getLineAttributes());
      idr.drawLine(lre);
      if (la.isVisible()) {
        anc=switchAnchor(ml.getLabelAnchor());
        if (bTransposed) {
          dOriginalAngle=la.getCaption().getFont().getRotation();
          try {
            la.getCaption().getFont().setRotation(pwa.getTransposedAngle(dOriginalAngle));
            anc=ChartUtil.transposeAnchor(anc);
          }
 catch (          IllegalArgumentException uiex) {
            throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,uiex);
          }
        }
        BoundingBox bb=null;
        try {
          bb=cComp.computeBox(idr.getDisplayServer(),IConstants.LEFT,la,0,0);
        }
 catch (        IllegalArgumentException uiex) {
          throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,uiex);
        }
        boText.set(0,0,bb.getWidth(),bb.getHeight());
        if (iOrientation == Orientation.VERTICAL) {
          if (anc != null) {
switch (anc.getValue()) {
case Anchor.NORTH:
case Anchor.NORTH_EAST:
case Anchor.NORTH_WEST:
              boText.setTop(loStart.getY() - boText.getHeight());
            break;
case Anchor.SOUTH:
case Anchor.SOUTH_EAST:
case Anchor.SOUTH_WEST:
          boText.setTop(loStart.getY());
        break;
default :
      boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
    break;
}
switch (anc.getValue()) {
case Anchor.NORTH_EAST:
case Anchor.SOUTH_EAST:
case Anchor.EAST:
  boText.setLeft(loEnd.getX() - boText.getWidth());
break;
case Anchor.NORTH_WEST:
case Anchor.SOUTH_WEST:
case Anchor.WEST:
boText.setLeft(loStart.getX());
break;
default :
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
break;
}
}
 else {
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
}
}
 else {
if (anc != null) {
switch (anc.getValue()) {
case Anchor.NORTH:
case Anchor.NORTH_EAST:
case Anchor.NORTH_WEST:
boText.setTop(loStart.getY());
break;
case Anchor.SOUTH:
case Anchor.SOUTH_EAST:
case Anchor.SOUTH_WEST:
boText.setTop(loEnd.getY() - boText.getHeight());
break;
default :
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
break;
}
switch (anc.getValue()) {
case Anchor.NORTH_EAST:
case Anchor.SOUTH_EAST:
case Anchor.EAST:
boText.setLeft(loStart.getX());
break;
case Anchor.NORTH_WEST:
case Anchor.SOUTH_WEST:
case Anchor.WEST:
boText.setLeft(loEnd.getX() - boText.getWidth());
break;
default :
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
break;
}
}
 else {
boText.setLeft(loStart.getX() + (loEnd.getX() - loStart.getX() - boText.getWidth()) / 2);
boText.setTop(loStart.getY() + (loEnd.getY() - loStart.getY() - boText.getHeight()) / 2);
}
}
tre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),TextRenderEvent.class);
tre.setBlockBounds(boText);
tre.setBlockAlignment(null);
tre.setLabel(la);
tre.setAction(TextRenderEvent.RENDER_TEXT_IN_BLOCK);
getDeferredCache().addLabel(tre);
}
if (isInteractivityEnabled()) {
Trigger tg;
EList<Trigger> elTriggers=ml.getTriggers();
if (!elTriggers.isEmpty()) {
final InteractionEvent iev=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),InteractionEvent.class);
iev.setCursor(ml.getCursor());
for (int t=0; t < elTriggers.size(); t++) {
tg=goFactory.copyOf(elTriggers.get(t));
processTrigger(tg,StructureSource.createMarkerLine(ml));
iev.addTrigger(tg);
}
Location[] loaHotspot=new Location[4];
if (iOrientation == Orientation.HORIZONTAL) {
loaHotspot[0]=goFactory.createLocation(loStart.getX() - IConstants.LINE_EXPAND_SIZE,loStart.getY());
loaHotspot[1]=goFactory.createLocation(loStart.getX() + IConstants.LINE_EXPAND_SIZE,loStart.getY());
loaHotspot[2]=goFactory.createLocation(loEnd.getX() + IConstants.LINE_EXPAND_SIZE,loEnd.getY());
loaHotspot[3]=goFactory.createLocation(loEnd.getX() - IConstants.LINE_EXPAND_SIZE,loEnd.getY());
}
 else {
loaHotspot[0]=goFactory.createLocation(loStart.getX(),loStart.getY() - IConstants.LINE_EXPAND_SIZE);
loaHotspot[1]=goFactory.createLocation(loEnd.getX(),loEnd.getY() - IConstants.LINE_EXPAND_SIZE);
loaHotspot[2]=goFactory.createLocation(loEnd.getX(),loEnd.getY() + IConstants.LINE_EXPAND_SIZE);
loaHotspot[3]=goFactory.createLocation(loStart.getX(),loStart.getY() + IConstants.LINE_EXPAND_SIZE);
}
final PolygonRenderEvent pre=((EventObjectCache)idr).getEventObject(StructureSource.createMarkerLine(ml),PolygonRenderEvent.class);
pre.setPoints(loaHotspot);
iev.setHotSpot(pre);
idr.enableInteraction(iev);
}
}
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_MARKER_LINE,ax,ml,getRunTimeContext().getScriptContext());
getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_MARKER_LINE,ml);
}
}
}