eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'WindowingTransformation':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: WindowingTransformation


Inheritance:

   Object
   |
   +--DisplayTransform
      |
      +--ScaleTransform
         |
         +--WindowingTransformation

Package:
stx:libview
Category:
Graphics-Transformations
Version:
rev: 1.32 date: 2022/03/08 22:41:59
user: cg
file: WindowingTransformation.st directory: libview
module: stx stc-classLibrary: libview

Description:


instances of WindowingTransformation can be used to scale, translate or
generally transform other objects in 2D space. 
They can also be set as the translation in a graphic context, 
which will then apply this to all of its drawing operations 
(see GraphicContext>>transformation:).

All 2-D objects are supposed to be able to be transformed using
instances of me.  Multiple instances of me can also be combined to form a
single composite transformation.

[Instance variables:]
    scale           <Number> or <Point> representing a linear scaling factor.
                    nil is interpreted as 1@1

    translation     <Number> or <Point> representing a translation in 2-D.
                    nil is interpreted as 0@0

copyright

COPYRIGHT (c) 1992 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  identity
returns a windowing transformation with no scaling (1@1)
and no translation (0@0).

Usage example(s):

     WindowingTransformation identity

o  scale: aScale
returns a windowing transformation with a scale factor of aScale and no translation

Usage example(s):

     |v|

     v := View new realize.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation scale:2 translation:0).
     'now, everything is magnfied by 2'.
     v displayLineFrom:10@10 to:30@30 

Usage example(s):

     |v|

     v := View new realize.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation scale:0.5 translation:0).
     'now, everything is shrunk by 2'.
     v displayLineFrom:10@10 to:30@30 

o  scale: aScale translation: aTranslation
returns a windowing transformation with a scale factor of
aScale and a translation offset of aTranslation.

Usage example(s):

     |v|

     v := View new realize.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation scale:2 translation:0).
     'now, everything is magnfied by 2'.
     v displayLineFrom:10@10 to:30@30 

Usage example(s):

     |v|

     v := View new realize.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation scale:0.5 translation:0).
     'now, everything is shrunk by 2'.
     v displayLineFrom:10@10 to:30@30 

o  translation: aTranslation
returns a windowing transformation with no scaling and a translation offset of aTranslation.

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.
     v displayLineFrom:10@10 to:30@30. 
     v transformation:(WindowingTransformation scale:2 translation:0).
     'now, everything is magnfied by 2'.
     v displayLineFrom:10@10 to:30@30. 

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.
     v displayLineFrom:10@10 to:30@30. 
     v transformation:(WindowingTransformation translation:50).
     'now, everything is offset by 50 pixels'.
     v displayLineFrom:10@10 to:30@30. 

o  unit: unitSymbol on: device
returns a windowing transformation with scaling
for unitSymbol and no translation (0@0).
With such a transformation, you can draw in your preferred
units.
UnitSymbol may be #mm, #cm, #inch, #point, #twip or #pixel (default).
Twip is 1/20th of a point, point is 1/72th of an inch
(i.e. the print-unit which is also used for font sizes etc.)
- not to confuse with device pixels.

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation unit:#inch on:Display).
     'now, we can think of drawing in inches ...'.
     v displayLineFrom:0.5@0.5 to:1@1 

Usage example(s):

     |v|

     v := View new openAndWaitUntilVisible.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation unit:#mm on:Display).
     'now, we can think of drawing in millimeters ...'.
     v displayLineFrom:2@2 to:10@10 

o  window: sourceRectangle viewport: destinationRectangle
returns a windowing transformation with a scale and
translation computed from sourceRectangle and destinationRectangle.
The scale and transformation are computed such that sourceRectangle
is transformed to destinationRectangle. Typically sourceRectangle
represents the logical coordinateSpace while destinationRectangle
represents the device coordinateSpace.

Usage example(s):

     |v|

     v := View new realize.
     (Delay forSeconds:3) wait.
     v transformation:(WindowingTransformation 
				window:(0@0 corner:1@1)
				viewport:(0@0 corner:100@100)).
     'now, we can think of drawing in 0..1/0..1 coordinates'.
     v displayLineFrom:0.1@0.1 to:0.9@0.9 

o  withAngle: angle


Instance protocol:

accessing
o  scale: aScale translation: aTranslation
sets the scale to aScale and the translation to aTranslation.

o  translation
return a copy of the receiver's translation.

o  translation: aTranslation
Set the receiver's translation to aTranslation, a Point or Number.

o  translationX
return the receiver's x-translation.

o  translationY
return the receiver's x-translation.

applying transform
o  applyInverseTo: anObject
Apply the inverse of the receiver to anObject
and return the result. This can be used to map back from logical
to physical coordinates, for example.

o  applyInverseToX: aNumber
Apply the receiver to a number representing an x-coordinate
and return the result.

o  applyInverseToY: aNumber
Apply the receiver to a number representing an y-coordinate
and return the result.

o  applyTo: anObject
Apply the receiver to anObject and return the result.

o  applyToX: aNumber
Apply the receiver to a number representing an x-coordinate
and return the result.

o  applyToY: aNumber
Apply the receiver to a number representing an y-coordinate
and return the result.

o  compose: aTransformation
return a new WindowingTransformation that is the
composition of the receiver and aTransformation.
The effect of applying the resulting WindowingTransformation
to an object is the same as that of first applying
aTransformation to the object and then applying the
receiver to its result.

o  composedWithLocal: aTransformation
(comment from inherited method)
Return the composition of the receiver and the local transformation passed in.
A 'local' transformation is defined as a transformation that takes place
between the receiver (the 'global') transformation and any 'local' point
computations, e.g., for the methods

globalPointToLocal: globalPoint
globalPoint -> globalTransform -> localTransform -> locaPoint

localPointToGlobal: localPoint
localPoint -> localTransform -> globalTransform -> globalPoint


o  transformPoint: p
Apply the receiver to a point, returning a new point.

o  transformRectangle: aRectangle
Apply the receiver to a rectangle, returning a new rectangle.

printing & storing
o  printOn: aStream
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.

private
o  inverseTranslation
return with a Point or Number representing the inverse of my
translation.

testing
o  isIdentityTransformation
return true if this is an identity transformation;
return false, otherwise.

transformations
o  scaleBy: aScale
scale the receiver.
This is a destructive operation, modifying the transformation
represented by the receiver

o  scaledBy: aScale
return a new WindowingTransformation with the scale and translation of
the receiver both scaled by aScale.

o  translateBy: aTranslation
translate the receiver.
This is a destructive operation, modifying the transformation
represented by the receiver

o  translatedBy: aPoint
return a new WindowingTransformation with the same scale and
rotations as the receiver and with a translation of the current
translation plus aPoint.


Examples:


example (drawing in inches):
 |v|

 v := View new realize.
 (Delay forSeconds:3) wait.
 v transformation:(WindowingTransformation unit:#inch on:Display).
 'now, we can think of drawing in inches ...'.
 v displayLineFrom:0.5@0.5 to:1@1 
example (drawing in millimeters):
 |v|

 v := View new realize.
 (Delay forSeconds:3) wait.
 v transformation:(WindowingTransformation unit:#mm on:Display).
 'now, we can think of drawing in millimeters ...'.
 v displayLineFrom:5@5 to:20@5 
example (drawing magnified):
 |v|

 v := View new realize.
 (Delay forSeconds:3) wait.
 v transformation:(WindowingTransformation scale:2 translation:0).
 'now, everything is magnfied by 2'.
 v displayLineFrom:10@10 to:30@30 
example (drawing shrunk):
 |v|

 v := View new realize.
 (Delay forSeconds:3) wait.
 v transformation:(WindowingTransformation scale:0.5 translation:0).
 'now, everything is shrunk by 2'.
 v displayLineFrom:10@10 to:30@30 


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:40:21 GMT