/* 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. Copyright (C) 2008 Kevin Darty, Alain Denise and Yann Ponty. electronic mail : Yann.Ponty@lri.fr paper mail : LRI, bat 490 Université Paris-Sud 91405 Orsay Cedex France This file is part of VARNA version 3.1. VARNA version 3.1 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. VARNA version 3.1 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with VARNA version 3.1. If not, see http://www.gnu.org/licenses. */ package fr.orsay.lri.varna.models.export; import java.awt.Color; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.Point2D.Double; import fr.orsay.lri.varna.models.rna.ModeleBP; public class SVGExport extends SecStrDrawingProducer { private double _fontsize = 10.0; private Rectangle2D.Double _bb = new Rectangle2D.Double(0, 0, 10, 10); double _thickness = 2.0; public SVGExport() { super(); super.setScale(0.5); } private String getRGBString(Color col) { int rpc = (int) ((((double) col.getRed()) / 255.0) * 100); int gpc = (int) ((((double) col.getGreen()) / 255.0) * 100); int bpc = (int) ((((double) col.getBlue()) / 255.0) * 100); return "rgb(" + rpc + "%, " + gpc + "%, " + bpc + "%)"; } public String drawCircleS(Point2D.Double base, double radius, double thickness) { _thickness = thickness; return "\n"; } public String drawLineS(Point2D.Double orig, Point2D.Double dest, double thickness) { _thickness = thickness; return "\n"; } public String drawRectangleS(Point2D.Double orig, Point2D.Double dims, double thickness) { _thickness = thickness; return ""; } public String drawTextS(Point2D.Double base, String txt) { //System.out.println(txt); return "" + txt + "\n"; } public String fillCircleS(Point2D.Double base, double radius, double thickness, Color col) { _thickness = thickness; return "\n"; } public String footerS() { return "\n"; } public String headerS(Rectangle2D.Double bb) { _bb = bb; return "\n" + "\n" + "\n" + "\n"; } public String setFontS(int font, double size) { _fontsize = 0.5 * size; return ""; } private Point2D.Double polarToCartesian(Point2D.Double center, double radiusX, double radiusY, double angleInDegrees) { double angleInRadians = (angleInDegrees) * Math.PI / 180.0; return new Point2D.Double(center.x + (radiusX * Math.cos(angleInRadians)), _bb.height - (center.y + (radiusY * Math.sin(angleInRadians)))); } public String drawArcS(Point2D.Double o, double width, double height, double startAngle, double endAngle) { double rx = width / 2.0; double ry = height / 2.0; Point2D.Double ps = polarToCartesian(o,rx,ry,startAngle); Point2D.Double pe = polarToCartesian(o,rx,ry,endAngle); String d = "\n"; return d; } public String drawPolygonS(Double[] points, double thickness) { String result = "\n"; return result; } @Override public String fillPolygonS(Double[] points, Color col) { String result = "\n"; return result; } @Override public String drawBaseStartS(int index) { return ""; } @Override public String drawBaseEndS(int index) { return ""; } @Override public String drawBasePairStartS(int i, int j, ModeleBP bps) { return ""; } @Override public String drawBasePairEndS(int index) { return ""; } @Override public String drawBackboneStartS(int i, int j) { return ""; } @Override public String drawBackboneEndS(int index) { return ""; } }