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.12 date: 2022/02/17 10:25:16
user: cg
file: ArrowedSpline.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


ArrowedSplines are like infilled splines, with arrowHeads.

copyright

COPYRIGHT (c) 1996 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

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 openAndWaitUntilVisible.

  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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:48:43 GMT