LineSegment.st
author Claus Gittinger <cg@exept.de>
Thu, 08 Jul 1999 18:14:43 +0200
changeset 764 89df81c57e5b
parent 490 ef43c7a69346
child 1302 995effeb0c8b
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
287
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    13
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    14
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    15
Geometric subclass:#LineSegment
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    16
	instanceVariableNames:'startPoint endPoint'
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Graphics-Geometry'
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    22
!LineSegment class methodsFor:'documentation'!
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 1996 by Claus Gittinger
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
              All Rights Reserved
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    42
    LineSegments represent a line consisting of start and endPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    43
    (actually, its a vector, since the direction makes a difference when
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    44
     instances are compared using #=).
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [author:]
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Claus Gittinger
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [see also:]
320
14e3290c1c0a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 319
diff changeset
    50
        Rectangle Polygon EllipticalArc Circle Spline Curve 
331
Claus Gittinger <cg@exept.de>
parents: 320
diff changeset
    51
        Point Arrow ArrowedSpline
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        GraphicsContext
317
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    53
        StrokingWrapper
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
317
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    56
!
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    57
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    58
examples
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    59
"
319
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    60
  low leel use:
317
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    61
                                                                        [exBegin]
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    62
    |v l|
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    63
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    64
    v := (View extent:100@100) openAndWait.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    65
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    66
    l := LineSegment from:10@10 to:90@90. 
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    67
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    68
    v paint:Color red.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    69
    l displayStrokedOn:v.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    70
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    71
    l start:90@10 end:10@90.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    72
    v paint:Color blue.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    73
    l displayStrokedOn:v.
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    74
                                                                        [exEnd]
319
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    75
  as component (automatic redraw):
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    76
                                                                        [exBegin]
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    77
    |v l|
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    78
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    79
    v := View extent:100@100.
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    80
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    81
    l := LineSegment from:10@10 to:90@90. 
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    82
    v addComponent:(StrokingWrapper on:l).
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    83
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    84
    l := LineSegment from:90@10 to:10@90. 
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    85
    v addComponent:((StrokingWrapper on:l) foregroundColor:(Color red)).
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    86
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    87
    v open.
f3230ce7e611 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 317
diff changeset
    88
                                                                        [exEnd]
317
7213ea91be61 example
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    89
"
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    90
! !
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    91
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    92
!LineSegment class methodsFor:'instance creation'!
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    93
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    94
from:start to:end
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    95
    "return a new lineSegment."
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    96
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    97
    ^ self new start:start end:end
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    98
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    99
    "Created: 8.5.1996 / 20:40:13 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   102
with:p1 with:p2
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   103
    "return a new lineSegment; the smaller point is taken as startPoint."
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   105
    p1 < p2 ifTrue:[
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   106
        self new start:p1 end:p2
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   107
    ].
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   108
    ^ self new start:p2 end:p1
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   110
    "Created: 8.5.1996 / 20:41:03 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   113
!LineSegment methodsFor:'accessing'!
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
end
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "return the endPoint"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    ^ endPoint
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   120
    "Created: 8.5.1996 / 20:41:43 / cg"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   121
!
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   122
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   123
end:aPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   124
    "set the endPoint"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   125
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   126
    endPoint := aPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   127
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   128
    "Created: 8.5.1996 / 20:41:54 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
start
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "return the startPoint"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    ^ startPoint
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   136
    "Created: 8.5.1996 / 20:41:35 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   139
start:aPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   140
    "set the startPoint"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   141
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   142
    startPoint := aPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   143
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   144
    "Created: 8.5.1996 / 20:42:07 / cg"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   145
!
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   146
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   147
start:p1 end:p2
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   148
    "set both the startPoint and the endPoint"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    startPoint := p1.
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   151
    endPoint := p2.
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   153
    "Created: 8.5.1996 / 20:48:32 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
! !
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
287
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   156
!LineSegment methodsFor:'comparing'!
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   157
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   158
= aLineSegment
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   159
    "return true, if the receiver represents the same lineSegment
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   160
     as the argument, aLineSegment"
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   161
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   162
    aLineSegment species ~~ self species ifTrue:[^ false].
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   163
    ^ (startPoint = aLineSegment start
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   164
      and:[endPoint = aLineSegment end])
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   165
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   166
    "Created: 8.5.1996 / 22:13:02 / cg"
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   167
    "Modified: 8.5.1996 / 22:14:34 / cg"
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   168
!
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   169
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   170
hash
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   171
    "return a number useul for hashing.
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   172
     Redefined, since #= is redefined."
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   173
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   174
    ^ (startPoint hash bitShift:12) bitOr:(endPoint hash)
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   175
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   176
    "Modified: 8.5.1996 / 22:14:12 / cg"
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   177
! !
779c959ab8f4 added #= & hash
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   178
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   179
!LineSegment methodsFor:'converting'!
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   180
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   181
asPointArray
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   182
    "return an array containing my points."
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   183
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   184
    ^ Array with:startPoint with:endPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   185
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   186
    "Created: 8.5.1996 / 20:46:08 / cg"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   187
! !
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   188
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   189
!LineSegment methodsFor:'displaying'!
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
displayFilledOn:aGC
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   192
    "raise an error - a lineSegment cannot be drawn filled"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   194
    self shouldNotImplement
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   196
    "Created: 8.5.1996 / 21:04:27 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
!
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
displayStrokedOn:aGC
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   200
    "display the receiver in the graphicsContext, aGC"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   201
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   202
    aGC displayLineFrom:startPoint to:endPoint
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   203
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   204
    "
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   205
     |v|
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   207
     v := View new openAndWait.
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   209
     (LineSegment from:10@10 to:50@50) displayStrokedOn:v
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   210
    "
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   211
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   212
    "Modified: 8.5.1996 / 14:40:53 / cg"
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   213
    "Created: 8.5.1996 / 21:05:16 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
! !
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   216
!LineSegment methodsFor:'queries'!
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   218
computeBounds
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    "return the smallest enclosing rectangle"
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
356
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   221
    |x y minX maxX minY maxY|
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
356
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   223
    minX := maxX := startPoint x.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   224
    x := endPoint x.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   225
    minX := minX min:x.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   226
    maxX := maxX max:x.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   227
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   228
    minY := maxY := startPoint y.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   229
    y := endPoint y.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   230
    minY := minY min:y.
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   231
    maxY := maxY max:y.
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   232
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   233
    ^ Rectangle left:minX right:maxX top:minY bottom:maxY
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   236
     (LineSegment from:(10@10) to:(90@90)) bounds 
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
356
125184ded1cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   239
    "Modified: 26.5.1996 / 13:06:55 / cg"
490
ef43c7a69346 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   240
    "Created: 12.2.1997 / 11:43:50 / cg"
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
! !
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
764
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   243
!LineSegment methodsFor:'testing'!
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   244
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   245
isLineSegment
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   246
    "return true, if the receiver is a line segment"
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   247
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   248
    ^ true
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   249
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   250
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   251
! !
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   252
286
09da374b5438 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   253
!LineSegment class methodsFor:'documentation'!
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
version
764
89df81c57e5b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 490
diff changeset
   256
    ^ '$Header: /cvs/stx/stx/libbasic2/LineSegment.st,v 1.11 1999-07-08 16:14:43 cg Exp $'
282
f2f29344e676 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
! !