# JSFigure

> Create a API with Module.createFigure.
>
> [JSFigure Type Constants](https://egiscorp.gitbook.io/xdworld_global_manual/etc/type-list#jsfigure-type-list)

```javascript
let figure = Module.createFigure("ID");
```

## Function

### getAngle() → number

> Returns the rotation angle around the y-axis of the object.

{% tabs %}
{% tab title="Information" %}

* Return
  * Valid angle (number): Successful return of the rotation angle.
  * -999.0 (number): If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var dAngle = figure.getAngle();
```

{% endtab %}
{% endtabs %}

### getBoundary() → [JSAABBox3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsaabbox3d)

> Returns the object's boundary.

{% tabs %}
{% tab title="Information" %}

* Return
  * [JSAABBox3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsaabbox3d): The function successfully returns the object's bounds.
  * null: Object bounds return failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
var boundary = figure.getBoundary();
var boundary_min = boundary.min;
var boundary_max = boundary.max;
```

{% endtab %}
{% endtabs %}

### getCenter() → [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)

> Returns the center point of the object.

{% tabs %}
{% tab title="Information" %}

* Return
  * [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d): Returns the centroid coordinates (longitude, latitude, altitude) of the object successfully.
  * null: Coordinate return failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vCenter = figure.getCenter();
var dCenterLon = vCenter.Longitude;
var dCenterLat = vCenter.Latitude;
var dCenterAlt = vCenter.Altitude;
```

{% endtab %}
{% endtabs %}

### getExtent() → number

> Returns the distance between Min-Max of the object boundary Box.

{% tabs %}
{% tab title="Information" %}

* Return
  * number: Distance between Min-Max of the object boundary Box.
    {% endtab %}

{% tab title="Template" %}

```javascript
var bExtends = figure.getExtent();
```

{% endtab %}
{% endtabs %}

### getFigureType() → number

> Returns the Figure type of the object.
>
> [JSFigure Type Constants](https://egiscorp.gitbook.io/xdworld_global_manual/etc/type-list#jsfigure-type-list)

{% tabs %}
{% tab title="Information" %}

* Return
  * Valid constant (number): Successful return of the Figure type.
  * -1 (number): If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var figureType = figure.getFigureType();
```

{% endtab %}
{% endtabs %}

### getId() → string

> Returns the ID of the object.

{% tabs %}
{% tab title="Information" %}

* Return
  * string: Successful return of the object's Key string.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
lat strKey = figure.getId();
```

{% endtab %}
{% endtabs %}

### getPosition() → [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)

> Returns the bottom center position of the object.

{% tabs %}
{% tab title="Information" %}

* Return
  * [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d): Returns the bottom center coordinates (longitude, latitude, altitude) of the object successfully.
  * null: Coordinate return failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
let position = figure.getPosition();
let longitude = position.x;
let latitude = position.y;
let altitude = position.z;
```

{% endtab %}
{% endtabs %}

### getSize() → [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)

> Returns the size values of the object.

{% tabs %}
{% tab title="Information" %}

* Return
  * [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d): Successfully returns the scale of the object corresponding to the x, y, z axes.
  * null: size return failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
let size = figure.getSize();
let width = size.x;
let height = size.y;
let depth = size.z;
```

{% endtab %}
{% endtabs %}

### setAngle(angle) → boolean

> Sets the rotation angle around the y-axis of the object.

{% tabs %}
{% tab title="Information" %}

| Name  | Type   | Description                                    |
| ----- | ------ | ---------------------------------------------- |
| angle | number | Rotation angle around the y-axis (in degrees). |

* Return
  * true: Rotation angle setting successful.
  * false: If the object is null or the input angle is outside the range of 0º to 360º.
    {% endtab %}

{% tab title="Template" %}

```javascript
figure.setAngle(50.0);
```

{% endtab %}
{% endtabs %}

### setDepth(depth) → boolean

> Sets the depth (Z-axis direction size) of the object.

{% tabs %}
{% tab title="Information" %}

| Name  | Type   | Description   |
| ----- | ------ | ------------- |
| depth | number | Object depth. |

* Return
  * true: Object depth setting successful.
  * false: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
figure.setDepth(200.0);
```

{% endtab %}
{% endtabs %}

### setHeight(height) → boolean

> Sets the height (Y-axis direction size) of the object.

{% tabs %}
{% tab title="Information" %}

| Name   | Type   | Description    |
| ------ | ------ | -------------- |
| height | number | Object height. |

* Return
  * true: Object height setting successful.
  * false: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
figure.setHeight(100.0);
```

{% endtab %}
{% endtabs %}

### setWidth(width) → boolean

> Sets the width (X-axis direction size) of the object.

{% tabs %}
{% tab title="Information" %}

| Name  | Type   | Description   |
| ----- | ------ | ------------- |
| width | number | Object width. |

* Return
  * true: Object width setting successful.
  * false: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
figure.setWidth(130.0);
```

{% endtab %}
{% endtabs %}

### setPosition(position) → boolean

> Sets the bottom center position of the object.

{% tabs %}
{% tab title="Information" %}

| Name     | Type                                                                                        | Description                                                                                     |
| -------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| position | [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d) | Figure location (based on the bottom center point) coordinates (longitude, latitude, altitude). |

* Return
  * true: Setting successful.
  * false: Setting failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vPos = new Module.JSVector3D("127.0273188", "37.4977981", "30.0");
figure.setPosition(vPos);
```

{% endtab %}
{% endtabs %}

### setSize(width, height, depth) → boolean

> Sets the size of the object.

{% tabs %}
{% tab title="Information" %}

| Name   | Type   | Description                                   |
| ------ | ------ | --------------------------------------------- |
| width  | number | Object width (size in the x-axis direction).  |
| height | number | Object height (size in the y-axis direction). |
| depth  | number | Object depth (size in the z-axis direction).  |

* Return
  * true: Object size setting successful.
  * false: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
figure.setSize(50.0, 100.0, 150.0);
```

{% endtab %}
{% endtabs %}

## Getter / Setter

### getDescription(), setDescription(desc) → string

> Set a description for the object.

{% tabs %}
{% tab title="Information" %}

| Name | Type   | Description                |
| ---- | ------ | -------------------------- |
| desc | string | Object description string. |

* Return
  * string: Successful return of the object's description string.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var strDesc = object.getDescription();
// ... or ...
object.setDescription("First Object.");
```

{% endtab %}
{% endtabs %}

### getName(), setName(name) → string

> Sets the name of the object.

{% tabs %}
{% tab title="Information" %}

| Name | Type   | Description                     |
| ---- | ------ | ------------------------------- |
| name | string | The name to set for the object. |

* Return
  * string: Successful return of the object's name.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var objName = object.getName();
// ... or ...
object.setName("MyObject");
```

{% endtab %}
{% endtabs %}

### getStyle(), setStyle(style) → [JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle)

> Changes the object style with options applied in [JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle).
>
> Currently settable styles (subject to updates - refer to [JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle))

{% tabs %}
{% tab title="Information" %}

| Name  | Type                                                                                                  | Description  |
| ----- | ----------------------------------------------------------------------------------------------------- | ------------ |
| style | [JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle) | Object style |

* Return
  * Valid object style ([JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle)): Successful return of the object style.
  * Simple initialized state of object style ([JSPolygonStyle](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspolygonstyle)): If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var figure = new Module.JSFigure();
var figureStyle = figure.getStyle();
// ... or ...
var figure = new Module.JSFigure();
var figureStyle = new Module.JSFigureStyle();
//...
figure.setStyle(figureStyle);
```

{% endtab %}
{% endtabs %}

### getVisible(), setVisible(visible) → boolean

> Sets the visibility state of an object.

{% tabs %}
{% tab title="Information" %}

| Name    | Type    | Description                                                      |
| ------- | ------- | ---------------------------------------------------------------- |
| visible | boolean | <p>true: Make the object visible.<br>false: Hide the object.</p> |

* Return
  * true: Object visible state.
  * false: Object hidden state.
    {% endtab %}

{% tab title="Template" %}

```javascript
var objName = object.getName();
// ... or ...
object.setVisible(true);
```

{% endtab %}
{% endtabs %}
