Arrow.st
author Claus Gittinger <cg@exept.de>
Wed, 12 Feb 1997 13:23:57 +0100
changeset 490 ef43c7a69346
parent 455 9789991dd799
child 728 c7a227ec2897
permissions -rw-r--r--
added dummy Scale & InverseScale classVars. based #bounds on #computeBounds
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
    12
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
LineSegment subclass:#Arrow
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	instanceVariableNames:'arrowHeadPosition arrowHeadLength arrowHeadAngle'
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	classVariableNames:'DefaultLength DefaultAngle'
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	poolDictionaries:''
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	category:'Graphics-Geometry'
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!Arrow class methodsFor:'documentation'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
copyright
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 COPYRIGHT (c) 1996 by Claus Gittinger
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
              All Rights Reserved
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 This software is furnished under a license and may be used
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 hereby transferred.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
documentation
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    Arrows are just what the name says - a directed LineSegment, which
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    draws itself with an arrowHead. The position of the arrowhead can
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    be set to be anywhere along the lineSegement (default is at the end).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    42
    Arrows can be drawn stroked or filled - when filled, only the arrowHead
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    43
    is filled.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    44
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [author:]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        Claus Gittinger
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    [see also:]
320
14e3290c1c0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    49
        Rectangle Polygon EllipticalArc Circle Spline Curve Point 
331
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    50
        LineSegment ArrowedSpline 
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        GraphicsContext
331
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    52
        StrokingWrapper FillingWrapper
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
examples
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
  low level use:
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
                                                                        [exBegin]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    |v a|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    v := (View extent:100@100) openAndWait.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    a := Arrow from:10@10 to:90@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    v paint:Color red.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    a displayStrokedOn:v.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    a start:90@10 end:10@90.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    v paint:Color blue.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    a displayStrokedOn:v.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
                                                                        [exEnd]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
325
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    74
  as component (automatic redraw):
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    75
                                                                        [exBegin]
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    76
    |v a|
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    77
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    78
    v := View extent:100@100.
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    79
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    80
    a := Arrow from:50@50 to:10@10. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    81
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    82
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    83
    a := Arrow from:50@50 to:90@10. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    84
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    85
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    86
    a := Arrow from:50@50 to:10@90. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    87
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    88
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    89
    a := Arrow from:50@50 to:90@90. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    90
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    91
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    92
    v open
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    93
                                                                        [exEnd]
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    94
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    95
  as component filled vs. stroked:
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    96
                                                                        [exBegin]
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    97
    |v a|
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    98
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    99
    v := View extent:100@100.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   100
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   101
    a := Arrow from:10@10 to:90@10. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   102
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   103
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   104
    a := Arrow from:90@20 to:10@20. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   105
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   106
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   107
    a := Arrow from:10@50 to:90@50. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   108
    v addComponent:(FillingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   109
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   110
    a := Arrow from:90@60 to:10@60. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   111
    v addComponent:(FillingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   112
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   113
    v open
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   114
                                                                        [exEnd]
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   115
324
1a318dec0fd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
   116
  as component (varying lineStyles):
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                                                                        [exBegin]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    |v a|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    v := View extent:100@100.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    a := Arrow from:10@10 to:90@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    v addComponent:(StrokingWrapper on:a).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    a := Arrow from:10@10 to:90@10.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    a arrowHeadPosition:0.5.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    v addComponent:(StrokingWrapper on:a).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    a := Arrow from:90@10 to:10@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    v addComponent:((StrokingWrapper on:a) foregroundColor:(Color red)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    a := Arrow from:10@50 to:90@50. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    a arrowHeadLength:20; arrowHeadAngle:130.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    v addComponent:((StrokingWrapper on:a) 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
                        lineWidth:5;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
                        foregroundColor:(Color red)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    a := Arrow from:50@90 to:50@10. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    a arrowHeadLength:10; arrowHeadAngle:170.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    v addComponent:((StrokingWrapper on:a) 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                        lineWidth:2;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                        lineStyle:#dashed;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                        foregroundColor:(Color red);
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                        backgroundColor:(Color yellow)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    v open.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                                                                        [exEnd]
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   150
  varying the position:
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   151
                                                                        [exBegin]
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   152
    |v a|
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   153
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   154
    v := View extent:200@100.
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   155
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   156
    a := Arrow from:10@10 to:90@10. 
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   157
    a arrowHeadPosition:0.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   158
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   159
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   160
    a := Arrow from:10@30 to:90@30. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   161
    a arrowHeadPosition:(1/3).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   162
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   163
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   164
    a := Arrow from:10@40 to:90@40. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   165
    a arrowHeadPosition:0.5.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   166
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   167
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   168
    a := Arrow from:10@50 to:90@50. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   169
    a arrowHeadPosition:(2/3).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   170
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   171
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   172
    a := Arrow from:10@70 to:90@70. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   173
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   174
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   175
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   176
    a := Arrow from:100@10 to:150@90.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   177
    a arrowHeadPosition:(1/3).
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   178
    v addComponent:(FillingWrapper on:a).
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   179
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   180
    a := Arrow from:110@10 to:160@90.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   181
    a arrowHeadPosition:(2/3).
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   182
    v addComponent:(FillingWrapper on:a).
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   183
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   184
    a := Arrow from:120@10 to:170@90.
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   185
    v addComponent:(FillingWrapper on:a).
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   186
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   187
    v open.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   188
                                                                        [exEnd]
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
!Arrow class methodsFor:'initialization'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
initialize
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    DefaultAngle := 150.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    DefaultLength := 8
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
     Arrow initialize
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   203
!Arrow class methodsFor:'accessing defaults'!
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   204
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   205
defaultAngle
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   206
    ^ DefaultAngle
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   207
!
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   208
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   209
defaultLength
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   210
    ^ DefaultLength
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   211
! !
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   212
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
!Arrow methodsFor:'accessing'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
arrowHeadAngle
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "return the arrowHeads angle, in degrees.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
     The default is 150 degrees"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    arrowHeadAngle isNil ifTrue:[^ DefaultAngle].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    ^ arrowHeadAngle
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    "Modified: 12.5.1996 / 22:48:29 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "Created: 12.5.1996 / 22:56:36 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
arrowHeadAngle:angleInDegrees
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "set the arrowHeads angle, in degrees.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
     The default is 150 degrees"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    arrowHeadAngle := angleInDegrees
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    "Modified: 12.5.1996 / 22:48:29 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    "Created: 12.5.1996 / 22:57:47 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
arrowHeadLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "return the arrowHeads length, in pixels.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
     The default is 8 pixels"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    arrowHeadPosition isNil ifTrue:[^ DefaultLength].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    ^ arrowHeadLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    "Created: 12.5.1996 / 22:47:32 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "Modified: 12.5.1996 / 22:57:27 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
arrowHeadLength:pixels
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    "set the arrowHeads length, in pixels.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
     The default is 8 pixels"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    arrowHeadLength := pixels
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    "Created: 12.5.1996 / 22:47:48 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    "Modified: 12.5.1996 / 23:01:20 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
arrowHeadPosition
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    "return the arrowHeads position, as a fraction of the overall length;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
     0 is at the beginning, 1 is at the end, 0.5 is in the center."
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    arrowHeadPosition isNil ifTrue:[^ 1].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    ^ arrowHeadPosition
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    "Created: 12.5.1996 / 22:46:21 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "Modified: 12.5.1996 / 22:57:55 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
arrowHeadPosition:aFractionOfTheLinesLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    "set the arrowHeads position, as a fraction of the overall length;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
     0 is at the beginning, 1 is at the end, 0.5 is in the center."
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    arrowHeadPosition := aFractionOfTheLinesLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    "Created: 12.5.1996 / 22:46:54 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    "Modified: 12.5.1996 / 23:01:09 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
!Arrow methodsFor:'displaying'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   280
arrowPoints
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   281
    "return the arrowPoints in a collection"
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   283
    |arrowHeadPoint len pos angle point grad x1 y1 x2 y2
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   284
     savedLineStyle atn p1 p2 deriv dX dY|
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    arrowHeadPosition isNil ifTrue:[
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   287
        pos := 1
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    ] ifFalse:[
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   289
        pos := arrowHeadPosition max:0.0001.
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    ].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   292
    arrowHeadPoint := startPoint + ((endPoint - startPoint) * pos).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   293
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    len := arrowHeadLength.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    len isNil ifTrue:[
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
        len := DefaultLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    ].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    angle := arrowHeadAngle.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    angle isNil ifTrue:[
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
        angle := DefaultAngle
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    ].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    angle := angle degreesToRadians.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   305
    deriv := arrowHeadPoint - startPoint.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   306
    dX := deriv x.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   307
    dY := deriv y.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   308
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   309
    dX = 0 ifTrue: [
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   310
        grad := 99999999.9
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   311
    ] ifFalse: [
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   312
        grad := dY / dX
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   313
    ].
322
38c88d4b3976 avoid calling arcTan too often
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   314
38c88d4b3976 avoid calling arcTan too often
Claus Gittinger <cg@exept.de>
parents: 321
diff changeset
   315
    atn := grad arcTan.
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   316
    x1 := len * (angle - atn) cos.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   317
    y1 := len * (angle - atn) sin.
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   319
    x2 := len * (angle + atn) cos.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   320
    y2 := len * (angle + atn) sin.
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   322
    dX = 0 ifTrue:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   323
        dY > 0 ifTrue:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   324
            p1 := (dX + x1) @ (dY - y1).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   325
            p2 := (dX + x2) @ (dY + y2).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   326
        ] ifFalse:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   327
            p1 := (dX - x1) @ (dY + y1).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   328
            p2 := (dX - x2) @ (dY - y2).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   329
        ]
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   330
    ] ifFalse:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   331
        dX > 0 ifTrue:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   332
            p1 := (dX + x1) @ (dY - y1).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   333
            p2 := (dX + x2) @ (dY + y2).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   334
        ] ifFalse:[
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   335
            p1 := (dX - x1) @ (dY + y1).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   336
            p2 := (dX - x2) @ (dY - y2).
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   337
        ]
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   338
    ].
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
333
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   340
    p1 := startPoint + p1.
785f0e48fdb8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   341
    p2 := startPoint + p2.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   342
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   343
    ^ Array with:p1 with:arrowHeadPoint with:p2.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   344
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   345
    "Created: 12.5.1996 / 23:54:35 / cg"
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   346
    "Modified: 13.5.1996 / 20:55:51 / cg"
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   347
!
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   348
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   349
displayFilledOn:aGC
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   350
    "display the receiver in the graphicsContext, aGC"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   351
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   352
    self displayOn:aGC filled:true
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   353
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   354
    "Created: 12.5.1996 / 23:58:42 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   355
    "Modified: 4.6.1996 / 18:25:11 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   356
!
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   357
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   358
displayOn:aGC filled:filled
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   359
    "display the receivers arrow in the graphicsContext, aGC"
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   360
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   361
    |arrowHeadPoint savedLineStyle p1 p2 points middle oldCap|
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   362
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   363
    savedLineStyle := aGC lineStyle.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   364
    aGC lineStyle:#solid.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   365
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   366
    points := self arrowPoints.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   367
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   368
    p1 := points at:1.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   369
    arrowHeadPoint := points at:2.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   370
    p2 := points at:3.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   371
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   372
    filled ifFalse:[
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   373
        aGC displayLineFrom:startPoint to:endPoint.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   374
        aGC displayLineFrom:arrowHeadPoint to:p1.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   375
        aGC displayLineFrom:arrowHeadPoint to:p2.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   376
    ] ifTrue:[
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   377
        middle := (p1 + p2 / 2) rounded.
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   378
        oldCap := aGC capStyle.
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   379
        aGC capStyle:#notLast.
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   380
        aGC displayLineFrom:startPoint to:middle.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   381
        aGC fillPolygon:(Array with:p1 with:arrowHeadPoint with:p2).
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   382
        aGC capStyle:oldCap.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   383
    ].
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    aGC lineStyle:savedLineStyle.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
     |v|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
     v := View new openAndWait.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
     (Arrow from:10@10 to:50@50) displayStrokedOn:v
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   395
    "Modified: 4.6.1996 / 18:24:53 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   396
    "Created: 4.6.1996 / 18:25:15 / cg"
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   397
!
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   398
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   399
displayStrokedOn:aGC
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   400
    "display the receiver in the graphicsContext, aGC"
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   401
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   402
    self displayOn:aGC filled:false
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   403
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   404
    "Modified: 4.6.1996 / 18:25:07 / cg"
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   407
!Arrow methodsFor:'queries'!
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   408
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   409
canBeFilled
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   410
    "return true, if the receiver can be drawn as a filled geometric.
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   411
     Always true here. Notice, that Arrows only fill the arrowHeads."
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   412
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   413
    ^ true
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   414
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   415
!
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   416
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   417
computeBounds
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   418
    "return the smallest enclosing rectangle"
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   419
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   420
    |x y minX maxX minY maxY|
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   421
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   422
    minX := maxX := startPoint x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   423
    x := endPoint x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   424
    minX := minX min:x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   425
    maxX := maxX max:x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   426
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   427
    minY := maxY := startPoint y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   428
    y := endPoint y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   429
    minY := minY min:y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   430
    maxY := maxY max:y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   431
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   432
    self arrowPoints do:[:p |
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   433
        |x y|
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   434
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   435
        x := p x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   436
        y := p y.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   437
        minX := minX min:x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   438
        maxX := maxX max:x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   439
        minY := minY min:y.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   440
        maxY := maxY max:y.
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   441
    ].    
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   442
    ^ Rectangle left:minX right:maxX top:minY bottom:maxY
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   443
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   444
    "
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   445
     (Arrow from:(10@10) to:(90@90)) bounds 
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   446
     (Arrow from:(10@10) to:(10@90)) bounds  
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   447
    "
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   448
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   449
    "Modified: 26.5.1996 / 16:31:39 / cg"
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   450
    "Created: 12.2.1997 / 11:42:22 / cg"
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   451
! !
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   452
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
!Arrow class methodsFor:'documentation'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
version
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   456
    ^ '$Header: /cvs/stx/stx/libbasic2/Arrow.st,v 1.18 1997-02-12 12:23:19 cg Exp $'
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
Arrow initialize!