WindowingTransformation.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 06 Sep 2017 10:04:18 +0200
branchjv
changeset 8180 25149dfd68e0
parent 7059 2cfbbee08eb4
child 8595 7f9b84978a2e
child 8717 b40981a26bbd
permissions -rw-r--r--
Build files: removed a bunch of make rules for long-dead unsupported systems ...in order to unify and simplify the build. If a need to support this ancient systems arose, these hacks may ni longer be needed (due to new versions of tools) or the hacks would have to be written again (better) or retrieved from SCM (worse). Time will show.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7059
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
     1
"{ Encoding: utf8 }"
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
     2
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     3
"
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1992 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     5
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    13
"
3276
9ed39f7e7282 category change
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
    14
"{ Package: 'stx:libview' }"
9ed39f7e7282 category change
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
    15
6750
dfdcb5ea6f33 class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6697
diff changeset
    16
"{ NameSpace: Smalltalk }"
dfdcb5ea6f33 class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6697
diff changeset
    17
6697
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    18
ScaleTransform variableFloatSubclass:#WindowingTransformation
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
    19
	instanceVariableNames:'translation'
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    20
	classVariableNames:''
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    21
	poolDictionaries:''
2944
c1d0599fc178 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2804
diff changeset
    22
	category:'Graphics-Transformations'
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    23
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    24
3532
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    25
!WindowingTransformation class methodsFor:'documentation'!
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    26
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    27
copyright
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    28
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    29
 COPYRIGHT (c) 1992 by Claus Gittinger
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    30
	      All Rights Reserved
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    31
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    32
 This software is furnished under a license and may be used
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    33
 only in accordance with the terms of that license and with the
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    35
 be provided or otherwise made available to, or used by, any
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    36
 other person.  No title to or ownership of the software is
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    37
 hereby transferred.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    38
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    39
!
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    40
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    41
documentation
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    42
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    43
    instances of WindowingTransformation can be used to scale, translate or
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    44
    generally transform other objects in 2D space. 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    45
    They can also be set as the translation in a graphic context, 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    46
    which will then apply this to all of its drawing operations 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    47
    (see GraphicContext>>transformation:).
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    48
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    49
    All 2-D objects are supposed to be able to be transformed using
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    50
    instances of me.  Multiple instances of me can also be combined to form a
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    51
    single composite transformation.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    52
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    53
    [Instance variables:]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    54
        scale           <Number> or <Point> representing a linear scaling factor.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    55
                        nil is interpreted as 1@1
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    56
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    57
        translation     <Number> or <Point> representing a translation in 2-D.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    58
                        nil is interpreted as 0@0
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    59
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    60
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    61
    [author:]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    62
        Claus Gittinger
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    63
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    64
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    65
    "Modified: 25.4.1996 / 16:53:07 / cg"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    66
!
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    67
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    68
examples
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    69
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    70
    example (drawing in inches):
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    71
                                                                        [exBegin]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    72
     |v|
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    73
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    74
     v := View new realize.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    75
     (Delay forSeconds:3) wait.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    76
     v transformation:(WindowingTransformation unit:#inch on:Display).
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    77
     'now, we can think of drawing in inches ...'.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    78
     v displayLineFrom:0.5@0.5 to:1@1 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    79
                                                                        [exEnd]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    80
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    81
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    82
    example (drawing in millimeters):
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    83
                                                                        [exBegin]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    84
     |v|
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    85
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    86
     v := View new realize.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    87
     (Delay forSeconds:3) wait.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    88
     v transformation:(WindowingTransformation unit:#mm on:Display).
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    89
     'now, we can think of drawing in millimeters ...'.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    90
     v displayLineFrom:5@5 to:20@5 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    91
                                                                        [exEnd]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    92
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    93
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    94
    example (drawing magnified):
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    95
                                                                        [exBegin]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    96
     |v|
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    97
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    98
     v := View new realize.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
    99
     (Delay forSeconds:3) wait.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   100
     v transformation:(WindowingTransformation scale:2 translation:0).
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   101
     'now, everything is magnfied by 2'.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   102
     v displayLineFrom:10@10 to:30@30 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   103
                                                                        [exEnd]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   104
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   105
    example (drawing shrunk):
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   106
                                                                        [exBegin]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   107
     |v|
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   108
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   109
     v := View new realize.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   110
     (Delay forSeconds:3) wait.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   111
     v transformation:(WindowingTransformation scale:0.5 translation:0).
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   112
     'now, everything is shrunk by 2'.
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   113
     v displayLineFrom:10@10 to:30@30 
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   114
                                                                        [exEnd]
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   115
"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   116
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   117
    "Modified: 27.4.1996 / 19:45:43 / cg"
4a16a9eaac9b category included a space
Claus Gittinger <cg@exept.de>
parents: 3276
diff changeset
   118
! !
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   119
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   120
!WindowingTransformation class methodsFor:'instance creation'!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   121
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   122
identity
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   123
    "returns a windowing transformation with no scaling (1@1) 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   124
     and no translation (0@0)."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   125
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   126
    ^ self basicNew "/ scale:nil translation:nil 
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   127
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   128
    "
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   129
     WindowingTransformation identity
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   130
    "
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   131
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   132
    "Modified: 30.12.1996 / 16:59:27 / cg"
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   133
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   134
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   135
scale:aScale 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   136
    "returns a windowing transformation with a scale factor of  aScale and no translation"
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   137
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   138
    ^ self basicNew scale:aScale translation:0
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   139
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   140
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   141
     |v|
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   142
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   143
     v := View new realize.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   144
     (Delay forSeconds:3) wait.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   145
     v transformation:(WindowingTransformation scale:2 translation:0).
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   146
     'now, everything is magnfied by 2'.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   147
     v displayLineFrom:10@10 to:30@30 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   148
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   149
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   150
     |v|
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   151
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   152
     v := View new realize.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   153
     (Delay forSeconds:3) wait.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   154
     v transformation:(WindowingTransformation scale:0.5 translation:0).
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   155
     'now, everything is shrunk by 2'.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   156
     v displayLineFrom:10@10 to:30@30 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   157
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   158
!
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   159
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   160
scale:aScale translation:aTranslation 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   161
    "returns a windowing transformation with a scale factor of  
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   162
     aScale and a translation offset of aTranslation."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   163
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   164
    ^ self basicNew scale:aScale translation:aTranslation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   165
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   166
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   167
     |v|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   168
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   169
     v := View new realize.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   170
     (Delay forSeconds:3) wait.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   171
     v transformation:(WindowingTransformation scale:2 translation:0).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   172
     'now, everything is magnfied by 2'.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   173
     v displayLineFrom:10@10 to:30@30 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   174
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   175
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   176
     |v|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   177
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   178
     v := View new realize.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   179
     (Delay forSeconds:3) wait.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   180
     v transformation:(WindowingTransformation scale:0.5 translation:0).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   181
     'now, everything is shrunk by 2'.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   182
     v displayLineFrom:10@10 to:30@30 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   183
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   184
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   185
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   186
translation:aTranslation 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   187
    "returns a windowing transformation with no scaling and a translation offset of aTranslation."
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   188
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   189
    ^ self basicNew scale:nil translation:aTranslation
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   190
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   191
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   192
     |v|
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   193
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   194
     v := View new openAndWait.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   195
     v displayLineFrom:10@10 to:30@30. 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   196
     v transformation:(WindowingTransformation scale:2 translation:0).
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   197
     'now, everything is magnfied by 2'.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   198
     v displayLineFrom:10@10 to:30@30. 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   199
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   200
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   201
     |v|
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   202
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   203
     v := View new openAndWait.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   204
     v displayLineFrom:10@10 to:30@30. 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   205
     v transformation:(WindowingTransformation translation:50).
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   206
     'now, everything is offset by 50 pixels'.
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   207
     v displayLineFrom:10@10 to:30@30. 
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   208
    "
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   209
!
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   210
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   211
unit:unitSymbol on:device 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   212
    "returns a windowing transformation with scaling 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   213
     for unitSymbol and no translation (0@0).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   214
     With such a transformation, you can draw in your preferred 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   215
     units.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   216
     UnitSymbol may be #mm, #cm, #inch, #point, #twip or #pixel (default).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   217
     Twip is 1/20th of a point, point is 1/72th of an inch
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   218
     (i.e. the print-unit which is also used for font sizes etc.) 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   219
     - not to confuse with device pixels."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   220
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   221
    |ppmm ppi scale|
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   222
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   223
    ppmm := device pixelPerMillimeter.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   224
    ppi := device pixelPerInch.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   225
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   226
    unitSymbol == #mm ifTrue:[
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   227
        scale := ppmm.
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   228
    ] ifFalse:[
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   229
        unitSymbol == #cm ifTrue:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   230
            scale := ppmm * 10.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   231
        ] ifFalse:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   232
            unitSymbol == #twip ifTrue:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   233
                scale := ppi / 1440.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   234
            ] ifFalse:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   235
                unitSymbol == #point ifTrue:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   236
                    scale := ppi / 72.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   237
                ] ifFalse:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   238
                    unitSymbol == #inch ifTrue:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   239
                        scale := ppi.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   240
                    ] ifFalse:[
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   241
                        "sorry: unknown unit is taken as pixel"
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   242
                        ^ self new scale:nil translation:nil
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   243
                    ]
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   244
                ]
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   245
            ]
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   246
        ]
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   247
    ].
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   248
    ^ self basicNew scale:scale translation:nil
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   249
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   250
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   251
     |v|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   252
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   253
     v := View new openAndWait.
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   254
     (Delay forSeconds:3) wait.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   255
     v transformation:(WindowingTransformation unit:#inch on:Display).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   256
     'now, we can think of drawing in inches ...'.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   257
     v displayLineFrom:0.5@0.5 to:1@1 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   258
    "
1148
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   259
    "
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   260
     |v|
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   261
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   262
     v := View new openAndWait.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   263
     (Delay forSeconds:3) wait.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   264
     v transformation:(WindowingTransformation unit:#mm on:Display).
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   265
     'now, we can think of drawing in millimeters ...'.
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   266
     v displayLineFrom:2@2 to:10@10 
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   267
    "
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   268
d53113a7cd47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   269
    "Modified: 30.12.1996 / 16:57:59 / cg"
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   270
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   271
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   272
window:sourceRectangle viewport:destinationRectangle 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   273
    "returns a windowing transformation with a scale and
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   274
     translation computed from sourceRectangle and destinationRectangle.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   275
     The scale and transformation are computed such that sourceRectangle
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   276
     is transformed to destinationRectangle. Typically sourceRectangle
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   277
     represents the logical coordinateSpace while destinationRectangle 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   278
     represents the device coordinateSpace."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   279
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   280
    |sX sY tX tY newScale newTranslation|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   281
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   282
    sX := destinationRectangle width / sourceRectangle width.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   283
    sY := destinationRectangle height / sourceRectangle height.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   284
    tX := destinationRectangle left - sourceRectangle left.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   285
    tY := destinationRectangle top - sourceRectangle top.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   286
    ((tX = 1.0) and:[tY = 1.0]) ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   287
	newTranslation := nil
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   288
    ] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   289
	newTranslation := tX @ tY
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   290
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   291
    ((sX = 1.0) and:[sY = 1.0]) ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   292
	newScale := nil
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   293
    ] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   294
	newScale := sX @ sY
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   295
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   296
    ^ self basicNew scale:newScale translation:newTranslation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   297
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   298
    "
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   299
     |v|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   300
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   301
     v := View new realize.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   302
     (Delay forSeconds:3) wait.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   303
     v transformation:(WindowingTransformation 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   304
				window:(0@0 corner:1@1)
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   305
				viewport:(0@0 corner:100@100)).
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   306
     'now, we can think of drawing in 0..1/0..1 coordinates'.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   307
     v displayLineFrom:0.1@0.1 to:0.9@0.9 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   308
    "
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   309
!
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   310
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   311
withAngle:angle
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   312
    ^ MatrixTransform2x3 withAngle:angle
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   313
! !
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   314
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   315
!WindowingTransformation methodsFor:'accessing'!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   316
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   317
scale:aScale translation:aTranslation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   318
    "sets the scale to aScale and the translation to aTranslation."
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   319
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   320
    aScale isNil ifTrue:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   321
        scale := aScale
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   322
    ] ifFalse:[
4162
08acaf50fad0 Scale was set wrong when old scale was 1
Stefan Vogel <sv@exept.de>
parents: 3532
diff changeset
   323
        aScale = 1 ifTrue:[
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   324
            scale := nil
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   325
        ] ifFalse:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   326
            scale := aScale asPoint.
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   327
        ]
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   328
    ].
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   329
    aTranslation isNil ifTrue:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   330
        translation := aTranslation
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   331
    ] ifFalse:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   332
        aTranslation = 0 ifTrue:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   333
            translation := nil
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   334
        ] ifFalse:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   335
            translation := aTranslation asPoint
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   336
        ]
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   337
    ]
2147
c25e441abbcd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1148
diff changeset
   338
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   339
    "Modified: / 13.6.1998 / 14:04:42 / cg"
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   340
!
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   341
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   342
translation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   343
    "return a copy of the receiver's translation."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   344
6697
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   345
    translation isNil ifTrue:[^ Point x:0 y:0 ].
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   346
    ^ translation copy
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   347
!
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   348
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   349
translation:aTranslation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   350
    "Set the receiver's translation to aTranslation, a Point or Number."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   351
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   352
    aTranslation isNil ifTrue:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   353
        translation := aTranslation
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   354
    ] ifFalse:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   355
        aTranslation = 0 ifTrue:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   356
            translation := nil
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   357
        ] ifFalse:[
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   358
            translation := aTranslation asPoint
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   359
        ]
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   360
    ]
2147
c25e441abbcd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1148
diff changeset
   361
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   362
    "Modified: / 13.6.1998 / 14:04:15 / cg"
705
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   363
!
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   364
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   365
translationX
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   366
    "return the receiver's x-translation."
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   367
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   368
    translation isNil ifTrue:[^ 0].
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   369
    ^ translation x
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   370
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   371
    "Created: 21.5.1996 / 21:13:10 / cg"
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   372
!
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   373
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   374
translationY
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   375
    "return the receiver's x-translation."
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   376
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   377
    translation isNil ifTrue:[^ 0].
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   378
    ^ translation y
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   379
e8acdd90a071 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 619
diff changeset
   380
    "Created: 21.5.1996 / 21:13:21 / cg"
46
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
   381
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   382
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   383
!WindowingTransformation methodsFor:'applying transform'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   384
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   385
applyInverseTo:anObject 
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   386
    "Apply the inverse of the receiver to anObject
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   387
     and return the result. This can be used to map back from logical
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   388
     to physical coordinates, for example."
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   389
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   390
    |transformedObject|
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   391
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   392
    translation isNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   393
	scale isNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   394
	    ^ anObject
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   395
	].
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   396
	^ anObject scaledBy:self inverseScale 
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   397
    ].
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   398
    transformedObject := anObject translatedBy:(self inverseTranslation).
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   399
    scale notNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   400
	transformedObject scaleBy:(self inverseScale).
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   401
    ].
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   402
    ^ transformedObject
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   403
!
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   404
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   405
applyInverseToX:aNumber
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   406
    "Apply the receiver to a number representing an x-coordinate
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   407
     and return the result."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   408
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   409
    |t s|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   410
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   411
    scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   412
    translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   413
    ^ (aNumber - t) / s
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   414
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   415
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   416
applyInverseToY:aNumber
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   417
    "Apply the receiver to a number representing an y-coordinate
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   418
     and return the result."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   419
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   420
    |t s|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   421
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   422
    scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   423
    translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   424
    ^ (aNumber - t) / s
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   425
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   426
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   427
applyTo:anObject 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   428
    "Apply the receiver to anObject and return the result."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   429
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   430
    |transformedObject|
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   431
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   432
    scale isNil ifTrue:[
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   433
	translation isNil ifTrue:[
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   434
	    ^ anObject
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   435
	].
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   436
	^ anObject translatedBy:translation 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   437
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   438
    transformedObject := anObject scaledBy:scale.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   439
    translation notNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   440
	transformedObject translateBy:translation.
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   441
    ].
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   442
    ^ transformedObject
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   443
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   444
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   445
applyToX:aNumber
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   446
    "Apply the receiver to a number representing an x-coordinate
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   447
     and return the result."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   448
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   449
    |t s|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   450
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   451
    scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   452
    translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   453
    ^ aNumber * s + t
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   454
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   455
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   456
applyToY:aNumber
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   457
    "Apply the receiver to a number representing an y-coordinate
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   458
     and return the result."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   459
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   460
    |t s|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   461
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   462
    scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   463
    translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   464
    ^ aNumber * s + t
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   465
!
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   466
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   467
compose:aTransformation 
48194c26a46c Initial revision
claus
parents:
diff changeset
   468
    "return a new WindowingTransformation that is the
48194c26a46c Initial revision
claus
parents:
diff changeset
   469
     composition of the receiver and aTransformation.
48194c26a46c Initial revision
claus
parents:
diff changeset
   470
     The effect of applying the resulting WindowingTransformation
48194c26a46c Initial revision
claus
parents:
diff changeset
   471
     to an object is the same as that of first applying
48194c26a46c Initial revision
claus
parents:
diff changeset
   472
     aTransformation to the object and then applying the 
48194c26a46c Initial revision
claus
parents:
diff changeset
   473
     receiver to its result."
48194c26a46c Initial revision
claus
parents:
diff changeset
   474
48194c26a46c Initial revision
claus
parents:
diff changeset
   475
    |aTransformationScale newScale newTranslation|
48194c26a46c Initial revision
claus
parents:
diff changeset
   476
48194c26a46c Initial revision
claus
parents:
diff changeset
   477
    aTransformationScale := aTransformation scale.
78
1c9c22df3251 *** empty log message ***
claus
parents: 72
diff changeset
   478
    scale isNil ifTrue:[
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   479
        aTransformation isNoScale ifTrue:[
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   480
            newScale := nil
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   481
        ] ifFalse:[
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   482
            newScale := aTransformationScale
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   483
        ].
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   484
        newTranslation := (translation ? 0) + aTransformation translation
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   485
    ] ifFalse:[
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   486
        aTransformation isNoScale ifTrue:[
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   487
            newScale := scale
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   488
        ] ifFalse:[
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   489
            newScale := scale * aTransformationScale
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   490
        ].
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   491
        newTranslation := (translation ? 0)
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   492
                          + (scale * aTransformation translation)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   493
    ].
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   494
    ^ (self class) 
6690
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   495
          scale:newScale
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   496
          translation:newTranslation
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   497
!
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   498
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   499
composedWithLocal: aTransformation
57c36b83ea0e class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6355
diff changeset
   500
    ^ self compose:aTransformation
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   501
!
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   502
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   503
transformPoint:p 
6697
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   504
    "Apply the receiver to a point, returning a new point."
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   505
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   506
    scale isNil ifTrue:[
6355
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   507
        translation isNil ifTrue:[
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   508
            ^ p
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   509
        ].
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   510
        ^ p + translation
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   511
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   512
    translation isNil ifTrue:[
6355
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   513
        ^ p * scale
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   514
    ].
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   515
    ^ (p * scale + translation)
7038
94deb70cb1cd #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 6750
diff changeset
   516
!
94deb70cb1cd #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 6750
diff changeset
   517
7059
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   518
transformRectangle:aRectangle 
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   519
    "Apply the receiver to a rectangle, returning a new rectangle."
7038
94deb70cb1cd #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 6750
diff changeset
   520
7059
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   521
    ^ aRectangle scaledBy:scale translatedBy:translation.
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   522
! !
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   523
3276
9ed39f7e7282 category change
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
   524
!WindowingTransformation methodsFor:'printing & storing'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   525
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   526
printOn:aStream
2804
7ff4242eb1ee comment
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   527
    "append a user printed representation of the receiver to aStream.
7ff4242eb1ee comment
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   528
     The format is suitable for a human - not meant to be read back."
7ff4242eb1ee comment
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   529
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   530
    aStream nextPutAll:self class name.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   531
    aStream nextPutAll:' scale: '.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   532
    scale printOn:aStream.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   533
    aStream nextPutAll:' translation: '.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   534
    translation printOn:aStream
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   535
! !
48194c26a46c Initial revision
claus
parents:
diff changeset
   536
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   537
!WindowingTransformation methodsFor:'private'!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   538
48194c26a46c Initial revision
claus
parents:
diff changeset
   539
inverseTranslation
7059
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   540
    "return with a Point or Number representing the inverse of my
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   541
     translation."
48194c26a46c Initial revision
claus
parents:
diff changeset
   542
7059
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   543
    translation isNil ifTrue:[
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   544
        ^ nil.
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   545
    ].
2cfbbee08eb4 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 7038
diff changeset
   546
    ^ translation negated.
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   547
! !
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   548
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   549
!WindowingTransformation methodsFor:'testing'!
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   550
6355
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   551
isIdentityTransformation
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   552
    "return true if this is an identity transformation;
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   553
     return false, otherwise."
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   554
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   555
    ^ (scale isNil or:[scale x = 1 and:[scale y = 1]])
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   556
        and:[translation isNil or:[translation x = 0 and:[translation y = 0]]]
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   557
! !
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   558
3276
9ed39f7e7282 category change
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
   559
!WindowingTransformation methodsFor:'transformations'!
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   560
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   561
scaleBy:aScale 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   562
    "scale the receiver.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   563
     This is a destructive operation, modifying the transformation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   564
     represented by the receiver"
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   565
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   566
    |newScale|
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   567
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   568
    aScale isNil ifTrue:[^ self].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   569
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   570
    scale isNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   571
	newScale := aScale asPoint
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   572
    ] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   573
	newScale := scale * aScale
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   574
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   575
    translation notNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   576
	translation := translation * aScale.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   577
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   578
    scale := newScale.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   579
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   580
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   581
scaledBy:aScale 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   582
    "return a new WindowingTransformation with the scale and translation of 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   583
     the receiver both scaled by aScale."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   584
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   585
    |checkedScale newScale newTranslation|
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   586
601
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   587
    aScale isNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   588
	newScale := scale.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   589
	newTranslation := translation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   590
    ] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   591
	checkedScale := self checkScale:aScale.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   592
	scale isNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   593
	    newScale := checkedScale
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   594
	] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   595
	    newScale := scale * checkedScale
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   596
	].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   597
	translation notNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   598
	    newTranslation := checkedScale * translation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   599
	]
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   600
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   601
    ^ (self class) 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   602
	  scale:newScale
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   603
	  translation:newTranslation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   604
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   605
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   606
translateBy:aTranslation 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   607
    "translate the receiver.
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   608
     This is a destructive operation, modifying the transformation
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   609
     represented by the receiver"
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   610
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   611
    aTranslation isNil ifTrue:[^ self].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   612
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   613
    translation isNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   614
	translation := 0@0
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   615
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   616
    scale isNil ifTrue:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   617
	translation := translation + aTranslation asPoint
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   618
    ] ifFalse:[
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   619
	translation := translation + (scale * aTranslation)
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   620
    ].
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   621
!
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   622
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   623
translatedBy:aPoint 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   624
    "return a new WindowingTransformation with the same scale and 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   625
     rotations as the receiver and with a translation of the current 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   626
     translation plus aPoint."
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   627
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   628
    ^ (self class) 
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   629
	  scale:scale
2c4c1e797909 commentary
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   630
	  translation:(translation + aPoint)
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   631
! !
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
   632
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   633
!WindowingTransformation class methodsFor:'documentation'!
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   634
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   635
version
7038
94deb70cb1cd #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 6750
diff changeset
   636
    ^ '$Header$'
6697
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   637
!
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   638
ae3d20f6846b class: WindowingTransformation
Claus Gittinger <cg@exept.de>
parents: 6690
diff changeset
   639
version_CVS
7038
94deb70cb1cd #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 6750
diff changeset
   640
    ^ '$Header$'
2148
53800815fa32 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
   641
! !
6355
1ddfc032a8c5 class: WindowingTransformation
Stefan Vogel <sv@exept.de>
parents: 5827
diff changeset
   642