1 /*
2 * A simple utility for exporting an Inkscape svg image as a JavaFX
3 * scene tree.
4 *
5 * Authors:
6 * Bob Jamison <ishmal@inkscape.org>
7 * Silveira Neto <silveiraneto@gmail.com>
8 * Jim Clarke <Jim.Clarke@sun.com>
9 *
10 * Copyright (C) 2008 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #ifndef EXTENSION_INTERNAL_JAVAFX_OUT_H
16 #define EXTENSION_INTERNAL_JAVAFX_OUT_H
18 #include <glib.h>
19 #include "extension/implementation/implementation.h"
20 #include <document.h>
21 #include <sp-gradient.h>
23 namespace Inkscape
24 {
25 namespace Extension
26 {
27 namespace Internal
28 {
32 /**
33 * Output the current svg document in JavaFX format.
34 *
35 * For information, @see:
36 * https://openjfx.dev.java.net/
37 */
38 class JavaFXOutput : public Inkscape::Extension::Implementation::Implementation
39 {
42 public:
44 /**
45 * Our internal String definition
46 */
47 typedef Glib::ustring String;
50 /**
51 * Check whether we can actually output using this module
52 */
53 virtual bool check (Inkscape::Extension::Extension * module);
55 /**
56 * API call to perform the output to a file
57 */
58 virtual void save(Inkscape::Extension::Output *mod,
59 SPDocument *doc, gchar const *filename);
61 /**
62 * Inkscape runtime startup call.
63 */
64 static void init(void);
66 /**
67 * Reset variables to initial state
68 */
69 void reset();
71 private:
73 //output class name
74 String name;
76 //For formatted output
77 String outbuf; //main output buffer
78 String foutbuf; //header function buffer
81 /**
82 * Format text to our output buffer
83 */
84 void out(const char *fmt, ...) G_GNUC_PRINTF(2,3);
86 /**
87 * Format text to our function output buffer
88 */
89 void fout(const char *fmt, ...) G_GNUC_PRINTF(2,3);
91 //Output the parts of the file
93 /**
94 * Output the file header
95 */
96 bool doHeader();
98 /**
99 * Output gradient information to the buffer
100 */
101 bool doGradient(SPGradient *grad, const String &id);
103 /**
104 * Output an element's style attribute
105 */
106 bool doStyle(SPStyle *style);
108 /**
109 * Output the SVG document's curve data as JavaFX geometry types
110 */
111 bool doCurve(SPItem *item, const String &id);
112 bool doTreeRecursive(SPDocument *doc, SPObject *obj);
113 bool doTree(SPDocument *doc);
115 bool doBody(SPDocument *doc, SPObject *obj);
117 /**
118 * Output the file footer
119 */
120 bool doTail();
124 /**
125 * Actual method to save document
126 */
127 bool saveDocument(SPDocument *doc, gchar const *filename);
129 //For statistics
130 int nrNodes;
131 int nrShapes;
133 int idindex;
135 double minx;
136 double miny;
137 double maxx;
138 double maxy;
141 };
146 } // namespace Internal
147 } // namespace Extension
148 } // namespace Inkscape
152 #endif /* EXTENSION_INTERNAL_POV_OUT_H */