|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
JTikZ: A Drop-in Replacement for Java's AWT Graphics Library that Renders TikZDear all,
I often write simulations in Java, usually including some visualizations. I often want to use some of these visualizations as figures in my papers. Using screenshots is obviously not desirable since that would produce a raster image when the original was vector. Therefore, over the weekend I wrote a small Java library that extends off of java.awt.Graphics2D. My class, called TikzGraphics2D, can be passed to any window's paint() function and will output human readable TikZ/PGF code that can be cut/pasted into a document. It's still in the early stages of development, but it currently supports lines, shapes/polygons, ellipses, colors, alpha, arcs, curves/splines, and text. Here's an example: public void paint(Graphics g) { g.drawOval(3, 10, 5, 30); g.setColor(Color.RED); g.drawLine(1, 2, 3, 4); g.setColor(Color.BLUE); g.drawString("This is a test!",3, 10); g.setColor(new Color(128, 128, 255, 128)); g.fillArc(5, 11, 30, 30, 120, 90); } produces: \definecolor{color0}{rgb}{1.0,0.0,0.0} \definecolor{color1}{rgb}{0.0,0.0,1.0} \definecolor{color2}{rgb}{0.5,0.5,1.0} \begin{tikzpicture}[yscale=-1] \draw (5.5px, 25.0px) ellipse (2.5px and 15.0px); \draw[color0] (1px, 2px) -- (3px, 4px); \node[anchor=south west,text=color1] at (3.0px, 10.0px) {This is a test!}; \fill[color2,opacity=0.5] (20.0px, 26.0px) -- (12.5px, 13.0px) arc (-120:-210:15.0px and 15.0px) -- cycle; \end{tikzpicture} I figured that this might be useful to others, so I started a sourceforge project: http://jtikz.sourceforge.net/ You can download and compile the code as follows: $ svn co https://jtikz.svn.sourceforge.net/svnroot/jtikz jtikz $ cd tikz $ ant jar $ java -jar lib/example.jar I don't think it would take very much effort to make this library fully featured and mature. If and when it gets to that state, it would not be very hard for someone to use it to write a Java-based WYSIWYG TikZ editor. Please let me know if you have any comments/suggestions or if you are interested in contributing to the project. Thanks! - Evan Sultanik PhD Candidate Department of Computer Science Drexel University http://www.cs.drexel.edu/~eas28/ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: JTikZ: A Drop-in Replacement for Java's AWT Graphics Library that Renders TikZOn Mon, Oct 19, 2009 at 4:05 PM, Evan Sultanik <evan@...> wrote:
> Dear all, > > I often write simulations in Java, usually including some > visualizations. I often want to use some of these visualizations as > figures in my papers. Using screenshots is obviously not desirable > since that would produce a raster image when the original was vector. > > Therefore, over the weekend I wrote a small Java library that extends > off of java.awt.Graphics2D. My class, called TikzGraphics2D, can be > passed to any window's paint() function and will output human readable > TikZ/PGF code that can be cut/pasted into a document. > > It's still in the early stages of development, but it currently > supports lines, shapes/polygons, ellipses, colors, alpha, arcs, > curves/splines, and text. > Thanks for sharing Evan. I'm not a Java user, but I like the idea. Potentially very useful, especially when used together with plotting tools, map applications etc. > Here's an example: > > public void paint(Graphics g) { > g.drawOval(3, 10, 5, 30); > g.setColor(Color.RED); > g.drawLine(1, 2, 3, 4); > g.setColor(Color.BLUE); > g.drawString("This is a test!",3, 10); > g.setColor(new Color(128, 128, 255, 128)); > g.fillArc(5, 11, 30, 30, 120, 90); > } > > produces: > > \definecolor{color0}{rgb}{1.0,0.0,0.0} > \definecolor{color1}{rgb}{0.0,0.0,1.0} > \definecolor{color2}{rgb}{0.5,0.5,1.0} > \begin{tikzpicture}[yscale=-1] > \draw (5.5px, 25.0px) ellipse (2.5px and 15.0px); > \draw[color0] (1px, 2px) -- (3px, 4px); > \node[anchor=south west,text=color1] at (3.0px, 10.0px) {This > is a test!}; > \fill[color2,opacity=0.5] (20.0px, 26.0px) -- (12.5px, 13.0px) > arc (-120:-210:15.0px and 15.0px) -- cycle; > \end{tikzpicture} > Is px a valid TeX dimension? > I figured that this might be useful to others, so I started a > sourceforge project: > > http://jtikz.sourceforge.net/ > > You can download and compile the code as follows: > > $ svn co https://jtikz.svn.sourceforge.net/svnroot/jtikz jtikz > $ cd tikz > $ ant jar > $ java -jar lib/example.jar > > I don't think it would take very much effort to make this library > fully featured and mature. If and when it gets to that state, it > would not be very hard for someone to use it to write a Java-based > WYSIWYG TikZ editor. > > Please let me know if you have any comments/suggestions or if you are > interested in contributing to the project. > If you venture into the Python world, the Matplotlib[1] project could use a TikZ backend :) [1] http://matplotlib.sourceforge.net/ Best regards, Kjell Magne Fauske ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |