|
@@ 13101-13292 (lines=192) @@
|
| 13098 |
|
# end class GraphicRegionType |
| 13099 |
|
|
| 13100 |
|
|
| 13101 |
|
class LineDrawingRegionType(RegionType): |
| 13102 |
|
"""A line drawing is a single colour illustration without |
| 13103 |
|
solid areas. |
| 13104 |
|
The angle the rectangle encapsulating a region |
| 13105 |
|
has to be rotated in clockwise direction |
| 13106 |
|
in order to correct the present skew |
| 13107 |
|
(negative values indicate anti-clockwise rotation). |
| 13108 |
|
Range: -179.999,180 |
| 13109 |
|
The pen (foreground) colour of the region |
| 13110 |
|
The background colour of the region |
| 13111 |
|
Specifies whether the region also contains |
| 13112 |
|
text""" |
| 13113 |
|
__hash__ = GeneratedsSuper.__hash__ |
| 13114 |
|
member_data_items_ = [ |
| 13115 |
|
MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), |
| 13116 |
|
MemberSpec_('penColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), |
| 13117 |
|
MemberSpec_('bgColour', 'pc:ColourSimpleType', 0, 1, {'use': 'optional'}), |
| 13118 |
|
MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), |
| 13119 |
|
] |
| 13120 |
|
subclass = None |
| 13121 |
|
superclass = RegionType |
| 13122 |
|
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_): |
| 13123 |
|
self.gds_collector_ = gds_collector_ |
| 13124 |
|
self.gds_elementtree_node_ = None |
| 13125 |
|
self.original_tagname_ = None |
| 13126 |
|
self.parent_object_ = kwargs_.get('parent_object_') |
| 13127 |
|
self.ns_prefix_ = None |
| 13128 |
|
super(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_) |
| 13129 |
|
self.orientation = _cast(float, orientation) |
| 13130 |
|
self.orientation_nsprefix_ = "pc" |
| 13131 |
|
self.penColour = _cast(None, penColour) |
| 13132 |
|
self.penColour_nsprefix_ = "pc" |
| 13133 |
|
self.bgColour = _cast(None, bgColour) |
| 13134 |
|
self.bgColour_nsprefix_ = "pc" |
| 13135 |
|
self.embText = _cast(bool, embText) |
| 13136 |
|
self.embText_nsprefix_ = "pc" |
| 13137 |
|
def factory(*args_, **kwargs_): |
| 13138 |
|
if CurrentSubclassModule_ is not None: |
| 13139 |
|
subclass = getSubclassFromModule_( |
| 13140 |
|
CurrentSubclassModule_, LineDrawingRegionType) |
| 13141 |
|
if subclass is not None: |
| 13142 |
|
return subclass(*args_, **kwargs_) |
| 13143 |
|
if LineDrawingRegionType.subclass: |
| 13144 |
|
return LineDrawingRegionType.subclass(*args_, **kwargs_) |
| 13145 |
|
else: |
| 13146 |
|
return LineDrawingRegionType(*args_, **kwargs_) |
| 13147 |
|
factory = staticmethod(factory) |
| 13148 |
|
def get_ns_prefix_(self): |
| 13149 |
|
return self.ns_prefix_ |
| 13150 |
|
def set_ns_prefix_(self, ns_prefix): |
| 13151 |
|
self.ns_prefix_ = ns_prefix |
| 13152 |
|
def get_orientation(self): |
| 13153 |
|
return self.orientation |
| 13154 |
|
def set_orientation(self, orientation): |
| 13155 |
|
self.orientation = orientation |
| 13156 |
|
def get_penColour(self): |
| 13157 |
|
return self.penColour |
| 13158 |
|
def set_penColour(self, penColour): |
| 13159 |
|
self.penColour = penColour |
| 13160 |
|
def get_bgColour(self): |
| 13161 |
|
return self.bgColour |
| 13162 |
|
def set_bgColour(self, bgColour): |
| 13163 |
|
self.bgColour = bgColour |
| 13164 |
|
def get_embText(self): |
| 13165 |
|
return self.embText |
| 13166 |
|
def set_embText(self, embText): |
| 13167 |
|
self.embText = embText |
| 13168 |
|
def validate_ColourSimpleType(self, value): |
| 13169 |
|
# Validate type pc:ColourSimpleType, a restriction on string. |
| 13170 |
|
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
| 13171 |
|
if not isinstance(value, str): |
| 13172 |
|
lineno = self.gds_get_node_lineno_() |
| 13173 |
|
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
| 13174 |
|
return False |
| 13175 |
|
value = value |
| 13176 |
|
enumerations = ['black', 'blue', 'brown', 'cyan', 'green', 'grey', 'indigo', 'magenta', 'orange', 'pink', 'red', 'turquoise', 'violet', 'white', 'yellow', 'other'] |
| 13177 |
|
if value not in enumerations: |
| 13178 |
|
lineno = self.gds_get_node_lineno_() |
| 13179 |
|
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} ) |
| 13180 |
|
result = False |
| 13181 |
|
def hasContent_(self): |
| 13182 |
|
if ( |
| 13183 |
|
super(LineDrawingRegionType, self).hasContent_() |
| 13184 |
|
): |
| 13185 |
|
return True |
| 13186 |
|
else: |
| 13187 |
|
return False |
| 13188 |
|
def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LineDrawingRegionType', pretty_print=True): |
| 13189 |
|
imported_ns_def_ = GenerateDSNamespaceDefs_.get('LineDrawingRegionType') |
| 13190 |
|
if imported_ns_def_ is not None: |
| 13191 |
|
namespacedef_ = imported_ns_def_ |
| 13192 |
|
if pretty_print: |
| 13193 |
|
eol_ = '\n' |
| 13194 |
|
else: |
| 13195 |
|
eol_ = '' |
| 13196 |
|
if self.original_tagname_ is not None and name_ == 'LineDrawingRegionType': |
| 13197 |
|
name_ = self.original_tagname_ |
| 13198 |
|
if UseCapturedNS_ and self.ns_prefix_: |
| 13199 |
|
namespaceprefix_ = self.ns_prefix_ + ':' |
| 13200 |
|
showIndent(outfile, level, pretty_print) |
| 13201 |
|
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
| 13202 |
|
already_processed = set() |
| 13203 |
|
self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType') |
| 13204 |
|
if self.hasContent_(): |
| 13205 |
|
outfile.write('>%s' % (eol_, )) |
| 13206 |
|
self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LineDrawingRegionType', pretty_print=pretty_print) |
| 13207 |
|
showIndent(outfile, level, pretty_print) |
| 13208 |
|
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
| 13209 |
|
else: |
| 13210 |
|
outfile.write('/>%s' % (eol_, )) |
| 13211 |
|
def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='LineDrawingRegionType'): |
| 13212 |
|
super(LineDrawingRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='LineDrawingRegionType') |
| 13213 |
|
if self.orientation is not None and 'orientation' not in already_processed: |
| 13214 |
|
already_processed.add('orientation') |
| 13215 |
|
outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
| 13216 |
|
if self.penColour is not None and 'penColour' not in already_processed: |
| 13217 |
|
already_processed.add('penColour') |
| 13218 |
|
outfile.write(' penColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.penColour), input_name='penColour')), )) |
| 13219 |
|
if self.bgColour is not None and 'bgColour' not in already_processed: |
| 13220 |
|
already_processed.add('bgColour') |
| 13221 |
|
outfile.write(' bgColour=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.bgColour), input_name='bgColour')), )) |
| 13222 |
|
if self.embText is not None and 'embText' not in already_processed: |
| 13223 |
|
already_processed.add('embText') |
| 13224 |
|
outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) |
| 13225 |
|
def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LineDrawingRegionType', fromsubclass_=False, pretty_print=True): |
| 13226 |
|
super(LineDrawingRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
| 13227 |
|
def to_etree(self, parent_element=None, name_='LineDrawingRegionType', mapping_=None, nsmap_=None): |
| 13228 |
|
element = super(LineDrawingRegionType, self).to_etree(parent_element, name_, mapping_) |
| 13229 |
|
if self.orientation is not None: |
| 13230 |
|
element.set('orientation', self.gds_format_float(self.orientation)) |
| 13231 |
|
if self.penColour is not None: |
| 13232 |
|
element.set('penColour', self.gds_format_string(self.penColour)) |
| 13233 |
|
if self.bgColour is not None: |
| 13234 |
|
element.set('bgColour', self.gds_format_string(self.bgColour)) |
| 13235 |
|
if self.embText is not None: |
| 13236 |
|
element.set('embText', self.gds_format_boolean(self.embText)) |
| 13237 |
|
if mapping_ is not None: |
| 13238 |
|
mapping_[id(self)] = element |
| 13239 |
|
return element |
| 13240 |
|
def build(self, node, gds_collector_=None): |
| 13241 |
|
self.gds_collector_ = gds_collector_ |
| 13242 |
|
if SaveElementTreeNode: |
| 13243 |
|
self.gds_elementtree_node_ = node |
| 13244 |
|
already_processed = set() |
| 13245 |
|
self.ns_prefix_ = node.prefix |
| 13246 |
|
self.buildAttributes(node, node.attrib, already_processed) |
| 13247 |
|
for child in node: |
| 13248 |
|
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
| 13249 |
|
self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
| 13250 |
|
return self |
| 13251 |
|
def buildAttributes(self, node, attrs, already_processed): |
| 13252 |
|
value = find_attr_value_('orientation', node) |
| 13253 |
|
if value is not None and 'orientation' not in already_processed: |
| 13254 |
|
already_processed.add('orientation') |
| 13255 |
|
value = self.gds_parse_float(value, node, 'orientation') |
| 13256 |
|
self.orientation = value |
| 13257 |
|
value = find_attr_value_('penColour', node) |
| 13258 |
|
if value is not None and 'penColour' not in already_processed: |
| 13259 |
|
already_processed.add('penColour') |
| 13260 |
|
self.penColour = value |
| 13261 |
|
self.validate_ColourSimpleType(self.penColour) # validate type ColourSimpleType |
| 13262 |
|
value = find_attr_value_('bgColour', node) |
| 13263 |
|
if value is not None and 'bgColour' not in already_processed: |
| 13264 |
|
already_processed.add('bgColour') |
| 13265 |
|
self.bgColour = value |
| 13266 |
|
self.validate_ColourSimpleType(self.bgColour) # validate type ColourSimpleType |
| 13267 |
|
value = find_attr_value_('embText', node) |
| 13268 |
|
if value is not None and 'embText' not in already_processed: |
| 13269 |
|
already_processed.add('embText') |
| 13270 |
|
if value in ('true', '1'): |
| 13271 |
|
self.embText = True |
| 13272 |
|
elif value in ('false', '0'): |
| 13273 |
|
self.embText = False |
| 13274 |
|
else: |
| 13275 |
|
raise_parse_error(node, 'Bad boolean attribute') |
| 13276 |
|
super(LineDrawingRegionType, self).buildAttributes(node, attrs, already_processed) |
| 13277 |
|
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
| 13278 |
|
super(LineDrawingRegionType, self).buildChildren(child_, node, nodeName_, True) |
| 13279 |
|
pass |
| 13280 |
|
def __hash__(self): |
| 13281 |
|
return hash(self.id) |
| 13282 |
|
def set_orientation(self, orientation): |
| 13283 |
|
""" |
| 13284 |
|
Set deskewing angle to given `orientation` number. |
| 13285 |
|
Moreover, invalidate self's ``pc:AlternativeImage``s |
| 13286 |
|
(because they will have been rotated and enlarged |
| 13287 |
|
with the angle of the previous value). |
| 13288 |
|
""" |
| 13289 |
|
if hasattr(self, 'invalidate_AlternativeImage'): |
| 13290 |
|
# PageType, RegionType: |
| 13291 |
|
self.invalidate_AlternativeImage(feature_selector='deskewed') |
| 13292 |
|
self.orientation = orientation |
| 13293 |
|
# end class LineDrawingRegionType |
| 13294 |
|
|
| 13295 |
|
|
|
@@ 12906-13097 (lines=192) @@
|
| 12903 |
|
# end class TableRegionType |
| 12904 |
|
|
| 12905 |
|
|
| 12906 |
|
class GraphicRegionType(RegionType): |
| 12907 |
|
"""Regions containing simple graphics, such as a company |
| 12908 |
|
logo, should be marked as graphic regions. |
| 12909 |
|
The angle the rectangle encapsulating a region |
| 12910 |
|
has to be rotated in clockwise direction |
| 12911 |
|
in order to correct the present skew |
| 12912 |
|
(negative values indicate anti-clockwise rotation). |
| 12913 |
|
Range: -179.999,180 |
| 12914 |
|
The type of graphic in the region |
| 12915 |
|
An approximation of the number of colours |
| 12916 |
|
used in the region |
| 12917 |
|
Specifies whether the region also contains |
| 12918 |
|
text.""" |
| 12919 |
|
__hash__ = GeneratedsSuper.__hash__ |
| 12920 |
|
member_data_items_ = [ |
| 12921 |
|
MemberSpec_('orientation', 'float', 0, 1, {'use': 'optional'}), |
| 12922 |
|
MemberSpec_('type_', 'pc:GraphicsTypeSimpleType', 0, 1, {'use': 'optional'}), |
| 12923 |
|
MemberSpec_('numColours', 'int', 0, 1, {'use': 'optional'}), |
| 12924 |
|
MemberSpec_('embText', 'boolean', 0, 1, {'use': 'optional'}), |
| 12925 |
|
] |
| 12926 |
|
subclass = None |
| 12927 |
|
superclass = RegionType |
| 12928 |
|
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_): |
| 12929 |
|
self.gds_collector_ = gds_collector_ |
| 12930 |
|
self.gds_elementtree_node_ = None |
| 12931 |
|
self.original_tagname_ = None |
| 12932 |
|
self.parent_object_ = kwargs_.get('parent_object_') |
| 12933 |
|
self.ns_prefix_ = None |
| 12934 |
|
super(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_) |
| 12935 |
|
self.orientation = _cast(float, orientation) |
| 12936 |
|
self.orientation_nsprefix_ = "pc" |
| 12937 |
|
self.type_ = _cast(None, type_) |
| 12938 |
|
self.type__nsprefix_ = "pc" |
| 12939 |
|
self.numColours = _cast(int, numColours) |
| 12940 |
|
self.numColours_nsprefix_ = "pc" |
| 12941 |
|
self.embText = _cast(bool, embText) |
| 12942 |
|
self.embText_nsprefix_ = "pc" |
| 12943 |
|
def factory(*args_, **kwargs_): |
| 12944 |
|
if CurrentSubclassModule_ is not None: |
| 12945 |
|
subclass = getSubclassFromModule_( |
| 12946 |
|
CurrentSubclassModule_, GraphicRegionType) |
| 12947 |
|
if subclass is not None: |
| 12948 |
|
return subclass(*args_, **kwargs_) |
| 12949 |
|
if GraphicRegionType.subclass: |
| 12950 |
|
return GraphicRegionType.subclass(*args_, **kwargs_) |
| 12951 |
|
else: |
| 12952 |
|
return GraphicRegionType(*args_, **kwargs_) |
| 12953 |
|
factory = staticmethod(factory) |
| 12954 |
|
def get_ns_prefix_(self): |
| 12955 |
|
return self.ns_prefix_ |
| 12956 |
|
def set_ns_prefix_(self, ns_prefix): |
| 12957 |
|
self.ns_prefix_ = ns_prefix |
| 12958 |
|
def get_orientation(self): |
| 12959 |
|
return self.orientation |
| 12960 |
|
def set_orientation(self, orientation): |
| 12961 |
|
self.orientation = orientation |
| 12962 |
|
def get_type(self): |
| 12963 |
|
return self.type_ |
| 12964 |
|
def set_type(self, type_): |
| 12965 |
|
self.type_ = type_ |
| 12966 |
|
def get_numColours(self): |
| 12967 |
|
return self.numColours |
| 12968 |
|
def set_numColours(self, numColours): |
| 12969 |
|
self.numColours = numColours |
| 12970 |
|
def get_embText(self): |
| 12971 |
|
return self.embText |
| 12972 |
|
def set_embText(self, embText): |
| 12973 |
|
self.embText = embText |
| 12974 |
|
def validate_GraphicsTypeSimpleType(self, value): |
| 12975 |
|
# Validate type pc:GraphicsTypeSimpleType, a restriction on string. |
| 12976 |
|
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None: |
| 12977 |
|
if not isinstance(value, str): |
| 12978 |
|
lineno = self.gds_get_node_lineno_() |
| 12979 |
|
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, }) |
| 12980 |
|
return False |
| 12981 |
|
value = value |
| 12982 |
|
enumerations = ['logo', 'letterhead', 'decoration', 'frame', 'handwritten-annotation', 'stamp', 'signature', 'barcode', 'paper-grow', 'punch-hole', 'other'] |
| 12983 |
|
if value not in enumerations: |
| 12984 |
|
lineno = self.gds_get_node_lineno_() |
| 12985 |
|
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} ) |
| 12986 |
|
result = False |
| 12987 |
|
def hasContent_(self): |
| 12988 |
|
if ( |
| 12989 |
|
super(GraphicRegionType, self).hasContent_() |
| 12990 |
|
): |
| 12991 |
|
return True |
| 12992 |
|
else: |
| 12993 |
|
return False |
| 12994 |
|
def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GraphicRegionType', pretty_print=True): |
| 12995 |
|
imported_ns_def_ = GenerateDSNamespaceDefs_.get('GraphicRegionType') |
| 12996 |
|
if imported_ns_def_ is not None: |
| 12997 |
|
namespacedef_ = imported_ns_def_ |
| 12998 |
|
if pretty_print: |
| 12999 |
|
eol_ = '\n' |
| 13000 |
|
else: |
| 13001 |
|
eol_ = '' |
| 13002 |
|
if self.original_tagname_ is not None and name_ == 'GraphicRegionType': |
| 13003 |
|
name_ = self.original_tagname_ |
| 13004 |
|
if UseCapturedNS_ and self.ns_prefix_: |
| 13005 |
|
namespaceprefix_ = self.ns_prefix_ + ':' |
| 13006 |
|
showIndent(outfile, level, pretty_print) |
| 13007 |
|
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) |
| 13008 |
|
already_processed = set() |
| 13009 |
|
self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType') |
| 13010 |
|
if self.hasContent_(): |
| 13011 |
|
outfile.write('>%s' % (eol_, )) |
| 13012 |
|
self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='GraphicRegionType', pretty_print=pretty_print) |
| 13013 |
|
showIndent(outfile, level, pretty_print) |
| 13014 |
|
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) |
| 13015 |
|
else: |
| 13016 |
|
outfile.write('/>%s' % (eol_, )) |
| 13017 |
|
def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GraphicRegionType'): |
| 13018 |
|
super(GraphicRegionType, self).exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GraphicRegionType') |
| 13019 |
|
if self.orientation is not None and 'orientation' not in already_processed: |
| 13020 |
|
already_processed.add('orientation') |
| 13021 |
|
outfile.write(' orientation="%s"' % self.gds_format_float(self.orientation, input_name='orientation')) |
| 13022 |
|
if self.type_ is not None and 'type_' not in already_processed: |
| 13023 |
|
already_processed.add('type_') |
| 13024 |
|
outfile.write(' type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.type_), input_name='type')), )) |
| 13025 |
|
if self.numColours is not None and 'numColours' not in already_processed: |
| 13026 |
|
already_processed.add('numColours') |
| 13027 |
|
outfile.write(' numColours="%s"' % self.gds_format_integer(self.numColours, input_name='numColours')) |
| 13028 |
|
if self.embText is not None and 'embText' not in already_processed: |
| 13029 |
|
already_processed.add('embText') |
| 13030 |
|
outfile.write(' embText="%s"' % self.gds_format_boolean(self.embText, input_name='embText')) |
| 13031 |
|
def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GraphicRegionType', fromsubclass_=False, pretty_print=True): |
| 13032 |
|
super(GraphicRegionType, self).exportChildren(outfile, level, namespaceprefix_, namespacedef_, name_, True, pretty_print=pretty_print) |
| 13033 |
|
def to_etree(self, parent_element=None, name_='GraphicRegionType', mapping_=None, nsmap_=None): |
| 13034 |
|
element = super(GraphicRegionType, self).to_etree(parent_element, name_, mapping_) |
| 13035 |
|
if self.orientation is not None: |
| 13036 |
|
element.set('orientation', self.gds_format_float(self.orientation)) |
| 13037 |
|
if self.type_ is not None: |
| 13038 |
|
element.set('type', self.gds_format_string(self.type_)) |
| 13039 |
|
if self.numColours is not None: |
| 13040 |
|
element.set('numColours', self.gds_format_integer(self.numColours)) |
| 13041 |
|
if self.embText is not None: |
| 13042 |
|
element.set('embText', self.gds_format_boolean(self.embText)) |
| 13043 |
|
if mapping_ is not None: |
| 13044 |
|
mapping_[id(self)] = element |
| 13045 |
|
return element |
| 13046 |
|
def build(self, node, gds_collector_=None): |
| 13047 |
|
self.gds_collector_ = gds_collector_ |
| 13048 |
|
if SaveElementTreeNode: |
| 13049 |
|
self.gds_elementtree_node_ = node |
| 13050 |
|
already_processed = set() |
| 13051 |
|
self.ns_prefix_ = node.prefix |
| 13052 |
|
self.buildAttributes(node, node.attrib, already_processed) |
| 13053 |
|
for child in node: |
| 13054 |
|
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] |
| 13055 |
|
self.buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) |
| 13056 |
|
return self |
| 13057 |
|
def buildAttributes(self, node, attrs, already_processed): |
| 13058 |
|
value = find_attr_value_('orientation', node) |
| 13059 |
|
if value is not None and 'orientation' not in already_processed: |
| 13060 |
|
already_processed.add('orientation') |
| 13061 |
|
value = self.gds_parse_float(value, node, 'orientation') |
| 13062 |
|
self.orientation = value |
| 13063 |
|
value = find_attr_value_('type', node) |
| 13064 |
|
if value is not None and 'type' not in already_processed: |
| 13065 |
|
already_processed.add('type') |
| 13066 |
|
self.type_ = value |
| 13067 |
|
self.validate_GraphicsTypeSimpleType(self.type_) # validate type GraphicsTypeSimpleType |
| 13068 |
|
value = find_attr_value_('numColours', node) |
| 13069 |
|
if value is not None and 'numColours' not in already_processed: |
| 13070 |
|
already_processed.add('numColours') |
| 13071 |
|
self.numColours = self.gds_parse_integer(value, node, 'numColours') |
| 13072 |
|
value = find_attr_value_('embText', node) |
| 13073 |
|
if value is not None and 'embText' not in already_processed: |
| 13074 |
|
already_processed.add('embText') |
| 13075 |
|
if value in ('true', '1'): |
| 13076 |
|
self.embText = True |
| 13077 |
|
elif value in ('false', '0'): |
| 13078 |
|
self.embText = False |
| 13079 |
|
else: |
| 13080 |
|
raise_parse_error(node, 'Bad boolean attribute') |
| 13081 |
|
super(GraphicRegionType, self).buildAttributes(node, attrs, already_processed) |
| 13082 |
|
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None): |
| 13083 |
|
super(GraphicRegionType, self).buildChildren(child_, node, nodeName_, True) |
| 13084 |
|
pass |
| 13085 |
|
def __hash__(self): |
| 13086 |
|
return hash(self.id) |
| 13087 |
|
def set_orientation(self, orientation): |
| 13088 |
|
""" |
| 13089 |
|
Set deskewing angle to given `orientation` number. |
| 13090 |
|
Moreover, invalidate self's ``pc:AlternativeImage``s |
| 13091 |
|
(because they will have been rotated and enlarged |
| 13092 |
|
with the angle of the previous value). |
| 13093 |
|
""" |
| 13094 |
|
if hasattr(self, 'invalidate_AlternativeImage'): |
| 13095 |
|
# PageType, RegionType: |
| 13096 |
|
self.invalidate_AlternativeImage(feature_selector='deskewed') |
| 13097 |
|
self.orientation = orientation |
| 13098 |
|
# end class GraphicRegionType |
| 13099 |
|
|
| 13100 |
|
|