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