Program: 68620
Project: 68620
Buggy source:
public final void renderSeries(IPrimitiveRenderer ipr,Plot p,ISeriesRenderingHints isrh) throws ChartException {
  try {
    validateDataSetCount(isrh);
  }
 catch (  ChartException vex) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,vex);
  }
  boolean bRendering3D=isDimension3D();
  SeriesRenderingHints srh=null;
  SeriesRenderingHints3D srh3d=null;
  if (bRendering3D) {
    srh3d=(SeriesRenderingHints3D)isrh;
  }
 else {
    srh=(SeriesRenderingHints)isrh;
  }
  final ChartWithAxes cwa=(ChartWithAxes)getModel();
  final Bounds boClientArea=isrh.getClientAreaBounds(true);
  final AbstractScriptHandler sh=getRunTimeContext().getScriptHandler();
  logger.log(ILogger.INFORMATION,Messages.getString("String_Node_Str",new Object[]{getClass().getName(),Integer.valueOf(iSeriesIndex + 1),Integer.valueOf(iSeriesCount)},getRunTimeContext().getULocale()));
  final BarSeries bs=(BarSeries)getSeries();
  if (!bs.isVisible()) {
    return;
  }
  final RiserType rt=bs.getRiser();
  final double dSeriesThickness=bRendering3D ? 0 : srh.getSeriesThickness();
  final double dZeroLocation=bRendering3D ? srh3d.getPlotZeroLocation() : srh.getZeroLocation();
  double dBaseLocation=-1;
  final DataPointHints[] dpha=isrh.getDataPoints();
  validateNullDatapoint(dpha);
  double sizeForNonCategory=-1;
  if (!bRendering3D && !((SeriesRenderingHints)isrh).isCategoryScale() && dpha.length != 0) {
    sizeForNonCategory=computeSizeForNonCategoryBar(cwa.isTransposed(),dpha);
  }
  final ColorDefinition cd=bs.getRiserOutline();
  final LineAttributes lia=goFactory.createLineAttributes(cd == null ? null : goFactory.copyOf(cd),LineStyle.SOLID_LITERAL,1);
  double dX=0, dY=0, dZ=0;
  double dWidth=0, dHeight=0, dSpacing=0, dValue=0;
  double dWidthZ=0, dSpacingZ=0;
  Location lo;
  Location3D lo3d;
  Location[] loaFrontFace=null;
  List<Location3D[]> loa3dFace=null;
  boolean bInverted=false;
  final double dUnitSpacing=(!cwa.isSetUnitSpacing()) ? 50 : cwa.getUnitSpacing();
  final Bounds clipArea=goFactory.copyOf(boClientArea);
  if (cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL) {
    boClientArea.delta(-dSeriesThickness,dSeriesThickness,0,0);
    clipArea.delta(-dSeriesThickness,0,2 * dSeriesThickness,dSeriesThickness);
  }
  renderClipping(ipr,clipArea);
  AxisSubUnit au=null;
  Axis ax=getAxis();
  StackedSeriesLookup ssl=null;
  StackGroup sg=null;
  if (!bRendering3D) {
    ssl=srh.getStackedSeriesLookup();
    sg=ssl.getStackGroup(bs);
  }
  int iSharedUnitIndex=(sg == null) ? 0 : sg.getSharedIndex();
  int iSharedUnitCount=(sg == null) ? 1 : sg.getSharedCount();
  double dStart, dEnd;
  Label laDataPoint=null;
  Position pDataPoint=null;
  Location loDataPoint=null;
  Location3D loDataPoint3d=null;
  Bounds boDataPoint=null;
  try {
    laDataPoint=bRendering3D ? srh3d.getLabelAttributes(bs) : srh.getLabelAttributes(bs);
    if (laDataPoint.isVisible()) {
      pDataPoint=bRendering3D ? srh3d.getLabelPosition(bs) : srh.getLabelPosition(bs);
      loDataPoint=goFactory.createLocation(0,0);
      loDataPoint3d=goFactory.createLocation3D(0,0,0);
      boDataPoint=goFactory.createBounds(0,0,0,0);
    }
  }
 catch (  Exception ex) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
  }
  final SeriesDefinition sd=getSeriesDefinition();
  final EList<Fill> elPalette=sd.getSeriesPalette().getEntries();
  if (elPalette.isEmpty()) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{bs},Messages.getResourceBundle(getRunTimeContext().getULocale()));
  }
  final boolean bPaletteByCategory=(cwa.getLegend().getItemType().getValue() == LegendItemType.CATEGORIES);
  int iThisSeriesIndex=-1;
  if (!bPaletteByCategory) {
    iThisSeriesIndex=sd.getRunTimeSeries().indexOf(bs);
    if (iThisSeriesIndex < 0) {
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{bs,sd},Messages.getResourceBundle(getRunTimeContext().getULocale()));
    }
  }
  double[] faX=new double[dpha.length];
  double[] faY=new double[dpha.length];
  for (int i=0; i < dpha.length; i++) {
    faX[i]=Double.NaN;
    faY[i]=Double.NaN;
    int iOutside=checkEntryByType(getInternalBaseAxis().getScale(),dpha[i].getBaseValue());
    if (iOutside != 0) {
      dpha[i].markOutside();
      continue;
    }
    laDataPoint=bRendering3D ? srh3d.getLabelAttributes(bs) : srh.getLabelAttributes(bs);
    Fill f=null;
    if (bPaletteByCategory) {
      f=FillUtil.getPaletteFill(elPalette,i);
    }
 else {
      if (iThisSeriesIndex >= 0) {
        f=FillUtil.getPaletteFill(elPalette,iThisSeriesIndex);
      }
    }
    updateTranslucency(f,bs);
    Fill fixedFill;
    if (dpha[i] != null && dpha[i].getOrthogonalValue() instanceof Double) {
      fixedFill=ChartUtil.convertFill(f,((Double)dpha[i].getOrthogonalValue()).doubleValue(),null);
    }
 else {
      fixedFill=FillUtil.copyOf(f);
    }
    if (bRendering3D) {
      lo3d=dpha[i].getLocation3D();
      dX=lo3d.getX();
      dY=lo3d.getY();
      dZ=lo3d.getZ();
      dSpacing=((dpha[i].getSize2D().getWidth()) * dUnitSpacing) / 200;
      dSpacingZ=((dpha[i].getSize2D().getHeight()) * dUnitSpacing) / 200;
    }
 else {
      lo=dpha[i].getLocation();
      dX=lo.getX();
      dY=lo.getY();
      dSpacing=((dpha[i].getSize()) * dUnitSpacing) / 200;
    }
    if (cwa.isTransposed()) {
      BarAxisIdLookup basLookup=new BarAxisIdLookup((ChartWithAxes)cm,this.getAxis());
      if (((SeriesRenderingHints)isrh).isCategoryScale()) {
        dHeight=dpha[i].getSize();
        dHeight-=2 * dSpacing;
        dHeight/=basLookup.getCount();
        dY+=dHeight * basLookup.getId();
        dHeight/=iSharedUnitCount;
        dY+=iSharedUnitIndex * dHeight + dSpacing;
      }
 else {
        dHeight=Math.min(sizeForNonCategory,(dpha[i].getSize() - 2 * dSpacing) * .8);
        dSpacing=(dpha[i].getSize() - dHeight) / 2.0;
        dY-=dpha[i].getSize() * 0.5;
        dHeight/=basLookup.getCount();
        dY+=dHeight * basLookup.getId();
        dHeight/=iSharedUnitCount;
        dY+=iSharedUnitIndex * dHeight + dSpacing;
      }
      if (isStackedOrPercent(bs)) {
        au=ssl.getUnit(bs,i);
        dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
        double[] values=computeStackPosition(au,dValue,ax);
        dStart=values[0];
        dEnd=values[1];
        try {
          double dMargin=Math.floor(srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart)));
          double lastPosition=au.getLastPosition(dValue);
          if (Double.isNaN(lastPosition)) {
            dBaseLocation=Math.floor(srh.getLocationOnOrthogonal(new Double(dStart)));
          }
 else {
            dBaseLocation=au.getLastPosition(dValue);
          }
          au.setLastPosition(dValue,dBaseLocation,dMargin);
          dX=au.getLastPosition(dValue);
        }
 catch (        Exception ex) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
        }
      }
 else {
        if (!ChartUtil.isStudyLayout(cwa)) {
          dBaseLocation=dZeroLocation;
        }
 else {
          au=ssl.getUnit(bs,i);
          dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
          dStart=Methods.asDouble(srh.getOrthogonalScale().getMinimum()).doubleValue();
          dEnd=dValue;
          try {
            double dMargin=srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart));
            double lastPosition=au.getLastPosition(dValue);
            double precisionDelta=0.00000001d;
            if (Double.isNaN(lastPosition)) {
              dBaseLocation=srh.getLocationOnOrthogonal(new Double(dStart)) - precisionDelta;
            }
 else {
              dBaseLocation=au.getLastPosition(dValue) - precisionDelta;
            }
            au.setLastPosition(dValue,dBaseLocation,dMargin);
          }
 catch (          Exception ex) {
            throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
          }
          dX=au.getLastPosition(dValue);
        }
      }
      if (ChartUtil.mathLT(dX,boClientArea.getLeft())) {
        if (ChartUtil.mathLT(dBaseLocation,boClientArea.getLeft())) {
          continue;
        }
        dX=boClientArea.getLeft();
      }
 else       if (ChartUtil.mathLT(dBaseLocation,boClientArea.getLeft())) {
        dBaseLocation=boClientArea.getLeft();
      }
      if (ChartUtil.mathGT(dX,boClientArea.getLeft() + boClientArea.getWidth())) {
        if (ChartUtil.mathGT(dBaseLocation,boClientArea.getLeft() + boClientArea.getWidth())) {
          continue;
        }
        dX=boClientArea.getLeft() + boClientArea.getWidth();
      }
 else       if (ChartUtil.mathGT(dBaseLocation,boClientArea.getLeft() + boClientArea.getWidth())) {
        dBaseLocation=boClientArea.getLeft() + boClientArea.getWidth();
      }
      dWidth=dBaseLocation - dX;
      bInverted=dWidth <= 0;
      if (bInverted) {
        dX=dBaseLocation;
        dWidth=-dWidth;
      }
    }
 else {
      if (bRendering3D) {
        dWidth=dpha[i].getSize2D().getWidth();
        dWidth-=2 * dSpacing;
        dWidthZ=dpha[i].getSize2D().getHeight();
        dWidthZ-=2 * dSpacingZ;
        dX+=dSpacing;
        dZ+=dSpacingZ;
      }
 else {
        BarAxisIdLookup basLookup=new BarAxisIdLookup((ChartWithAxes)cm,this.getAxis());
        if (((SeriesRenderingHints)isrh).isCategoryScale()) {
          dWidth=dpha[i].getSize();
          dWidth-=2 * dSpacing;
          dWidth/=basLookup.getCount();
          dX+=dWidth * basLookup.getId();
          dWidth/=iSharedUnitCount;
          dX+=iSharedUnitIndex * dWidth + dSpacing;
        }
 else {
          dWidth=Math.min(sizeForNonCategory,(dpha[i].getSize() - 2 * dSpacing) * .8);
          dSpacing=(dpha[i].getSize() - dWidth) / 2.0;
          dX-=dpha[i].getSize() / 2;
          dWidth/=basLookup.getCount();
          dX+=dWidth * basLookup.getId();
          dWidth/=iSharedUnitCount;
          dX+=iSharedUnitIndex * dWidth + dSpacing;
        }
      }
      if (isStackedOrPercent(bs)) {
        if (bRendering3D) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.COMPUTATION,"String_Node_Str",Messages.getResourceBundle(getRunTimeContext().getULocale()));
        }
        au=ssl.getUnit(bs,i);
        dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
        double[] values=computeStackPosition(au,dValue,ax);
        dStart=values[0];
        dEnd=values[1];
        try {
          double dMargin=Math.floor(srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart)));
          double lastPosition=au.getLastPosition(dValue);
          if (Double.isNaN(lastPosition)) {
            dBaseLocation=Math.floor(srh.getLocationOnOrthogonal(new Double(dStart)));
          }
 else {
            dBaseLocation=au.getLastPosition(dValue);
          }
          au.setLastPosition(dValue,dBaseLocation,dMargin);
          dY=au.getLastPosition(dValue);
        }
 catch (        Exception ex) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
        }
      }
 else {
        if (!ChartUtil.isStudyLayout(cwa)) {
          dBaseLocation=dZeroLocation;
        }
 else {
          au=ssl.getUnit(bs,i);
          dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
          dStart=Methods.asDouble(srh.getOrthogonalScale().getMinimum()).doubleValue();
          dEnd=dValue;
          try {
            double dMargin=srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart));
            double lastPosition=au.getLastPosition(dValue);
            if (Double.isNaN(lastPosition)) {
              dBaseLocation=srh.getLocationOnOrthogonal(new Double(dStart));
            }
 else {
              dBaseLocation=au.getLastPosition(dValue);
            }
            au.setLastPosition(dValue,dBaseLocation,dMargin);
          }
 catch (          Exception ex) {
            throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
          }
          dY=au.getLastPosition(dValue);
        }
      }
      if (bRendering3D) {
        double plotBaseLocation=srh3d.getPlotBaseLocation();
        if (dY < plotBaseLocation) {
          if (dBaseLocation < plotBaseLocation) {
            continue;
          }
          dY=plotBaseLocation;
        }
 else         if (dBaseLocation < plotBaseLocation) {
          dBaseLocation=plotBaseLocation;
        }
        if (dY > plotBaseLocation + srh3d.getPlotHeight()) {
          if (dBaseLocation > plotBaseLocation + srh3d.getPlotHeight()) {
            continue;
          }
          dY=plotBaseLocation + srh3d.getPlotHeight();
        }
 else         if (dBaseLocation > plotBaseLocation + srh3d.getPlotHeight()) {
          dBaseLocation=plotBaseLocation + srh3d.getPlotHeight();
        }
      }
 else {
        if (dY < boClientArea.getTop()) {
          if (dBaseLocation < boClientArea.getTop()) {
            continue;
          }
          dY=boClientArea.getTop();
        }
 else         if (dBaseLocation < boClientArea.getTop()) {
          dBaseLocation=boClientArea.getTop();
        }
        if (dY > boClientArea.getTop() + boClientArea.getHeight()) {
          if (dBaseLocation > boClientArea.getTop() + boClientArea.getHeight()) {
            continue;
          }
          dY=boClientArea.getTop() + boClientArea.getHeight();
        }
 else         if (dBaseLocation > boClientArea.getTop() + boClientArea.getHeight()) {
          dBaseLocation=boClientArea.getTop() + boClientArea.getHeight();
        }
      }
      dHeight=dBaseLocation - dY;
      bInverted=bRendering3D ? dHeight <= 0 : dHeight < 0;
      if (bInverted) {
        dY=dBaseLocation;
        dHeight=-dHeight;
      }
    }
    if (rt.getValue() == RiserType.RECTANGLE) {
      if (bRendering3D) {
        loa3dFace=computeRiserRectangle3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        loaFrontFace=computeRiserRectangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
      }
    }
 else     if (rt.getValue() == RiserType.TRIANGLE) {
      if (bRendering3D) {
        loa3dFace=computeRiserTriangle3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        if (isStackedOrPercent(bs)) {
          StackedSizeHints slh=getCurrentStackedSizeHints(i);
          double[] size=null;
          if (isTransposed()) {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dHeight);
          }
 else {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dWidth);
          }
          loaFrontFace=computeStackedRiserTriangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth,size[0],size[1],getCurrentStackedSizeHints(i));
        }
 else {
          loaFrontFace=computeRiserTriangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
        }
      }
    }
 else     if (rt.getValue() == RiserType.TUBE) {
      if (bRendering3D) {
        loa3dFace=computeRiserTube3D(dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        loaFrontFace=computeRiserTube2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
      }
    }
 else     if (rt.getValue() == RiserType.CONE) {
      if (bRendering3D) {
        loa3dFace=computeRiserCone3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        if (isStackedOrPercent(bs)) {
          StackedSizeHints slh=getCurrentStackedSizeHints(i);
          double[] size=null;
          if (isTransposed()) {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dHeight);
          }
 else {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dWidth);
          }
          loaFrontFace=computeStackedRiserCone2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth,size[0],size[1]);
        }
 else {
          loaFrontFace=computeRiserCone2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
        }
      }
    }
 else {
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{rt.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
    }
    if (isNaN(dpha[i].getOrthogonalValue())) {
      faX[i]=Double.NaN;
      faY[i]=Double.NaN;
      continue;
    }
    if (bRendering3D) {
    }
 else {
      for (int j=0; j < loaFrontFace.length; j++) {
        Location location=loaFrontFace[j];
        if (location.getX() < boClientArea.getLeft()) {
          location.setX(boClientArea.getLeft());
        }
 else         if (location.getX() > boClientArea.getLeft() + boClientArea.getWidth()) {
          location.setX(boClientArea.getLeft() + boClientArea.getWidth());
        }
        if (location.getY() < boClientArea.getTop()) {
          location.setY(boClientArea.getTop());
        }
 else         if (location.getY() > boClientArea.getTop() + boClientArea.getHeight()) {
          location.setY(boClientArea.getTop() + boClientArea.getHeight());
        }
      }
    }
    if (isInteractivityEnabled()) {
      final EList<Trigger> elTriggers=bs.getTriggers();
      if (!elTriggers.isEmpty()) {
        final StructureSource iSource=WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]);
        if (bRendering3D) {
          for (int j=0; j < loa3dFace.size(); j++) {
            Location3D[] points=loa3dFace.get(j);
            if (points.length <= 2) {
              continue;
            }
            final InteractionEvent iev=createEvent(iSource,elTriggers,ipr);
            iev.setCursor(bs.getCursor());
            final Polygon3DRenderEvent pre3d=((EventObjectCache)ipr).getEventObject(StructureSource.createSeries(bs),Polygon3DRenderEvent.class);
            pre3d.setPoints3D(points);
            final Location panningOffset=getPanningOffset();
            if (get3DEngine().processEvent(pre3d,panningOffset.getX(),panningOffset.getY()) != null) {
              iev.setHotSpot(pre3d);
              ipr.enableInteraction(iev);
            }
          }
        }
 else {
          final InteractionEvent iev=createEvent(iSource,elTriggers,ipr);
          iev.setCursor(bs.getCursor());
          final PolygonRenderEvent pre=((EventObjectCache)ipr).getEventObject(StructureSource.createSeries(bs),PolygonRenderEvent.class);
          Location[] hotspotLoa=new Location[loaFrontFace.length];
          for (int a=0; a < hotspotLoa.length; a++) {
            hotspotLoa[a]=goFactory.createLocation(loaFrontFace[a].getX(),loaFrontFace[a].getY());
          }
          if (hotspotLoa.length == 4) {
            if (isTransposed()) {
              if (hotspotLoa[2].getX() - hotspotLoa[1].getX() < MIN_HEIGHT) {
                hotspotLoa[2].setX(hotspotLoa[1].getX() + MIN_HEIGHT);
                hotspotLoa[3].setX(hotspotLoa[0].getX() + MIN_HEIGHT);
              }
            }
 else {
              if (hotspotLoa[1].getY() - hotspotLoa[0].getY() < MIN_HEIGHT) {
                hotspotLoa[0].setY(hotspotLoa[1].getY() - MIN_HEIGHT);
                hotspotLoa[3].setY(hotspotLoa[2].getY() - MIN_HEIGHT);
              }
            }
          }
 else           if (hotspotLoa.length == 3) {
            if (isTransposed()) {
              if (hotspotLoa[1].getX() - hotspotLoa[0].getX() < MIN_HEIGHT) {
                hotspotLoa[1].setX(hotspotLoa[0].getX() + MIN_HEIGHT);
              }
            }
 else {
              if (hotspotLoa[0].getY() - hotspotLoa[1].getY() < MIN_HEIGHT) {
                hotspotLoa[1].setY(hotspotLoa[0].getY() - MIN_HEIGHT);
              }
            }
          }
          pre.setPoints(hotspotLoa);
          iev.setHotSpot(pre);
          ipr.enableInteraction(iev);
        }
      }
    }
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_ELEMENT,dpha[i],fixedFill);
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT,dpha[i],fixedFill,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_ELEMENT,dpha[i]);
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT,dpha[i]);
    if (dHeight != 0) {
      if (bRendering3D) {
        if (rt.getValue() == RiserType.TUBE) {
          renderRiserTube3D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia,dpha[i]);
        }
 else         if (rt.getValue() == RiserType.CONE) {
          renderRiserCone3D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia,dpha[i]);
        }
 else {
          render3DPlane(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia);
        }
      }
 else {
        if (rt.getValue() == RiserType.TUBE) {
          renderRiserTube2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),dpha[i],loaFrontFace,fixedFill,lia,cwa.getDimension(),cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL ? dSeriesThickness / 2 : dSeriesThickness / 4,cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL,isTransposed(),true,bInverted,isStackedOrPercent(bs));
        }
 else         if (rt.getValue() == RiserType.CONE) {
          boolean isStacked=isStackedOrPercent(bs);
          double coneThickness=cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL ? dSeriesThickness / 2 : dSeriesThickness / 4;
          double coneBottomHeight=computeBottomOvalHeightOfCone(i,coneThickness,loaFrontFace,dValue,isStacked);
          renderRiserCone2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),dpha[i],loaFrontFace,fixedFill,lia,cwa.getDimension(),coneThickness,cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL,isTransposed(),true,bInverted,isStackedOrPercent(bs),coneBottomHeight);
        }
 else         if (rt.getValue() == RiserType.TRIANGLE) {
          double[] thicknesses=computeThicknessesWithTriangle2D(loaFrontFace,dWidth,dHeight,dSeriesThickness);
          int zorder_hint=0;
          if (cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL) {
            adjustLocationsWithTriangle2D(loaFrontFace,thicknesses[0],thicknesses[1],dSeriesThickness);
            zorder_hint=isStackedOrPercent(bs) ? i : i * getSeriesCount() + getSeriesIndex();
          }
          renderRiserTriangle2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loaFrontFace,fixedFill,lia,cwa.getDimension(),thicknesses[0],thicknesses[1],true,zorder_hint);
        }
 else {
          int zorder_hint=isStackedOrPercent(bs) ? i : i * getSeriesCount() + getSeriesIndex();
          renderPlane(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loaFrontFace,fixedFill,lia,cwa.getDimension(),dSeriesThickness,true,zorder_hint);
        }
      }
    }
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_ELEMENT,dpha[i],fixedFill);
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT,dpha[i],fixedFill,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_ELEMENT,dpha[i]);
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT,dpha[i]);
    laDataPoint.getCaption().setValue(dpha[i].getDisplayValue());
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT_LABEL,dpha[i],laDataPoint,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT_LABEL,laDataPoint);
    if (laDataPoint.isVisible() && dHeight != 0 && dWidth != 0) {
      if (!dpha[i].isOutside()) {
        if (!cwa.isTransposed()) {
          if (bRendering3D) {
            if (pDataPoint.getValue() == Position.OUTSIDE) {
              if (!bInverted) {
                loDataPoint3d.set(dX + dWidth / 2,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                Text3DRenderEvent tre=((EventObjectCache)ipr).getEventObject(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),Text3DRenderEvent.class);
                tre.setLabel(laDataPoint);
                tre.setTextPosition(TextRenderEvent.BELOW);
                tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
                Location3D[] loa3d=new Location3D[5];
                loa3d[0]=loDataPoint3d;
                loa3d[1]=goFactory.createLocation3D(dX,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[2]=goFactory.createLocation3D(dX,dY - p.getVerticalSpacing() - 16,dZ + dWidthZ / 2);
                loa3d[3]=goFactory.createLocation3D(dX + dWidth,dY - p.getVerticalSpacing() - 16,dZ + dWidthZ / 2);
                loa3d[4]=goFactory.createLocation3D(dX + dWidth,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                tre.setBlockBounds3D(loa3d);
                getDeferredCache().addLabel(tre);
              }
 else {
                loDataPoint3d.set(dX + dWidth / 2,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                Text3DRenderEvent tre=((EventObjectCache)ipr).getEventObject(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),Text3DRenderEvent.class);
                tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
                tre.setLabel(laDataPoint);
                tre.setTextPosition(TextRenderEvent.ABOVE);
                Location3D[] loa3d=new Location3D[5];
                loa3d[0]=loDataPoint3d;
                loa3d[1]=goFactory.createLocation3D(dX + dWidth,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[2]=goFactory.createLocation3D(dX + dWidth,dY + dHeight + 16+ p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[3]=goFactory.createLocation3D(dX,dY + dHeight + 16+ p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[4]=goFactory.createLocation3D(dX,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                tre.setBlockBounds3D(loa3d);
                getDeferredCache().addLabel(tre);
              }
            }
 else {
              throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
            }
          }
 else {
switch (pDataPoint.getValue()) {
case Position.OUTSIDE:
              if (!bInverted) {
                loDataPoint.set(dX + dWidth / 2,dY - p.getVerticalSpacing());
                renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.ABOVE_LITERAL,loDataPoint,null);
              }
 else {
                loDataPoint.set(dX + dWidth / 2,dY + dHeight + p.getVerticalSpacing());
                renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.BELOW_LITERAL,loDataPoint,null);
              }
            break;
case Position.INSIDE:
          if (rt.getValue() == RiserType.CONE || rt.getValue() == RiserType.TRIANGLE) {
            if (!bInverted) {
              loDataPoint.set(dX + dWidth / 2,dY + dHeight);
              renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.ABOVE_LITERAL,loDataPoint,null);
            }
 else {
              loDataPoint.set(dX + dWidth / 2,dY);
              renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.BELOW_LITERAL,loDataPoint,null);
            }
          }
 else {
            boDataPoint.updateFrom(loaFrontFace);
            renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_IN_BLOCK,laDataPoint,null,null,boDataPoint);
          }
        break;
default :
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
  }
}
}
 else {
switch (pDataPoint.getValue()) {
case Position.OUTSIDE:
  if (!bInverted) {
    loDataPoint.set(dX - p.getHorizontalSpacing(),dY + dHeight / 2);
    renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.LEFT_LITERAL,loDataPoint,null);
  }
 else {
    loDataPoint.set(dX + dWidth + p.getHorizontalSpacing(),dY + dHeight / 2);
    renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.RIGHT_LITERAL,loDataPoint,null);
  }
break;
case Position.INSIDE:
if (rt.getValue() == RiserType.CONE || rt.getValue() == RiserType.TRIANGLE) {
if (!bInverted) {
  loDataPoint.set(dX + dWidth,dY + dHeight / 2);
  renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.LEFT_LITERAL,loDataPoint,null);
}
 else {
  loDataPoint.set(dX,dY + dHeight / 2);
  renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.RIGHT_LITERAL,loDataPoint,null);
}
}
 else {
boDataPoint.updateFrom(loaFrontFace);
renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_IN_BLOCK,laDataPoint,null,null,boDataPoint);
}
break;
default :
throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
}
}
}
}
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT_LABEL,dpha[i],laDataPoint,getRunTimeContext().getScriptContext());
getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT_LABEL,laDataPoint);
}
if (!bRendering3D) {
List<double[]> points=new ArrayList<double[]>();
for (int i=0; i < faX.length; i++) {
points.add(new double[]{faX[i],faY[i]});
}
points=filterNull(points);
if (isLastRuntimeSeriesInAxis()) {
getRunTimeContext().putState(STACKED_SERIES_LOCATION_KEY,null);
}
 else {
getRunTimeContext().putState(STACKED_SERIES_LOCATION_KEY,points);
}
if (getSeries().getCurveFitting() != null) {
Location[] larray=createLocationArray(points);
renderFittingCurve(ipr,larray,getSeries().getCurveFitting(),false,true);
}
}
resetAllStackedSizeHints();
if (!bRendering3D) {
restoreClipping(ipr);
}
}

Fixed version (ground truth):
public final void renderSeries(IPrimitiveRenderer ipr,Plot p,ISeriesRenderingHints isrh) throws ChartException {
  try {
    validateDataSetCount(isrh);
  }
 catch (  ChartException vex) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,vex);
  }
  boolean bRendering3D=isDimension3D();
  SeriesRenderingHints srh=null;
  SeriesRenderingHints3D srh3d=null;
  if (bRendering3D) {
    srh3d=(SeriesRenderingHints3D)isrh;
  }
 else {
    srh=(SeriesRenderingHints)isrh;
  }
  final ChartWithAxes cwa=(ChartWithAxes)getModel();
  final Bounds boClientArea=isrh.getClientAreaBounds(true);
  final AbstractScriptHandler sh=getRunTimeContext().getScriptHandler();
  logger.log(ILogger.INFORMATION,Messages.getString("String_Node_Str",new Object[]{getClass().getName(),Integer.valueOf(iSeriesIndex + 1),Integer.valueOf(iSeriesCount)},getRunTimeContext().getULocale()));
  final BarSeries bs=(BarSeries)getSeries();
  if (!bs.isVisible()) {
    return;
  }
  final RiserType rt=bs.getRiser();
  final double dSeriesThickness=bRendering3D ? 0 : srh.getSeriesThickness();
  final double dZeroLocation=bRendering3D ? srh3d.getPlotZeroLocation() : srh.getZeroLocation();
  double dBaseLocation=-1;
  final DataPointHints[] dpha=isrh.getDataPoints();
  validateNullDatapoint(dpha);
  double sizeForNonCategory=-1;
  if (!bRendering3D && !((SeriesRenderingHints)isrh).isCategoryScale() && dpha.length != 0) {
    sizeForNonCategory=computeSizeForNonCategoryBar(cwa.isTransposed(),dpha);
  }
  final ColorDefinition cd=bs.getRiserOutline();
  final LineAttributes lia=goFactory.createLineAttributes(cd == null ? null : goFactory.copyOf(cd),LineStyle.SOLID_LITERAL,1);
  double dX=0, dY=0, dZ=0;
  double dWidth=0, dHeight=0, dSpacing=0, dValue=0;
  double dWidthZ=0, dSpacingZ=0;
  Location lo;
  Location3D lo3d;
  Location[] loaFrontFace=null;
  List<Location3D[]> loa3dFace=null;
  boolean bInverted=false;
  final double dUnitSpacing=(!cwa.isSetUnitSpacing()) ? 50 : cwa.getUnitSpacing();
  final Bounds clipArea=goFactory.copyOf(boClientArea);
  if (cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL) {
    boClientArea.delta(-dSeriesThickness,dSeriesThickness,0,0);
    clipArea.delta(-dSeriesThickness,0,2 * dSeriesThickness,dSeriesThickness);
  }
  renderClipping(ipr,clipArea);
  AxisSubUnit au=null;
  Axis ax=getAxis();
  StackedSeriesLookup ssl=null;
  StackGroup sg=null;
  if (!bRendering3D) {
    ssl=srh.getStackedSeriesLookup();
    sg=ssl.getStackGroup(bs);
  }
  int iSharedUnitIndex=(sg == null) ? 0 : sg.getSharedIndex();
  int iSharedUnitCount=(sg == null) ? 1 : sg.getSharedCount();
  double dStart, dEnd;
  Label laDataPoint=null;
  Position pDataPoint=null;
  Location loDataPoint=null;
  Location3D loDataPoint3d=null;
  Bounds boDataPoint=null;
  try {
    laDataPoint=bRendering3D ? srh3d.getLabelAttributes(bs) : srh.getLabelAttributes(bs);
    if (laDataPoint.isVisible()) {
      pDataPoint=bRendering3D ? srh3d.getLabelPosition(bs) : srh.getLabelPosition(bs);
      loDataPoint=goFactory.createLocation(0,0);
      loDataPoint3d=goFactory.createLocation3D(0,0,0);
      boDataPoint=goFactory.createBounds(0,0,0,0);
    }
  }
 catch (  Exception ex) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
  }
  final SeriesDefinition sd=getSeriesDefinition();
  final EList<Fill> elPalette=sd.getSeriesPalette().getEntries();
  if (elPalette.isEmpty()) {
    throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{bs},Messages.getResourceBundle(getRunTimeContext().getULocale()));
  }
  final boolean bPaletteByCategory=(cwa.getLegend().getItemType().getValue() == LegendItemType.CATEGORIES);
  int iThisSeriesIndex=-1;
  if (!bPaletteByCategory) {
    iThisSeriesIndex=sd.getRunTimeSeries().indexOf(bs);
    if (iThisSeriesIndex < 0) {
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{bs,sd},Messages.getResourceBundle(getRunTimeContext().getULocale()));
    }
  }
  double[] faX=new double[dpha.length];
  double[] faY=new double[dpha.length];
  boolean bShowOutside=isShowOutside();
  for (int i=0; i < dpha.length; i++) {
    faX[i]=Double.NaN;
    faY[i]=Double.NaN;
    int iOutside=checkEntryByType(getInternalBaseAxis().getScale(),dpha[i].getBaseValue());
    if (iOutside != 0) {
      dpha[i].markOutside();
      continue;
    }
    laDataPoint=bRendering3D ? srh3d.getLabelAttributes(bs) : srh.getLabelAttributes(bs);
    Fill f=null;
    if (bPaletteByCategory) {
      f=FillUtil.getPaletteFill(elPalette,i);
    }
 else {
      if (iThisSeriesIndex >= 0) {
        f=FillUtil.getPaletteFill(elPalette,iThisSeriesIndex);
      }
    }
    updateTranslucency(f,bs);
    Fill fixedFill;
    if (dpha[i] != null && dpha[i].getOrthogonalValue() instanceof Double) {
      fixedFill=ChartUtil.convertFill(f,((Double)dpha[i].getOrthogonalValue()).doubleValue(),null);
    }
 else {
      fixedFill=FillUtil.copyOf(f);
    }
    if (bRendering3D) {
      lo3d=dpha[i].getLocation3D();
      dX=lo3d.getX();
      dY=lo3d.getY();
      dZ=lo3d.getZ();
      dSpacing=((dpha[i].getSize2D().getWidth()) * dUnitSpacing) / 200;
      dSpacingZ=((dpha[i].getSize2D().getHeight()) * dUnitSpacing) / 200;
    }
 else {
      lo=dpha[i].getLocation();
      dX=lo.getX();
      dY=lo.getY();
      dSpacing=((dpha[i].getSize()) * dUnitSpacing) / 200;
    }
    if (cwa.isTransposed()) {
      BarAxisIdLookup basLookup=new BarAxisIdLookup((ChartWithAxes)cm,this.getAxis());
      if (((SeriesRenderingHints)isrh).isCategoryScale()) {
        dHeight=dpha[i].getSize();
        dHeight-=2 * dSpacing;
        dHeight/=basLookup.getCount();
        dY+=dHeight * basLookup.getId();
        dHeight/=iSharedUnitCount;
        dY+=iSharedUnitIndex * dHeight + dSpacing;
      }
 else {
        dHeight=Math.min(sizeForNonCategory,(dpha[i].getSize() - 2 * dSpacing) * .8);
        dSpacing=(dpha[i].getSize() - dHeight) / 2.0;
        dY-=dpha[i].getSize() * 0.5;
        dHeight/=basLookup.getCount();
        dY+=dHeight * basLookup.getId();
        dHeight/=iSharedUnitCount;
        dY+=iSharedUnitIndex * dHeight + dSpacing;
      }
      if (isStackedOrPercent(bs)) {
        au=ssl.getUnit(bs,i);
        dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
        double[] values=computeStackPosition(au,dValue,ax);
        dStart=values[0];
        dEnd=values[1];
        try {
          double dMargin=Math.floor(srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart)));
          double lastPosition=au.getLastPosition(dValue);
          if (Double.isNaN(lastPosition)) {
            dBaseLocation=Math.floor(srh.getLocationOnOrthogonal(new Double(dStart)));
          }
 else {
            dBaseLocation=au.getLastPosition(dValue);
          }
          au.setLastPosition(dValue,dBaseLocation,dMargin);
          dX=au.getLastPosition(dValue);
        }
 catch (        Exception ex) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
        }
      }
 else {
        if (!ChartUtil.isStudyLayout(cwa)) {
          dBaseLocation=dZeroLocation;
        }
 else {
          au=ssl.getUnit(bs,i);
          dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
          dStart=Methods.asDouble(srh.getOrthogonalScale().getMinimum()).doubleValue();
          dEnd=dValue;
          try {
            double dMargin=srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart));
            double lastPosition=au.getLastPosition(dValue);
            double precisionDelta=0.00000001d;
            if (Double.isNaN(lastPosition)) {
              dBaseLocation=srh.getLocationOnOrthogonal(new Double(dStart)) - precisionDelta;
            }
 else {
              dBaseLocation=au.getLastPosition(dValue) - precisionDelta;
            }
            au.setLastPosition(dValue,dBaseLocation,dMargin);
          }
 catch (          Exception ex) {
            throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
          }
          dX=au.getLastPosition(dValue);
        }
      }
      if (ChartUtil.mathLT(dX,boClientArea.getLeft())) {
        if (ChartUtil.mathLT(dBaseLocation,boClientArea.getLeft())) {
          if (!bShowOutside) {
            continue;
          }
        }
        dX=boClientArea.getLeft();
      }
 else       if (ChartUtil.mathLT(dBaseLocation,boClientArea.getLeft())) {
        dBaseLocation=boClientArea.getLeft();
      }
      if (ChartUtil.mathGT(dX,boClientArea.getLeft() + boClientArea.getWidth())) {
        if (ChartUtil.mathGT(dBaseLocation,boClientArea.getLeft() + boClientArea.getWidth())) {
          continue;
        }
        dX=boClientArea.getLeft() + boClientArea.getWidth();
      }
 else       if (ChartUtil.mathGT(dBaseLocation,boClientArea.getLeft() + boClientArea.getWidth())) {
        dBaseLocation=boClientArea.getLeft() + boClientArea.getWidth();
      }
      dWidth=dBaseLocation - dX;
      bInverted=dWidth <= 0;
      if (bInverted) {
        dX=dBaseLocation;
        dWidth=-dWidth;
      }
    }
 else {
      if (bRendering3D) {
        dWidth=dpha[i].getSize2D().getWidth();
        dWidth-=2 * dSpacing;
        dWidthZ=dpha[i].getSize2D().getHeight();
        dWidthZ-=2 * dSpacingZ;
        dX+=dSpacing;
        dZ+=dSpacingZ;
      }
 else {
        BarAxisIdLookup basLookup=new BarAxisIdLookup((ChartWithAxes)cm,this.getAxis());
        if (((SeriesRenderingHints)isrh).isCategoryScale()) {
          dWidth=dpha[i].getSize();
          dWidth-=2 * dSpacing;
          dWidth/=basLookup.getCount();
          dX+=dWidth * basLookup.getId();
          dWidth/=iSharedUnitCount;
          dX+=iSharedUnitIndex * dWidth + dSpacing;
        }
 else {
          dWidth=Math.min(sizeForNonCategory,(dpha[i].getSize() - 2 * dSpacing) * .8);
          dSpacing=(dpha[i].getSize() - dWidth) / 2.0;
          dX-=dpha[i].getSize() / 2;
          dWidth/=basLookup.getCount();
          dX+=dWidth * basLookup.getId();
          dWidth/=iSharedUnitCount;
          dX+=iSharedUnitIndex * dWidth + dSpacing;
        }
      }
      if (isStackedOrPercent(bs)) {
        if (bRendering3D) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.COMPUTATION,"String_Node_Str",Messages.getResourceBundle(getRunTimeContext().getULocale()));
        }
        au=ssl.getUnit(bs,i);
        dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
        double[] values=computeStackPosition(au,dValue,ax);
        dStart=values[0];
        dEnd=values[1];
        try {
          double dMargin=Math.floor(srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart)));
          double lastPosition=au.getLastPosition(dValue);
          if (Double.isNaN(lastPosition)) {
            dBaseLocation=Math.floor(srh.getLocationOnOrthogonal(new Double(dStart)));
          }
 else {
            dBaseLocation=au.getLastPosition(dValue);
          }
          au.setLastPosition(dValue,dBaseLocation,dMargin);
          dY=au.getLastPosition(dValue);
        }
 catch (        Exception ex) {
          throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
        }
      }
 else {
        if (!ChartUtil.isStudyLayout(cwa)) {
          dBaseLocation=dZeroLocation;
        }
 else {
          au=ssl.getUnit(bs,i);
          dValue=isNaN(dpha[i].getOrthogonalValue()) ? 0 : ((Double)dpha[i].getOrthogonalValue()).doubleValue();
          dStart=Methods.asDouble(srh.getOrthogonalScale().getMinimum()).doubleValue();
          dEnd=dValue;
          try {
            double dMargin=srh.getLocationOnOrthogonal(new Double(dEnd)) - srh.getLocationOnOrthogonal(new Double(dStart));
            double lastPosition=au.getLastPosition(dValue);
            if (Double.isNaN(lastPosition)) {
              dBaseLocation=srh.getLocationOnOrthogonal(new Double(dStart));
            }
 else {
              dBaseLocation=au.getLastPosition(dValue);
            }
            au.setLastPosition(dValue,dBaseLocation,dMargin);
          }
 catch (          Exception ex) {
            throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,ex);
          }
          dY=au.getLastPosition(dValue);
        }
      }
      if (bRendering3D) {
        double plotBaseLocation=srh3d.getPlotBaseLocation();
        if (dY < plotBaseLocation) {
          if (bShowOutside) {
            dBaseLocation=plotBaseLocation;
            dY=plotBaseLocation;
          }
 else {
            if (dBaseLocation < plotBaseLocation) {
              continue;
            }
            dY=plotBaseLocation;
          }
        }
 else         if (dBaseLocation < plotBaseLocation) {
          dBaseLocation=plotBaseLocation;
        }
        if (dY > plotBaseLocation + srh3d.getPlotHeight()) {
          if (dBaseLocation > plotBaseLocation + srh3d.getPlotHeight()) {
            continue;
          }
          dY=plotBaseLocation + srh3d.getPlotHeight();
        }
 else         if (dBaseLocation > plotBaseLocation + srh3d.getPlotHeight()) {
          dBaseLocation=plotBaseLocation + srh3d.getPlotHeight();
        }
      }
 else {
        if (dY < boClientArea.getTop()) {
          if (dBaseLocation < boClientArea.getTop()) {
            continue;
          }
          dY=boClientArea.getTop();
        }
 else         if (dBaseLocation < boClientArea.getTop()) {
          dBaseLocation=boClientArea.getTop();
        }
        if (dY > boClientArea.getTop() + boClientArea.getHeight()) {
          if (dBaseLocation > boClientArea.getTop() + boClientArea.getHeight()) {
            if (!bShowOutside) {
              continue;
            }
          }
          dY=boClientArea.getTop() + boClientArea.getHeight();
        }
 else         if (dBaseLocation > boClientArea.getTop() + boClientArea.getHeight()) {
          dBaseLocation=boClientArea.getTop() + boClientArea.getHeight();
        }
      }
      dHeight=dBaseLocation - dY;
      bInverted=bRendering3D ? dHeight <= 0 : dHeight < 0;
      if (bInverted) {
        dY=dBaseLocation;
        dHeight=-dHeight;
      }
    }
    if (rt.getValue() == RiserType.RECTANGLE) {
      if (bRendering3D) {
        loa3dFace=computeRiserRectangle3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        loaFrontFace=computeRiserRectangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
      }
    }
 else     if (rt.getValue() == RiserType.TRIANGLE) {
      if (bRendering3D) {
        loa3dFace=computeRiserTriangle3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        if (isStackedOrPercent(bs)) {
          StackedSizeHints slh=getCurrentStackedSizeHints(i);
          double[] size=null;
          if (isTransposed()) {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dHeight);
          }
 else {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dWidth);
          }
          loaFrontFace=computeStackedRiserTriangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth,size[0],size[1],getCurrentStackedSizeHints(i));
        }
 else {
          loaFrontFace=computeRiserTriangle2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
        }
      }
    }
 else     if (rt.getValue() == RiserType.TUBE) {
      if (bRendering3D) {
        loa3dFace=computeRiserTube3D(dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        loaFrontFace=computeRiserTube2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
      }
    }
 else     if (rt.getValue() == RiserType.CONE) {
      if (bRendering3D) {
        loa3dFace=computeRiserCone3D(bInverted,dX,dY,dZ,dHeight,dWidth,dWidthZ);
      }
 else {
        if (isStackedOrPercent(bs)) {
          StackedSizeHints slh=getCurrentStackedSizeHints(i);
          double[] size=null;
          if (isTransposed()) {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dHeight);
          }
 else {
            size=computeStacked2DTopNBottomSize(slh,au,dValue,dWidth);
          }
          loaFrontFace=computeStackedRiserCone2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth,size[0],size[1]);
        }
 else {
          loaFrontFace=computeRiserCone2D(bInverted,i,faX,faY,dX,dY,dHeight,dWidth);
        }
      }
    }
 else {
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{rt.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
    }
    if (isNaN(dpha[i].getOrthogonalValue())) {
      faX[i]=Double.NaN;
      faY[i]=Double.NaN;
      continue;
    }
    if (bRendering3D) {
    }
 else {
      for (int j=0; j < loaFrontFace.length; j++) {
        Location location=loaFrontFace[j];
        if (location.getX() < boClientArea.getLeft()) {
          location.setX(boClientArea.getLeft());
        }
 else         if (location.getX() > boClientArea.getLeft() + boClientArea.getWidth()) {
          location.setX(boClientArea.getLeft() + boClientArea.getWidth());
        }
        if (location.getY() < boClientArea.getTop()) {
          location.setY(boClientArea.getTop());
        }
 else         if (location.getY() > boClientArea.getTop() + boClientArea.getHeight()) {
          location.setY(boClientArea.getTop() + boClientArea.getHeight());
        }
      }
    }
    if (isInteractivityEnabled()) {
      final EList<Trigger> elTriggers=bs.getTriggers();
      if (!elTriggers.isEmpty()) {
        final StructureSource iSource=WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]);
        if (bRendering3D) {
          for (int j=0; j < loa3dFace.size(); j++) {
            Location3D[] points=loa3dFace.get(j);
            if (points.length <= 2) {
              continue;
            }
            final InteractionEvent iev=createEvent(iSource,elTriggers,ipr);
            iev.setCursor(bs.getCursor());
            final Polygon3DRenderEvent pre3d=((EventObjectCache)ipr).getEventObject(StructureSource.createSeries(bs),Polygon3DRenderEvent.class);
            pre3d.setPoints3D(points);
            final Location panningOffset=getPanningOffset();
            if (get3DEngine().processEvent(pre3d,panningOffset.getX(),panningOffset.getY()) != null) {
              iev.setHotSpot(pre3d);
              ipr.enableInteraction(iev);
            }
          }
        }
 else {
          final InteractionEvent iev=createEvent(iSource,elTriggers,ipr);
          iev.setCursor(bs.getCursor());
          final PolygonRenderEvent pre=((EventObjectCache)ipr).getEventObject(StructureSource.createSeries(bs),PolygonRenderEvent.class);
          Location[] hotspotLoa=new Location[loaFrontFace.length];
          for (int a=0; a < hotspotLoa.length; a++) {
            hotspotLoa[a]=goFactory.createLocation(loaFrontFace[a].getX(),loaFrontFace[a].getY());
          }
          if (hotspotLoa.length == 4) {
            if (isTransposed()) {
              if (hotspotLoa[2].getX() - hotspotLoa[1].getX() < MIN_HEIGHT) {
                hotspotLoa[2].setX(hotspotLoa[1].getX() + MIN_HEIGHT);
                hotspotLoa[3].setX(hotspotLoa[0].getX() + MIN_HEIGHT);
              }
            }
 else {
              if (hotspotLoa[1].getY() - hotspotLoa[0].getY() < MIN_HEIGHT) {
                hotspotLoa[0].setY(hotspotLoa[1].getY() - MIN_HEIGHT);
                hotspotLoa[3].setY(hotspotLoa[2].getY() - MIN_HEIGHT);
              }
            }
          }
 else           if (hotspotLoa.length == 3) {
            if (isTransposed()) {
              if (hotspotLoa[1].getX() - hotspotLoa[0].getX() < MIN_HEIGHT) {
                hotspotLoa[1].setX(hotspotLoa[0].getX() + MIN_HEIGHT);
              }
            }
 else {
              if (hotspotLoa[0].getY() - hotspotLoa[1].getY() < MIN_HEIGHT) {
                hotspotLoa[1].setY(hotspotLoa[0].getY() - MIN_HEIGHT);
              }
            }
          }
          pre.setPoints(hotspotLoa);
          iev.setHotSpot(pre);
          ipr.enableInteraction(iev);
        }
      }
    }
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_ELEMENT,dpha[i],fixedFill);
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT,dpha[i],fixedFill,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_ELEMENT,dpha[i]);
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT,dpha[i]);
    if (dHeight != 0 || bShowOutside) {
      if (bRendering3D) {
        if (rt.getValue() == RiserType.TUBE) {
          renderRiserTube3D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia,dpha[i]);
        }
 else         if (rt.getValue() == RiserType.CONE) {
          renderRiserCone3D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia,dpha[i]);
        }
 else {
          render3DPlane(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loa3dFace,fixedFill,lia);
        }
      }
 else {
        if (rt.getValue() == RiserType.TUBE) {
          renderRiserTube2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),dpha[i],loaFrontFace,fixedFill,lia,cwa.getDimension(),cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL ? dSeriesThickness / 2 : dSeriesThickness / 4,cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL,isTransposed(),true,bInverted,isStackedOrPercent(bs));
        }
 else         if (rt.getValue() == RiserType.CONE) {
          boolean isStacked=isStackedOrPercent(bs);
          double coneThickness=cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL ? dSeriesThickness / 2 : dSeriesThickness / 4;
          double coneBottomHeight=computeBottomOvalHeightOfCone(i,coneThickness,loaFrontFace,dValue,isStacked);
          renderRiserCone2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),dpha[i],loaFrontFace,fixedFill,lia,cwa.getDimension(),coneThickness,cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL,isTransposed(),true,bInverted,isStackedOrPercent(bs),coneBottomHeight);
        }
 else         if (rt.getValue() == RiserType.TRIANGLE) {
          double[] thicknesses=computeThicknessesWithTriangle2D(loaFrontFace,dWidth,dHeight,dSeriesThickness);
          int zorder_hint=0;
          if (cwa.getDimension() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL) {
            adjustLocationsWithTriangle2D(loaFrontFace,thicknesses[0],thicknesses[1],dSeriesThickness);
            zorder_hint=isStackedOrPercent(bs) ? i : i * getSeriesCount() + getSeriesIndex();
          }
          renderRiserTriangle2D(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loaFrontFace,fixedFill,lia,cwa.getDimension(),thicknesses[0],thicknesses[1],true,zorder_hint);
        }
 else {
          int zorder_hint=isStackedOrPercent(bs) ? i : i * getSeriesCount() + getSeriesIndex();
          renderPlane(ipr,WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),loaFrontFace,fixedFill,lia,cwa.getDimension(),dSeriesThickness,true,zorder_hint);
        }
      }
    }
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_ELEMENT,dpha[i],fixedFill);
    ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT,dpha[i],fixedFill,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_ELEMENT,dpha[i]);
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT,dpha[i]);
    laDataPoint.getCaption().setValue(dpha[i].getDisplayValue());
    ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT_LABEL,dpha[i],laDataPoint,getRunTimeContext().getScriptContext());
    getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT_LABEL,laDataPoint);
    if (laDataPoint.isVisible() && (dHeight != 0 || bShowOutside) && dWidth != 0) {
      if (!dpha[i].isOutside()) {
        if (!cwa.isTransposed()) {
          if (bRendering3D) {
            if (pDataPoint.getValue() == Position.OUTSIDE) {
              if (!bInverted) {
                loDataPoint3d.set(dX + dWidth / 2,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                Text3DRenderEvent tre=((EventObjectCache)ipr).getEventObject(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),Text3DRenderEvent.class);
                tre.setLabel(laDataPoint);
                tre.setTextPosition(TextRenderEvent.BELOW);
                tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
                Location3D[] loa3d=new Location3D[5];
                loa3d[0]=loDataPoint3d;
                loa3d[1]=goFactory.createLocation3D(dX,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[2]=goFactory.createLocation3D(dX,dY - p.getVerticalSpacing() - 16,dZ + dWidthZ / 2);
                loa3d[3]=goFactory.createLocation3D(dX + dWidth,dY - p.getVerticalSpacing() - 16,dZ + dWidthZ / 2);
                loa3d[4]=goFactory.createLocation3D(dX + dWidth,dY - p.getVerticalSpacing(),dZ + dWidthZ / 2);
                tre.setBlockBounds3D(loa3d);
                getDeferredCache().addLabel(tre);
              }
 else {
                loDataPoint3d.set(dX + dWidth / 2,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                Text3DRenderEvent tre=((EventObjectCache)ipr).getEventObject(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),Text3DRenderEvent.class);
                tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
                tre.setLabel(laDataPoint);
                tre.setTextPosition(TextRenderEvent.ABOVE);
                Location3D[] loa3d=new Location3D[5];
                loa3d[0]=loDataPoint3d;
                loa3d[1]=goFactory.createLocation3D(dX + dWidth,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[2]=goFactory.createLocation3D(dX + dWidth,dY + dHeight + 16+ p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[3]=goFactory.createLocation3D(dX,dY + dHeight + 16+ p.getVerticalSpacing(),dZ + dWidthZ / 2);
                loa3d[4]=goFactory.createLocation3D(dX,dY + dHeight + p.getVerticalSpacing(),dZ + dWidthZ / 2);
                tre.setBlockBounds3D(loa3d);
                getDeferredCache().addLabel(tre);
              }
            }
 else {
              throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
            }
          }
 else {
switch (pDataPoint.getValue()) {
case Position.OUTSIDE:
              if (!bInverted) {
                loDataPoint.set(dX + dWidth / 2,dY - p.getVerticalSpacing());
                renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.ABOVE_LITERAL,loDataPoint,null);
              }
 else {
                loDataPoint.set(dX + dWidth / 2,dY + dHeight + p.getVerticalSpacing());
                renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.BELOW_LITERAL,loDataPoint,null);
              }
            break;
case Position.INSIDE:
          if (rt.getValue() == RiserType.CONE || rt.getValue() == RiserType.TRIANGLE) {
            if (!bInverted) {
              loDataPoint.set(dX + dWidth / 2,dY + dHeight);
              renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.ABOVE_LITERAL,loDataPoint,null);
            }
 else {
              loDataPoint.set(dX + dWidth / 2,dY);
              renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.BELOW_LITERAL,loDataPoint,null);
            }
          }
 else {
            boDataPoint.updateFrom(loaFrontFace);
            renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_IN_BLOCK,laDataPoint,null,null,boDataPoint);
          }
        break;
default :
      throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
  }
}
}
 else {
switch (pDataPoint.getValue()) {
case Position.OUTSIDE:
  if (!bInverted) {
    loDataPoint.set(dX - p.getHorizontalSpacing(),dY + dHeight / 2);
    renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.LEFT_LITERAL,loDataPoint,null);
  }
 else {
    loDataPoint.set(dX + dWidth + p.getHorizontalSpacing(),dY + dHeight / 2);
    renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.RIGHT_LITERAL,loDataPoint,null);
  }
break;
case Position.INSIDE:
if (rt.getValue() == RiserType.CONE || rt.getValue() == RiserType.TRIANGLE) {
if (!bInverted) {
  loDataPoint.set(dX + dWidth,dY + dHeight / 2);
  renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.LEFT_LITERAL,loDataPoint,null);
}
 else {
  loDataPoint.set(dX,dY + dHeight / 2);
  renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_AT_LOCATION,laDataPoint,Position.RIGHT_LITERAL,loDataPoint,null);
}
}
 else {
boDataPoint.updateFrom(loaFrontFace);
renderLabel(WrappedStructureSource.createSeriesDataPoint(bs,dpha[i]),TextRenderEvent.RENDER_TEXT_IN_BLOCK,laDataPoint,null,null,boDataPoint);
}
break;
default :
throw new ChartException(ChartEngineExtensionPlugin.ID,ChartException.RENDERING,"String_Node_Str",new Object[]{pDataPoint.getName()},Messages.getResourceBundle(getRunTimeContext().getULocale()));
}
}
}
}
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT_LABEL,dpha[i],laDataPoint,getRunTimeContext().getScriptContext());
getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT_LABEL,laDataPoint);
}
if (!bRendering3D) {
List<double[]> points=new ArrayList<double[]>();
for (int i=0; i < faX.length; i++) {
points.add(new double[]{faX[i],faY[i]});
}
points=filterNull(points);
if (isLastRuntimeSeriesInAxis()) {
getRunTimeContext().putState(STACKED_SERIES_LOCATION_KEY,null);
}
 else {
getRunTimeContext().putState(STACKED_SERIES_LOCATION_KEY,points);
}
if (getSeries().getCurveFitting() != null) {
Location[] larray=createLocationArray(points);
renderFittingCurve(ipr,larray,getSeries().getCurveFitting(),false,true);
}
}
resetAllStackedSizeHints();
if (!bRendering3D) {
restoreClipping(ipr);
}
}