Code Duplication    Length = 150-152 lines in 5 locations

src/ocrd_models/ocrd_page_generateds.py 5 locations

@@ 12251-12402 (lines=152) @@
12248
# end class MathsRegionType
12249
12250
12251
class SeparatorRegionType(RegionType):
12252
    """Separators are lines that lie between columns and
12253
    paragraphs and can be used to logically separate
12254
    different articles from each other.
12255
    The angle the rectangle encapsulating a region
12256
    has to be rotated in clockwise direction
12257
    in order to correct the present skew
12258
    (negative values indicate anti-clockwise rotation).
12259
    Range: -179.999,180
12260
    The colour of the separator"""
12261
    __hash__ = GeneratedsSuper.__hash__
12262
    member_data_items_ = [
12263
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}),
12264
        MemberSpec_('colour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}),
12265
    ]
12266
    subclass = None
12267
    superclass = RegionType
12268
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, colour=None, gds_collector_=None, **kwargs_):
12269
        self.gds_collector_ = gds_collector_
12270
        self.gds_elementtree_node_ = None
12271
        self.original_tagname_ = None
12272
        self.parent_object_ = kwargs_.get('parent_object_')
12273
        self.ns_prefix_ = None
12274
        super(SeparatorRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12275
        self.orientation = _cast(float, orientation)
12276
        self.orientation_nsprefix_ = "pc"
12277
        self.colour = _cast(None, colour)
12278
        self.colour_nsprefix_ = "pc"
12279
    def factory(*args_, **kwargs_):
12280
        if CurrentSubclassModule_ is not None:
12281
            subclass = getSubclassFromModule_(
12282
                CurrentSubclassModule_, SeparatorRegionType)
12283
            if subclass is not None:
12284
                return subclass(*args_, **kwargs_)
12285
        if SeparatorRegionType.subclass:
12286
            return SeparatorRegionType.subclass(*args_, **kwargs_)
12287
        else:
12288
            return SeparatorRegionType(*args_, **kwargs_)
12289
    factory = staticmethod(factory)
12290
    def get_ns_prefix_(self):
12291
        return self.ns_prefix_
12292
    def set_ns_prefix_(self, ns_prefix):
12293
        self.ns_prefix_ = ns_prefix
12294
    def get_orientation(self):
12295
        return self.orientation
12296
    def set_orientation(self, orientation):
12297
        self.orientation = orientation
12298
    def get_colour(self):
12299
        return self.colour
12300
    def set_colour(self, colour):
12301
        self.colour = colour
12302
    def validate_ColourSimpleType(self, value):
12303
        # Validate type pc:ColourSimpleType, a restriction on string.
12304
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12305
            if not isinstance(value, str):
12306
                lineno = self.gds_get_node_lineno_()
12307
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12308
                return False
12309
            value = value
12310
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12311
            if value not in enumerations:
12312
                lineno = self.gds_get_node_lineno_()
12313
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12314
                result = False
12315
    def hasContent_(self):
12316
        if (
12317
            super(SeparatorRegionType, self).hasContent_()
12318
        ):
12319
            return True
12320
        else:
12321
            return False
12322
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SeparatorRegionType', pretty_print=True):
12323
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('SeparatorRegionType')
12324
        if imported_ns_def_ is not None:
12325
            namespacedef_ = imported_ns_def_
12326
        if pretty_print:
12327
            eol_ = '\n'
12328
        else:
12329
            eol_ = ''
12330
        if self.original_tagname_ is not None and name_ == 'SeparatorRegionType':
12331
            name_ = self.original_tagname_
12332
        if UseCapturedNS_ and self.ns_prefix_:
12333
            namespaceprefix_ = self.ns_prefix_ + ':'
12334
        showIndent(outfile, level, pretty_print)
12335
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12336
        already_processed = set()
12337
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
12338
        if self.hasContent_():
12339
            outfile.write('>%s' % (eol_, ))
12340
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SeparatorRegionType', pretty_print=pretty_print)
12341
            showIndent(outfile, level, pretty_print)
12342
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12343
        else:
12344
            outfile.write('/>%s' % (eol_, ))
12345
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SeparatorRegionType'):
12346
        super(SeparatorRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SeparatorRegionType')
12347
        if self.orientation is not None and 'orientation' not in already_processed:
12348
            already_processed.add('orientation')
12349
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12350
        if self.colour is not None and 'colour' not in already_processed:
12351
            already_processed.add('colour')
12352
            outfile.write(' colour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.colour), input_name='colour')), ))
12353
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SeparatorRegionType', fromsubclass_=False, pretty_print=True):
12354
        super(SeparatorRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12355
    def to_etree(self, parent_element=None, name_='SeparatorRegionType', mapping_=None, nsmap_=None):
12356
        element = super(SeparatorRegionType, self).to_etree(parent_element, name_, mapping_)
12357
        if self.orientation is not None:
12358
            element.set('orientation', self.gds_format_float(self.orientation))
12359
        if self.colour is not None:
12360
            element.set('colour', self.gds_format_string(self.colour))
12361
        if mapping_ is not None:
12362
            mapping_[id(self)] = element
12363
        return element
12364
    def build(self, node, gds_collector_=None):
12365
        self.gds_collector_ = gds_collector_
12366
        if SaveElementTreeNode:
12367
            self.gds_elementtree_node_ = node
12368
        already_processed = set()
12369
        self.ns_prefix_ = node.prefix
12370
        self.buildAttributes(node, node.attrib, already_processed)
12371
        for child in node:
12372
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12373
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12374
        return self
12375
    def buildAttributes(self, node, attrs, already_processed):
12376
        value = find_attr_value_('orientation', node)
12377
        if value is not None and 'orientation' not in already_processed:
12378
            already_processed.add('orientation')
12379
            value = self.gds_parse_float(value, node, 'orientation')
12380
            self.orientation = value
12381
        value = find_attr_value_('colour', node)
12382
        if value is not None and 'colour' not in already_processed:
12383
            already_processed.add('colour')
12384
            self.colour = value
12385
            self.validate_ColourSimpleType(self.colour)    # validate type ColourSimpleType
12386
        super(SeparatorRegionType, self).buildAttributes(node, attrs, already_processed)
12387
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12388
        super(SeparatorRegionType, self).buildChildren(child_, node, nodeName_, True)
12389
        pass
12390
    def __hash__(self):
12391
        return hash(self.id)
12392
    def set_orientation(self, orientation):
12393
        """
12394
        Set deskewing angle to given `orientation` number.
12395
        Moreover, invalidate self's ``pc:AlternativeImage``s
12396
        (because they will have been rotated and enlarged
12397
        with the angle of the previous value).
12398
        """
12399
        if hasattr(self, 'invalidate_AlternativeImage'):
12400
            # PageType, RegionType:
12401
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12402
        self.orientation = orientation
12403
# end class SeparatorRegionType
12404
12405
@@ 12097-12247 (lines=151) @@
12094
# end class ChemRegionType
12095
12096
12097
class MathsRegionType(RegionType):
12098
    """Regions containing equations and mathematical symbols
12099
    should be marked as maths regions.
12100
    The angle the rectangle encapsulating a region
12101
    has to be rotated in clockwise direction
12102
    in order to correct the present skew
12103
    (negative values indicate anti-clockwise rotation).
12104
    Range: -179.999,180
12105
    The background colour of the region"""
12106
    __hash__ = GeneratedsSuper.__hash__
12107
    member_data_items_ = [
12108
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}),
12109
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}),
12110
    ]
12111
    subclass = None
12112
    superclass = RegionType
12113
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
12114
        self.gds_collector_ = gds_collector_
12115
        self.gds_elementtree_node_ = None
12116
        self.original_tagname_ = None
12117
        self.parent_object_ = kwargs_.get('parent_object_')
12118
        self.ns_prefix_ = None
12119
        super(MathsRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
12120
        self.orientation = _cast(float, orientation)
12121
        self.orientation_nsprefix_ = "pc"
12122
        self.bgColour = _cast(None, bgColour)
12123
        self.bgColour_nsprefix_ = "pc"
12124
    def factory(*args_, **kwargs_):
12125
        if CurrentSubclassModule_ is not None:
12126
            subclass = getSubclassFromModule_(
12127
                CurrentSubclassModule_, MathsRegionType)
12128
            if subclass is not None:
12129
                return subclass(*args_, **kwargs_)
12130
        if MathsRegionType.subclass:
12131
            return MathsRegionType.subclass(*args_, **kwargs_)
12132
        else:
12133
            return MathsRegionType(*args_, **kwargs_)
12134
    factory = staticmethod(factory)
12135
    def get_ns_prefix_(self):
12136
        return self.ns_prefix_
12137
    def set_ns_prefix_(self, ns_prefix):
12138
        self.ns_prefix_ = ns_prefix
12139
    def get_orientation(self):
12140
        return self.orientation
12141
    def set_orientation(self, orientation):
12142
        self.orientation = orientation
12143
    def get_bgColour(self):
12144
        return self.bgColour
12145
    def set_bgColour(self, bgColour):
12146
        self.bgColour = bgColour
12147
    def validate_ColourSimpleType(self, value):
12148
        # Validate type pc:ColourSimpleType, a restriction on string.
12149
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
12150
            if not isinstance(value, str):
12151
                lineno = self.gds_get_node_lineno_()
12152
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
12153
                return False
12154
            value = value
12155
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12156
            if value not in enumerations:
12157
                lineno = self.gds_get_node_lineno_()
12158
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12159
                result = False
12160
    def hasContent_(self):
12161
        if (
12162
            super(MathsRegionType, self).hasContent_()
12163
        ):
12164
            return True
12165
        else:
12166
            return False
12167
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MathsRegionType', pretty_print=True):
12168
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MathsRegionType')
12169
        if imported_ns_def_ is not None:
12170
            namespacedef_ = imported_ns_def_
12171
        if pretty_print:
12172
            eol_ = '\n'
12173
        else:
12174
            eol_ = ''
12175
        if self.original_tagname_ is not None and name_ == 'MathsRegionType':
12176
            name_ = self.original_tagname_
12177
        if UseCapturedNS_ and self.ns_prefix_:
12178
            namespaceprefix_ = self.ns_prefix_ + ':'
12179
        showIndent(outfile, level, pretty_print)
12180
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12181
        already_processed = set()
12182
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
12183
        if self.hasContent_():
12184
            outfile.write('>%s' % (eol_, ))
12185
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MathsRegionType', pretty_print=pretty_print)
12186
            showIndent(outfile, level, pretty_print)
12187
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12188
        else:
12189
            outfile.write('/>%s' % (eol_, ))
12190
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MathsRegionType'):
12191
        super(MathsRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MathsRegionType')
12192
        if self.orientation is not None and 'orientation' not in already_processed:
12193
            already_processed.add('orientation')
12194
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12195
        if self.bgColour is not None and 'bgColour' not in already_processed:
12196
            already_processed.add('bgColour')
12197
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12198
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MathsRegionType', fromsubclass_=False, pretty_print=True):
12199
        super(MathsRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12200
    def to_etree(self, parent_element=None, name_='MathsRegionType', mapping_=None, nsmap_=None):
12201
        element = super(MathsRegionType, self).to_etree(parent_element, name_, mapping_)
12202
        if self.orientation is not None:
12203
            element.set('orientation', self.gds_format_float(self.orientation))
12204
        if self.bgColour is not None:
12205
            element.set('bgColour', self.gds_format_string(self.bgColour))
12206
        if mapping_ is not None:
12207
            mapping_[id(self)] = element
12208
        return element
12209
    def build(self, node, gds_collector_=None):
12210
        self.gds_collector_ = gds_collector_
12211
        if SaveElementTreeNode:
12212
            self.gds_elementtree_node_ = node
12213
        already_processed = set()
12214
        self.ns_prefix_ = node.prefix
12215
        self.buildAttributes(node, node.attrib, already_processed)
12216
        for child in node:
12217
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12218
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12219
        return self
12220
    def buildAttributes(self, node, attrs, already_processed):
12221
        value = find_attr_value_('orientation', node)
12222
        if value is not None and 'orientation' not in already_processed:
12223
            already_processed.add('orientation')
12224
            value = self.gds_parse_float(value, node, 'orientation')
12225
            self.orientation = value
12226
        value = find_attr_value_('bgColour', node)
12227
        if value is not None and 'bgColour' not in already_processed:
12228
            already_processed.add('bgColour')
12229
            self.bgColour = value
12230
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12231
        super(MathsRegionType, self).buildAttributes(node, attrs, already_processed)
12232
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12233
        super(MathsRegionType, self).buildChildren(child_, node, nodeName_, True)
12234
        pass
12235
    def __hash__(self):
12236
        return hash(self.id)
12237
    def set_orientation(self, orientation):
12238
        """
12239
        Set deskewing angle to given `orientation` number.
12240
        Moreover, invalidate self's ``pc:AlternativeImage``s
12241
        (because they will have been rotated and enlarged
12242
        with the angle of the previous value).
12243
        """
12244
        if hasattr(self, 'invalidate_AlternativeImage'):
12245
            # PageType, RegionType:
12246
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12247
        self.orientation = orientation
12248
# end class MathsRegionType
12249
12250
@@ 11943-12093 (lines=151) @@
11940
# end class MapRegionType
11941
11942
11943
class ChemRegionType(RegionType):
11944
    """Regions containing chemical formulas.
11945
    The angle the rectangle encapsulating a
11946
    region has to be rotated in clockwise
11947
    direction in order to correct the present
11948
    skew (negative values indicate
11949
    anti-clockwise rotation). Range:
11950
    -179.999,180
11951
    The background colour of the region"""
11952
    __hash__ = GeneratedsSuper.__hash__
11953
    member_data_items_ = [
11954
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}),
11955
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}),
11956
    ]
11957
    subclass = None
11958
    superclass = RegionType
11959
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
11960
        self.gds_collector_ = gds_collector_
11961
        self.gds_elementtree_node_ = None
11962
        self.original_tagname_ = None
11963
        self.parent_object_ = kwargs_.get('parent_object_')
11964
        self.ns_prefix_ = None
11965
        super(ChemRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
11966
        self.orientation = _cast(float, orientation)
11967
        self.orientation_nsprefix_ = "pc"
11968
        self.bgColour = _cast(None, bgColour)
11969
        self.bgColour_nsprefix_ = "pc"
11970
    def factory(*args_, **kwargs_):
11971
        if CurrentSubclassModule_ is not None:
11972
            subclass = getSubclassFromModule_(
11973
                CurrentSubclassModule_, ChemRegionType)
11974
            if subclass is not None:
11975
                return subclass(*args_, **kwargs_)
11976
        if ChemRegionType.subclass:
11977
            return ChemRegionType.subclass(*args_, **kwargs_)
11978
        else:
11979
            return ChemRegionType(*args_, **kwargs_)
11980
    factory = staticmethod(factory)
11981
    def get_ns_prefix_(self):
11982
        return self.ns_prefix_
11983
    def set_ns_prefix_(self, ns_prefix):
11984
        self.ns_prefix_ = ns_prefix
11985
    def get_orientation(self):
11986
        return self.orientation
11987
    def set_orientation(self, orientation):
11988
        self.orientation = orientation
11989
    def get_bgColour(self):
11990
        return self.bgColour
11991
    def set_bgColour(self, bgColour):
11992
        self.bgColour = bgColour
11993
    def validate_ColourSimpleType(self, value):
11994
        # Validate type pc:ColourSimpleType, a restriction on string.
11995
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11996
            if not isinstance(value, str):
11997
                lineno = self.gds_get_node_lineno_()
11998
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11999
                return False
12000
            value = value
12001
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
12002
            if value not in enumerations:
12003
                lineno = self.gds_get_node_lineno_()
12004
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
12005
                result = False
12006
    def hasContent_(self):
12007
        if (
12008
            super(ChemRegionType, self).hasContent_()
12009
        ):
12010
            return True
12011
        else:
12012
            return False
12013
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChemRegionType', pretty_print=True):
12014
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('ChemRegionType')
12015
        if imported_ns_def_ is not None:
12016
            namespacedef_ = imported_ns_def_
12017
        if pretty_print:
12018
            eol_ = '\n'
12019
        else:
12020
            eol_ = ''
12021
        if self.original_tagname_ is not None and name_ == 'ChemRegionType':
12022
            name_ = self.original_tagname_
12023
        if UseCapturedNS_ and self.ns_prefix_:
12024
            namespaceprefix_ = self.ns_prefix_ + ':'
12025
        showIndent(outfile, level, pretty_print)
12026
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
12027
        already_processed = set()
12028
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
12029
        if self.hasContent_():
12030
            outfile.write('>%s' % (eol_, ))
12031
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ChemRegionType', pretty_print=pretty_print)
12032
            showIndent(outfile, level, pretty_print)
12033
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
12034
        else:
12035
            outfile.write('/>%s' % (eol_, ))
12036
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ChemRegionType'):
12037
        super(ChemRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ChemRegionType')
12038
        if self.orientation is not None and 'orientation' not in already_processed:
12039
            already_processed.add('orientation')
12040
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
12041
        if self.bgColour is not None and 'bgColour' not in already_processed:
12042
            already_processed.add('bgColour')
12043
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
12044
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ChemRegionType', fromsubclass_=False, pretty_print=True):
12045
        super(ChemRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
12046
    def to_etree(self, parent_element=None, name_='ChemRegionType', mapping_=None, nsmap_=None):
12047
        element = super(ChemRegionType, self).to_etree(parent_element, name_, mapping_)
12048
        if self.orientation is not None:
12049
            element.set('orientation', self.gds_format_float(self.orientation))
12050
        if self.bgColour is not None:
12051
            element.set('bgColour', self.gds_format_string(self.bgColour))
12052
        if mapping_ is not None:
12053
            mapping_[id(self)] = element
12054
        return element
12055
    def build(self, node, gds_collector_=None):
12056
        self.gds_collector_ = gds_collector_
12057
        if SaveElementTreeNode:
12058
            self.gds_elementtree_node_ = node
12059
        already_processed = set()
12060
        self.ns_prefix_ = node.prefix
12061
        self.buildAttributes(node, node.attrib, already_processed)
12062
        for child in node:
12063
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
12064
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
12065
        return self
12066
    def buildAttributes(self, node, attrs, already_processed):
12067
        value = find_attr_value_('orientation', node)
12068
        if value is not None and 'orientation' not in already_processed:
12069
            already_processed.add('orientation')
12070
            value = self.gds_parse_float(value, node, 'orientation')
12071
            self.orientation = value
12072
        value = find_attr_value_('bgColour', node)
12073
        if value is not None and 'bgColour' not in already_processed:
12074
            already_processed.add('bgColour')
12075
            self.bgColour = value
12076
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
12077
        super(ChemRegionType, self).buildAttributes(node, attrs, already_processed)
12078
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
12079
        super(ChemRegionType, self).buildChildren(child_, node, nodeName_, True)
12080
        pass
12081
    def __hash__(self):
12082
        return hash(self.id)
12083
    def set_orientation(self, orientation):
12084
        """
12085
        Set deskewing angle to given `orientation` number.
12086
        Moreover, invalidate self's ``pc:AlternativeImage``s
12087
        (because they will have been rotated and enlarged
12088
        with the angle of the previous value).
12089
        """
12090
        if hasattr(self, 'invalidate_AlternativeImage'):
12091
            # PageType, RegionType:
12092
            self.invalidate_AlternativeImage(feature_selector='deskewed')
12093
        self.orientation = orientation
12094
# end class ChemRegionType
12095
12096
@@ 11667-11816 (lines=150) @@
11664
# end class AdvertRegionType
11665
11666
11667
class MusicRegionType(RegionType):
11668
    """Regions containing musical notations.
11669
    The angle the rectangle encapsulating a region
11670
    has to be rotated in clockwise direction
11671
    in order to correct the present skew
11672
    (negative values indicate anti-clockwise rotation).
11673
    Range: -179.999,180
11674
    The background colour of the region"""
11675
    __hash__ = GeneratedsSuper.__hash__
11676
    member_data_items_ = [
11677
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}),
11678
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}),
11679
    ]
11680
    subclass = None
11681
    superclass = RegionType
11682
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
11683
        self.gds_collector_ = gds_collector_
11684
        self.gds_elementtree_node_ = None
11685
        self.original_tagname_ = None
11686
        self.parent_object_ = kwargs_.get('parent_object_')
11687
        self.ns_prefix_ = None
11688
        super(MusicRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
11689
        self.orientation = _cast(float, orientation)
11690
        self.orientation_nsprefix_ = "pc"
11691
        self.bgColour = _cast(None, bgColour)
11692
        self.bgColour_nsprefix_ = "pc"
11693
    def factory(*args_, **kwargs_):
11694
        if CurrentSubclassModule_ is not None:
11695
            subclass = getSubclassFromModule_(
11696
                CurrentSubclassModule_, MusicRegionType)
11697
            if subclass is not None:
11698
                return subclass(*args_, **kwargs_)
11699
        if MusicRegionType.subclass:
11700
            return MusicRegionType.subclass(*args_, **kwargs_)
11701
        else:
11702
            return MusicRegionType(*args_, **kwargs_)
11703
    factory = staticmethod(factory)
11704
    def get_ns_prefix_(self):
11705
        return self.ns_prefix_
11706
    def set_ns_prefix_(self, ns_prefix):
11707
        self.ns_prefix_ = ns_prefix
11708
    def get_orientation(self):
11709
        return self.orientation
11710
    def set_orientation(self, orientation):
11711
        self.orientation = orientation
11712
    def get_bgColour(self):
11713
        return self.bgColour
11714
    def set_bgColour(self, bgColour):
11715
        self.bgColour = bgColour
11716
    def validate_ColourSimpleType(self, value):
11717
        # Validate type pc:ColourSimpleType, a restriction on string.
11718
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11719
            if not isinstance(value, str):
11720
                lineno = self.gds_get_node_lineno_()
11721
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11722
                return False
11723
            value = value
11724
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
11725
            if value not in enumerations:
11726
                lineno = self.gds_get_node_lineno_()
11727
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11728
                result = False
11729
    def hasContent_(self):
11730
        if (
11731
            super(MusicRegionType, self).hasContent_()
11732
        ):
11733
            return True
11734
        else:
11735
            return False
11736
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MusicRegionType', pretty_print=True):
11737
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('MusicRegionType')
11738
        if imported_ns_def_ is not None:
11739
            namespacedef_ = imported_ns_def_
11740
        if pretty_print:
11741
            eol_ = '\n'
11742
        else:
11743
            eol_ = ''
11744
        if self.original_tagname_ is not None and name_ == 'MusicRegionType':
11745
            name_ = self.original_tagname_
11746
        if UseCapturedNS_ and self.ns_prefix_:
11747
            namespaceprefix_ = self.ns_prefix_ + ':'
11748
        showIndent(outfile, level, pretty_print)
11749
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11750
        already_processed = set()
11751
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
11752
        if self.hasContent_():
11753
            outfile.write('>%s' % (eol_, ))
11754
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='MusicRegionType', pretty_print=pretty_print)
11755
            showIndent(outfile, level, pretty_print)
11756
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11757
        else:
11758
            outfile.write('/>%s' % (eol_, ))
11759
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='MusicRegionType'):
11760
        super(MusicRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='MusicRegionType')
11761
        if self.orientation is not None and 'orientation' not in already_processed:
11762
            already_processed.add('orientation')
11763
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
11764
        if self.bgColour is not None and 'bgColour' not in already_processed:
11765
            already_processed.add('bgColour')
11766
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
11767
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='MusicRegionType', fromsubclass_=False, pretty_print=True):
11768
        super(MusicRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11769
    def to_etree(self, parent_element=None, name_='MusicRegionType', mapping_=None, nsmap_=None):
11770
        element = super(MusicRegionType, self).to_etree(parent_element, name_, mapping_)
11771
        if self.orientation is not None:
11772
            element.set('orientation', self.gds_format_float(self.orientation))
11773
        if self.bgColour is not None:
11774
            element.set('bgColour', self.gds_format_string(self.bgColour))
11775
        if mapping_ is not None:
11776
            mapping_[id(self)] = element
11777
        return element
11778
    def build(self, node, gds_collector_=None):
11779
        self.gds_collector_ = gds_collector_
11780
        if SaveElementTreeNode:
11781
            self.gds_elementtree_node_ = node
11782
        already_processed = set()
11783
        self.ns_prefix_ = node.prefix
11784
        self.buildAttributes(node, node.attrib, already_processed)
11785
        for child in node:
11786
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11787
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11788
        return self
11789
    def buildAttributes(self, node, attrs, already_processed):
11790
        value = find_attr_value_('orientation', node)
11791
        if value is not None and 'orientation' not in already_processed:
11792
            already_processed.add('orientation')
11793
            value = self.gds_parse_float(value, node, 'orientation')
11794
            self.orientation = value
11795
        value = find_attr_value_('bgColour', node)
11796
        if value is not None and 'bgColour' not in already_processed:
11797
            already_processed.add('bgColour')
11798
            self.bgColour = value
11799
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
11800
        super(MusicRegionType, self).buildAttributes(node, attrs, already_processed)
11801
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11802
        super(MusicRegionType, self).buildChildren(child_, node, nodeName_, True)
11803
        pass
11804
    def __hash__(self):
11805
        return hash(self.id)
11806
    def set_orientation(self, orientation):
11807
        """
11808
        Set deskewing angle to given `orientation` number.
11809
        Moreover, invalidate self's ``pc:AlternativeImage``s
11810
        (because they will have been rotated and enlarged
11811
        with the angle of the previous value).
11812
        """
11813
        if hasattr(self, 'invalidate_AlternativeImage'):
11814
            # PageType, RegionType:
11815
            self.invalidate_AlternativeImage(feature_selector='deskewed')
11816
        self.orientation = orientation
11817
# end class MusicRegionType
11818
11819
@@ 11514-11663 (lines=150) @@
11511
# end class NoiseRegionType
11512
11513
11514
class AdvertRegionType(RegionType):
11515
    """Regions containing advertisements.
11516
    The angle the rectangle encapsulating a region
11517
    has to be rotated in clockwise direction
11518
    in order to correct the present skew
11519
    (negative values indicate anti-clockwise rotation).
11520
    Range: -179.999,180
11521
    The background colour of the region"""
11522
    __hash__ = GeneratedsSuper.__hash__
11523
    member_data_items_ = [
11524
        MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}),
11525
        MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}),
11526
    ]
11527
    subclass = None
11528
    superclass = RegionType
11529
    def __init__(self, id=None, custom=None, comments=None, continuation=None, AlternativeImage=None, Coords=None, UserDefined=None, Labels=None, Roles=None, TextRegion=None, ImageRegion=None, LineDrawingRegion=None, GraphicRegion=None, TableRegion=None, ChartRegion=None, SeparatorRegion=None, MathsRegion=None, ChemRegion=None, MusicRegion=None, AdvertRegion=None, NoiseRegion=None, UnknownRegion=None, CustomRegion=None, orientation=None, bgColour=None, gds_collector_=None, **kwargs_):
11530
        self.gds_collector_ = gds_collector_
11531
        self.gds_elementtree_node_ = None
11532
        self.original_tagname_ = None
11533
        self.parent_object_ = kwargs_.get('parent_object_')
11534
        self.ns_prefix_ = None
11535
        super(AdvertRegionType, self).__init__(id, custom, comments, continuation, AlternativeImage, Coords, UserDefined, Labels, Roles, TextRegion, ImageRegion, LineDrawingRegion, GraphicRegion, TableRegion, ChartRegion, SeparatorRegion, MathsRegion, ChemRegion, MusicRegion, AdvertRegion, NoiseRegion, UnknownRegion, CustomRegion,  **kwargs_)
11536
        self.orientation = _cast(float, orientation)
11537
        self.orientation_nsprefix_ = "pc"
11538
        self.bgColour = _cast(None, bgColour)
11539
        self.bgColour_nsprefix_ = "pc"
11540
    def factory(*args_, **kwargs_):
11541
        if CurrentSubclassModule_ is not None:
11542
            subclass = getSubclassFromModule_(
11543
                CurrentSubclassModule_, AdvertRegionType)
11544
            if subclass is not None:
11545
                return subclass(*args_, **kwargs_)
11546
        if AdvertRegionType.subclass:
11547
            return AdvertRegionType.subclass(*args_, **kwargs_)
11548
        else:
11549
            return AdvertRegionType(*args_, **kwargs_)
11550
    factory = staticmethod(factory)
11551
    def get_ns_prefix_(self):
11552
        return self.ns_prefix_
11553
    def set_ns_prefix_(self, ns_prefix):
11554
        self.ns_prefix_ = ns_prefix
11555
    def get_orientation(self):
11556
        return self.orientation
11557
    def set_orientation(self, orientation):
11558
        self.orientation = orientation
11559
    def get_bgColour(self):
11560
        return self.bgColour
11561
    def set_bgColour(self, bgColour):
11562
        self.bgColour = bgColour
11563
    def validate_ColourSimpleType(self, value):
11564
        # Validate type pc:ColourSimpleType, a restriction on string.
11565
        if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
11566
            if not isinstance(value, str):
11567
                lineno = self.gds_get_node_lineno_()
11568
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
11569
                return False
11570
            value = value
11571
            enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other']
11572
            if value not in enumerations:
11573
                lineno = self.gds_get_node_lineno_()
11574
                self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on ColourSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} )
11575
                result = False
11576
    def hasContent_(self):
11577
        if (
11578
            super(AdvertRegionType, self).hasContent_()
11579
        ):
11580
            return True
11581
        else:
11582
            return False
11583
    def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='AdvertRegionType', pretty_print=True):
11584
        imported_ns_def_ = GenerateDSNamespaceDefs_.get('AdvertRegionType')
11585
        if imported_ns_def_ is not None:
11586
            namespacedef_ = imported_ns_def_
11587
        if pretty_print:
11588
            eol_ = '\n'
11589
        else:
11590
            eol_ = ''
11591
        if self.original_tagname_ is not None and name_ == 'AdvertRegionType':
11592
            name_ = self.original_tagname_
11593
        if UseCapturedNS_ and self.ns_prefix_:
11594
            namespaceprefix_ = self.ns_prefix_ + ':'
11595
        showIndent(outfile, level, pretty_print)
11596
        outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
11597
        already_processed = set()
11598
        self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
11599
        if self.hasContent_():
11600
            outfile.write('>%s' % (eol_, ))
11601
            self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='AdvertRegionType', pretty_print=pretty_print)
11602
            showIndent(outfile, level, pretty_print)
11603
            outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
11604
        else:
11605
            outfile.write('/>%s' % (eol_, ))
11606
    def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='AdvertRegionType'):
11607
        super(AdvertRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='AdvertRegionType')
11608
        if self.orientation is not None and 'orientation' not in already_processed:
11609
            already_processed.add('orientation')
11610
            outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation'))
11611
        if self.bgColour is not None and 'bgColour' not in already_processed:
11612
            already_processed.add('bgColour')
11613
            outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), ))
11614
    def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='AdvertRegionType', fromsubclass_=False, pretty_print=True):
11615
        super(AdvertRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print)
11616
    def to_etree(self, parent_element=None, name_='AdvertRegionType', mapping_=None, nsmap_=None):
11617
        element = super(AdvertRegionType, self).to_etree(parent_element, name_, mapping_)
11618
        if self.orientation is not None:
11619
            element.set('orientation', self.gds_format_float(self.orientation))
11620
        if self.bgColour is not None:
11621
            element.set('bgColour', self.gds_format_string(self.bgColour))
11622
        if mapping_ is not None:
11623
            mapping_[id(self)] = element
11624
        return element
11625
    def build(self, node, gds_collector_=None):
11626
        self.gds_collector_ = gds_collector_
11627
        if SaveElementTreeNode:
11628
            self.gds_elementtree_node_ = node
11629
        already_processed = set()
11630
        self.ns_prefix_ = node.prefix
11631
        self.buildAttributes(node, node.attrib, already_processed)
11632
        for child in node:
11633
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
11634
            self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
11635
        return self
11636
    def buildAttributes(self, node, attrs, already_processed):
11637
        value = find_attr_value_('orientation', node)
11638
        if value is not None and 'orientation' not in already_processed:
11639
            already_processed.add('orientation')
11640
            value = self.gds_parse_float(value, node, 'orientation')
11641
            self.orientation = value
11642
        value = find_attr_value_('bgColour', node)
11643
        if value is not None and 'bgColour' not in already_processed:
11644
            already_processed.add('bgColour')
11645
            self.bgColour = value
11646
            self.validate_ColourSimpleType(self.bgColour)    # validate type ColourSimpleType
11647
        super(AdvertRegionType, self).buildAttributes(node, attrs, already_processed)
11648
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
11649
        super(AdvertRegionType, self).buildChildren(child_, node, nodeName_, True)
11650
        pass
11651
    def __hash__(self):
11652
        return hash(self.id)
11653
    def set_orientation(self, orientation):
11654
        """
11655
        Set deskewing angle to given `orientation` number.
11656
        Moreover, invalidate self's ``pc:AlternativeImage``s
11657
        (because they will have been rotated and enlarged
11658
        with the angle of the previous value).
11659
        """
11660
        if hasattr(self, 'invalidate_AlternativeImage'):
11661
            # PageType, RegionType:
11662
            self.invalidate_AlternativeImage(feature_selector='deskewed')
11663
        self.orientation = orientation
11664
# end class AdvertRegionType
11665
11666