PathShape (クラス)
public PathShape {inherits Shape}
パッケージ: CURL.GUI.SHAPES

Path を描画する Shape の実装です。つまり、線または曲線のセットです。PathShape は、細い線 (既定値) または太い線をレンダリングするために使用されます。

注意事項

このクラスは次の形状オプションを使用します。

この例には、パラメータを指定して、細い矢印を記述する Path を作成するプロシージャが含まれます。このプロシージャは独自の矢印を実装する場合に役立ちます。

例: 細い矢印を作成する PathShape の使用
{import * from CURL.GUI.SHAPES}
{define-proc package {make-arrow-path
                         start:Distance2d,
                         end:Distance2d,
                         head-width:Distance,
                         head-length:Distance
                     }:Path
    let constant length:Distance = (start - end).magnitude
    {if length == 0m then
        {return {Path}}
    }

    let constant head-unit-vec:Direction2d = (end - start) / length
    let constant head-vec:Distance2d = head-unit-vec * head-length
    let constant perpendicular-vec:Distance2d =
        (head-width * {Direction2d -head-unit-vec.y, head-unit-vec.x})
    let constant side-point-right:Distance2d =
        end - head-vec + perpendicular-vec
    let constant side-point-left:Distance2d =
        end - head-vec - perpendicular-vec
    let path:Path =
        {Path
            start,
            PathOperation.line-to,
            end,
            PathOperation.move-to,
            side-point-left,
            PathOperation.line-to,
            end,
            PathOperation.line-to,
            side-point-right
        }
    {return path}
}

{let shape:PathShape =
    {PathShape
        {make-arrow-path
            {Distance2d 1cm, 2cm},
            {Distance2d 3cm, 4cm},
            2.5mm,
            5mm
        }
    }
}

{HBox
    "stroke-thickness: ",
    {TextField
        width = .5in,
        value = "0px",
        {on ValueFinished at field:TextField do
            set shape.stroke-thickness = {evaluate field.value}
        }
    }
}

{value shape}

コンストラクタ
default:新しい PathShape を作成します。
コンストラクタ public {PathShape.default path:Path, ...}

プロパティ
color:この形状とその子の色。
非ローカル オプション public PathShape.color:FillPattern
display-context:このオブジェクトに関連付けられている DisplayContext
非ローカル オプション public PathShape.display-context:#DisplayContext
line-style:Shape の境界線プリミティブをレンダリングするスタイル。
非ローカル オプション public PathShape.line-style:LineStyle
path:このオブジェクトによってレンダリングされる Path です。
アクセサ public final PathShape.path:Path
セッター public final PathShape.path:Path
stroke-thickness:Shape オブジェクト内の線の太さです。
非ローカル オプション public PathShape.stroke-thickness:any
style-element:スタイリングの目的のための、この Visual の "要素" や "型" です。
アクセサ public PathShape.style-element:String
プロパティ 継承 Shape: as-Shape, border-color, draw-operation, option-parent, selection-context, shape-parent, shape-selectable, transformation, visible?
プロパティ 継承 ShapeContainerBase: as-ShapeRoot, shape-children
プロパティ 継承 Visual: _style-element, clonable-class?, completely-clonable-children?, cursor, data-source, dragee, font-size, input-method-enabled?, input-method-keyboard-mode, name, options, options-present-here, style-class, style-manager, style-options, test-description, test-name, test-parent?, test-type-name, test-visible?, tooltip, user-data
プロパティ 継承 DataBindingTarget: data-binding-context, data-bindings
プロパティ 継承 EventTarget: event-handlers
プロパティ 継承 OptionListInterface: option-register-proc, registered-option-keys

メソッド
draw:このオブジェクトの可視表現を描画します。
public {PathShape.draw renderer2d:Renderer2d}:void
get-own-bounds:ローカル座標系におけるこの Shape の四角形のレンダリング境界を計算します。
public {PathShape.get-own-bounds dest:GRect = {GRect.empty}}:GRect
get-own-layout-bounds:ローカル座標系におけるこの Shape の四角形のレイアウト境界を計算します。
public {PathShape.get-own-layout-bounds
lc:LayoutContext,
width-first?:bool = true,
dest:GRect = {GRect.empty}
}:GRect
overdraw-for-selection:このオブジェクトの上に選択アフォーダンスを描画します。
public {PathShape.overdraw-for-selection}:void
self-contains-point?:ポイントがこの Shape 内にあるかどうかを判定します。
public {PathShape.self-contains-point? x:Distance, y:Distance}:bool
self-intersects-polygon?:ポリゴンがこの Shape と交差するかどうかを判定します。
public {PathShape.self-intersects-polygon?}:bool
transformation-changed:Shape.transformation が変更されたことの通知。
public {PathShape.transformation-changed}:void
メソッド 継承 Shape: apply-rotation, apply-scale, apply-transformation, apply-translation, apply-translation-in-parent, constrain-own-layout-bounds, constrain-shape-layout-bounds, contains-point?, detach, find-graphical-ancestor, fire-crossing-event, fire-in-child, get-display-context, get-down-orientation-in-shape-parent, get-graphical-root, get-local-device-pixel-size, get-origin-in-graphical-ancestor, get-origin-in-root, get-origin-in-shape-parent, get-origin-in-shape-root, get-own-bounds-in-shape-root, get-right-orientation-in-shape-parent, get-shape-bounds, get-shape-bounds-in-shape-root, get-shape-layout-bounds, get-top-left-in-ancestor, get-transformation-to-shape-root, keyword-init-arg, option-change-notify, quantize-line-thickness, request-draw, request-draw-self, reset-transformation, set-rotation, set-scale, set-transformation, set-translation-in-parent, to-Graphic, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-point-from-shape-root, transform-point-to-shape-root, transform-to-display-coordinates, transform-to-graphical-root-coordinates, transform-vector-from-shape-root, transform-vector-to-shape-root, transformation-changing
メソッド 継承 ShapeContainerBase: add, clear, draw-shape-child, draw-shape-children, get-all-children-at-point, get-child-at-point, get-leaf-at-point, get-shape-root, note-attached, note-detaching, notify-option-children, on-drag-enter, on-pointer-enter, on-pointer-envelope-event, register-options, remove, set-shape-index, set-shape-index-after, set-shape-index-before, shape-container-fire-inferior-crossing-event, shape-container-handle-crossing, shape-container-pick-child, shape-container-pointer-enter-occurred, shape-container-pointer-leave-occurred
メソッド 継承 Visual: add-from-init-args, add-option, add-style-option, animate, change-cursor, clonable-appearance?, clone-appearance, clone-appearance-helper, find-test-children, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-text, get-view, maybe-fire-attach-event, maybe-fire-detach-event, non-keyword-init-arg, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, release-key-focus, remove-option, remove-style-option, request-key-focus, scroll-to-include, test-record, test-run, xy-offset-to
メソッド 継承 GraphicOptions: any-to-Distance
メソッド 継承 GuiEventTarget: handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-in, on-focus-out, on-grab-release, on-gui-event, on-input-method-event, on-inspection, on-key-event, on-key-press, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-press, on-pointer-release, on-pointer-scroll, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class
メソッド 継承 DataBindingTarget: add-data-binding, get-data-binding, refresh-data-binding, remove-data-binding, unset-property, update-data-binding, validate-data-binding
メソッド 継承 EventTarget: accepts-event-class?, add-event-handler, event-handler-present?, remove-event-handler, verify-event
メソッド 継承 OptionListInterface: change-option-parent-notify, clone-options, get-option, get-option-by-name, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-changed, option-lookup, option-lookup-here, option-propagate-notify, option-set?, propagate-option-change, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name
メソッド 継承 BasicEventTarget: enqueue-event
メソッド 継承 InitRestArgParser: process-rest-args
メソッド 継承 Object: object-describe, object-describe-for-debugging, object-serialize



コンストラクタ詳細
default (コンストラクタ)
public {PathShape.default path:Path, ...}

新しい PathShape を作成します。

path: 表示される Path
...: 通常の Shape の作成引数を渡せます。たとえば、イニシャライザ、変換、子 Shape などです。詳細については、Shape.default を参照してください。

注意事項

path は格納されますが、PathShape に渡されると変更できなくなります。代わりに、新しいパスを PathShape.path に割り当ててください。



プロパティ詳細
color (非ローカル オプション)
public PathShape.color:FillPattern

この形状とその子の色。

説明

形状を塗りつぶさない場合は、このオプションを FillPattern.transparent に設定できます。通常、この設定は、Shape.self-contains-point? の結果または形状に渡されるマウス イベントには影響を与えません。

注意事項

すべての形状オブジェクトにこのオプションがあり、継承されるか、またはオブジェクトに直接設定されます。
形状オブジェクトによっては、このプロパティを直接使用しないものがあります。たとえば、ShapeGroup はこのプロパティを使用しません。しかし、ShapeGroup オブジェクトにこのようなプロパティを設定すると、形状オブジェクトのすべての子が既定でプロパティを継承するので便利です。


display-context (非ローカル オプション)
public PathShape.display-context:#DisplayContext

このオブジェクトに関連付けられている DisplayContext

プログラミング注意事項

このオプションは、Curl グラフィック システム内での通信のために使用されます。これは、ユーザー コードで不用意に設定や設定解除を行わないでください。また、通常は、ユーザー コードで直接読み取るべきではありません。現在の DisplayContext が必要な場合は、Visual.get-display-context を呼び出すことによりフェッチしてください。

画面上のウィンドウまたは印刷されたページで表示可能なすべてのグラフィック階層は、そのルートにおいて、display-context オプションを DisplayContext オブジェクトに設定するオブジェクトを持つ必要があります。このオブジェクトは、グラフィック階層の表示に使用される表示媒体に適しています。つまり、オブジェクトは、display-context オプションの値が null から非 null DisplayContext オブジェクトに変更されるのをモニタリングすることにより、表示不可能なグラフィック階層に連結されていることを認識します。したがって、特定の動作を実行する必要のある Visual のサブクラスは、表示不可能なグラフィック階層に接続された場合、次のようなオプション宣言を含むことにより display-context オプションをモニタリングします。

{nonlocal-option public display-context:#DisplayContext
change handler}


ここで、change handler 内のコードは display-context オプションの現在値 (変数 display-context の値として、変更ハンドラ内にある) を取得し、null および非 null の値の間で行われる変更をモニタリングし、必要とされる動作を実行します。

ただし、このプログラミング熟語を使用するプログラマーは、グラフィカル表示を再配列する際、グラフィック階層からグラフィカル オブジェクトを一時的に分離し、これらを同じ階層に再アタッチすることが、割に一般的であることを理解するべきです。この処理により、一時的に分離されたオブジェクトは、display-context オブジェクトが null になり、再び非 null になるのを観察します。display-context オプションでの変更をモニタリングするコードは、この可能性を考慮に入れ、この状況における望ましくない動作の実行を回避しなくてはなりません。


line-style (非ローカル オプション)
public PathShape.line-style:LineStyle

Shape の境界線プリミティブをレンダリングするスタイル。

説明

このオプションは PathShape に適用されます。このオプションは境界には適用されません。 EllipseShape などのいくつかのクラスには、EllipseShape.border-line-style などの境界用のローカル オプションがあります。
詳細については、LineStyle を参照してください。

注意事項

すべての形状オブジェクトにこのオプションがあり、継承されるか、またはオブジェクトに直接設定されます。
形状オブジェクトによっては、このプロパティを直接使用しないものがあります。たとえば、ShapeGroup はこのプロパティを使用しません。しかし、ShapeGroup オブジェクトにこのようなプロパティを設定すると、形状オブジェクトのすべての子が既定でプロパティを継承するので便利です。


path (アクセサ)
アクセサ public final PathShape.path:Path
セッター public final PathShape.path:Path

このオブジェクトによってレンダリングされる Path です。

注意事項

path は格納されますが、PathShape に渡されると変更できなくなります。代わりに、新しいパスを PathShape.path に割り当ててください。


stroke-thickness (非ローカル オプション)
public PathShape.stroke-thickness:any

Shape オブジェクト内の線の太さです。

説明

stroke-thickness を参照してください。


style-element (アクセサ)
アクセサ public PathShape.style-element:String

スタイリングの目的のための、この Visual の "要素" や "型" です。

説明

この実装によって Visual._style-elementの値が返されますが、通常は定数を返すためにオーバーライドされます。

オーバーライド

Visual のサブクラスのスタイルが他のオブジェクトと異なる場合、このゲッターは適切な文字列を返すようにオーバーライドされる必要があります。 慣例では,この文字列はクラス名または、オブジェクトを生成するマークアップの名前です。
オーバーライドでは、空の文字列でないかぎり、self._style-elementを返さなければなりません。
導入: バージョン 6.0





メソッド詳細
draw (メソッド)
public {PathShape.draw renderer2d:Renderer2d}:void

このオブジェクトの可視表現を描画します。

renderer2d: このオブジェクトを使用してそれ自身を描画する Renderer2d

オーバーライド

Shape をサブクラス化する場合は、このメソッドをオーバーライドする必要があります。


get-own-bounds (メソッド)
public {PathShape.get-own-bounds dest:GRect = {GRect.empty}}:GRect

ローカル座標系におけるこの Shape の四角形のレンダリング境界を計算します。

dest: データを返すために使用されるオプションの GRect オブジェクト。

戻り値

境界を含む GRect オブジェクト。これは、常に dest と同じオブジェクトになります。この GRect は正しい形式である必要があります。つまり、次の条件が true でなければなりません。 -dest.lextent <= dest.rextent and -dest.ascent <= dest.descent

説明

返された境界は、このオブジェクトによって描画されるすべてのピクセルをカバーしている必要があります。ただし、このオブジェクトのすべての子を含んでいません

注意事項

レンダリング境界 (get-own-bounds) とレイアウト境界 (get-own-layout-bounds) は、通常似ていますが、同じではありません。特に、レンダリング境界は非常に包括的ですが、レイアウト境界はそれぞれが整然と隣接するため、Shape を厳密に記述しなければならなりません。

オーバーライド

Shape をサブクラス化する場合は、このメソッドをオーバーライドする必要があります。データを返すには、dest パラメータを使用する必要があります。


get-own-layout-bounds (メソッド)
public {PathShape.get-own-layout-bounds
lc:LayoutContext,
width-first?:bool = true,
dest:GRect = {GRect.empty}
}:GRect

ローカル座標系におけるこの Shape の四角形のレイアウト境界を計算します。

lc: このレイアウト ネゴシエーションで有効な LayoutContext
width-first?: GraphicShape の場合、width-first レイアウト ネゴシエーションを使用して計算されるべき境界であるかを示します。このパラメータは、通常他のサブクラスでは使用されません。
dest: データを返すために使用されるオプションの GRect オブジェクト。

戻り値

境界を含む GRect オブジェクト。これは、常に dest と同じオブジェクトになります。この GRect は正しい形式である必要があります。つまり、次の条件が true でなければなりません。 -dest.lextent <= dest.rextent and -dest.ascent <= dest.descent

説明

返された境界には、レイアウトの使用について、オブジェクトに関する詳細な記述があります。ただし、このオブジェクトのすべての子は含まれていません

注意事項

レンダリング境界 (get-own-bounds) とレイアウト境界 (get-own-layout-bounds) は、通常似ていますが、同じではありません。特に、レンダリング境界は非常に包括的ですが、レイアウト境界はそれぞれが整然と隣接するため、Shape を厳密に記述しなければならなりません。

オーバーライド

既定の実装では、get-own-bounds を呼び出すだけです。データを返すには、dest パラメータを使用する必要があります。


overdraw-for-selection (メソッド)
public {PathShape.overdraw-for-selection}:void

このオブジェクトの上に選択アフォーダンスを描画します。

説明

このメソッドは、内部の形状描画メカニズムにより呼び出されます。通常は、直接呼び出す必要はありません。

オーバーライド

このメソッドの既定の実装では、オブジェクトの境界を Shape.get-own-bounds によって返されるものとみなしています。draw-styleinvert の場合は、DrawOperation.invert-destination を使用して四角形をレンダリングします。mask の場合は、Renderer2d.render-stippled-rectangle が使用されます。
Shape の実装でこのメソッドをオーバーライドする必要はありませんが、形状のレンダリングされたプリミティブの真上に選択アフォーダンスを描画したほうが選択が見やすくなる場合があります。


self-contains-point? (メソッド)
public {PathShape.self-contains-point? x:Distance, y:Distance}:bool

ポイントがこの Shape 内にあるかどうかを判定します。

x: 点の X 座標。
y: 点の Y 座標。

戻り値

この Shape が (xy) を含む場合は、true

説明

ポイントは、このオブジェクトのローカル座標系にあります。このメソッドは、その子を考慮しません。

オーバーライド

Shape をサブクラス化する場合は、このメソッドをオーバーライドする必要があります。このメソッドは、PointerMotion などのマウス イベントをこのオブジェクトにいつ送信するかなどを決定します。
通常は、このメソッドを実装して、ポイントが形状の境界内にあるかどうかだけでなく、ポイントが形状のレンダリングされたプリミティブ内にあるどうかを確認する必要があります。このメソッドは必要なメトリックを使用して自在に実装できます。


self-intersects-polygon? (メソッド)
public {PathShape.self-intersects-polygon?}:bool

ポリゴンがこの Shape と交差するかどうかを判定します。

polygon: この形状のローカル座標空間にポリゴンを記述するポイント セットを含むオブジェクト。このポリゴンは必ず凸型であり、反時計回りのワインディング順に従います。

説明

このメソッドは、ポイントではなく領域を処理する点を除けば、Shape.self-contains-point? とよく似ています。主に領域ベースの選択をサポートするために使用されますが、直接呼び出すこともできます。

オーバーライド

Shape をサブクラス化する場合は、このメソッドをオーバーライドする必要があります。子を考慮する必要はありません。
通常は、このメソッドを実装して、領域が形状の境界内にあるかどうかだけでなく、領域が形状のレンダリングされたプリミティブと交差するかどうかを確認する必要があります。このメソッドは、必要なメトリックを使用して自在に実装できます。このメソッドの実装が Shape.self-contains-point? と調和しない場合は、このオブジェクトを選択すると予期しない結果になります。
選択機能を使用しない場合は、このメソッドを単純に false を返すように実装できます。


transformation-changed (メソッド)
public {PathShape.transformation-changed}:void

Shape.transformation が変更されたことの通知。

オーバーライド

重要:このメソッドのオーバーライド実装にスーパークラス実装の呼び出しを含めて、オブジェクトの新しい領域を無効にする必要があります。