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