summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/javafx-out.h
blob: 9c1c8778ba0489ab798a00e00fbcf126375bae45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * A simple utility for exporting an Inkscape svg image as a JavaFX
 * scene tree.
 *
 * Authors:
 *   Bob Jamison <ishmal@inkscape.org>
 *   Silveira Neto <silveiraneto@gmail.com>
 *   Jim Clarke <Jim.Clarke@sun.com>
 *
 * Copyright (C) 2008 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#ifndef EXTENSION_INTERNAL_JAVAFX_OUT_H
#define EXTENSION_INTERNAL_JAVAFX_OUT_H

#include <glib.h>
#include "extension/implementation/implementation.h"
#include <document.h>
#include <sp-gradient.h>

namespace Inkscape
{
namespace Extension
{
namespace Internal
{



/**
 * Output the current svg document in JavaFX format.
 * 
 * For information, @see:  
 * https://openjfx.dev.java.net/
 */ 
class JavaFXOutput : public Inkscape::Extension::Implementation::Implementation
{


public:

    /**
     * Our internal String definition
     */
    typedef Glib::ustring String;


    /**
     * Check whether we can actually output using this module
     */
	virtual bool check (Inkscape::Extension::Extension * module);

    /**
     * API call to perform the output to a file
     */
    virtual void save(Inkscape::Extension::Output *mod,
                      SPDocument *doc, gchar const *filename);

    /**
     * Inkscape runtime startup call.
     */
	static void init(void);
	
    /**
     * Reset variables to initial state
     */
	void reset();
	
private:

    //output class name
    String name;

    //For formatted output
	String outbuf;   //main output buffer
	String foutbuf;  //header function buffer


	/**
	 * Format text to our output buffer
	 */
	void out(const char *fmt, ...) G_GNUC_PRINTF(2,3);

	/**
	 * Format text to our function output buffer
	 */
	void fout(const char *fmt, ...) G_GNUC_PRINTF(2,3);

	//Output the parts of the file

    /**
     * Output the file header
     */
	bool doHeader();

    /**
     *  Output gradient information to the buffer
     */
    bool doGradient(SPGradient *grad, const String &id);

    /**
     *  Output an element's style attribute
     */
    bool doStyle(SPStyle *style);

    /**
     * Output the SVG document's curve data as JavaFX geometry types
     */
    bool doCurve(SPItem *item, const String &id);
    bool doTreeRecursive(SPDocument *doc, SPObject *obj);
    bool doTree(SPDocument *doc);

    bool doBody(SPDocument *doc, SPObject *obj);

    /**
     * Output the file footer
     */
	bool doTail();



    /**
     * Actual method to save document
     */
	bool saveDocument(SPDocument *doc, gchar const *filename);

    //For statistics
    int nrNodes;
    int nrShapes;
    
    int idindex;

    double minx;
    double miny;
    double maxx;
    double maxy;
    

};




}  // namespace Internal
}  // namespace Extension
}  // namespace Inkscape



#endif /* EXTENSION_INTERNAL_POV_OUT_H */