import { NativeModules } from 'react-native'; import { MPError, MPIconSize } from "../../index"; import { MPIconPlacement } from './MPIconPlacement'; import { MPLabelType } from './MPLabelType'; import { MPBadgePosition } from './MPBadgePosition'; import MPLabelGraphic from './MPLabelGraphic'; import { MPLabelPosition } from './MPLabelPosition'; const { DisplayRule } = NativeModules; /** * A collection of settings that dictate how MapsIndoors entities are displayed on the map. * * @export * @class MPDisplayRule * @typedef {MPDisplayRule} */ export default class MPDisplayRule { /** * Creates an instance of MPDisplayRule. * * @constructor * @private * @param {string} id */ private constructor(readonly id: string) { } /** * Creator for MPDisplayRule, used to decode JSON from the MapsIndoors SDK. * * This is primarily for internal use, and should not be used outside the SDK. * * @public * @static * @param {?*} [object] * @returns {MPDisplayRule} */ public static create(object?: any): MPDisplayRule { const mpDisplayRule: MPDisplayRule = new MPDisplayRule(object?.id); return mpDisplayRule; } /** * Get the general visibility value. * * @public * @async * @returns {Promise} */ public async isVisible(): Promise { return DisplayRule.isVisible(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the general visibility value. * * @public * @async * @param {boolean} visible * @returns {Promise} */ public async setVisible(visible: boolean): Promise { return DisplayRule.setVisible(this.id, JSON.stringify(visible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the icon's visibility value. * * @public * @async * @returns {Promise} */ public async isIconVisible(): Promise { return DisplayRule.isIconVisible(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the icon's visibility value. * * @public * @async * @param {boolean} iconVisible * @returns {Promise} */ public async setIconVisible(iconVisible: boolean): Promise { return DisplayRule.setIconVisible(this.id, JSON.stringify(iconVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's visibility value. * * @public * @async * @returns {Promise} */ public async isPolygonVisible(): Promise { return DisplayRule.isPolygonVisible(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's visibility value. * * @public * @async * @param {boolean} polygonVisible * @returns {Promise} */ public async setPolygonVisible(polygonVisible: boolean): Promise { return DisplayRule.setPolygonVisible(this.id, JSON.stringify(polygonVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's visibility value. * * @public * @async * @returns {Promise} */ public async isLabelVisible(): Promise { return DisplayRule.isLabelVisible(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's visibility value. * * @public * @async * @param {boolean} labelVisible * @returns {Promise} */ public async setLabelVisible(labelVisible: boolean): Promise { return DisplayRule.setLabelVisible(this.id, JSON.stringify(labelVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's visibility value. * * @public * @async * @returns {Promise} */ public async isModel2DVisible(): Promise { return DisplayRule.isModel2DVisible(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's visibility value. * * @public * @async * @param {boolean} model2DVisible * @returns {Promise} */ public async setModel2DVisible(model2DVisible: boolean): Promise { return DisplayRule.setModel2DVisible(this.id, JSON.stringify(model2DVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's visibility value. * * @public * @async * @returns {Promise} */ public async isWallVisible(): Promise { return DisplayRule.isWallVisible(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's visibility value. * * @public * @async * @param {boolean} wallVisible * @returns {Promise} */ public async setWallVisible(wallVisible: boolean): Promise { return DisplayRule.setWallVisible(this.id, JSON.stringify(wallVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's visibility value. * * @public * @async * @returns {Promise} */ public async isExtrusionVisible(): Promise { return DisplayRule.isExtrusionVisible(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the extrusion's visibility value. * * @public * @async * @param {boolean} extrusionVisible * @returns {Promise} */ public async setExtrusionVisible(extrusionVisible: boolean): Promise { return DisplayRule.setExtrusionVisible(this.id, JSON.stringify(extrusionVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the general zoom from value. * * @public * @async * @returns {Promise} */ public async getZoomFrom(): Promise { return DisplayRule.getZoomFrom(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the general zoom from value. * * @public * @async * @param {number} zoomFrom * @returns {Promise} */ public async setZoomFrom(zoomFrom: number): Promise { if (zoomFrom == null) { zoomFrom = -1; } return DisplayRule.setZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the general zoom to value. * * @public * @async * @returns {Promise} */ public async getZoomTo(): Promise { return DisplayRule.getZoomTo(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the general zoom to value. * * @public * @async * @param {number} zoomTo * @returns {Promise} */ public async setZoomTo(zoomTo: number): Promise { if (zoomTo == null) { zoomTo = -1; } return DisplayRule.setZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the icon's URL. * * @public * @async * @returns {Promise} */ public async getIconUrl(): Promise { return DisplayRule.getIconUrl(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the icon's URL. * * @public * @async * @param {string} iconUrl * @returns {Promise} */ public async setIcon(iconUrl: string): Promise { return DisplayRule.setIcon(this.id, iconUrl).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the icon's size. * * @public * @async * @returns {Promise} */ public async getIconSize(): Promise { //TODO: handle rejection propagation let iconSize = await DisplayRule.getIconSize(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); return Promise.resolve(MPIconSize.create(JSON.parse(iconSize))).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the icon's size. * * @public * @async * @param {MPIconSize} iconSize * @returns {Promise} */ public async setIconSize(iconSize: MPIconSize): Promise { return DisplayRule.setIconSize(this.id, JSON.stringify(iconSize)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label string. * * @public * @async * @returns {Promise} */ public async getLabel(): Promise { return DisplayRule.getLabel(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label string. * * @public * @async * @param {string} label * @returns {Promise} */ public async setLabel(label: string): Promise { return DisplayRule.setLabel(this.id, label).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's zoom from value. * * @public * @async * @returns {Promise} */ public async getLabelZoomFrom(): Promise { return DisplayRule.getLabelZoomFrom(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's zoom from value. * * @public * @async * @param {number} zoomFrom * @returns {Promise} */ public async setLabelZoomFrom(zoomFrom: number): Promise { if (zoomFrom == null) { zoomFrom = -1; } return DisplayRule.setLabelZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's zoom to value. * * @public * @async * @returns {Promise} */ public async getLabelZoomTo(): Promise { return DisplayRule.getLabelZoomTo(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's zoom to value. * * @public * @async * @param {number} zoomTo * @returns {Promise} */ public async setLabelZoomTo(zoomTo: number): Promise { if (zoomTo == null) { zoomTo = -1; } return DisplayRule.setLabelZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's max width value. * * @public * @async * @returns {Promise} */ public async getLabelMaxWidth(): Promise { return DisplayRule.getLabelMaxWidth(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's max width value. * * @public * @async * @param {number} labelMaxWidth * @returns {Promise} */ public async setLabelMaxWidth(labelMaxWidth: number): Promise { if (labelMaxWidth == null) { labelMaxWidth = -1; } return DisplayRule.setLabelMaxWidth(this.id, labelMaxWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the plygon's zoom from value. * * @public * @async * @returns {Promise} */ public async getPolygonZoomFrom(): Promise { return DisplayRule.getPolygonZoomFrom(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the plygon's zoom from value. * * @public * @async * @param {number} polygonZoomFrom * @returns {Promise} */ public async setPolygonZoomFrom(polygonZoomFrom: number): Promise { if (polygonZoomFrom == null) { polygonZoomFrom = -1; } return DisplayRule.setPolygonZoomFrom(this.id, polygonZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's zoom to value. * * @public * @async * @returns {Promise} */ public async getPolygonZoomTo(): Promise { return DisplayRule.getPolygonZoomTo(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's zoom to value. * * @public * @async * @param {number} polygonZoomTo * @returns {Promise} */ public async setPolygonZoomTo(polygonZoomTo: number): Promise { if (polygonZoomTo == null) { polygonZoomTo = -1; } return DisplayRule.setPolygonZoomFrom(this.id, polygonZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's stroke width value. * * @public * @async * @returns {Promise} */ public async getPolygonStrokeWidth(): Promise { return DisplayRule.getPolygonStrokeWidth(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's stroke width value. * * @public * @async * @param {number} strokeWidth * @returns {Promise} */ public async setPolygonStrokeWidth(strokeWidth: number): Promise { if (strokeWidth == null) { strokeWidth = -1; } return DisplayRule.setPolygonStrokeWidth(this.id, strokeWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's stroke color value. * * @public * @async * @returns {Promise} */ public async getPolygonStrokeColor(): Promise { return DisplayRule.getPolygonStrokeColor(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's stroke color value. * * @public * @async * @param {string} strokeColor * @returns {Promise} */ public async setPolygonStrokeColor(strokeColor: string): Promise { return DisplayRule.setPolygonStrokeColor(this.id, strokeColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's stroke opacity value. * * @public * @async * @returns {Promise} */ public async getPolygonStrokeOpacity(): Promise { return DisplayRule.getPolygonStrokeOpacity(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's stroke opacity value. * * @public * @async * @param {number} strokeOpacity * @returns {Promise} */ public async setPolygonStrokeOpacity(strokeOpacity: number): Promise { if (strokeOpacity == null) { strokeOpacity = -1; } return DisplayRule.setPolygonStrokeOpacity(this.id, strokeOpacity).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's fill opacity value. * * @public * @async * @returns {Promise} */ public async getPolygonFillOpacity(): Promise { return DisplayRule.getPolygonFillOpacity(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's fill opacity value. * * @public * @async * @param {number} fillOpacity * @returns {Promise} */ public async setPolygonFillOpacity(fillOpacity: number): Promise { if (fillOpacity == null) { fillOpacity = -1; } return DisplayRule.setPolygonFillOpacity(this.id, fillOpacity).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's fill color value. * * @public * @async * @returns {Promise} */ public async getPolygonFillColor(): Promise { return DisplayRule.getPolygonFillColor(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's fill color value. * * @public * @async * @param {string} fillColor * @returns {Promise} */ public async setPolygonFillColor(fillColor: string): Promise { return DisplayRule.setPolygonFillColor(this.id, fillColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's color value. * * @public * @async * @returns {Promise} */ public async getWallColor(): Promise { return DisplayRule.getWallColor(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's color value. * * @public * @async * @param {string} wallColor * @returns {Promise} */ public async setWallColor(wallColor: string): Promise { return DisplayRule.setWallColor(this.id, wallColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's height value. * * @public * @async * @returns {Promise} */ public async getWallHeight(): Promise { return DisplayRule.getWallHeight(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's height value. * * @public * @async * @param {number} wallHeight * @returns {Promise} */ public async setWallHeight(wallHeight: number): Promise { if (wallHeight == null) { wallHeight = -1; } return DisplayRule.setWallHeight(this.id, wallHeight).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's zoom from value. * * @public * @async * @returns {Promise} */ public async getWallZoomFrom(): Promise { return DisplayRule.getWallZoomFrom(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's zoom from value. * * @public * @async * @param {number} wallZoomFrom * @returns {Promise} */ public async setWallZoomFrom(wallZoomFrom: number): Promise { if (wallZoomFrom == null) { wallZoomFrom = -1; } return DisplayRule.setWallZoomFrom(this.id, wallZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's zoom to value. * * @public * @async * @returns {Promise} */ public async getWallZoomTo(): Promise { return DisplayRule.getWallZoomTo(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's zoom to value. * * @public * @async * @param {number} wallZoomTo * @returns {Promise} */ public async setWallZoomTo(wallZoomTo: number): Promise { if (wallZoomTo == null) { wallZoomTo = -1; } return DisplayRule.setWallZoomTo(this.id, wallZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's color value. * * @public * @async * @returns {Promise} */ public async getExtrusionColor(): Promise { return DisplayRule.getExtrusionColor(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the extrusion's color value. * * @public * @async * @param {string} extrusionColor * @returns {Promise} */ public async setExtrusionColor(extrusionColor: string): Promise { return DisplayRule.setExtrusionColor(this.id, extrusionColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's height value. * * @public * @async * @returns {Promise} */ public async getExtrusionHeight(): Promise { return DisplayRule.getExtrusionHeight(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the extrusion's height value. * * @public * @async * @param {number} extrusionHeight * @returns {Promise} */ public async setExtrusionHeight(extrusionHeight: number): Promise { if (extrusionHeight == null) { extrusionHeight = -1; } return DisplayRule.setExtrusionHeight(this.id, extrusionHeight).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's zoom from value. * * @public * @async * @returns {Promise} */ public async getExtrusionZoomFrom(): Promise { return DisplayRule.getExtrusionZoomFrom(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the extrusion's zoom from value. * * @public * @async * @param {number} extrusionZoomFrom * @returns {Promise} */ public async setExtrusionZoomFrom(extrusionZoomFrom: number): Promise { if (extrusionZoomFrom == null) { extrusionZoomFrom = -1; } return DisplayRule.setExtrusionZoomFrom(this.id, extrusionZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's zoom to value. * * @public * @async * @returns {Promise} */ public async getExtrusionZoomTo(): Promise { return DisplayRule.getExtrusionZoomTo(this.id,).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's zoom to value. * * @public * @async * @param {number} extrusionZoomTo * @returns {Promise} */ public async setExtrusionZoomTo(extrusionZoomTo: number): Promise { if (extrusionZoomTo == null) { extrusionZoomTo = -1; } return DisplayRule.setExtrusionZoomTo(this.id, extrusionZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's zoom from value. * * @public * @async * @returns {Promise} */ public async getModel2DZoomFrom(): Promise { return DisplayRule.getModel2DZoomFrom(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's zoom from value. * * @public * @async * @param {number} zoomFrom * @returns {Promise} */ public async setModel2DZoomFrom(zoomFrom: number): Promise { if (zoomFrom == null) { zoomFrom = -1; } return DisplayRule.setModel2DZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's zoom to value. * * @public * @async * @returns {Promise} */ public async getModel2DZoomTo(): Promise { return DisplayRule.getModel2DZoomTo(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's zoom to value. * * @public * @async * @param {number} zoomTo * @returns {Promise} */ public async setModel2DZoomTo(zoomTo: number): Promise { if (zoomTo == null) { zoomTo = -1; } return DisplayRule.setModel2DZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's URL. * * @public * @async * @returns {Promise} */ public async getModel2DModel(): Promise { return DisplayRule.getModel2DModel(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's URL. * * @public * @async * @param {string} url * @returns {Promise} */ public async setModel2DModel(url: string): Promise { return DisplayRule.setModel2DModel(this.id, url).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's width in meters. * * @public * @async * @returns {Promise} */ public async getModel2DWidthMeters(): Promise { return DisplayRule.getModel2DWidthMeters(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's width in meters. * * @public * @async * @param {number} width * @returns {Promise} */ public async setModel2DWidthMeters(width: number): Promise { if (width == null) { width = -1; } return DisplayRule.setModel2DWidthMeters(this.id, width).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's height in meters. * * @public * @async * @returns {Promise} */ public async getModel2DHeightMeters(): Promise { return DisplayRule.getModel2DHeightMeters(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 2D model's height in meters. * * @public * @async * @param {number} height * @returns {Promise} */ public async setModel2DHeightMeters(height: number): Promise { if (height == null) { height = -1; } return DisplayRule.setModel2DHeightMeters(this.id, height).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's bearing value. * * @public * @async * @returns {Promise} */ public async getModel2DBearing(): Promise { return DisplayRule.getModel2DBearing(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 2D model's bearing value. * * @public * @async * @param {number} bearing * @returns {Promise} */ public async setModel2DBearing(bearing: number): Promise { if (bearing == null) { bearing = -1; } return DisplayRule.setModel2DBearing(this.id, bearing).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the scale value of the icon. * @returns Promise */ public async getIconScale(): Promise { return DisplayRule.getIconScale(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the scale value of the icon. * @returns Promise */ public async setIconScale(iconScale: number): Promise { if (iconScale == null) { iconScale = -1; } return DisplayRule.setIconScale(this.id, iconScale).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the icon's anchor value. * @returns Promise */ public async getIconPlacement(): Promise { return DisplayRule.getIconPlacement(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the icon's anchor value. * @returns Promise */ public async setIconPlacement(iconPlacement: MPIconPlacement): Promise { if (iconPlacement == null) { return DisplayRule.setIconPlacement(this.id, -1).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); }else { return DisplayRule.setIconPlacement(this.id, iconPlacement.valueOf()).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } } /** * Get the type of the label. * @returns Promise */ public async getLabelType(): Promise { return DisplayRule.getLabelType(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the type of the label. * @returns Promise */ public async setLabelType(labelType: MPLabelType): Promise { if (labelType == null) { return DisplayRule.setLabelType(this.id, -1).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); }else { return DisplayRule.setLabelType(this.id, labelType.valueOf()).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } } /** * Get the label's text size. * @returns Promise */ public async getLabelStyleTextSize(): Promise { return DisplayRule.getLabelStyleTextSize(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's text size. * @returns Promise */ public async setLabelStyleTextSize(textSize: number): Promise { if (textSize == null) { textSize = -1; } return DisplayRule.setLabelStyleTextSize(this.id, textSize).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's text color * @returns Promise */ public async getLabelStyleTextColor(): Promise { return DisplayRule.getLabelStyleTextColor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's text color * @returns Promise */ public async setLabelStyleTextColor(textColor: String): Promise { return DisplayRule.setLabelStyleTextColor(this.id, textColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's text opacity * @returns Promise */ public async getLabelStyleTextOpacity(): Promise { return DisplayRule.getLabelStyleTextOpacity(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's text opacity * @returns Promise */ public async setLabelStyleTextOpacity(textOpacity: number): Promise { if (textOpacity == null) { textOpacity = -1; } return DisplayRule.setLabelStyleTextOpacity(this.id, textOpacity).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's halo color * @returns Promise */ public async getLabelStyleHaloColor(): Promise { return DisplayRule.getLabelStyleHaloColor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's halo color * @returns Promise */ public async setLabelStyleHaloColor(color: string): Promise { return DisplayRule.setLabelStyleHaloColor(this.id, color).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's halo width * @returns Promise */ public async getLabelStyleHaloWidth(): Promise { return DisplayRule.getLabelStyleHaloWidth(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's halo width * @returns Promise */ public async setLabelStyleHaloWidth(haloWidth: number): Promise { if (haloWidth == null) { haloWidth = -1; } return DisplayRule.setLabelStyleHaloWidth(this.id, haloWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's halo blur * @returns Promise */ public async getLabelStyleHaloBlur(): Promise { return DisplayRule.getLabelStyleHaloBlur(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's halo blur * @returns Promise */ public async setLabelStyleHaloBlur(haloBlur: number): Promise { if (haloBlur == null) { haloBlur = -1; } return DisplayRule.setLabelStyleHaloBlur(this.id, haloBlur).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's bearing * @returns Promise */ public async getLabelStyleBearing(): Promise { return DisplayRule.getLabelStyleBearing(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's bearing * @returns Promise */ public async setLabelStyleBearing(bearing: number): Promise { if (bearing == null) { bearing = -1; } return DisplayRule.setLabelStyleBearing(this.id, bearing).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's position * @returns Promise */ public async getLabelStylePosition(): Promise { return DisplayRule.getLabelStylePosition(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's position * @param position MPLabelPosition * @returns Promise */ public async setLabelStylePosition(position: MPLabelPosition): Promise { return DisplayRule.setLabelStylePosition(this.id, position.valueOf()).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the label's Graphic style * @param graphicLabel MPLabelGraphic * @returns Promise */ public async setLabelStyleGraphic(graphicLabel: MPLabelGraphic): Promise { return DisplayRule.setLabelStyleGraphic(this.id, JSON.stringify(graphicLabel)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the label's Graphic style * @returns Promise */ public async getLabelStyleGraphic(): Promise { return DisplayRule.getLabelStyleGraphic(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the polygon's lightness factor. * @returns Promise */ public async getPolygonLightnessFactor(): Promise { return DisplayRule.getPolygonLightnessFactor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the polygon's lightness factor. * @returns Promise */ public async setPolygonLightnessFactor(lightnessFactor: number): Promise { if (lightnessFactor == null) { lightnessFactor = -2; } return DisplayRule.setPolygonLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the wall's lightness factor. * @returns Promise */ public async getWallLightnessFactor(): Promise { return DisplayRule.getWallLightnessFactor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the wall's lightness factor. * @returns Promise */ public async setWallLightnessFactor(lightnessFactor: number): Promise { if (lightnessFactor == null) { lightnessFactor = -2; } return DisplayRule.setWallLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the extrusion's lightness factor. * @returns Promise */ public async getExtrusionLightnessFactor(): Promise { return DisplayRule.getExtrusionLightnessFactor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the extrusion's lightness factor. * @returns Promise */ public async setExtrusionLightnessFactor(lightnessFactor: number): Promise { if (lightnessFactor == null) { lightnessFactor = -2; } return DisplayRule.setExtrusionLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's visibility. * @returns Promise */ public async isBadgeVisible(): Promise { return DisplayRule.isBadgeVisible(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's visibility. * @returns Promise */ public async setBadgeVisible(visible: boolean): Promise { return DisplayRule.setBadgeVisible(this.id, JSON.stringify(visible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's Zoom From value. * @returns Promise */ public async getBadgeZoomFrom(): Promise { return DisplayRule.getBadgeZoomFrom(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's Zoom From value. * @returns Promise */ public async setBadgeZoomFrom(zoomFrom: number): Promise { if (zoomFrom == null) { zoomFrom = -1; } return DisplayRule.setBadgeZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's Zoom To value. * @returns Promise */ public async getBadgeZoomTo(): Promise { return DisplayRule.getBadgeZoomTo(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's Zoom To value. * @returns Promise */ public async setBadgeZoomTo(zoomTo: number): Promise { if (zoomTo == null) { zoomTo = -1; } return DisplayRule.setBadgeZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's radius. * @returns Promise */ public async getBadgeRadius(): Promise { return DisplayRule.getBadgeRadius(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's radius. * @returns Promise */ public async setBadgeRadius(radius: number): Promise { if (radius == null) { radius = -1; } return DisplayRule.setBadgeRadius(this.id, radius).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's stroke width. * @returns Promise */ public async getBadgeStrokeWidth(): Promise { return DisplayRule.getBadgeStrokeWidth(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's stroke width. * @returns Promise */ public async setBadgeStrokeWidth(strokeWidth: number): Promise { if (strokeWidth == null) { strokeWidth = -1; } return DisplayRule.setBadgeStrokeWidth(this.id, strokeWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's stroke color. * @returns Promise */ public async getBadgeStrokeColor(): Promise { return DisplayRule.getBadgeStrokeColor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's stroke color. * @returns Promise */ public async setBadgeStrokeColor(strokeColor: string): Promise { return DisplayRule.setBadgeStrokeColor(this.id, strokeColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's fill color. * @returns Promise */ public async getBadgeFillColor(): Promise { return DisplayRule.getBadgeFillColor(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's fill color. * @returns Promise */ public async setBadgeFillColor(fillColor: string): Promise { return DisplayRule.setBadgeFillColor(this.id, fillColor).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's scale. * @returns Promise */ public async getBadgeScale(): Promise { return DisplayRule.getBadgeScale(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's scale. * @returns Promise */ public async setBadgeScale(badgeScale: number): Promise { if (badgeScale == null) { badgeScale = -1; } return DisplayRule.setBadgeScale(this.id, badgeScale).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the badge's position. * @returns Promise */ public async getBadgePosition(): Promise { return DisplayRule.getBadgePosition(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the badge's position. * @returns Promise */ public async setBadgePosition(badgePosition: MPBadgePosition): Promise { if (badgePosition == null) { return DisplayRule.setBadgePosition(this.id, -1).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); }else { return DisplayRule.setBadgePosition(this.id, badgePosition.valueOf()).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } } /** * Get the 3D model's URL. * @returns Promise */ public async getModel3DModel(): Promise { return DisplayRule.getModel3DModel(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's URL. * @param url string * @returns Promise */ public async setModel3DModel(url: string): Promise { return DisplayRule.setModel3DModel(this.id, url).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's rotation X. * @returns Promise */ public async getModel3DRotationX(): Promise { return DisplayRule.getModel3DRotationX(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's rotation X. * @param rotationX number * @returns Promise */ public async setModel3DRotationX(rotationX: number): Promise { if (rotationX == null) { rotationX = -1; } return DisplayRule.setModel3DRotationX(this.id, rotationX).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's rotation Y. * @returns Promise */ public async getModel3DRotationY(): Promise { return DisplayRule.getModel3DRotationY(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's rotation Y. * @param rotationY number * @returns Promise */ public async setModel3DRotationY(rotationY: number): Promise { if (rotationY == null) { rotationY = -1; } return DisplayRule.setModel3DRotationY(this.id, rotationY).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's rotation Z. * @returns Promise */ public async getModel3DRotationZ(): Promise { return DisplayRule.getModel3DRotationZ(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's rotation Z. * @param rotationZ number * @returns Promise */ public async setModel3DRotationZ(rotationZ: number): Promise { if (rotationZ == null) { rotationZ = -1; } return DisplayRule.setModel3DRotationZ(this.id, rotationZ).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's scale. * @returns Promise */ public async getModel3DScale(): Promise { return DisplayRule.getModel3DScale(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's scale. * @param scale number * @returns Promise */ public async setModel3DScale(scale: number): Promise { if (scale == null) { scale = -1; } return DisplayRule.setModel3DScale(this.id, scale).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's zoom from value. * @returns Promise */ public async getModel3DZoomFrom(): Promise { return DisplayRule.getModel3DZoomFrom(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's zoom from value. * @param zoomFrom number * @returns Promise */ public async setModel3DZoomFrom(zoomFrom: number): Promise { if (zoomFrom == null) { zoomFrom = -1; } return DisplayRule.setModel3DZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's zoom to value. * @returns Promise */ public async getModel3DZoomTo(): Promise { return DisplayRule.getModel3DZoomTo(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's zoom to value. * @param zoomTo number * @returns Promise */ public async setModel3DZoomTo(zoomTo: number): Promise { if (zoomTo == null) { zoomTo = -1; } return DisplayRule.setModel3DZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Get the 3D model's visibility. * @returns Promise */ public async isModel3DVisible(): Promise { return DisplayRule.isModel3DVisible(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Set the 3D model's visibility. * @param visible boolean * @returns Promise */ public async setModel3DVisible(visible: boolean): Promise { return DisplayRule.setModel3DVisible(this.id, JSON.stringify(visible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } /** * Resets the display rule to its default state. * * @public * @async * @returns {Promise} */ public async reset(): Promise { return DisplayRule.reset(this.id).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } }