This file is indexed.

/usr/share/pyshared/gaphas/matrix.py is in python-gaphas 0.7.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
"""
Some Gaphor specific updates to the canvas. This is done by setting the
correct properties on gaphas' modules.

Matrix
------
Small utility class wrapping cairo.Matrix. The `Matrix` class
adds state preservation capabilities.
"""

__version__ = "$Revision$"
# $HeadURL$

import cairo
from state import observed, reversible_method


class Matrix(object):
    """
    Matrix wrapper. This version sends @observed messages on state changes

    >>> cairo.Matrix()
    cairo.Matrix(1, 0, 0, 1, 0, 0)
    >>> Matrix()
    Matrix(1, 0, 0, 1, 0, 0)
    """

    def __init__(self, xx=1.0, yx=0.0, xy=0.0, yy=1.0, x0=0.0, y0=0.0):
        self._matrix = cairo.Matrix(xx, yx, xy, yy, x0, y0)

    @staticmethod
    def init_rotate(radians):
        return cairo.Matrix.init_rotate(radians)

    @observed
    def invert(self):
        return self._matrix.invert()

    @observed
    def rotate(self, radians):
        return self._matrix.rotate(radians)

    @observed
    def scale(self, sx, sy):
        return self._matrix.scale(sx, sy)

    @observed
    def translate(self, tx, ty):
        self._matrix.translate(tx, ty)

    @observed
    def multiply(self, m):
        return self._matrix.multiply(m)

    reversible_method(invert, invert)
    reversible_method(rotate, rotate,
                      { 'radians': lambda radians: -radians })
    reversible_method(scale, scale,
                      { 'sx': lambda sx: 1/sx, 'sy': lambda sy: 1/sy })
    reversible_method(translate, translate,
                      { 'tx': lambda tx: -tx, 'ty': lambda ty: -ty })

    def transform_distance(self, dx, dy):
        self._matrix.transform_distance(dx, dy)

    def transform_point(self, x, y):
        self._matrix.transform_point(x, y)

    def __eq__(self, other):
        return self._matrix.__eq__(other)

    def __ne__(self, other):
        return self._matrix.__ne__(other)

    def __le__(self, other):
        return self._matrix.__le__(other)

    def __lt__(self, other):
        return self._matrix.__lt__(other)

    def __ge__(self, other):
        return self._matrix.__ge__(other)

    def __gt__(self, other):
        return self._matrix.__gt__(other)

    def __getitem__(self, val):
        return self._matrix.__getitem__(val)

    @observed
    def __mul__(self, other):
        return self._matrix.__mul__(other)

    @observed
    def __rmul__(self, other):
        return self._matrix.__rmul__(other)
 
    def __repr__(self):
        return 'Matrix(%g, %g, %g, %g, %g, %g)' % tuple(self._matrix)

# vim:sw=4:et