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.34 date: 2022/02/17 10:26:07
user: cg
file: Arrow.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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.

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.

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  displayFilledOn: aGC
display the receiver in the graphicsContext, aGC

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.

     (Arrow from:10@10 to:50@50) displayFilledOn:v

o  displayOn: aGC filled: filled
display the receiver arrow in the graphicsContext, aGC

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

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.

     (Arrow from:10@10 to:50@50) displayStrokedOn:v

private
o  arrowPointsFor: sP and: eP
compute the position of the arrow along the line segment,
from the specified arrowHeadPosition.

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:120@120) openAndWaitUntilVisible.

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

  v paint:Color red.
  a displayStrokedOn:v.

  a setStart:90@10 end:10@90.
  v paint:Color blue.
  a displayFilledOn:v.
with closed arrowHead:
  |v a|

  v := (View extent:120@120) openAndWaitUntilVisible.

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

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

  v := (View extent:120@120) openAndWaitUntilVisible.

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

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

  v := View extent:120@120.

  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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 10 Oct 2024 10:18:04 GMT