YouTube | Facebook | X(Twitter) | RSS

テキスト エレメントのサイズと位置

2016/9/1 (木)

Dim pTextElement As ITextElement
Set pTextElement = pElement
 
Dim pElementProperties As IElementProperties3
Set pElementProperties = pElement
 
Dim pEnvelope As IEnvelope
Set pEnvelope = New Envelope
 
pElement.QueryBounds pMxDocument.ActiveView.ScreenDisplay, pEnvelope
 
Dim pPoint As IPoint
 
'エレメントのアンカー位置を取得
Select Case pElementProperties.AnchorPoint
    Case esriTopLeftCorner      '左上
        Set pPoint = pEnvelope.LowerLeft
     
    Case esriTopMidPoint        '中央上
        Set pPoint = New Point
        pPoint.X = pEnvelope.XMin + pEnvelope.Width / 2
        pPoint.Y = pEnvelope.YMax
     
    Case esriTopRightCorner     '右上
        Set pPoint = pEnvelope.LowerLeft
     
    Case esriLeftMidPoint       '左中央
        Set pPoint = New Point
        pPoint.X = pEnvelope.XMax
        pPoint.Y = pEnvelope.YMin + pEnvelope.Height / 2
         
    Case esriCenterPoint        '中心
        Dim pArea As IArea
        Set pArea = pEnvelope
        Set pPoint = pArea.Centroid
         
    Case esriRightMidPoint      '右中央
        Set pPoint = New Point
        pPoint.X = pEnvelope.XMin
        pPoint.Y = pEnvelope.YMin + pEnvelope.Height / 2
         
    Case esriBottomLeftCorner   '左下
        Set pPoint = pEnvelope.LowerLeft
         
    Case esriBottomMidPoint     '中央下
        Set pPoint = New Point
        pPoint.X = pEnvelope.XMin + pEnvelope.Width / 2
        pPoint.Y = pEnvelope.YMin
         
    Case esriBottomRightCorner  '右下
        Set pPoint = pEnvelope.LowerRight
 
End Select
 
'テキスト シンボルのアンカー配置位置
Dim pTextSymbol As ITextSymbol
Set pTextSymbol = pTextElement.Symbol
 
Debug.Print pTextSymbol.HorizontalAlignment, pTextSymbol.VerticalAlignment
 
pTextSymbol.HorizontalAlignment = esriTHALeft
pTextSymbol.VerticalAlignment = esriTVABottom
 
pTextElement.Symbol = pTextSymbol
 
pMxDocument.ActiveView.Refresh

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,

WINGFIELD since1981をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む