Arrow.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 4240 8a3ead2b3d72
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:
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
"
979
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
    13
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
    14
"{ NameSpace: Smalltalk }"
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
    15
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
LineSegment subclass:#Arrow
728
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    17
	instanceVariableNames:'arrowHeadPosition arrowHeadLength arrowHeadAngle arrowHeadClosed'
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'DefaultLength DefaultAngle'
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
1303
6ca5f36cdc63 category
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
    20
	category:'Graphics-Geometry-Objects'
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!Arrow class methodsFor:'documentation'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 1996 by Claus Gittinger
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Arrows are just what the name says - a directed LineSegment, which
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    draws itself with an arrowHead. The position of the arrowhead can
4240
8a3ead2b3d72 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3785
diff changeset
    43
    be set to be anywhere along the lineSegment (default is at the end).
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    45
    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
    46
    is filled.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
    47
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    [author:]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        Claus Gittinger
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    [see also:]
320
14e3290c1c0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    52
        Rectangle Polygon EllipticalArc Circle Spline Curve Point 
331
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    53
        LineSegment ArrowedSpline 
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        GraphicsContext
331
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    55
        StrokingWrapper FillingWrapper
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
examples
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
  low level use:
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
                                                                        [exBegin]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    |v a|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    v := (View extent:100@100) openAndWait.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    a := Arrow from:10@10 to:90@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    v paint:Color red.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    a displayStrokedOn:v.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    a start:90@10 end:10@90.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    v paint:Color blue.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    a displayStrokedOn:v.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
                                                                        [exEnd]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
728
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    77
  with closed arrowHead:
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    78
                                                                        [exBegin]
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    79
    |v a|
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    80
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    81
    v := (View extent:100@100) openAndWait.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    82
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    83
    a := Arrow from:10@10 to:90@90. 
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    84
    a arrowHeadClosed:true.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    85
    v paint:Color red.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    86
    a displayStrokedOn:v.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    87
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    88
    a start:90@10 end:10@90.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    89
    v paint:Color blue.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    90
    a displayStrokedOn:v.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    91
                                                                        [exEnd]
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    92
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    93
  with longer closed arrowHead:
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    94
                                                                        [exBegin]
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    95
    |v a|
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    96
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    97
    v := (View extent:100@100) openAndWait.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    98
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
    99
    a := Arrow from:10@10 to:90@90. 
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   100
    a arrowHeadClosed:true.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   101
    a arrowHeadLength:16.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   102
    v paint:Color red.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   103
    a displayStrokedOn:v.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   104
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   105
    a start:90@10 end:10@90.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   106
    v paint:Color blue.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   107
    a displayStrokedOn:v.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   108
                                                                        [exEnd]
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   109
325
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   110
  as component (automatic redraw):
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   111
                                                                        [exBegin]
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   112
    |v a|
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   113
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   114
    v := View extent:100@100.
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   115
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   116
    a := Arrow from:50@50 to:10@10. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   117
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   118
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   119
    a := Arrow from:50@50 to:90@10. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   120
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   121
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   122
    a := Arrow from:50@50 to:10@90. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   123
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   124
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   125
    a := Arrow from:50@50 to:90@90. 
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   126
    v addComponent:(StrokingWrapper on:a).
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   127
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   128
    v open
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   129
                                                                        [exEnd]
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   130
f4835579dc09 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   131
  as component filled vs. stroked:
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   132
                                                                        [exBegin]
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   133
    |v a|
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   134
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   135
    v := View extent:100@100.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   136
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   137
    a := Arrow from:10@10 to:90@10. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   138
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   139
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   140
    a := Arrow from:90@20 to:10@20. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   141
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   142
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   143
    a := Arrow from:10@50 to:90@50. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   144
    v addComponent:(FillingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   145
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   146
    a := Arrow from:90@60 to:10@60. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   147
    v addComponent:(FillingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   148
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   149
    v open
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   150
                                                                        [exEnd]
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   151
324
1a318dec0fd7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
   152
  as component (varying lineStyles):
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
                                                                        [exBegin]
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    |v a|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    v := View extent:100@100.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    a := Arrow from:10@10 to:90@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    v addComponent:(StrokingWrapper on:a).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    a := Arrow from:10@10 to:90@10.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    a arrowHeadPosition:0.5.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    v addComponent:(StrokingWrapper on:a).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    a := Arrow from:90@10 to:10@90. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    v addComponent:((StrokingWrapper on:a) foregroundColor:(Color red)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    a := Arrow from:10@50 to:90@50. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    a arrowHeadLength:20; arrowHeadAngle:130.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    v addComponent:((StrokingWrapper on:a) 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
                        lineWidth:5;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
                        foregroundColor:(Color red)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    a := Arrow from:50@90 to:50@10. 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    a arrowHeadLength:10; arrowHeadAngle:170.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    v addComponent:((StrokingWrapper on:a) 
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
                        lineWidth:2;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
                        lineStyle:#dashed;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
                        foregroundColor:(Color red);
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
                        backgroundColor:(Color yellow)).
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    v open.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
                                                                        [exEnd]
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   186
  varying the position:
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   187
                                                                        [exBegin]
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   188
    |v a|
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   189
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   190
    v := View extent:200@100.
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   191
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   192
    a := Arrow from:10@10 to:90@10. 
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   193
    a arrowHeadPosition:0.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   194
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   195
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   196
    a := Arrow from:10@30 to:90@30. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   197
    a arrowHeadPosition:(1/3).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   198
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   199
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   200
    a := Arrow from:10@40 to:90@40. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   201
    a arrowHeadPosition:0.5.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   202
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   203
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   204
    a := Arrow from:10@50 to:90@50. 
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   205
    a arrowHeadPosition:(2/3).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   206
    v addComponent:(StrokingWrapper on:a).
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   207
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   208
    a := Arrow from:10@70 to:90@70. 
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   209
    v addComponent:(StrokingWrapper on:a).
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   210
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   211
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   212
    a := Arrow from:100@10 to:150@90.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   213
    a arrowHeadPosition:(1/3).
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   214
    v addComponent:(FillingWrapper on:a).
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   215
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   216
    a := Arrow from:110@10 to:160@90.
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   217
    a arrowHeadPosition:(2/3).
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   218
    v addComponent:(FillingWrapper on:a).
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   219
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   220
    a := Arrow from:120@10 to:170@90.
326
2be7d1d78659 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 325
diff changeset
   221
    v addComponent:(FillingWrapper on:a).
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   222
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   223
    v open.
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   224
                                                                        [exEnd]
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!Arrow class methodsFor:'initialization'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
initialize
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    DefaultAngle := 150.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    DefaultLength := 8
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
     Arrow initialize
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
2034
872e9cf15f88 category change
Claus Gittinger <cg@exept.de>
parents: 1930
diff changeset
   239
!Arrow class methodsFor:'accessing-defaults'!
321
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   240
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   241
defaultAngle
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   242
    ^ DefaultAngle
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   243
!
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   244
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   245
defaultLength
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   246
    ^ DefaultLength
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   247
! !
49c7fd30093c kludge for position of 0
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
   248
1930
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   249
!Arrow class methodsFor:'displaying'!
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   250
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   251
arrowPointsFor:sP and:eP position:arrowHeadPosition length:arrowHeadLength angle:arrowHeadAngle
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   252
    "return the arrowPoints for an arrow from sP to eP in a collection"
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   253
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   254
    ^ self
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   255
        arrowPointsFor:sP and:eP 
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   256
        position:arrowHeadPosition offset:nil
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   257
        length:arrowHeadLength angle:arrowHeadAngle
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   258
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   259
    "Modified: / 14-03-2011 / 10:57:13 / cg"
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   260
!
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   261
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   262
arrowPointsFor:sP and:eP position:arrowHeadPosition offset:arrowHeadOffset length:arrowHeadLength angle:arrowHeadAngle
2549
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   263
    "return the arrowPoints for an arrow from sP to eP as a collection of points (for a polygon-fill)"
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   264
1930
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   265
    |arrowHeadPoint len pos angle grad x1 y1 x2 y2
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   266
     atn p1 p2 deriv dX dY|
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   267
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   268
    arrowHeadPosition isNil ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   269
        pos := 1
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   270
    ] ifFalse:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   271
        pos := arrowHeadPosition max:0.0001.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   272
    ].
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   273
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   274
    arrowHeadPoint := sP + ((eP - sP) * pos).
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   275
    arrowHeadOffset notNil ifTrue:[
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   276
        (eP x = sP x) ifTrue:[
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   277
            "/ vertical
2549
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   278
            (eP y > sP y) ifTrue:[
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   279
                arrowHeadPoint := arrowHeadPoint + (0 @ arrowHeadOffset)
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   280
            ] ifFalse:[
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   281
                arrowHeadPoint := arrowHeadPoint - (0 @ arrowHeadOffset)
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   282
            ].
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   283
        ] ifFalse:[
2549
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   284
            (eP y = sP y) ifTrue:[
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   285
                "/ horizontal
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   286
                (eP x > sP x) ifTrue:[
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   287
                    arrowHeadPoint := arrowHeadPoint + (arrowHeadOffset @ 0)
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   288
                ] ifFalse:[
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   289
                    arrowHeadPoint := arrowHeadPoint - (arrowHeadOffset @ 0)
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   290
                ].
ccbf8e948229 changed: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2548
diff changeset
   291
            ].
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   292
        ].
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   293
    ].
1930
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   294
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   295
    len := arrowHeadLength.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   296
    len isNil ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   297
        len := DefaultLength
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   298
    ].
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   299
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   300
    angle := arrowHeadAngle.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   301
    angle isNil ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   302
        angle := DefaultAngle
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   303
    ].
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   304
    angle := angle degreesToRadians.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   305
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   306
    deriv := arrowHeadPoint - sP.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   307
    dX := deriv x.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   308
    dY := deriv y.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   309
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   310
    dX = 0 ifTrue: [
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   311
        grad := 99999999.9
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   312
    ] ifFalse: [
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   313
        grad := dY / dX
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   314
    ].
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   315
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   316
    atn := grad arcTan.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   317
    x1 := len * (angle - atn) cos.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   318
    y1 := len * (angle - atn) sin.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   319
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   320
    x2 := len * (angle + atn) cos.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   321
    y2 := len * (angle + atn) sin.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   322
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   323
    dX = 0 ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   324
        dY > 0 ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   325
            p1 := (dX + x1) @ (dY - y1).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   326
            p2 := (dX + x2) @ (dY + y2).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   327
        ] ifFalse:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   328
            p1 := (dX - x1) @ (dY + y1).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   329
            p2 := (dX - x2) @ (dY - y2).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   330
        ]
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   331
    ] ifFalse:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   332
        dX > 0 ifTrue:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   333
            p1 := (dX + x1) @ (dY - y1).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   334
            p2 := (dX + x2) @ (dY + y2).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   335
        ] ifFalse:[
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   336
            p1 := (dX - x1) @ (dY + y1).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   337
            p2 := (dX - x2) @ (dY - y2).
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   338
        ]
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   339
    ].
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   340
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   341
    p1 := sP + p1.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   342
    p2 := sP + p2.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   343
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   344
    ^ Array with:p1 with:arrowHeadPoint with:p2.
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   345
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   346
    "Created: / 14-03-2011 / 10:55:22 / cg"
1930
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   347
! !
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   348
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
!Arrow methodsFor:'accessing'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
arrowHeadAngle
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    "return the arrowHeads angle, in degrees.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
     The default is 150 degrees"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    arrowHeadAngle isNil ifTrue:[^ DefaultAngle].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    ^ arrowHeadAngle
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    "Modified: 12.5.1996 / 22:48:29 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    "Created: 12.5.1996 / 22:56:36 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
arrowHeadAngle:angleInDegrees
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    "set the arrowHeads angle, in degrees.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
     The default is 150 degrees"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    arrowHeadAngle := angleInDegrees
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    "Modified: 12.5.1996 / 22:48:29 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
    "Created: 12.5.1996 / 22:57:47 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
728
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   372
arrowHeadClosed
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   373
    "return the arrowHeadClosed flag; if true, the arrowHead is drawn
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   374
     as a closed polygon; if false (the default), the arrowHead is drawn open.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   375
     This only affects non-filled drawing."
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   376
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   377
    ^ arrowHeadClosed ? false
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   378
!
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   379
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   380
arrowHeadClosed:aBoolean
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   381
    "set the arrowHeadClosed flag; if true, the arrowHead is drawn
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   382
     as a closed polygon; if false (the default), the arrowHead is drawn open.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   383
     This only affects non-filled drawing."
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   384
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   385
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   386
    arrowHeadClosed := aBoolean.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   387
!
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   388
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
arrowHeadLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    "return the arrowHeads length, in pixels.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
     The default is 8 pixels"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    arrowHeadPosition isNil ifTrue:[^ DefaultLength].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    ^ arrowHeadLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "Created: 12.5.1996 / 22:47:32 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
    "Modified: 12.5.1996 / 22:57:27 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
arrowHeadLength:pixels
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    "set the arrowHeads length, in pixels.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
     The default is 8 pixels"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    arrowHeadLength := pixels
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    "Created: 12.5.1996 / 22:47:48 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    "Modified: 12.5.1996 / 23:01:20 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
arrowHeadPosition
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    "return the arrowHeads position, as a fraction of the overall length;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
     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
   413
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    arrowHeadPosition isNil ifTrue:[^ 1].
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    ^ arrowHeadPosition
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    "Created: 12.5.1996 / 22:46:21 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    "Modified: 12.5.1996 / 22:57:55 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
arrowHeadPosition:aFractionOfTheLinesLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
    "set the arrowHeads position, as a fraction of the overall length;
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
     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
   424
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
    arrowHeadPosition := aFractionOfTheLinesLength
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    "Created: 12.5.1996 / 22:46:54 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
    "Modified: 12.5.1996 / 23:01:09 / cg"
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
!Arrow methodsFor:'displaying'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
729
bd9dfb8c9b17 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
   433
arrowPointsFor:sP and:eP
1930
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   434
    ^ self class 
935b2870be2e arrow points reusable (class protocol)
Claus Gittinger <cg@exept.de>
parents: 1626
diff changeset
   435
        arrowPointsFor:sP and:eP 
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   436
        position:arrowHeadPosition offset:nil
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   437
        length:arrowHeadLength angle:arrowHeadAngle
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   438
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   439
    "Modified: / 14-03-2011 / 10:56:17 / cg"
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   440
!
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   441
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   442
displayFilledOn:aGC
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   443
    "display the receiver in the graphicsContext, aGC"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   444
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   445
    self displayOn:aGC filled:true
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   446
979
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   447
    "
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   448
     |v|
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   449
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   450
     v := View new openAndWait.
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   451
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   452
     (Arrow from:10@10 to:50@50) displayFilledOn:v
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   453
    "
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   454
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   455
    "Created: 12.5.1996 / 23:58:42 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   456
    "Modified: 4.6.1996 / 18:25:11 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   457
!
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   458
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   459
displayOn:aGC filled:filled
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
   460
    "display the receiver's arrow in the graphicsContext, aGC"
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   461
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
   462
    |arrowHeadPoint savedLineStyle p1 p2 arrowPoints middle oldCap|
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   463
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   464
    savedLineStyle := aGC lineStyle.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   465
    aGC lineStyle:#solid.
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   466
1626
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   467
    arrowPoints := self arrowPointsFor:startPoint and:endPoint.
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   468
1626
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   469
    p1 := arrowPoints at:1.
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   470
    arrowHeadPoint := arrowPoints at:2.
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   471
    p2 := arrowPoints at:3.
354
909581778d57 checkin from browser
ca
parents: 333
diff changeset
   472
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   473
    filled ifFalse:[
728
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   474
        arrowHeadClosed == true ifTrue:[
1626
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   475
            middle := ((p1 + p2) / 2).
729
bd9dfb8c9b17 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
   476
            aGC displayLineFrom:startPoint to:middle.
728
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   477
            aGC displayLineFrom:arrowHeadPoint to:p1.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   478
            aGC displayLineFrom:arrowHeadPoint to:p2.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   479
            aGC displayLineFrom:p1 to:p2.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   480
        ] ifFalse:[
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   481
            aGC displayLineFrom:startPoint to:endPoint.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   482
            aGC displayLineFrom:arrowHeadPoint to:p1.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   483
            aGC displayLineFrom:arrowHeadPoint to:p2.
c7a227ec2897 added optional closed arrowHead.
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   484
        ]
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   485
    ] ifTrue:[
1626
8a0e7e7151b9 do not round here (transformation could be nonNil)
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
   486
        middle := ((p1 + p2) / 2).
455
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   487
        oldCap := aGC capStyle.
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   488
        aGC capStyle:#notLast.
9789991dd799 do not draw the line in the filled part
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   489
        aGC displayLineFrom:startPoint to:middle.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   490
        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
   491
        aGC capStyle:oldCap.
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   492
    ].
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
    aGC lineStyle:savedLineStyle.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
     |v|
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
     v := View new openAndWait.
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
     (Arrow from:10@10 to:50@50) displayStrokedOn:v
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    "
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   504
    "Modified: 4.6.1996 / 18:24:53 / cg"
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   505
    "Created: 4.6.1996 / 18:25:15 / cg"
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   506
!
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   507
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   508
displayStrokedOn:aGC
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   509
    "display the receiver in the graphicsContext, aGC"
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   510
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   511
    self displayOn:aGC filled:false
323
125bc8f428a4 added filled arrows
Claus Gittinger <cg@exept.de>
parents: 322
diff changeset
   512
979
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   513
    "
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   514
     |v|
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   515
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   516
     v := View new openAndWait.
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   517
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   518
     (Arrow from:10@10 to:50@50) displayStrokedOn:v
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   519
    "
df76c50c02ac comment
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
   520
387
bcd98f85086f dont draw the line twice
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   521
    "Modified: 4.6.1996 / 18:25:07 / cg"
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
! !
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   524
!Arrow methodsFor:'queries'!
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   525
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   526
computeBounds
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   527
    "return the smallest enclosing rectangle"
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   528
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   529
    |x y minX maxX minY maxY|
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   530
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   531
    minX := maxX := startPoint x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   532
    x := endPoint x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   533
    minX := minX min:x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   534
    maxX := maxX max:x.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   535
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   536
    minY := maxY := startPoint y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   537
    y := endPoint y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   538
    minY := minY min:y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   539
    maxY := maxY max:y.
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   540
729
bd9dfb8c9b17 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
   541
    (self arrowPointsFor:startPoint and:endPoint) do:[:p |
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   542
        |x y|
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   543
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   544
        x := p x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   545
        y := p y.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   546
        minX := minX min:x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   547
        maxX := maxX max:x.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   548
        minY := minY min:y.
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   549
        maxY := maxY max:y.
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   550
    ].    
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   551
    ^ Rectangle left:minX right:maxX top:minY bottom:maxY
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   552
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   553
    "
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   554
     (Arrow from:(10@10) to:(90@90)) bounds 
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   555
     (Arrow from:(10@10) to:(10@90)) bounds  
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   556
    "
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   557
358
cdc2277521ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   558
    "Modified: 26.5.1996 / 16:31:39 / cg"
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 455
diff changeset
   559
    "Created: 12.2.1997 / 11:42:22 / cg"
357
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   560
! !
9b43dacb35d1 fixed bounds computation
Claus Gittinger <cg@exept.de>
parents: 354
diff changeset
   561
2153
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   562
!Arrow methodsFor:'testing'!
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   563
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   564
canBeFilled
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   565
    "return true, if the receiver can be drawn as a filled geometric.
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   566
     Always true here. Notice, that Arrows only fill the arrowHeads."
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   567
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   568
    ^ true
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   569
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   570
! !
640a60c624ad category changes
Claus Gittinger <cg@exept.de>
parents: 2034
diff changeset
   571
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
!Arrow class methodsFor:'documentation'!
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
version
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
   575
    ^ '$Header$'
2548
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   576
!
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   577
381d28941d3a added: #arrowPointsFor:and:position:offset:length:angle:
Claus Gittinger <cg@exept.de>
parents: 2153
diff changeset
   578
version_CVS
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
   579
    ^ '$Header$'
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
! !
1303
6ca5f36cdc63 category
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   581
3785
67f47b59ad54 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 2549
diff changeset
   582
318
27d26332a987 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
Arrow initialize!