Program: 66127
Project: 66127
Buggy source:
/** 
 * @param idr
 * @param bo
 * @throws ChartException
 */
public final void render(IDeviceRenderer idr,Bounds bo) throws ChartException {
  dc=dial.getDeferredCache();
  Bounds boCA=goFactory.copyOf(bo);
  ChartWithoutAxes cwa=(ChartWithoutAxes)dial.getModel();
  if (cwa.isSetCoverage()) {
    double rate=cwa.getCoverage();
    double ww=0.5 * (1d - rate) * bo.getWidth();
    double hh=0.5 * (1d - rate) * bo.getHeight();
    insCA=goFactory.createInsets(hh,ww,hh,ww);
  }
  boCA.adjust(insCA);
  final boolean bDialSuperimposed=dial.isDialSuperimposed();
  final boolean bFirstSeries=dial.isFirstDial();
  final org.eclipse.birt.chart.model.component.Dial dialComponent=ds.getDial();
  final Needle needleComponent=ds.getNeedle();
  if (!bDialSuperimposed) {
    DataSetIterator dsi=new DataSetIterator(dial.getSeries().getDataSet());
    BigDecimal divisor=null;
    dsi.reset();
    while (dsi.hasNext()) {
      Object o=dsi.next();
      if (NumberUtil.isBigNumber(o)) {
        divisor=((BigNumber)o).getDivisor();
        break;
      }
    }
    dRadius=getDialRadius();
    dStartAngle=getDialStartAngle();
    dStopAngle=getDialStopAngle();
    inverseScale=isInverseScale();
    sc=getDialScale();
    asc=getAutoScale(dStartAngle,dStopAngle,sc,bo,divisor);
    dExtraSpacing=getDialExtraSpacing(asc);
  }
  if (dial.isRightToLeft()) {
    inverseScale=!inverseScale;
  }
  final boolean bFullDisc=dStopAngle < 0 || dStopAngle > 180 || dStartAngle < 0 || dStartAngle > 180;
  double dFullRadius=Math.min(boCA.getWidth() / 2d,boCA.getHeight() / 2d);
  if (dExtraSpacing > dFullRadius / 3) {
    dExtraSpacing=dFullRadius / 3;
    if (dSafeSpacing > dFullRadius / 10d) {
      dSafeSpacing=dFullRadius / 10d;
    }
  }
  if (dRadius > 0 && (dRadius + dExtraSpacing + dSafeSpacing * 2) < dFullRadius) {
    dFullRadius=dRadius + dExtraSpacing + dSafeSpacing * 2;
  }
  final ArcRenderEvent are=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent),ArcRenderEvent.class);
  Bounds fullBounds=goFactory.createBounds(boCA.getLeft() + (boCA.getWidth() - 2 * dFullRadius) / 2,(boCA.getTop() + (boCA.getHeight() - (bFullDisc ? 2 : 1) * dFullRadius) / 2),2 * dFullRadius,2 * dFullRadius);
  if (!bDialSuperimposed || bFirstSeries) {
    final Fill dialFill=dialComponent.getFill();
    double safeAngle=Math.toDegrees(Math.abs(Math.asin(dSafeSpacing / dFullRadius)));
    are.setBounds(fullBounds);
    are.setStartAngle(bFullDisc ? 0 : -safeAngle);
    are.setAngleExtent(bFullDisc ? 360 : (180 + 2 * safeAngle));
    are.setOutline(dialComponent.getLineAttributes());
    are.setBackground(dialFill);
    are.setStyle(ArcRenderEvent.CLOSED);
    idr.fillArc(are);
    idr.drawArc(are);
  }
  Bounds dialBounds=goFactory.createBounds(fullBounds.getLeft() + dExtraSpacing + dSafeSpacing,fullBounds.getTop() + dExtraSpacing + dSafeSpacing,fullBounds.getWidth() - 2 * (dExtraSpacing + dSafeSpacing),fullBounds.getHeight() - 2 * (dExtraSpacing + dSafeSpacing));
  if (!bDialSuperimposed || bFirstSeries) {
    double tsa=dStartAngle;
    double tpa=dStopAngle;
    if (tsa > tpa) {
      double temp=tsa;
      tsa=tpa;
      tpa=temp;
    }
    are.setBounds(dialBounds);
    are.setStartAngle(tsa);
    are.setAngleExtent(tpa - tsa);
    are.setOutline(dialComponent.getMajorGrid().getLineAttributes());
    are.setStyle(Math.abs(dStopAngle - dStartAngle) < 360 ? ArcRenderEvent.SECTOR : ArcRenderEvent.OPEN);
    idr.drawArc(are);
  }
  double xc=dialBounds.getLeft() + dialBounds.getWidth() / 2d;
  double yc=dialBounds.getTop() + dialBounds.getHeight() / 2d;
  double dDialRadius=dialBounds.getHeight() / 2d;
  for (int i=0; i < dialComponent.getDialRegions().size(); i++) {
    DialRegion dregion=dialComponent.getDialRegions().get(i);
    double drStartValue=((NumberDataElement)dregion.getStartValue()).getValue();
    double drEndValue=((NumberDataElement)dregion.getEndValue()).getValue();
    double ascMinValue=Double.parseDouble(asc.getMinimum().toString());
    double ascMaxValue=Double.parseDouble(asc.getMaximum().toString());
    if (!((Math.max(drStartValue,drEndValue) <= ascMinValue) || (Math.min(drStartValue,drEndValue) >= (ascMaxValue)) || (drStartValue == drEndValue))) {
      double sAngle=Methods.getLocation(asc,drStartValue);
      double eAngle=Methods.getLocation(asc,drEndValue);
      if (sAngle < dStartAngle) {
        sAngle=dStartAngle;
      }
      if (sAngle > dStopAngle) {
        sAngle=dStopAngle;
      }
      if (eAngle < dStartAngle) {
        eAngle=dStartAngle;
      }
      if (eAngle > dStopAngle) {
        eAngle=dStopAngle;
      }
      double tsa=transformAngle(sAngle);
      double tpa=transformAngle(eAngle);
      if (tsa > tpa) {
        double temp=tsa;
        tsa=tpa;
        tpa=temp;
      }
      are.setBounds(dialBounds);
      are.setStartAngle(tsa);
      are.setAngleExtent(tpa - tsa);
      are.setBackground(dregion.getFill());
      are.setOutline(dregion.getOutline());
      are.setStyle(ArcRenderEvent.SECTOR);
      are.setInnerRadius(dregion.isSetInnerRadius() ? Math.min(dregion.getInnerRadius() * dScale,dDialRadius) : 0);
      if (dregion.isSetOuterRadius()) {
        if (dregion.getOuterRadius() == -1) {
          are.setOuterRadius(dDialRadius);
        }
 else {
          are.setOuterRadius(Math.min(dregion.getOuterRadius() * dScale,dDialRadius));
        }
      }
 else {
        are.setOuterRadius(0);
      }
      idr.fillArc(are);
      idr.drawArc(are);
    }
  }
  final LineRenderEvent lre=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent),LineRenderEvent.class);
  AxisTickCoordinates tickCoord=asc.getTickCordinates();
  if (!bDialSuperimposed || bFirstSeries) {
    if (dialComponent.getMajorGrid().getTickAttributes().isVisible() || dialComponent.getMinorGrid().getTickAttributes().isVisible()) {
      double[] minorCoord=asc.getMinorCoordinates(sc.getMinorGridsPerUnit());
      Location start=goFactory.createLocation(0,0);
      Location end=goFactory.createLocation(0,0);
      for (int i=0; i < asc.getTickCount(); i++) {
        double mtd=tickCoord.getCoordinate(i);
        mtd=transformAngle(mtd);
        double mtr=Math.toRadians(mtd);
        if (dialComponent.getMajorGrid().getTickAttributes().isVisible()) {
          lre.setLineAttributes(dialComponent.getMajorGrid().getTickAttributes());
switch (dialComponent.getMajorGrid().getTickStyle().getValue()) {
case TickStyle.ABOVE:
            start.set(xc + dDialRadius * Math.cos(mtr),yc - dDialRadius * Math.sin(mtr));
          end.set(xc + (dDialRadius + getTickSize()) * Math.cos(mtr),yc - (dDialRadius + getTickSize()) * Math.sin(mtr));
        break;
case TickStyle.ACROSS:
      start.set(xc + (dDialRadius + getTickSize() / 2d) * Math.cos(mtr),yc - (dDialRadius + getTickSize() / 2d) * Math.sin(mtr));
    end.set(xc + (dDialRadius - getTickSize() / 2d) * Math.cos(mtr),yc - (dDialRadius - getTickSize() / 2d) * Math.sin(mtr));
  break;
case TickStyle.BELOW:
start.set(xc + dDialRadius * Math.cos(mtr),yc - dDialRadius * Math.sin(mtr));
end.set(xc + (dDialRadius - getTickSize()) * Math.cos(mtr),yc - (dDialRadius - getTickSize()) * Math.sin(mtr));
break;
default :
throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",Messages.getResourceBundle(dial.getRunTimeContext().getULocale()));
}
lre.setStart(start);
lre.setEnd(end);
dc.addLine(lre);
}
if (dialComponent.getMinorGrid().getTickAttributes().isVisible() && i != asc.getTickCount() - 1) {
lre.setLineAttributes(dialComponent.getMinorGrid().getTickAttributes());
for (int j=0; j < sc.getMinorGridsPerUnit() - 1; j++) {
double minortd=minorCoord[j];
if ((inverseScale && mtd + minortd >= transformAngle(tickCoord.getCoordinate(i + 1))) || (!inverseScale && mtd - minortd <= transformAngle(tickCoord.getCoordinate(i + 1)))) {
continue;
}
double minortr=Math.toRadians(inverseScale ? (mtd + minortd) : (mtd - minortd));
switch (dialComponent.getMinorGrid().getTickStyle().getValue()) {
case TickStyle.ABOVE:
start.set(xc + dDialRadius * Math.cos(minortr),yc - dDialRadius * Math.sin(minortr));
end.set(xc + (dDialRadius + getTickSize()) * Math.cos(minortr),yc - (dDialRadius + getTickSize()) * Math.sin(minortr));
break;
case TickStyle.ACROSS:
start.set(xc + (dDialRadius + getTickSize() / 2d) * Math.cos(minortr),yc - (dDialRadius + getTickSize() / 2d) * Math.sin(minortr));
end.set(xc + (dDialRadius - getTickSize() / 2d) * Math.cos(minortr),yc - (dDialRadius - getTickSize() / 2d) * Math.sin(minortr));
break;
case TickStyle.BELOW:
start.set(xc + dDialRadius * Math.cos(minortr),yc - dDialRadius * Math.sin(minortr));
end.set(xc + (dDialRadius - getTickSize()) * Math.cos(minortr),yc - (dDialRadius - getTickSize()) * Math.sin(minortr));
break;
default :
throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",Messages.getResourceBundle(dial.getRunTimeContext().getULocale()));
}
lre.setStart(start);
lre.setEnd(end);
dc.addLine(lre);
}
}
}
}
}
if (!bDialSuperimposed || (bDialSuperimposed && bFirstSeries)) {
if (dialComponent.getLabel().isVisible()) {
final TextRenderEvent tre=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent.getLabel()),TextRenderEvent.class);
Label lbScale=goFactory.copyOf(dialComponent.getLabel());
Location loc=goFactory.createLocation(0,0);
tre.setLabel(lbScale);
tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
tre.setLocation(loc);
for (int i=0; i < tickCoord.size(); i++) {
if (dStopAngle - dStartAngle == 360 && i == tickCoord.size() - 1) {
continue;
}
lbScale.getCaption().setValue(sla[i]);
double tickAngle=dStartAngle + (tickCoord.getNormalizedCoordinate(i)) / (tickCoord.getEnd() - tickCoord.getStart()) * (dStopAngle - dStartAngle);
tickAngle=transformAngle(tickAngle);
int quad=ChartUtil.getQuadrant(tickAngle);
double tickRadians=Math.toRadians(tickAngle);
double tx=xc + dDialRadius * Math.cos(tickRadians);
double ty=yc - dDialRadius * Math.sin(tickRadians);
switch (quad) {
case -1:
loc.set(tx + dSafeSpacing / 2,ty);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
case -2:
loc.set(tx,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.ABOVE);
break;
case -3:
loc.set(tx - dSafeSpacing / 2,ty);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case -4:
loc.set(tx,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.BELOW);
break;
case 1:
loc.set(tx + dSafeSpacing / 2,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
case 2:
loc.set(tx - dSafeSpacing / 2,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case 3:
loc.set(tx - dSafeSpacing / 2,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case 4:
loc.set(tx + dSafeSpacing / 2,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
}
dc.addLabel(tre);
}
}
}
double needleAngle=Methods.getLocation(asc,dValue);
if (needleAngle < dStartAngle || needleAngle > dStopAngle) {
return;
}
needleAngle=transformAngle(needleAngle);
boolean bCategoryStyle=(((ChartWithoutAxes)dial.getModel()).getLegend().getItemType() == LegendItemType.CATEGORIES_LITERAL);
LineAttributes lia=goFactory.copyOf(needleComponent.getLineAttributes());
Fill fl=bCategoryStyle ? (FillUtil.getPaletteFill(pa.getEntries(),iValueValidIndex)) : (FillUtil.getPaletteFill(pa.getEntries(),(dial.getSeriesDefinition().getRunTimeSeries().indexOf(ds))));
dial.updateTranslucency(fl,ds);
final AbstractScriptHandler<?> sh=dial.getRunTimeContext().getScriptHandler();
ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT,dphValue,fl,dial.getRunTimeContext().getScriptContext());
dial.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT,dphValue);
fl=ChartUtil.convertFill(fl,((Number)dphValue.getOrthogonalValue()).doubleValue(),null);
if (fl instanceof ColorDefinition) {
lia.setColor((ColorDefinition)fl);
}
 else if (fl instanceof Gradient) {
lia.setColor(((Gradient)fl).getStartColor());
}
final LineRenderEvent lreNeedle=((EventObjectCache)idr).getEventObject(WrappedStructureSource.createSeriesDataPoint(ds,dphValue),LineRenderEvent.class);
lreNeedle.setLineAttributes(lia);
lreNeedle.setStart(goFactory.createLocation(dialBounds.getLeft() + dialBounds.getWidth() / 2,dialBounds.getTop() + dialBounds.getHeight() / 2));
double xOffset=dDialRadius * Math.cos(Math.toRadians(needleAngle));
double yOffset=dDialRadius * Math.sin(Math.toRadians(needleAngle));
lreNeedle.setEnd(goFactory.createLocation(lreNeedle.getStart().getX() + xOffset,lre.getStart().getY() - yOffset));
dc.addLine(lreNeedle);
if (dial.isInteractivityEnabled()) {
final EList<Trigger> elTriggers=ds.getTriggers();
if (!elTriggers.isEmpty()) {
final StructureSource iSource=WrappedStructureSource.createSeriesDataPoint(ds,dphValue);
final InteractionEvent iev=((EventObjectCache)idr).getEventObject(iSource,InteractionEvent.class);
iev.setCursor(ds.getCursor());
Trigger tg;
for (int t=0; t < elTriggers.size(); t++) {
tg=goFactory.copyOf(elTriggers.get(t));
dial.processTrigger(tg,iSource);
iev.addTrigger(tg);
}
iev.setHotSpot(lreNeedle);
idr.enableInteraction(iev);
}
}
renderNeedleDecorator(idr,needleComponent,lreNeedle.getStart(),lreNeedle.getEnd(),lreNeedle.getLineAttributes(),fl,needleAngle,dialBounds.getWidth() / 2d,dphValue);
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT,dphValue,fl,dial.getRunTimeContext().getScriptContext());
dial.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT,dphValue);
}

Fixed version (ground truth):
/** 
 * @param idr
 * @param bo
 * @throws ChartException
 */
public final void render(IDeviceRenderer idr,Bounds bo) throws ChartException {
  dc=dial.getDeferredCache();
  Bounds boCA=goFactory.copyOf(bo);
  ChartWithoutAxes cwa=(ChartWithoutAxes)dial.getModel();
  if (cwa.isSetCoverage()) {
    double rate=cwa.getCoverage();
    double ww=0.5 * (1d - rate) * bo.getWidth();
    double hh=0.5 * (1d - rate) * bo.getHeight();
    insCA=goFactory.createInsets(hh,ww,hh,ww);
  }
  boCA.adjust(insCA);
  final boolean bDialSuperimposed=dial.isDialSuperimposed();
  final boolean bFirstSeries=dial.isFirstDial();
  final org.eclipse.birt.chart.model.component.Dial dialComponent=ds.getDial();
  final Needle needleComponent=ds.getNeedle();
  if (!bDialSuperimposed) {
    DataSetIterator dsi=new DataSetIterator(dial.getSeries().getDataSet());
    BigDecimal divisor=null;
    dsi.reset();
    while (dsi.hasNext()) {
      Object o=dsi.next();
      if (NumberUtil.isBigNumber(o)) {
        divisor=((BigNumber)o).getDivisor();
        break;
      }
    }
    dRadius=getDialRadius();
    dStartAngle=getDialStartAngle();
    dStopAngle=getDialStopAngle();
    inverseScale=isInverseScale();
    sc=getDialScale();
    asc=getAutoScale(dStartAngle,dStopAngle,sc,bo,divisor);
    dExtraSpacing=getDialExtraSpacing(asc);
  }
  if (dial.isRightToLeft()) {
    inverseScale=!inverseScale;
  }
  final boolean bFullDisc=dStopAngle < 0 || dStopAngle > 180 || dStartAngle < 0 || dStartAngle > 180;
  double dFullRadius=Math.min(boCA.getWidth() / 2d,boCA.getHeight() / 2d);
  if (dExtraSpacing > dFullRadius / 3) {
    dExtraSpacing=dFullRadius / 3;
    if (dSafeSpacing > dFullRadius / 10d) {
      dSafeSpacing=dFullRadius / 10d;
    }
  }
  if (dRadius > 0 && (dRadius + dExtraSpacing + dSafeSpacing * 2) < dFullRadius) {
    dFullRadius=dRadius + dExtraSpacing + dSafeSpacing * 2;
  }
  final ArcRenderEvent are=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent),ArcRenderEvent.class);
  Bounds fullBounds=goFactory.createBounds(boCA.getLeft() + (boCA.getWidth() - 2 * dFullRadius) / 2,(boCA.getTop() + (boCA.getHeight() - (bFullDisc ? 2 : 1) * dFullRadius) / 2),2 * dFullRadius,2 * dFullRadius);
  if (!bDialSuperimposed || bFirstSeries) {
    final Fill dialFill=dialComponent.getFill();
    double safeAngle=Math.toDegrees(Math.abs(Math.asin(dSafeSpacing / dFullRadius)));
    are.setBounds(fullBounds);
    are.setStartAngle(bFullDisc ? 0 : -safeAngle);
    are.setAngleExtent(bFullDisc ? 360 : (180 + 2 * safeAngle));
    are.setOutline(dialComponent.getLineAttributes());
    are.setBackground(dialFill);
    are.setStyle(ArcRenderEvent.CLOSED);
    idr.fillArc(are);
    idr.drawArc(are);
  }
  Bounds dialBounds=goFactory.createBounds(fullBounds.getLeft() + dExtraSpacing + dSafeSpacing,fullBounds.getTop() + dExtraSpacing + dSafeSpacing,fullBounds.getWidth() - 2 * (dExtraSpacing + dSafeSpacing),fullBounds.getHeight() - 2 * (dExtraSpacing + dSafeSpacing));
  if (!bDialSuperimposed || bFirstSeries) {
    double tsa=dStartAngle;
    double tpa=dStopAngle;
    if (tsa > tpa) {
      double temp=tsa;
      tsa=tpa;
      tpa=temp;
    }
    are.setBounds(dialBounds);
    are.setStartAngle(tsa);
    are.setAngleExtent(tpa - tsa);
    are.setOutline(dialComponent.getMajorGrid().getLineAttributes());
    are.setStyle(Math.abs(dStopAngle - dStartAngle) < 360 ? ArcRenderEvent.SECTOR : ArcRenderEvent.OPEN);
    idr.drawArc(are);
  }
  double xc=dialBounds.getLeft() + dialBounds.getWidth() / 2d;
  double yc=dialBounds.getTop() + dialBounds.getHeight() / 2d;
  double dDialRadius=dialBounds.getHeight() / 2d;
  for (int i=0; i < dialComponent.getDialRegions().size(); i++) {
    DialRegion dregion=dialComponent.getDialRegions().get(i);
    double ascMinValue=Double.parseDouble(asc.getMinimum().toString());
    double ascMaxValue=Double.parseDouble(asc.getMaximum().toString());
    double drStartValue=dregion.getStartValue() == null ? ascMinValue : ((NumberDataElement)dregion.getStartValue()).getValue();
    double drEndValue=dregion.getEndValue() == null ? ascMaxValue : ((NumberDataElement)dregion.getEndValue()).getValue();
    if (!((Math.max(drStartValue,drEndValue) <= ascMinValue) || (Math.min(drStartValue,drEndValue) >= (ascMaxValue)) || (drStartValue == drEndValue))) {
      double sAngle=Methods.getLocation(asc,drStartValue);
      double eAngle=Methods.getLocation(asc,drEndValue);
      if (sAngle < dStartAngle) {
        sAngle=dStartAngle;
      }
      if (sAngle > dStopAngle) {
        sAngle=dStopAngle;
      }
      if (eAngle < dStartAngle) {
        eAngle=dStartAngle;
      }
      if (eAngle > dStopAngle) {
        eAngle=dStopAngle;
      }
      double tsa=transformAngle(sAngle);
      double tpa=transformAngle(eAngle);
      if (tsa > tpa) {
        double temp=tsa;
        tsa=tpa;
        tpa=temp;
      }
      are.setBounds(dialBounds);
      are.setStartAngle(tsa);
      are.setAngleExtent(tpa - tsa);
      are.setBackground(dregion.getFill());
      are.setOutline(dregion.getOutline());
      are.setStyle(ArcRenderEvent.SECTOR);
      are.setInnerRadius(dregion.isSetInnerRadius() ? Math.min(dregion.getInnerRadius() * dScale,dDialRadius) : 0);
      if (dregion.isSetOuterRadius()) {
        if (dregion.getOuterRadius() == -1) {
          are.setOuterRadius(dDialRadius);
        }
 else {
          are.setOuterRadius(Math.min(dregion.getOuterRadius() * dScale,dDialRadius));
        }
      }
 else {
        are.setOuterRadius(0);
      }
      idr.fillArc(are);
      idr.drawArc(are);
    }
  }
  final LineRenderEvent lre=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent),LineRenderEvent.class);
  AxisTickCoordinates tickCoord=asc.getTickCordinates();
  if (!bDialSuperimposed || bFirstSeries) {
    if (dialComponent.getMajorGrid().getTickAttributes().isVisible() || dialComponent.getMinorGrid().getTickAttributes().isVisible()) {
      double[] minorCoord=asc.getMinorCoordinates(sc.getMinorGridsPerUnit());
      Location start=goFactory.createLocation(0,0);
      Location end=goFactory.createLocation(0,0);
      for (int i=0; i < asc.getTickCount(); i++) {
        double mtd=tickCoord.getCoordinate(i);
        mtd=transformAngle(mtd);
        double mtr=Math.toRadians(mtd);
        if (dialComponent.getMajorGrid().getTickAttributes().isVisible()) {
          lre.setLineAttributes(dialComponent.getMajorGrid().getTickAttributes());
switch (dialComponent.getMajorGrid().getTickStyle().getValue()) {
case TickStyle.ABOVE:
            start.set(xc + dDialRadius * Math.cos(mtr),yc - dDialRadius * Math.sin(mtr));
          end.set(xc + (dDialRadius + getTickSize()) * Math.cos(mtr),yc - (dDialRadius + getTickSize()) * Math.sin(mtr));
        break;
case TickStyle.ACROSS:
      start.set(xc + (dDialRadius + getTickSize() / 2d) * Math.cos(mtr),yc - (dDialRadius + getTickSize() / 2d) * Math.sin(mtr));
    end.set(xc + (dDialRadius - getTickSize() / 2d) * Math.cos(mtr),yc - (dDialRadius - getTickSize() / 2d) * Math.sin(mtr));
  break;
case TickStyle.BELOW:
start.set(xc + dDialRadius * Math.cos(mtr),yc - dDialRadius * Math.sin(mtr));
end.set(xc + (dDialRadius - getTickSize()) * Math.cos(mtr),yc - (dDialRadius - getTickSize()) * Math.sin(mtr));
break;
default :
throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",Messages.getResourceBundle(dial.getRunTimeContext().getULocale()));
}
lre.setStart(start);
lre.setEnd(end);
dc.addLine(lre);
}
if (dialComponent.getMinorGrid().getTickAttributes().isVisible() && i != asc.getTickCount() - 1) {
lre.setLineAttributes(dialComponent.getMinorGrid().getTickAttributes());
for (int j=0; j < sc.getMinorGridsPerUnit() - 1; j++) {
double minortd=minorCoord[j];
if ((inverseScale && mtd + minortd >= transformAngle(tickCoord.getCoordinate(i + 1))) || (!inverseScale && mtd - minortd <= transformAngle(tickCoord.getCoordinate(i + 1)))) {
continue;
}
double minortr=Math.toRadians(inverseScale ? (mtd + minortd) : (mtd - minortd));
switch (dialComponent.getMinorGrid().getTickStyle().getValue()) {
case TickStyle.ABOVE:
start.set(xc + dDialRadius * Math.cos(minortr),yc - dDialRadius * Math.sin(minortr));
end.set(xc + (dDialRadius + getTickSize()) * Math.cos(minortr),yc - (dDialRadius + getTickSize()) * Math.sin(minortr));
break;
case TickStyle.ACROSS:
start.set(xc + (dDialRadius + getTickSize() / 2d) * Math.cos(minortr),yc - (dDialRadius + getTickSize() / 2d) * Math.sin(minortr));
end.set(xc + (dDialRadius - getTickSize() / 2d) * Math.cos(minortr),yc - (dDialRadius - getTickSize() / 2d) * Math.sin(minortr));
break;
case TickStyle.BELOW:
start.set(xc + dDialRadius * Math.cos(minortr),yc - dDialRadius * Math.sin(minortr));
end.set(xc + (dDialRadius - getTickSize()) * Math.cos(minortr),yc - (dDialRadius - getTickSize()) * Math.sin(minortr));
break;
default :
throw new ChartException(ChartEnginePlugin.ID,ChartException.RENDERING,"String_Node_Str",Messages.getResourceBundle(dial.getRunTimeContext().getULocale()));
}
lre.setStart(start);
lre.setEnd(end);
dc.addLine(lre);
}
}
}
}
}
if (!bDialSuperimposed || (bDialSuperimposed && bFirstSeries)) {
if (dialComponent.getLabel().isVisible()) {
final TextRenderEvent tre=((EventObjectCache)idr).getEventObject(StructureSource.createUnknown(dialComponent.getLabel()),TextRenderEvent.class);
Label lbScale=goFactory.copyOf(dialComponent.getLabel());
Location loc=goFactory.createLocation(0,0);
tre.setLabel(lbScale);
tre.setAction(TextRenderEvent.RENDER_TEXT_AT_LOCATION);
tre.setLocation(loc);
for (int i=0; i < tickCoord.size(); i++) {
if (dStopAngle - dStartAngle == 360 && i == tickCoord.size() - 1) {
continue;
}
lbScale.getCaption().setValue(sla[i]);
double tickAngle=dStartAngle + (tickCoord.getNormalizedCoordinate(i)) / (tickCoord.getEnd() - tickCoord.getStart()) * (dStopAngle - dStartAngle);
tickAngle=transformAngle(tickAngle);
int quad=ChartUtil.getQuadrant(tickAngle);
double tickRadians=Math.toRadians(tickAngle);
double tx=xc + dDialRadius * Math.cos(tickRadians);
double ty=yc - dDialRadius * Math.sin(tickRadians);
switch (quad) {
case -1:
loc.set(tx + dSafeSpacing / 2,ty);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
case -2:
loc.set(tx,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.ABOVE);
break;
case -3:
loc.set(tx - dSafeSpacing / 2,ty);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case -4:
loc.set(tx,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.BELOW);
break;
case 1:
loc.set(tx + dSafeSpacing / 2,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
case 2:
loc.set(tx - dSafeSpacing / 2,ty - dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case 3:
loc.set(tx - dSafeSpacing / 2,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.LEFT);
break;
case 4:
loc.set(tx + dSafeSpacing / 2,ty + dSafeSpacing / 2);
tre.setTextPosition(TextRenderEvent.RIGHT);
break;
}
dc.addLabel(tre);
}
}
}
double needleAngle=Methods.getLocation(asc,dValue);
if (needleAngle < dStartAngle || needleAngle > dStopAngle) {
return;
}
needleAngle=transformAngle(needleAngle);
boolean bCategoryStyle=(((ChartWithoutAxes)dial.getModel()).getLegend().getItemType() == LegendItemType.CATEGORIES_LITERAL);
LineAttributes lia=goFactory.copyOf(needleComponent.getLineAttributes());
Fill fl=bCategoryStyle ? (FillUtil.getPaletteFill(pa.getEntries(),iValueValidIndex)) : (FillUtil.getPaletteFill(pa.getEntries(),(dial.getSeriesDefinition().getRunTimeSeries().indexOf(ds))));
dial.updateTranslucency(fl,ds);
final AbstractScriptHandler<?> sh=dial.getRunTimeContext().getScriptHandler();
ScriptHandler.callFunction(sh,ScriptHandler.BEFORE_DRAW_DATA_POINT,dphValue,fl,dial.getRunTimeContext().getScriptContext());
dial.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.BEFORE_DRAW_DATA_POINT,dphValue);
fl=ChartUtil.convertFill(fl,((Number)dphValue.getOrthogonalValue()).doubleValue(),null);
if (fl instanceof ColorDefinition) {
lia.setColor((ColorDefinition)fl);
}
 else if (fl instanceof Gradient) {
lia.setColor(((Gradient)fl).getStartColor());
}
final LineRenderEvent lreNeedle=((EventObjectCache)idr).getEventObject(WrappedStructureSource.createSeriesDataPoint(ds,dphValue),LineRenderEvent.class);
lreNeedle.setLineAttributes(lia);
lreNeedle.setStart(goFactory.createLocation(dialBounds.getLeft() + dialBounds.getWidth() / 2,dialBounds.getTop() + dialBounds.getHeight() / 2));
double xOffset=dDialRadius * Math.cos(Math.toRadians(needleAngle));
double yOffset=dDialRadius * Math.sin(Math.toRadians(needleAngle));
lreNeedle.setEnd(goFactory.createLocation(lreNeedle.getStart().getX() + xOffset,lre.getStart().getY() - yOffset));
dc.addLine(lreNeedle);
if (dial.isInteractivityEnabled()) {
final EList<Trigger> elTriggers=ds.getTriggers();
if (!elTriggers.isEmpty()) {
final StructureSource iSource=WrappedStructureSource.createSeriesDataPoint(ds,dphValue);
final InteractionEvent iev=((EventObjectCache)idr).getEventObject(iSource,InteractionEvent.class);
iev.setCursor(ds.getCursor());
Trigger tg;
for (int t=0; t < elTriggers.size(); t++) {
tg=goFactory.copyOf(elTriggers.get(t));
dial.processTrigger(tg,iSource);
iev.addTrigger(tg);
}
iev.setHotSpot(lreNeedle);
idr.enableInteraction(iev);
}
}
renderNeedleDecorator(idr,needleComponent,lreNeedle.getStart(),lreNeedle.getEnd(),lreNeedle.getLineAttributes(),fl,needleAngle,dialBounds.getWidth() / 2d,dphValue);
ScriptHandler.callFunction(sh,ScriptHandler.AFTER_DRAW_DATA_POINT,dphValue,fl,dial.getRunTimeContext().getScriptContext());
dial.getRunTimeContext().notifyStructureChange(IStructureDefinitionListener.AFTER_DRAW_DATA_POINT,dphValue);
}