import { ObservableArray, addWeakEventListener } from '@nativescript/core';
import * as commonModule from './common';
export class RadRadialGauge extends commonModule.RadRadialGauge {
    get nativeObject() {
        return this._android;
    }
    get _nativeView() {
        return this._android;
    }
    createNativeView() {
        this._android = new com.telerik.widget.gauge.RadRadialGaugeView(this._context);
        if (this.scales) {
            addWeakEventListener(this.scales, ObservableArray.changeEvent, this.scalesCollectionChanged, this);
            this.initializer.updateNativeObject(this);
            this.reloadScales();
        }
        return this._android;
    }
}
export class RadialScale extends commonModule.RadialScale {
    get android() {
        return this._android;
    }
    get nativeObject() {
        return this._android;
    }
    get _nativeView() {
        return this._android;
    }
    get owner() {
        return this._owner;
    }
    set owner(value) {
        this._owner = value;
        this._android = new com.telerik.widget.scales.GaugeRadialScale(this._owner._context);
        if (this.indicators) {
            addWeakEventListener(this.indicators, ObservableArray.changeEvent, this.indicatorsCollectionChanged, this);
        }
        this.initializer.updateNativeObject(this);
        this.updateNativeRadialScale();
    }
    updateNativeRadialScale() {
        this._android.setStartAngle(this.startAngle);
        this._android.setSweepAngle(this.sweepAngle);
        this._android.setRadius(this.radius);
    }
    _onStartAnglePropertyChanged(oldValue, newValue) {
        if (!this._android) {
            return;
        }
        this._android.setStartAngle(newValue);
    }
    _onSweepAnglePropertyChanged(oldValue, newValue) {
        if (!this._android) {
            return;
        }
        this._android.setSweepAngle(newValue);
    }
    _onRadiusPropertyChanged(oldValue, newValue) {
        if (!this._android) {
            return;
        }
        this._android.setRadius(newValue);
    }
}
export class ScaleStyle extends commonModule.ScaleStyle {
    _onLineColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setStrokeColor(newValue.android);
        }
    }
    _onLineThicknessPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            if (newValue === 0) {
                this.owner._nativeView.setLineVisible(false);
            }
            else {
                this.owner._nativeView.setLineVisible(true);
            }
            this.owner._nativeView.setStrokeWidth(newValue);
        }
    }
    _onTicksVisiblePropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setTicksVisible(newValue);
        }
    }
    _onMajorTicksCountPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMajorTicksCount(newValue);
        }
    }
    _onMinorTicksCountPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMinorTicksCount(newValue);
        }
    }
    _onТicksOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setTicksOffset(newValue);
        }
    }
    _onTicksLayoutModePropertyChanged(oldValue, newValue) {
        if (!this.shouldUpdateNativeObject()) {
            return;
        }
        if (newValue === commonModule.GaugeScaleLayoutMode.Inner) {
            this.owner._nativeView.setTicksLayoutMode(com.telerik.widget.scales.GaugeScaleTicksLayoutMode.INNER);
        }
        else if (newValue === commonModule.GaugeScaleLayoutMode.Outer) {
            this.owner._nativeView.setTicksLayoutMode(com.telerik.widget.scales.GaugeScaleTicksLayoutMode.OUTER);
        }
    }
    _onMajorTicksWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMajorTicksWidth(newValue);
        }
    }
    _onMinorTicksWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMinorTicksWidth(newValue);
        }
    }
    _onMajorTicksLengthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMajorTicksLength(newValue);
        }
    }
    _onMinorTicksLengthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setMinorTicksLength(newValue);
        }
    }
    _onMajorTicksStrokeColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setMajorTicksStrokeColor(newValue.android);
        }
    }
    _onМinorTicksStrokeColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setMinorTickStrokeColor(newValue.android);
        }
    }
    _onMajorTicksFillColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setMajorTicksFillColor(newValue.android);
        }
    }
    _onMinorTicksFillColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setMinorTicksFillColor(newValue.android);
        }
    }
    _onМajorTicksStrokeWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getMajorTicksStrokePaint().setStrokeWidth(newValue);
        }
    }
    _onМinorTicksStrokeWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getMinorTicksStrokePaint().setStrokeWidth(newValue);
        }
    }
    _onLabelsVisiblePropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setLabelsVisible(newValue);
        }
    }
    _onLabelsCountPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setLabelsCount(newValue);
        }
    }
    _onLabelsLayoutModePropertyChanged(oldValue, newValue) {
        if (!this.shouldUpdateNativeObject()) {
            return;
        }
        if (newValue === commonModule.GaugeScaleLayoutMode.Inner) {
            this.owner._nativeView.setLabelsLayoutMode(com.telerik.widget.scales.GaugeScaleLabelsLayoutMode.INNER);
        }
        else if (newValue === commonModule.GaugeScaleLayoutMode.Outer) {
            this.owner._nativeView.setLabelsLayoutMode(com.telerik.widget.scales.GaugeScaleLabelsLayoutMode.OUTER);
        }
    }
    _onLabelsOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setLabelsOffset(newValue);
        }
    }
    _onLabelsSizePropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getLabelsPaint().setTextSize(newValue);
        }
    }
    _onLabelsColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setLabelsColor(newValue.android);
        }
    }
}
export class TitleStyle extends commonModule.TitleStyle {
    _onTextSizePropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getTitle().setTextSize(newValue);
        }
    }
    _onTextColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.getTitle().setTextColor(newValue.android);
        }
    }
    _onHorizontalOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setTitleHorizontalOffset(newValue);
        }
    }
    _onVerticalOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setTitleVerticalOffset(newValue);
        }
    }
}
export class SubtitleStyle extends commonModule.SubtitleStyle {
    _onTextSizePropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getSubtitle().setTextSize(newValue);
        }
    }
    _onTextColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.getSubtitle().setTextColor(newValue.android);
        }
    }
    _onHorizontalOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setSubtitleHorizontalOffset(newValue);
        }
    }
    _onVerticalOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setSubtitleVerticalOffset(newValue);
        }
    }
}
/////////////////////////// INDICATORS
export class RadialNeedle extends commonModule.RadialNeedle {
    constructor() {
        super(...arguments);
        this._androidViewId = -1;
    }
    initNativeView() {
        super.initNativeView();
        if (this._androidViewId < 0) {
            this._androidViewId = android.view.View.generateViewId();
        }
        this._android.setId(this._androidViewId);
    }
    get android() {
        return this._android;
    }
    get owner() {
        return this._owner;
    }
    set owner(value) {
        this._owner = value;
        let gaugeView = value.owner;
        this._android = new com.telerik.widget.indicators.GaugeRadialNeedle(gaugeView._context);
        this.initializer.updateNativeObject(this);
        if (this.value !== undefined) {
            this._android.setValue(this.value);
        }
    }
    get nativeObject() {
        return this._android;
    }
    get _nativeView() {
        return this._android;
    }
    _onValuePropertyChanged(oldValue, newValue) {
        if (!this._android) {
            return;
        }
        this._android.setValue(newValue);
    }
}
export class NeedleStyle extends commonModule.NeedleStyle {
    _onLengthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setLength(newValue);
        }
    }
    _onBottomWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setBottomWidth(newValue);
        }
    }
    _onTopWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setTopWidth(newValue);
        }
    }
    _onCircleRadiusPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setCircleRadius(newValue);
        }
    }
    _onCircleInnerRadiusPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setCircleInnerRadius(newValue);
        }
    }
    _onOffsetPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setOffset(newValue);
        }
    }
    _onCircleFillColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setCircleFillColor(newValue.android);
        }
    }
    _onCircleStrokeColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setCircleStrokeColor(newValue.android);
        }
    }
    _onCircleStrokeWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.getCircleStrokePaint().setStrokeWidth(newValue);
        }
    }
    _onFillColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setFillColor(newValue.android);
        }
    }
    _onStrokeColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setStrokeColor(newValue.android);
        }
    }
    _onStrokeWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setStrokeWidth(newValue);
        }
    }
}
export class RadialBarIndicator extends commonModule.RadialBarIndicator {
    constructor() {
        super(...arguments);
        this._androidViewId = -1;
    }
    initNativeView() {
        super.initNativeView();
        if (this._androidViewId < 0) {
            this._androidViewId = android.view.View.generateViewId();
        }
        this._android.setId(this._androidViewId);
    }
    get owner() {
        return this._owner;
    }
    set owner(value) {
        this._owner = value;
        let gaugeView = value.owner;
        this._android = new com.telerik.widget.indicators.GaugeRadialBarIndicator(gaugeView._context);
        this.initializer.updateNativeObject(this);
    }
    get android() {
        return this._android;
    }
    get nativeObject() {
        return this._android;
    }
    get _nativeView() {
        return this._android;
    }
}
export class BarIndicatorStyle extends commonModule.BarIndicatorStyle {
    _onCapPropertyChanged(oldValue, newValue) {
        if (!this.shouldUpdateNativeObject()) {
            return;
        }
        if (newValue === commonModule.GaugeIndicatorCapMode.Edge) {
            this.owner._nativeView.setCap(com.telerik.widget.indicators.GaugeBarIndicatorCapMode.EDGE);
        }
        else if (newValue === commonModule.GaugeIndicatorCapMode.Round) {
            this.owner._nativeView.setCap(com.telerik.widget.indicators.GaugeBarIndicatorCapMode.ROUND);
        }
    }
    _onBarWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setBarWidth(newValue);
        }
    }
    _onFillColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setFillColor(newValue.android);
        }
    }
    _onStrokeColorPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject() && newValue) {
            this.owner._nativeView.setStrokeColor(newValue.android);
        }
    }
    _onStrokeWidthPropertyChanged(oldValue, newValue) {
        if (this.shouldUpdateNativeObject()) {
            this.owner._nativeView.setStrokeWidth(newValue);
        }
    }
}
//# sourceMappingURL=index.android.js.map