eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Arrow':

Home

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

Class: Arrow


Inheritance:

   Object
   |
   +--Geometric
      |
      +--LineSegment
         |
         +--Arrow

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.30 date: 2016/12/23 06:32:36
user: cg
file: Arrow.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


Arrows are just what the name says - a directed LineSegment, which
draws itself with an arrowHead. The position of the arrowhead can
be set to be anywhere along the lineSegment (default is at the end).

Arrows can be drawn stroked or filled - when filled, only the arrowHead
is filled.


Related information:

    Rectangle
    Polygon
    EllipticalArc
    Circle
    Spline
    Curve
    Point
    LineSegment
    ArrowedSpline
    GraphicsContext
    StrokingWrapper
    FillingWrapper

Class protocol:

accessing-defaults
o  defaultAngle

o  defaultLength

displaying
o  arrowPointsFor: sP and: eP position: arrowHeadPosition length: arrowHeadLength angle: arrowHeadAngle
return the arrowPoints for an arrow from sP to eP in a collection

o  arrowPointsFor: sP and: eP position: arrowHeadPosition offset: arrowHeadOffset length: arrowHeadLength angle: arrowHeadAngle
return the arrowPoints for an arrow from sP to eP as a collection of points (for a polygon-fill)

initialization
o  initialize
Arrow initialize


Instance protocol:

accessing
o  arrowHeadAngle
return the arrowHeads angle, in degrees.
The default is 150 degrees

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

o  arrowHeadClosed
return the arrowHeadClosed flag; if true, the arrowHead is drawn
as a closed polygon; if false (the default), the arrowHead is drawn open.
This only affects non-filled drawing.

o  arrowHeadClosed: aBoolean
set the arrowHeadClosed flag; if true, the arrowHead is drawn
as a closed polygon; if false (the default), the arrowHead is drawn open.
This only affects non-filled drawing.

o  arrowHeadLength
return the arrowHeads length, in pixels.
The default is 8 pixels

o  arrowHeadLength: pixels
set the arrowHeads length, in pixels.
The default is 8 pixels

o  arrowHeadPosition
return the arrowHeads position, as a fraction of the overall length;
0 is at the beginning, 1 is at the end, 0.5 is in the center.

o  arrowHeadPosition: aFractionOfTheLinesLength
set the arrowHeads position, as a fraction of the overall length;
0 is at the beginning, 1 is at the end, 0.5 is in the center.

displaying
o  arrowPointsFor: sP and: eP

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

o  displayOn: aGC filled: filled
display the receiver's arrow 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 Arrows only fill the arrowHeads.


Examples:


low level use:
  |v a|

  v := (View extent:100@100) openAndWait.

  a := Arrow from:10@10 to:90@90. 

  v paint:Color red.
  a displayStrokedOn:v.

  a start:90@10 end:10@90.
  v paint:Color blue.
  a displayStrokedOn:v.
with closed arrowHead:
  |v a|

  v := (View extent:100@100) openAndWait.

  a := Arrow from:10@10 to:90@90. 
  a arrowHeadClosed:true.
  v paint:Color red.
  a displayStrokedOn:v.

  a start:90@10 end:10@90.
  v paint:Color blue.
  a displayStrokedOn:v.
with longer closed arrowHead:
  |v a|

  v := (View extent:100@100) openAndWait.

  a := Arrow from:10@10 to:90@90. 
  a arrowHeadClosed:true.
  a arrowHeadLength:16.
  v paint:Color red.
  a displayStrokedOn:v.

  a start:90@10 end:10@90.
  v paint:Color blue.
  a displayStrokedOn:v.
as component (automatic redraw):
  |v a|

  v := View extent:100@100.

  a := Arrow from:50@50 to:10@10. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:50@50 to:90@10. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:50@50 to:10@90. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:50@50 to:90@90. 
  v addComponent:(StrokingWrapper on:a).

  v open
as component filled vs. stroked:
  |v a|

  v := View extent:100@100.

  a := Arrow from:10@10 to:90@10. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:90@20 to:10@20. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@50 to:90@50. 
  v addComponent:(FillingWrapper on:a).

  a := Arrow from:90@60 to:10@60. 
  v addComponent:(FillingWrapper on:a).

  v open
as component (varying lineStyles):
  |v a|

  v := View extent:100@100.

  a := Arrow from:10@10 to:90@90. 
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@10 to:90@10.
  a arrowHeadPosition:0.5.
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:90@10 to:10@90. 
  v addComponent:((StrokingWrapper on:a) foregroundColor:(Color red)).

  a := Arrow from:10@50 to:90@50. 
  a arrowHeadLength:20; arrowHeadAngle:130.

  v addComponent:((StrokingWrapper on:a) 
                      lineWidth:5;
                      foregroundColor:(Color red)).

  a := Arrow from:50@90 to:50@10. 
  a arrowHeadLength:10; arrowHeadAngle:170.

  v addComponent:((StrokingWrapper on:a) 
                      lineWidth:2;
                      lineStyle:#dashed;
                      foregroundColor:(Color red);
                      backgroundColor:(Color yellow)).

  v open.
varying the position:
  |v a|

  v := View extent:200@100.

  a := Arrow from:10@10 to:90@10. 
  a arrowHeadPosition:0.
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@30 to:90@30. 
  a arrowHeadPosition:(1/3).
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@40 to:90@40. 
  a arrowHeadPosition:0.5.
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@50 to:90@50. 
  a arrowHeadPosition:(2/3).
  v addComponent:(StrokingWrapper on:a).

  a := Arrow from:10@70 to:90@70. 
  v addComponent:(StrokingWrapper on:a).


  a := Arrow from:100@10 to:150@90.
  a arrowHeadPosition:(1/3).
  v addComponent:(FillingWrapper on:a).

  a := Arrow from:110@10 to:160@90.
  a arrowHeadPosition:(2/3).
  v addComponent:(FillingWrapper on:a).

  a := Arrow from:120@10 to:170@90.
  v addComponent:(FillingWrapper on:a).

  v open.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 23 Apr 2024 09:53:39 GMT