Format the label text.

@param scaleUnit The unit used for the scalebar.
@param value The scale value.
@param intervalUnit The scaled unit for the intervals.
357440
@VisibleForTesting
    protected static String createLabelText(
            final DistanceUnit scaleUnit, final double value, final DistanceUnit intervalUnit) {
        double scaledValue = scaleUnit.convertTo(value, intervalUnit);

        // assume that there is no interval smaller then 0.0001
        scaledValue = Math.round(scaledValue * 10000) / 10000;
        String decimals = Double.toString(scaledValue).split("\\.")[1];

        if (Double.valueOf(decimals) == 0) {
            return Long.toString(Math.round(scaledValue));
        } else {
            return Double.toString(scaledValue);
        }
    }
163576
@Override protected void resizeDynamicText() {
        double maxWidth = unitText.isVisible() ? size * 0.725 : size * 0.9;
        double fontSize = size * 0.24;
        valueText.setFont(Fonts.latoRegular(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }

        percentageUnitText.relocate(percentageText.getLayoutBounds().getMaxX() + size * 0.075, height - size * 0.25);
    }
108494
protected ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) {
        this.prevMapPosition = this.mapViewPosition.getMapPosition();
        double groundResolution = MercatorProjection.calculateGroundResolution(this.prevMapPosition.latLong.latitude,
                MercatorProjection.getMapSize(this.prevMapPosition.zoomLevel, this.displayModel.getTileSize()));

        groundResolution = groundResolution / unitAdapter.getMeterRatio();
        int[] scaleBarValues = unitAdapter.getScaleBarValues();

        int scaleBarLength = 0;
        int mapScaleValue = 0;

        for (int scaleBarValue : scaleBarValues) {
            mapScaleValue = scaleBarValue;
            scaleBarLength = (int) (mapScaleValue / groundResolution);
            if (scaleBarLength < (this.mapScaleBitmap.getWidth() - 10)) {
                break;
            }
        }

        return new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue);
    }
1202844
public static void push(String metric, int interval, Object value) {
        SingleRxXian.call("monitor", "pushToFalcon", new JSONObject() {{
            put("metric", metric);
            put("step", interval);
            put("value", value);
        }}).subscribe(unitResponse -> LOG.info("监控数据推送完毕:" + unitResponse));
    }
443473
public void setUnitPerMillimeter(int unitPerMillimeter)
	{
		if (1 > unitPerMillimeter)
		{
			String _message = "The specified unitPerMillimetre ({0}) is incorrect, it must be greater or equal than 1.";
			Object[] _parameters =
			{
				new Integer(unitPerMillimeter)
			};
			throw new IllegalArgumentException(MessageFormat.format(_message, _parameters));
		}
		myUnitPerMillimeter = unitPerMillimeter;
	}
934759
public void initializeIntervalConf(int interval, TimeUnit unit)
    {
        boolean isIntervalValid = TimeIntervalFormatUtil.checkValidInterval(interval, unit);

        if (isIntervalValid == false)
        {
            String logFormat = "File switch interval is invalid. Apply default interval 10 minutes. : Interval={0} , TimeUnit={1}";
            String logMessage = MessageFormat.format(logFormat, interval, unit.toString());
            logger.warn(logMessage);
        }
        else
        {
            this.switchTimeInterval = interval;
            this.switchTimeUnit = unit;
        }
    }
1024757
void setInterval(String interval) {

        final int i = CmsSerialDateUtil.toIntWithDefault(interval, -1);
        if (m_model.getInterval() != i) {
            removeExceptionsOnChange(new Command() {

                public void execute() {

                    m_model.setInterval(i);
                    onValueChange();
                }
            });
        }

    }
700660
@Override
    public void setScale(IChemModel chemModel) {
        double bondLength = AverageBondLengthCalculator.calculateAverageBondLength(chemModel);
        double scale = this.calculateScaleForBondLength(bondLength);

        // store the scale so that other components can access it
        this.rendererModel.getParameter(Scale.class).setValue(scale);
    }
246500
private static void doLayout(
            final Graphics2D graphics2d, final ScalebarAttributeValues scalebarParams,
            final ScaleBarRenderSettings settings) {
        final Dimension maxLabelSize = getMaxLabelSize(settings);

        int numSubIntervals = 1;
        if (scalebarParams.subIntervals) {
            numSubIntervals = getNbSubIntervals(
                    settings.getScaleUnit(), settings.getIntervalLengthInWorldUnits(),
                    settings.getIntervalUnit());
        }

        settings.setBarSize(getBarSize(settings));
        settings.setLabelDistance(getLabelDistance(settings));
        settings.setLineWidth(getLineWidth(settings));
        settings.setSize(getSize(scalebarParams, settings, maxLabelSize));
        settings.setMaxLabelSize(maxLabelSize);
        settings.setNumSubIntervals(numSubIntervals);

        ScalebarDrawer drawer = scalebarParams.getType().createDrawer(graphics2d, settings);
        drawer.draw();
    }
444969
public static final BigInteger printWorkUnits(TimeUnit value)
   {
      int result;

      if (value == null)
      {
         value = TimeUnit.HOURS;
      }

      switch (value)
      {
         case MINUTES:
         {
            result = 1;
            break;
         }

         case DAYS:
         {
            result = 3;
            break;
         }

         case WEEKS:
         {
            result = 4;
            break;
         }

         case MONTHS:
         {
            result = 5;
            break;
         }

         case YEARS:
         {
            result = 7;
            break;
         }

         default:
         case HOURS:
         {
            result = 2;
            break;
         }
      }

      return (BigInteger.valueOf(result));
   }
1029924
function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
    var ordinalScale = axis.scale;
    var labelFormatter = makeLabelFormatter(axis);
    var result = [];

    zrUtil.each(ordinalScale.getTicks(), function (tickValue) {
        var rawLabel = ordinalScale.getLabel(tickValue);
        if (categoryInterval(tickValue, rawLabel)) {
            result.push(onlyTick
                ? tickValue
                : {
                    formattedLabel: labelFormatter(tickValue),
                    rawLabel: rawLabel,
                    tickValue: tickValue
                }
            );
        }
    });

    return result;
}
269032
public void setCustomTickLabelFontSize(final double SIZE) {
        if (null == customTickLabelFontSize) {
            _customTickLabelFontSize = Helper.clamp(0.0, 72.0, SIZE);
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            customTickLabelFontSize.set(SIZE);
        }
    }
764335
public void setScale(final float scale) {
        if (equal(mScale, scale) != true) {
            Log.d(TAG, "setScale(): old: %.2f, new: %.2f", mScale, scale);
            mScale = scale;
            setScale(mSceneRootObject, scale);
            setScale(mMainCameraRootObject, scale);
            setScale(mLeftCameraRootObject, scale);
            setScale(mRightCameraRootObject, scale);
            for (OnScaledListener listener : mOnScaledListeners) {
                try {
                    listener.onScaled(scale);
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.e(TAG, e, "setScale()");
                }
            }
        }
    }
383871
private void setValidity(Object val) throws CertificateException {
        if (!(val instanceof CertificateValidity)) {
            throw new CertificateException(
                             "CertificateValidity class type invalid.");
        }
        interval = (CertificateValidity)val;
    }
673007
public final void setPlaceholderTextSize(int unit,
                                             int size) {
        if (size < 0) {
            throw new IllegalArgumentException("Text size cannot be less than zero.");
        }

        int scaledSize = (int) TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics());
        setPlaceholderTextInternal(mText, mTextColor, scaledSize, true);
    }
220289
func ScaledLabel(value int64, fromUnit, toUnit string) string {
	v, u := Scale(value, fromUnit, toUnit)
	sv := strings.TrimSuffix(fmt.Sprintf("%.2f", v), ".00")
	if sv == "0" || sv == "-0" {
		return "0"
	}
	return sv + u
}
825238
protected static function paramsValidation($value, int $scale = null)
    {
        if (null === $value) {
            throw new \InvalidArgumentException('$value must be a non null number');
        }

        if (null !== $scale && $scale < 0) {
            throw new \InvalidArgumentException('$scale must be a positive integer');
        }
    }