skyline移动端创建一个文本标签

这个例子演示了如何创建一个标签,一个文本标签样式在地形上的特定位置。这个例子使用 IPosition701 (Copy, Pitch), ILabelStyle701 (FontName, Italic, BackgroundColor, Scale), ITerrainLabel701, ICreator701 (CreatePosition, CreateLabelStyle, CreateTextLabel), IColor701 (FromBGRColor, SetAlpha, 和 INavigate701 (FlyTo) 的属性和方法。

private void CreateTextLabel() {
        UI.runOnRenderThread(new Runnable() {
            @Override
            public void run() {
                try {

                    //
                    // B.  Create position for label
                    //       {
                    // B1. Set position  input parameters (San Fransico shore)
                    double dXCoord = -122.49460;
                    double dYCoord = 37.78816;
                    double dAltitude = 100.0;
                    int eAltitudeTypeCode = 0; //AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                    double dYaw = 0.0;
                    double dPitch = 0.0;
                    double dRoll = 0.0;
                    double dDistance = 500;
                    // B2. Create Position
                    IPosition cPos = ISGWorld.getInstance().getCreator().CreatePosition(dXCoord, dYCoord, dAltitude, eAltitudeTypeCode, dYaw, dPitch, dRoll, dDistance);
                    // }
                    //
                    // C.  Create label style for label
                    //       {
                    // C1. Create label syle
                    ILabelStyle cLabelStyle = ISGWorld.getInstance().getCreator().CreateLabelStyle();
                    // C2. Change label style settings
                    // {
                    int nBGRValue = 0xFF0000;// Blue
                    double dAlpha = 0.5;  // 50% opacity
                    IColor cBackgroundColor = cLabelStyle.getBackgroundColor();
//                 Get label style background color
                    cBackgroundColor.FromABGRColor(nBGRValue); // Set background to blue
                    cBackgroundColor.SetAlpha(dAlpha); //Set transparency to 50%
                    cLabelStyle.setBackgroundColor(cBackgroundColor); // Set label style background color
                    cLabelStyle.setFontName("Arial");                       // Set font name to Arial
                    //cLabelStyle.setItalic(true); // Set label style font to italic  可能Android不支持此属性导致app崩溃
                    cLabelStyle.setScale(3);                                  // Set label style scale
                    // }
                    // }
                    //       // D. Create text label using label style       //
                    //       {
                    // D1. Set label style params
                    String tText = "Skyline";
                    // D2. Create label style
//                    ITerrainLabel cTextLabel = ISGWorld.getInstance().getCreator().CreateTextLabel(cPos, tText, cLabelStyle, "", "TextLabel");
                    ITerrainLabel iTerrainLabel = ISGWorld.getInstance().getCreator().CreateTextLabel(cPos, tText);
                    ITerraExplorerMessage me = ISGWorld.getInstance().getCreator().CreateMessage(5, "hello world", 0, true);
                    iTerrainLabel.getMessage().setMessageID(me.getID());


//            }       //
                    // E. FlyTo text label
                    //       {
                    IPosition cFlyToPos = cPos.Copy();
                    cFlyToPos.setPitch(-89.0); // Set camera to look downward on text label
                    ISGWorld.getInstance().getNavigate().FlyTo(cFlyToPos);

                } catch (Exception e) {
                    Log.e("Tag", e.getMessage());
                }
            }
        });


    }

4.34 ILabelStyle701
一个标签对象,可以包含文字,图片或两者兼而有之。如需更多 TerraExplorer 的标签的信息, 请参阅 TerraExplorer 用户指南。 属性
BackgroundColor 一个 IColor701,表示标签的背景颜色。

Bold 如果这个参数设置为 TRUE,字体样式设置为粗体。

FontName 字体的名称。

FontSize 以像素为单位的字体大小。文本的大小尺寸范围从 8 至 72。

FrameFileName 作为标签边界的框架文件路径名或 URL。

IconColor IColor701 表示在标签中图标图像的颜色。

Italic 如果这个参数设置为 TRUE,字体样式设置为斜体。

LimitScreenSize 如果这个参数设置为 TRUE,标签保持其原始大小。

LineColor IColor701 表示标签的行底色。

LineToGroundLengt h
设置标签延伸到地面线的长度

LineToGroundType 设置标签延伸到地面线的类型

LockMode 确定文本标签位置参数。

MaxImageSize 如果它有一个最大尺寸的图像,则为标签的图像的最大尺寸。

MaxViewingHeight 确定该标签可见的最大高度。

MinViewingHeight 确定该标签可见的最低高度。

MultilineJustificati on
如果有多行文本,确定文本对齐方式。

PivotAlignment 决定了标签相对于其支点对齐。

Scale 决定了标签在每个像素的尺寸。

ShowTextBehavior 决定标签中的文本是一直显示还是鼠标移动到上面的时候显示

SmallestVisibleSiz e
获取和设置最小的字体高度,当离开标签时标签消失。

TextAlignment 决定了有关的背景文本的水平和垂直对齐。

TextColor IColor701 表示文本的颜色。

TextOnImage 获取和设置布尔值,确定文本是否显示在图像上。

Underline 如果是 TRUE,字体样式设置为下划线。4.34 ILabelStyle701
一个标签对象,可以包含文字,图片或两者兼而有之。如需更多 TerraExplorer 的标签的信息, 请参阅 TerraExplorer 用户指南。 属性
BackgroundColor 一个 IColor701,表示标签的背景颜色。

Bold 如果这个参数设置为 TRUE,字体样式设置为粗体。

FontName 字体的名称。

FontSize 以像素为单位的字体大小。文本的大小尺寸范围从 8 至 72。

FrameFileName 作为标签边界的框架文件路径名或 URL。

IconColor IColor701 表示在标签中图标图像的颜色。

Italic 如果这个参数设置为 TRUE,字体样式设置为斜体。

LimitScreenSize 如果这个参数设置为 TRUE,标签保持其原始大小。

LineColor IColor701 表示标签的行底色。

LineToGroundLengt h
设置标签延伸到地面线的长度

LineToGroundType 设置标签延伸到地面线的类型

LockMode 确定文本标签位置参数。

MaxImageSize 如果它有一个最大尺寸的图像,则为标签的图像的最大尺寸。

MaxViewingHeight 确定该标签可见的最大高度。

MinViewingHeight 确定该标签可见的最低高度。

MultilineJustificati on
如果有多行文本,确定文本对齐方式。

PivotAlignment 决定了标签相对于其支点对齐。

Scale 决定了标签在每个像素的尺寸。

ShowTextBehavior 决定标签中的文本是一直显示还是鼠标移动到上面的时候显示

SmallestVisibleSiz e
获取和设置最小的字体高度,当离开标签时标签消失。

TextAlignment 决定了有关的背景文本的水平和垂直对齐。

TextColor IColor701 表示文本的颜色。

TextOnImage 获取和设置布尔值,确定文本是否显示在图像上。

Underline 如果是 TRUE,字体样式设置为下划线。

你可能感兴趣的:(skyline移动端创建一个文本标签)