|
Class: Arrow
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
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.
copyrightCOPYRIGHT (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.
accessing-defaults
-
defaultAngle
-
-
defaultLength
-
displaying
-
arrowPointsFor: sP and: eP position: arrowHeadPosition length: arrowHeadLength angle: arrowHeadAngle
-
return the arrowPoints for an arrow from sP to eP in a collection
-
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
-
initialize
-
Arrow initialize
accessing
-
arrowHeadAngle
-
return the arrowHeads angle, in degrees.
The default is 150 degrees
-
arrowHeadAngle: angleInDegrees
-
set the arrowHeads angle, in degrees.
The default is 150 degrees
-
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.
-
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.
-
arrowHeadLength
-
return the arrowHeads length, in pixels.
The default is 8 pixels
-
arrowHeadLength: pixels
-
set the arrowHeads length, in pixels.
The default is 8 pixels
-
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.
-
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
-
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
|
-
displayOn: aGC filled: filled
-
display the receiver arrow in the graphicsContext, aGC
-
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
-
arrowPointsFor: sP and: eP
-
compute the position of the arrow along the line segment,
from the specified arrowHeadPosition.
queries
-
computeBounds
-
return the smallest enclosing rectangle
testing
-
canBeFilled
-
return true, if the receiver can be drawn as a filled geometric.
Always true here. Notice, that Arrows only fill the arrowHeads.
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.
|
|