eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ArrowedSpline':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ArrowedSpline


Inheritance:

   Object
   |
   +--Geometric
      |
      +--Spline
         |
         +--ArrowedSpline

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.10 date: 2009/06/06 10:12:15
user: cg
file: ArrowedSpline.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


ArrowedSplines are like infilled splines, with arrowHeads.


Related information:

    Polygon
    LineSegment
    Circle
    EllipticalArc
    Rectangle
    Curve
    Arrow
    Spline
    GraphicsContext
    StrokingWrapper
    FillingWrapper

Instance protocol:

accessing
o  arrowHeadAngle
return the arrowHeads angle, in degrees.
The default is defined in Arrow (150 degrees)

o  arrowHeadAngle: angleInDegrees
set the arrowHeads angle, in degrees.
The default is defined in Arrow (150 degrees)

o  arrowHeadLength
return the arrowHeads length, in pixels.
The default is define in Arrow (8 pixels)

o  arrowHeadLength: pixels
set the arrowHeads length, in pixels.
The default is defined in Arrow (8 pixels)

o  arrowHeadPositions: collectionOfPositions
set the arrowHeads positions. Each collections element gives
theindex of a controlPoint, on which an arrowHead is drawn.
The default is #(<controlPoints size>) i.e. a single arrowHead
on the last controlPoint.
To have arrowHeads on all controlPoints, define arrowHeadPositions
as (1 to:controlPoints size)

displaying
o  arrowPoints
helper: return a collection of arrow-points

o  displayArrowsOn: aGC filled: filled
display the receiver in the graphicsContext, aGC

o  displayFilledOn: aGC
display the receiver in the graphicsContext, aGC

o  displayStrokedOn: aGC
display the receiver in the graphicsContext, aGC

queries
o  computeBounds
return the smallest enclosing rectangle

testing
o  canBeFilled
return true, if the receiver can be drawn as a filled geometric.
Always true here. Notice, that only the arrowHeads are filled.


Examples:


arrowedspline:
  |v a|

  v := View extent:100@100.

  a := ArrowedSpline controlPoints:
              (Array with:(20@20)
                     with:(80@80)
                     with:(20@80)).

  v addComponent:((StrokingWrapper on:a) foregroundColor:Color red).
  v open.
filled arrow:
  |v a|

  v := View extent:100@100.

  a := ArrowedSpline controlPoints:
              (Array with:(20@20)
                     with:(80@80)
                     with:(20@50)
                     with:(90@10)).

  v addComponent:((FillingWrapper on:a) foregroundColor:Color red).
  v open.
more arrowHeads:
  |v a|

  v := View extent:100@100.

  a := ArrowedSpline controlPoints:
              (Array with:(20@20)
                     with:(80@80)
                     with:(20@50)
                     with:(90@10)).
  a arrowHeadPositions:#(1 4).
  v addComponent:((FillingWrapper on:a) foregroundColor:Color red).
  v open.
interactive:
  |v points eventCatcher|

  v := StandardSystemView extent:(450 @ 450).
  v label:'ArrowedSpline Example - (click left/middle)'.

  points := OrderedCollection new.
  v openAndWait.

  eventCatcher := Plug new.
  eventCatcher respondTo:#handlesButtonPress:inView:
                    with:[:butt :view | true].
  eventCatcher respondTo:#buttonPress:x:y:view:
                    with:[:butt :x :y :view | 
                          v paint:(Color white).
                          v fillCircle:(x @ y) radius:3.
                          points add:(x @ y).

                          (butt == 1 or:[butt == #select]) ifFalse:[
                              v paint:(Color white).
                              v fillCircle:(x @ y) radius:3.

                              ((ArrowedSpline controlPoints:points)
                                      arrowHeadPositions:(1 to:points size);
                                      arrowHeadLength:15)
                                      displayStrokedOn:v.

                              points := OrderedCollection new.
                          ]
                         ].

  v delegate:(eventCatcher)


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 21 Jan 2020 06:38:15 GMT