|
@@ 14216-14420 (lines=205) @@
|
| 14213 |
|
# end class GraphicRegionType |
| 14214 |
|
|
| 14215 |
|
|
| 14216 |
|
class LineDrawingRegionType(RegionType): |
| 14217 |
|
"""LineDrawingRegionType -- |
| 14218 |
|
A line drawing is a single colour illustration without |
| 14219 |
|
solid areas. |
| 14220 |
|
|
| 14221 |
|
* orientation -- |
| 14222 |
|
The angle the rectangle encapsulating a region |
| 14223 |
|
has to be rotated in clockwise direction |
| 14224 |
|
in order to correct the present skew |
| 14225 |
|
(negative values indicate anti-clockwise rotation). |
| 14226 |
|
Range: -179.999,180 |
| 14227 |
|
|
| 14228 |
|
* penColour -- |
| 14229 |
|
The pen (foreground) colour of the region |
| 14230 |
|
|
| 14231 |
|
* bgColour -- |
| 14232 |
|
The background colour of the region |
| 14233 |
|
|
| 14234 |
|
* embText -- |
| 14235 |
|
Specifies whether the region also contains |
| 14236 |
|
text |
| 14237 |
|
|
| 14238 |
|
""" |
| 14239 |
|
__hash__ = GeneratedsSuper.__hash__ |
| 14240 |
|
member_data_items_ = [ |
| 14241 |
|
MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
| 14242 |
|
MemberSpec_('penColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'penColour'}), |
| 14243 |
|
MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional', 'name': 'bgColour'}), |
| 14244 |
|
MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}), |
| 14245 |
|
] |
| 14246 |
|
subclass = None |
| 14247 |
|
superclass = RegionType |
| 14248 |
|
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, penColour=None, bgColour=None, embText=None, gds_collector_=None, **kwargs_): |
| 14249 |
|
self.gds_collector_ = gds_collector_ |
| 14250 |
|
self.gds_elementtree_node_ = None |
| 14251 |
|
self.original_tagname_ = None |
| 14252 |
|
self.parent_object_ = kwargs_.get('parent_object_') |
| 14253 |
|
self.ns_prefix_ = "pc" |
| 14254 |
|
super(globals().get("LineDrawingRegionType"), 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_) |
| 14255 |
|
self.orientation = _cast(float, orientation) |
| 14256 |
|
self.orientation_nsprefix_ = "pc" |
| 14257 |
|
self.penColour = _cast(None, penColour) |
| 14258 |
|
self.penColour_nsprefix_ = "pc" |
| 14259 |
|
self.bgColour = _cast(None, bgColour) |
| 14260 |
|
self.bgColour_nsprefix_ = "pc" |
| 14261 |
|
self.embText = _cast(bool, embText) |
| 14262 |
|
self.embText_nsprefix_ = "pc" |
| 14263 |
|
def factory(*args_, **kwargs_): |
| 14264 |
|
if CurrentSubclassModule_ is not None: |
| 14265 |
|
subclass = getSubclassFromModule_( |
| 14266 |
|
CurrentSubclassModule_, LineDrawingRegionType) |
| 14267 |
|
if subclass is not None: |
| 14268 |
|
return subclass(*args_, **kwargs_) |
| 14269 |
|
if LineDrawingRegionType.subclass: |
| 14270 |
|
return LineDrawingRegionType.subclass(*args_, **kwargs_) |
| 14271 |
|
else: |
| 14272 |
|
return LineDrawingRegionType(*args_, **kwargs_) |
| 14273 |
|
factory = staticmethod(factory) |
| 14274 |
|
def get_ns_prefix_(self): |
| 14275 |
|
return self.ns_prefix_ |
| 14276 |
|
def set_ns_prefix_(self, ns_prefix): |
| 14277 |
|
self.ns_prefix_ = ns_prefix |
| 14278 |
|
def get_orientation(self): |
| 14279 |
|
return self.orientation |
| 14280 |
|
def set_orientation(self, orientation): |
| 14281 |
|
self.orientation = orientation |
| 14282 |
|
def get_penColour(self): |
| 14283 |
|
return self.penColour |
| 14284 |
|
def set_penColour(self, penColour): |
| 14285 |
|
self.penColour = penColour |
| 14286 |
|
def get_bgColour(self): |
| 14287 |
|
return self.bgColour |
| 14288 |
|
def set_bgColour(self, bgColour): |
| 14289 |
|
self.bgColour = bgColour |
| 14290 |
|
def get_embText(self): |
| 14291 |
|
return self.embText |
| 14292 |
|
def set_embText(self, embText): |
| 14293 |
|
self.embText = embText |
| 14294 |
|
def validate_ColourSimpleType(self, value): |
| 14295 |
|
# Validate type pc:ColourSimpleType, a restriction on string. |
| 14296 |
|
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
| 14297 |
|
if not isinstance(value, str): |
| 14298 |
|
lineno = self.gds_get_node_lineno_() |
| 14299 |
|
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
| 14300 |
|
return False |
| 14301 |
|
value = value |
| 14302 |
|
enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
| 14303 |
|
if value not in enumerations: |
| 14304 |
|
lineno = self.gds_get_node_lineno_() |
| 14305 |
|
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} ) |
| 14306 |
|
result = False |
| 14307 |
|
def has__content(self): |
| 14308 |
|
if ( |
| 14309 |
|
super(LineDrawingRegionType, self).has__content() |
| 14310 |
|
): |
| 14311 |
|
return True |
| 14312 |
|
else: |
| 14313 |
|
return False |
| 14314 |
|
def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', pretty_print=True): |
| 14315 |
|
imported_ns_def_ = GenerateDSNamespaceDefs_.get('LineDrawingRegionType') |
| 14316 |
|
if imported_ns_def_ is not None: |
| 14317 |
|
namespacedef_ = imported_ns_def_ |
| 14318 |
|
if pretty_print: |
| 14319 |
|
eol_ = '\n' |
| 14320 |
|
else: |
| 14321 |
|
eol_ = '' |
| 14322 |
|
if self.original_tagname_ is not None and name_ == 'LineDrawingRegionType': |
| 14323 |
|
name_ = self.original_tagname_ |
| 14324 |
|
if UseCapturedNS_ and self.ns_prefix_: |
| 14325 |
|
namespaceprefix_ = self.ns_prefix_ + ':' |
| 14326 |
|
showIndent(outfile, level, pretty_print) |
| 14327 |
|
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
| 14328 |
|
already_processed = set() |
| 14329 |
|
self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType') |
| 14330 |
|
if self.has__content(): |
| 14331 |
|
outfile.write('>%s' % (eol_, )) |
| 14332 |
|
self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LineDrawingRegionType', pretty_print=pretty_print) |
| 14333 |
|
showIndent(outfile, level, pretty_print) |
| 14334 |
|
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
| 14335 |
|
else: |
| 14336 |
|
outfile.write('/>%s' % (eol_, )) |
| 14337 |
|
def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LineDrawingRegionType'): |
| 14338 |
|
super(LineDrawingRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType') |
| 14339 |
|
if self.orientation is not None and 'orientation' not in already_processed: |
| 14340 |
|
already_processed.add('orientation') |
| 14341 |
|
outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
| 14342 |
|
if self.penColour is not None and 'penColour' not in already_processed: |
| 14343 |
|
already_processed.add('penColour') |
| 14344 |
|
outfile.write(' penColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.penColour), input_name='penColour')), )) |
| 14345 |
|
if self.bgColour is not None and 'bgColour' not in already_processed: |
| 14346 |
|
already_processed.add('bgColour') |
| 14347 |
|
outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
| 14348 |
|
if self.embText is not None and 'embText' not in already_processed: |
| 14349 |
|
already_processed.add('embText') |
| 14350 |
|
outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) |
| 14351 |
|
def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True): |
| 14352 |
|
super(LineDrawingRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
| 14353 |
|
def to_etree(self, parent_element=None, name_='LineDrawingRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
| 14354 |
|
element = super(LineDrawingRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
| 14355 |
|
if self.orientation is not None: |
| 14356 |
|
element.set('orientation', self.gds_format_float(self.orientation)) |
| 14357 |
|
if self.penColour is not None: |
| 14358 |
|
element.set('penColour', self.gds_format_string(self.penColour)) |
| 14359 |
|
if self.bgColour is not None: |
| 14360 |
|
element.set('bgColour', self.gds_format_string(self.bgColour)) |
| 14361 |
|
if self.embText is not None: |
| 14362 |
|
element.set('embText', self.gds_format_boolean(self.embText)) |
| 14363 |
|
if mapping_ is not None: |
| 14364 |
|
mapping_[id(self)] = element |
| 14365 |
|
if reverse_mapping_ is not None: |
| 14366 |
|
reverse_mapping_[element] = self |
| 14367 |
|
return element |
| 14368 |
|
def build(self, node, gds_collector_=None): |
| 14369 |
|
self.gds_collector_ = gds_collector_ |
| 14370 |
|
if SaveElementTreeNode: |
| 14371 |
|
self.gds_elementtree_node_ = node |
| 14372 |
|
already_processed = set() |
| 14373 |
|
self.ns_prefix_ = node.prefix |
| 14374 |
|
self._buildAttributes(node, node.attrib, already_processed) |
| 14375 |
|
for child in node: |
| 14376 |
|
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
| 14377 |
|
self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
| 14378 |
|
return self |
| 14379 |
|
def _buildAttributes(self, node, attrs, already_processed): |
| 14380 |
|
value = find_attr_value_('orientation', node) |
| 14381 |
|
if value is not None and 'orientation' not in already_processed: |
| 14382 |
|
already_processed.add('orientation') |
| 14383 |
|
value = self.gds_parse_float(value, node, 'orientation') |
| 14384 |
|
self.orientation = value |
| 14385 |
|
value = find_attr_value_('penColour', node) |
| 14386 |
|
if value is not None and 'penColour' not in already_processed: |
| 14387 |
|
already_processed.add('penColour') |
| 14388 |
|
self.penColour = value |
| 14389 |
|
self.validate_ColourSimpleType(self.penColour) # validate type ColourSimpleType |
| 14390 |
|
value = find_attr_value_('bgColour', node) |
| 14391 |
|
if value is not None and 'bgColour' not in already_processed: |
| 14392 |
|
already_processed.add('bgColour') |
| 14393 |
|
self.bgColour = value |
| 14394 |
|
self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
| 14395 |
|
value = find_attr_value_('embText', node) |
| 14396 |
|
if value is not None and 'embText' not in already_processed: |
| 14397 |
|
already_processed.add('embText') |
| 14398 |
|
if value in ('true', '1'): |
| 14399 |
|
self.embText = True |
| 14400 |
|
elif value in ('false', '0'): |
| 14401 |
|
self.embText = False |
| 14402 |
|
else: |
| 14403 |
|
raise_parse_error(node, 'Bad boolean attribute') |
| 14404 |
|
super(LineDrawingRegionType, self)._buildAttributes(node, attrs, already_processed) |
| 14405 |
|
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
| 14406 |
|
super(LineDrawingRegionType, self)._buildChildren(child_, node, nodeName_, True) |
| 14407 |
|
pass |
| 14408 |
|
def __hash__(self): |
| 14409 |
|
return hash(self.id) |
| 14410 |
|
def set_orientation(self, orientation): |
| 14411 |
|
""" |
| 14412 |
|
Set deskewing angle to given `orientation` number. |
| 14413 |
|
Moreover, invalidate self's ``pc:AlternativeImage``s |
| 14414 |
|
(because they will have been rotated and enlarged |
| 14415 |
|
with the angle of the previous value). |
| 14416 |
|
""" |
| 14417 |
|
if hasattr(self, 'invalidate_AlternativeImage'): |
| 14418 |
|
# PageType, RegionType: |
| 14419 |
|
self.invalidate_AlternativeImage(feature_selector='deskewed') |
| 14420 |
|
self.orientation = orientation |
| 14421 |
|
# end class LineDrawingRegionType |
| 14422 |
|
|
| 14423 |
|
|
|
@@ 14008-14212 (lines=205) @@
|
| 14005 |
|
# end class TableRegionType |
| 14006 |
|
|
| 14007 |
|
|
| 14008 |
|
class GraphicRegionType(RegionType): |
| 14009 |
|
"""GraphicRegionType -- |
| 14010 |
|
Regions containing simple graphics, such as a company |
| 14011 |
|
logo, should be marked as graphic regions. |
| 14012 |
|
|
| 14013 |
|
* orientation -- |
| 14014 |
|
The angle the rectangle encapsulating a region |
| 14015 |
|
has to be rotated in clockwise direction |
| 14016 |
|
in order to correct the present skew |
| 14017 |
|
(negative values indicate anti-clockwise rotation). |
| 14018 |
|
Range: -179.999,180 |
| 14019 |
|
|
| 14020 |
|
* type -- |
| 14021 |
|
The type of graphic in the region |
| 14022 |
|
|
| 14023 |
|
* numColours -- |
| 14024 |
|
An approximation of the number of colours |
| 14025 |
|
used in the region |
| 14026 |
|
|
| 14027 |
|
* embText -- |
| 14028 |
|
Specifies whether the region also contains |
| 14029 |
|
text. |
| 14030 |
|
|
| 14031 |
|
""" |
| 14032 |
|
__hash__ = GeneratedsSuper.__hash__ |
| 14033 |
|
member_data_items_ = [ |
| 14034 |
|
MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional', 'name': 'orientation'}), |
| 14035 |
|
MemberSpec_('type_', 'pc:GraphicsTypeSimpleType', 0, 1, {'use': 'optional', 'name': 'type_'}), |
| 14036 |
|
MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional', 'name': 'numColours'}), |
| 14037 |
|
MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional', 'name': 'embText'}), |
| 14038 |
|
] |
| 14039 |
|
subclass = None |
| 14040 |
|
superclass = RegionType |
| 14041 |
|
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, type_=None, numColours=None, embText=None, gds_collector_=None, **kwargs_): |
| 14042 |
|
self.gds_collector_ = gds_collector_ |
| 14043 |
|
self.gds_elementtree_node_ = None |
| 14044 |
|
self.original_tagname_ = None |
| 14045 |
|
self.parent_object_ = kwargs_.get('parent_object_') |
| 14046 |
|
self.ns_prefix_ = "pc" |
| 14047 |
|
super(globals().get("GraphicRegionType"), 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_) |
| 14048 |
|
self.orientation = _cast(float, orientation) |
| 14049 |
|
self.orientation_nsprefix_ = "pc" |
| 14050 |
|
self.type_ = _cast(None, type_) |
| 14051 |
|
self.type__nsprefix_ = "pc" |
| 14052 |
|
self.numColours = _cast(int, numColours) |
| 14053 |
|
self.numColours_nsprefix_ = "pc" |
| 14054 |
|
self.embText = _cast(bool, embText) |
| 14055 |
|
self.embText_nsprefix_ = "pc" |
| 14056 |
|
def factory(*args_, **kwargs_): |
| 14057 |
|
if CurrentSubclassModule_ is not None: |
| 14058 |
|
subclass = getSubclassFromModule_( |
| 14059 |
|
CurrentSubclassModule_, GraphicRegionType) |
| 14060 |
|
if subclass is not None: |
| 14061 |
|
return subclass(*args_, **kwargs_) |
| 14062 |
|
if GraphicRegionType.subclass: |
| 14063 |
|
return GraphicRegionType.subclass(*args_, **kwargs_) |
| 14064 |
|
else: |
| 14065 |
|
return GraphicRegionType(*args_, **kwargs_) |
| 14066 |
|
factory = staticmethod(factory) |
| 14067 |
|
def get_ns_prefix_(self): |
| 14068 |
|
return self.ns_prefix_ |
| 14069 |
|
def set_ns_prefix_(self, ns_prefix): |
| 14070 |
|
self.ns_prefix_ = ns_prefix |
| 14071 |
|
def get_orientation(self): |
| 14072 |
|
return self.orientation |
| 14073 |
|
def set_orientation(self, orientation): |
| 14074 |
|
self.orientation = orientation |
| 14075 |
|
def get_type(self): |
| 14076 |
|
return self.type_ |
| 14077 |
|
def set_type(self, type_): |
| 14078 |
|
self.type_ = type_ |
| 14079 |
|
def get_numColours(self): |
| 14080 |
|
return self.numColours |
| 14081 |
|
def set_numColours(self, numColours): |
| 14082 |
|
self.numColours = numColours |
| 14083 |
|
def get_embText(self): |
| 14084 |
|
return self.embText |
| 14085 |
|
def set_embText(self, embText): |
| 14086 |
|
self.embText = embText |
| 14087 |
|
def validate_GraphicsTypeSimpleType(self, value): |
| 14088 |
|
# Validate type pc:GraphicsTypeSimpleType, a restriction on string. |
| 14089 |
|
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
| 14090 |
|
if not isinstance(value, str): |
| 14091 |
|
lineno = self.gds_get_node_lineno_() |
| 14092 |
|
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
| 14093 |
|
return False |
| 14094 |
|
value = value |
| 14095 |
|
enumerations = ['logo', 'letterhead', 'decoration', 'frame', 'handwritten-annotation', 'stamp', 'signature', 'barcode', 'paper-grow', 'punch-hole', 'other'] |
| 14096 |
|
if value not in enumerations: |
| 14097 |
|
lineno = self.gds_get_node_lineno_() |
| 14098 |
|
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd enumeration restriction on GraphicsTypeSimpleType' % {"value" : encode_str_2_3(value), "lineno": lineno} ) |
| 14099 |
|
result = False |
| 14100 |
|
def has__content(self): |
| 14101 |
|
if ( |
| 14102 |
|
super(GraphicRegionType, self).has__content() |
| 14103 |
|
): |
| 14104 |
|
return True |
| 14105 |
|
else: |
| 14106 |
|
return False |
| 14107 |
|
def export(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', pretty_print=True): |
| 14108 |
|
imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphicRegionType') |
| 14109 |
|
if imported_ns_def_ is not None: |
| 14110 |
|
namespacedef_ = imported_ns_def_ |
| 14111 |
|
if pretty_print: |
| 14112 |
|
eol_ = '\n' |
| 14113 |
|
else: |
| 14114 |
|
eol_ = '' |
| 14115 |
|
if self.original_tagname_ is not None and name_ == 'GraphicRegionType': |
| 14116 |
|
name_ = self.original_tagname_ |
| 14117 |
|
if UseCapturedNS_ and self.ns_prefix_: |
| 14118 |
|
namespaceprefix_ = self.ns_prefix_ + ':' |
| 14119 |
|
showIndent(outfile, level, pretty_print) |
| 14120 |
|
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
| 14121 |
|
already_processed = set() |
| 14122 |
|
self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType') |
| 14123 |
|
if self.has__content(): |
| 14124 |
|
outfile.write('>%s' % (eol_, )) |
| 14125 |
|
self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphicRegionType', pretty_print=pretty_print) |
| 14126 |
|
showIndent(outfile, level, pretty_print) |
| 14127 |
|
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
| 14128 |
|
else: |
| 14129 |
|
outfile.write('/>%s' % (eol_, )) |
| 14130 |
|
def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphicRegionType'): |
| 14131 |
|
super(GraphicRegionType, self)._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType') |
| 14132 |
|
if self.orientation is not None and 'orientation' not in already_processed: |
| 14133 |
|
already_processed.add('orientation') |
| 14134 |
|
outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
| 14135 |
|
if self.type_ is not None and 'type_' not in already_processed: |
| 14136 |
|
already_processed.add('type_') |
| 14137 |
|
outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) |
| 14138 |
|
if self.numColours is not None and 'numColours' not in already_processed: |
| 14139 |
|
already_processed.add('numColours') |
| 14140 |
|
outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours')) |
| 14141 |
|
if self.embText is not None and 'embText' not in already_processed: |
| 14142 |
|
already_processed.add('embText') |
| 14143 |
|
outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) |
| 14144 |
|
def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15"', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True): |
| 14145 |
|
super(GraphicRegionType, self)._exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
| 14146 |
|
def to_etree(self, parent_element=None, name_='GraphicRegionType', mapping_=None, reverse_mapping_=None, nsmap_=None): |
| 14147 |
|
element = super(GraphicRegionType, self).to_etree(parent_element, name_, mapping_, reverse_mapping_, nsmap_) |
| 14148 |
|
if self.orientation is not None: |
| 14149 |
|
element.set('orientation', self.gds_format_float(self.orientation)) |
| 14150 |
|
if self.type_ is not None: |
| 14151 |
|
element.set('type', self.gds_format_string(self.type_)) |
| 14152 |
|
if self.numColours is not None: |
| 14153 |
|
element.set('numColours', self.gds_format_integer(self.numColours)) |
| 14154 |
|
if self.embText is not None: |
| 14155 |
|
element.set('embText', self.gds_format_boolean(self.embText)) |
| 14156 |
|
if mapping_ is not None: |
| 14157 |
|
mapping_[id(self)] = element |
| 14158 |
|
if reverse_mapping_ is not None: |
| 14159 |
|
reverse_mapping_[element] = self |
| 14160 |
|
return element |
| 14161 |
|
def build(self, node, gds_collector_=None): |
| 14162 |
|
self.gds_collector_ = gds_collector_ |
| 14163 |
|
if SaveElementTreeNode: |
| 14164 |
|
self.gds_elementtree_node_ = node |
| 14165 |
|
already_processed = set() |
| 14166 |
|
self.ns_prefix_ = node.prefix |
| 14167 |
|
self._buildAttributes(node, node.attrib, already_processed) |
| 14168 |
|
for child in node: |
| 14169 |
|
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
| 14170 |
|
self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
| 14171 |
|
return self |
| 14172 |
|
def _buildAttributes(self, node, attrs, already_processed): |
| 14173 |
|
value = find_attr_value_('orientation', node) |
| 14174 |
|
if value is not None and 'orientation' not in already_processed: |
| 14175 |
|
already_processed.add('orientation') |
| 14176 |
|
value = self.gds_parse_float(value, node, 'orientation') |
| 14177 |
|
self.orientation = value |
| 14178 |
|
value = find_attr_value_('type', node) |
| 14179 |
|
if value is not None and 'type' not in already_processed: |
| 14180 |
|
already_processed.add('type') |
| 14181 |
|
self.type_ = value |
| 14182 |
|
self.validate_GraphicsTypeSimpleType(self.type_) # validate type GraphicsTypeSimpleType |
| 14183 |
|
value = find_attr_value_('numColours', node) |
| 14184 |
|
if value is not None and 'numColours' not in already_processed: |
| 14185 |
|
already_processed.add('numColours') |
| 14186 |
|
self.numColours = self.gds_parse_integer(value, node, 'numColours') |
| 14187 |
|
value = find_attr_value_('embText', node) |
| 14188 |
|
if value is not None and 'embText' not in already_processed: |
| 14189 |
|
already_processed.add('embText') |
| 14190 |
|
if value in ('true', '1'): |
| 14191 |
|
self.embText = True |
| 14192 |
|
elif value in ('false', '0'): |
| 14193 |
|
self.embText = False |
| 14194 |
|
else: |
| 14195 |
|
raise_parse_error(node, 'Bad boolean attribute') |
| 14196 |
|
super(GraphicRegionType, self)._buildAttributes(node, attrs, already_processed) |
| 14197 |
|
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
| 14198 |
|
super(GraphicRegionType, self)._buildChildren(child_, node, nodeName_, True) |
| 14199 |
|
pass |
| 14200 |
|
def __hash__(self): |
| 14201 |
|
return hash(self.id) |
| 14202 |
|
def set_orientation(self, orientation): |
| 14203 |
|
""" |
| 14204 |
|
Set deskewing angle to given `orientation` number. |
| 14205 |
|
Moreover, invalidate self's ``pc:AlternativeImage``s |
| 14206 |
|
(because they will have been rotated and enlarged |
| 14207 |
|
with the angle of the previous value). |
| 14208 |
|
""" |
| 14209 |
|
if hasattr(self, 'invalidate_AlternativeImage'): |
| 14210 |
|
# PageType, RegionType: |
| 14211 |
|
self.invalidate_AlternativeImage(feature_selector='deskewed') |
| 14212 |
|
self.orientation = orientation |
| 14213 |
|
# end class GraphicRegionType |
| 14214 |
|
|
| 14215 |
|
|