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