summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84c065b)
raw | patch | inline | side by side (parent: 84c065b)
author | ishmal <ishmal@users.sourceforge.net> | |
Wed, 30 Jul 2008 20:42:16 +0000 (20:42 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Wed, 30 Jul 2008 20:42:16 +0000 (20:42 +0000) |
src/extension/internal/javafx-out.cpp | patch | blob | history | |
src/extension/internal/javafx-out.h | patch | blob | history |
index 8ca1298fb47a0b0e6f5768f2860a8d06d1e9ea91..d521c34472d26b02ab848db3891cfa6996bf22b4 100644 (file)
/**\r
* Output the file header\r
*/\r
-bool JavaFXOutput::doHeader(gchar const *uri)\r
+bool JavaFXOutput::doHeader(const String &name)\r
{\r
time_t tim = time(NULL);\r
out("/*###################################################################\n");\r
out("import javafx.ui.UIElement;\n");\r
out("import javafx.ui.*;\n");\r
out("import javafx.ui.canvas.*;\n");\r
- out("\n");\r
- out("public class %s extends CompositeNode {\n", uri);\r
- out("\n");\r
- out("\n\n\n");\r
+ out("\n\n");\r
+ out("public class %s extends CompositeNode {\n", name.c_str());\r
+ out("}\n");\r
+ out("\n\n");\r
return true;\r
}\r
\r
/**\r
* Output the file footer\r
*/\r
-bool JavaFXOutput::doTail(gchar const *uri)\r
+bool JavaFXOutput::doTail(const String &name)\r
{\r
- out("} // end class $s\n", uri);\r
- out("\n\n");\r
+ out("\n\n\n\n");\r
out("/*###################################################################\n");\r
- out("### E N D F I L E\n");\r
+ out("### E N D C L A S S %s\n", name.c_str());\r
out("###################################################################*/\n");\r
out("\n\n");\r
return true;\r
/**\r
* Output the curve data to buffer\r
*/\r
-bool JavaFXOutput::doCurves(SPDocument *doc, gchar const *uri)\r
+bool JavaFXOutput::doCurves(SPDocument *doc, const String &name)\r
{\r
using Geom::X;\r
using Geom::Y;\r
if (results.size() == 0)\r
return true;\r
\r
- out("function composeNode()\n");\r
- out("{\n");\r
+ out("function %s.composeNode() =\n", name.c_str());\r
out("Group\n");\r
out(" {\n");\r
out(" content:\n");\r
out(" ###################################################*/\n");\r
out(" Path \n");\r
out(" {\n");\r
- out(" name : \"%s\"\n", id.c_str());\r
+ out(" id : \"%s\"\n", id.c_str());\r
\r
- //Try to get the fill color of the shape\r
+ /**\r
+ * Get the fill and stroke of the shape\r
+ */\r
SPStyle *style = SP_OBJECT_STYLE(shape);\r
- /* fixme: Handle other fill types, even if this means translating gradients to a single\r
- flat colour. */\r
- if (style && (style->fill.isColor()))\r
+ if (style)\r
{\r
- // see color.h for how to parse SPColor\r
- gint alpha = 0xffffffff;\r
- guint32 rgba = style->fill.value.color.toRGBA32(alpha);\r
- unsigned int r = SP_RGBA32_R_U(rgba);\r
- unsigned int g = SP_RGBA32_G_U(rgba);\r
- unsigned int b = SP_RGBA32_B_U(rgba);\r
- unsigned int a = SP_RGBA32_A_U(rgba);\r
- out(" fill: rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",\r
+ /**\r
+ * Fill\r
+ */\r
+ if (style->fill.isColor())\r
+ {\r
+ // see color.h for how to parse SPColor\r
+ gint alpha = 0xffffffff;\r
+ guint32 rgba = style->fill.value.color.toRGBA32(alpha);\r
+ unsigned int r = SP_RGBA32_R_U(rgba);\r
+ unsigned int g = SP_RGBA32_G_U(rgba);\r
+ unsigned int b = SP_RGBA32_B_U(rgba);\r
+ unsigned int a = SP_RGBA32_A_U(rgba);\r
+ out(" fill: rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",\r
r, g, b, a);\r
+ }\r
+ /**\r
+ * Stroke\r
+ */\r
+ /**\r
+ * TODO: stroke code here\r
+ */\r
}\r
\r
\r
out(" d :\n");\r
out(" [\n");\r
\r
- int segmentNr = 0;\r
+ unsigned int segmentNr = 0;\r
\r
nrSegments += segmentCount;\r
\r
}\r
\r
out(" ] // d\n");\r
- out(" } // Path\n");\r
+ out(" }, // Path\n");\r
\r
\r
out(" /*###################################################\n");\r
}//for\r
\r
out(" ] // content\n");\r
- out(" } // Group\n");\r
- out("} // function composeNode()\n");\r
+ out(" }; // Group\n");\r
+ out("// end function %s.composeNode()\n", name.c_str());\r
\r
return true;\r
\r
{\r
reset();\r
\r
+\r
+ String name = Glib::path_get_basename(uri);\r
+ int pos = name.find('.');\r
+ if (pos > 0)\r
+ name = name.substr(0, pos);\r
+\r
+\r
//###### SAVE IN POV FORMAT TO BUFFER\r
//# Lets do the curves first, to get the stats\r
- if (!doCurves(doc, uri))\r
+ \r
+ if (!doCurves(doc, name))\r
return false;\r
String curveBuf = outbuf;\r
outbuf.clear();\r
\r
- if (!doHeader(uri))\r
+ if (!doHeader(name))\r
return false;\r
\r
outbuf.append(curveBuf);\r
\r
- if (!doTail(uri))\r
+ if (!doTail(name))\r
return false;\r
\r
\r
index 6f2dbd4a796e5b8cb84bebfff50e44e8cb44f1a1..471d021d633922279a9f54cfaa5a6ef3729a4e1b 100644 (file)
/**\r
* Output the file header\r
*/\r
- bool doHeader(gchar const *uri);\r
+ bool doHeader(const String &name);\r
\r
/**\r
* Output the SVG document's curve data as POV curves\r
*/\r
- bool doCurves(SPDocument *doc, gchar const *uri);\r
+ bool doCurves(SPDocument *doc, const String &name);\r
\r
/**\r
* Output the file footer\r
*/\r
- bool doTail(gchar const *uri);\r
+ bool doTail(const String &name);\r
\r
\r
\r