indexing description: "Objects that draw to an SVG STRING or file" keywords: SVG, Vision2, drawable, "vector graphics" author: "Colin Adams" copyright: "Copyright (c) Barr Rosenberg Reasearch Center LLC 2008" license: "GNU General Public License version 3 (see gpl-3.0.txt)" class SV_DRAWABLE inherit EV_DRAWABLE redefine implementation end create default_create feature -- Access svg_text (a_serializer: SV_XML_SERIALIZER): STRING is -- Generated SVG; -- Consider calling `optimize_svg_file_size' prior to calling this query. require a_serializer_not_void: a_serializer /= Void do Result := implementation.svg_text (a_serializer) ensure svg_text_not_void: Result /= Void svg_text_not_empty: not Result.is_empty end svg_prefix: STRING is -- Optional prefix for elements in SVG namespace do Result := implementation.svg_prefix end document: XM_DOCUMENT is -- Generated SVG; -- Consider calling `optimize_svg_file_size' prior to calling this query. do Result := implementation.document ensure document_not_void: Result /= Void end feature -- Measurement width: INTEGER_32 is -- Horizontal size in pixels. do Result := implementation.width end height: INTEGER_32 is -- Vertical size in pixels. do Result := implementation.height end feature -- Status report indenting: BOOLEAN is -- Will the serializer indent the XML? do Result := implementation.indenting end omitting_xml_declaration: BOOLEAN is -- Will the serializer omit the XML declaration? do Result := implementation.omitting_xml_declaration end wants_doctype: BOOLEAN is -- Does the user want a DOCTYPE to be emitted? do Result := implementation.wants_doctype end uses_default_aspect_ratio: BOOLEAN is -- Does the user want the "preserveAspectRatio" attribute to be omitted? do Result := implementation.uses_default_aspect_ratio end aspect_ratio: STRING is -- Value of "preserveAspectRatio" attribute to be generated; -- Only applicable if `uses_default_aspect_ratio' is `False'. -- If `Void', then a value of "none" is used. do Result := implementation.aspect_ratio end feature -- Setting set_svg_prefix (a_prefix: STRING) is -- Set prefix to use for SVG namespace. -- WARNING: call zero or one times, and do not call after `set_size' or any drawing operation. require a_prefix_not_void: a_prefix /= Void a_prefix_not_empty: not a_prefix.is_empty do implementation.set_svg_prefix (a_prefix) ensure svg_prefix_set: svg_prefix = a_prefix end set_size (a_width, a_height: INTEGER_32) is -- Set width to `a_width' and height to `a_height'. -- Must not be called after any drawing commands. require positive: a_width >= 0 and a_height >= 0 do implementation.set_size (a_width, a_height) ensure set: width = a_width and height = a_height end set_indenting (a_indenting: BOOLEAN) is -- Set `indenting' to `a_indenting'. do implementation.set_indenting (a_indenting) ensure indenting_set: indenting = a_indenting end set_omitting_xml_declaration (a_omitting: BOOLEAN) is -- Set `omitting_xml_declaration' to `a_omitting'. do implementation.set_omitting_xml_declaration (a_omitting) ensure omitting_xml_declaration_set: omitting_xml_declaration = a_omitting end set_wants_doctype (a_status: BOOLEAN) is -- Set `wants_doctype' to `a_status'. do implementation.set_wants_doctype (a_status) ensure wants_doctype_set: wants_doctype = a_status end use_default_aspect_ratio (a_status: BOOLEAN) is -- Do not generate a "preserveAspectRatio" attribute if `a_status' = `True'. -- By default, a preserveAspectRatio="none" attribute is generated. -- Useless if called after `set_size'. do implementation.use_default_aspect_ratio (a_status) ensure default_aspect_ratio_used: uses_default_aspect_ratio = a_status end set_aspect_ratio (a_aspect_ratio: STRING) is -- Generate a preserveAspectRatio="`a_aspect_ratio'" attribute. -- Useless if called after `set_size'. require a_aspect_ratio_not_void: a_aspect_ratio /= Void do implementation.set_aspect_ratio (a_aspect_ratio) ensure aspect_ratio_set: aspect_ratio = a_aspect_ratio default_aspect_ratio_not_used: not uses_default_aspect_ratio end feature -- Basic operations optimize_svg_file_size is -- Eliminate empty "g" elements, to minimize SVG file size. -- Best called (if at all) immediately prior to `svg_text'. do implementation.optimize_svg_file_size end save_to_named_file (a_file_name: FILE_NAME; a_serializer: SV_XML_SERIALIZER; a_compress: BOOLEAN) is -- Save `Current' to `a_file_name' with optional optimization of SVG file size. require a_serializer_not_void: a_serializer /= Void a_file_name_not_void: a_file_name /= Void do implementation.save_to_named_file (a_file_name, a_serializer, a_compress) end feature {EV_ANY} -- Implementation create_implementation is -- Create implementation. do create implementation.make (Current) end feature {EV_ANY, EV_ANY_I} -- Implementation implementation: SV_DRAWABLE_IMP -- Portable implementation end