2 VARNA is a tool for the automated drawing, visualization and annotation of the secondary structure of RNA, designed as a companion software for web servers and databases.
3 Copyright (C) 2008 Kevin Darty, Alain Denise and Yann Ponty.
4 electronic mail : Yann.Ponty@lri.fr
5 paper mail : LRI, bat 490 Université Paris-Sud 91405 Orsay Cedex France
7 This file is part of VARNA version 3.1.
8 VARNA version 3.1 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 VARNA version 3.1 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with VARNA version 3.1.
16 If not, see http://www.gnu.org/licenses.
18 package fr.orsay.lri.varna.models.export;
20 import java.awt.Color;
21 import java.awt.geom.Point2D;
22 import java.awt.geom.Rectangle2D;
23 import java.awt.geom.Point2D.Double;
24 import java.util.Hashtable;
26 import fr.orsay.lri.varna.models.rna.ModeleBP;
28 public class TikzExport extends SecStrDrawingProducer {
38 private String TikzHeader() {
39 return "\\documentclass[tikz,border=10pt]{standalone}\n"
40 +"\\usepackage{tikz,relsize}\n"
41 +"\\usetikzlibrary{positioning}\n"
42 +"\\begin{document}\n"
43 +"\\begin{tikzpicture}[inner sep=0, fill=none,draw=none,text=none,font={\\sf}]\n";
46 private String formatPoint(Point2D.Double p)
48 return formatPoint(p.x,p.y);
51 private String formatPoint(double x, double y)
53 return "("+(super.getScale()*x)+","+(super.getScale()*y)+")";
56 public String drawCircleS(Point2D.Double p, double radius, double thickness) {
57 return " \\draw[draw=currColor] "+formatPoint(p)+" circle ("+(radius*super.getScale())+");\n";
60 public String fillCircleS(Point2D.Double p, double radius,
61 double thickness, Color col) {
63 +" \\fill[fill=currColor] "+formatPoint(p)+" circle ("+(radius*super.getScale())+");\n";
67 public String drawLineS(Point2D.Double p0, Point2D.Double p1,
69 return " \\draw[draw=currColor] "+formatPoint(p0)+" -- "+formatPoint(p1)+";\n";
72 public String drawRectangleS(Point2D.Double p, Point2D.Double dims,
74 return " \\draw[draw=currColor] "+formatPoint(p)+" -- "+formatPoint(p.x+dims.x,p.y)+" -- "+formatPoint(p.x+dims.x,p.y+dims.y)+" -- "+formatPoint(p.x,p.y+dims.y)+" -- "+formatPoint(p)+";\n";
77 public String drawTextS(Point2D.Double p, String txt) {
78 return " \\node[text=currColor] at "+formatPoint(p)+" {"+txt+"};\n";
81 public String setFontS(int font, double size) {
83 _fontsize = 1.2 * size;
87 public String setColorS(Color col) {
89 return "\\definecolor{currColor}{rgb}{"+(((double)col.getRed())/255.)+","+(((double)col.getGreen())/255.)+","+(((double)col.getBlue())/255.)+"}\n";
92 public String footerS() {
93 return "\\end{tikzpicture}\n"
97 public String headerS(Rectangle2D.Double bb) {
102 public String drawArcS(Point2D.Double origine, double width, double height,
103 double startAngle, double endAngle) {
109 public String drawPolygonS(Double[] points, double thickness) {
110 if (points.length > 0) {
111 String result = "\\draw[draw=currColor] ";
112 for (int i = 0; i < points.length; i++) {
113 result += ""+formatPoint(points[i])+" -- ";
115 result += ""+formatPoint(points[0])+";";
123 public String fillPolygonS(Double[] points, Color col) {
124 if (points.length > 0) {
125 String result = "\\fill[fill=currColor] ";
126 for (int i = 0; i < points.length; i++) {
127 result += ""+formatPoint(points[i])+" -- ";
129 result += ""+formatPoint(points[0])+";";
130 return setColorS(col)
133 return setColorS(col);
138 public String drawBaseStartS(int index) {
143 public String drawBaseEndS(int index) {
148 public String drawBasePairStartS(int i, int j, ModeleBP bps) {
153 public String drawBasePairEndS(int index) {
158 public String drawBackboneStartS(int i, int j) {
163 public String drawBackboneEndS(int index) {