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