JAL-3026 srcjar files for VARNA and log4j
[jalview.git] / srcjar / fr / orsay / lri / varna / models / export / SecStrProducerGraphics.java
1 package fr.orsay.lri.varna.models.export;
2
3 import java.awt.Color;
4 import java.awt.Dimension;
5 import java.awt.Font;
6 import java.awt.Shape;
7 import java.awt.geom.Ellipse2D;
8 import java.awt.geom.GeneralPath;
9 import java.io.FileWriter;
10 import java.io.IOException;
11
12 import fr.orsay.lri.varna.exceptions.ExceptionWritingForbidden;
13 import fr.orsay.lri.varna.models.rna.RNA;
14
15 public class SecStrProducerGraphics implements VueVARNAGraphics{
16         SecStrDrawingProducer _ss;
17         double _thickness;
18         Color _color;
19         
20         public SecStrProducerGraphics(SecStrDrawingProducer ss)
21         {
22                 _ss = ss;
23         }
24
25         public void draw(GeneralPath s) {
26                         _ss.fillPolygon(s, getColor());
27         }
28         
29         public void drawArc(double x, double y, double rx, double ry,
30                         double angleStart, double angleEnd) {
31                 // TODO Auto-generated method stub
32                 
33         }
34         
35         public void drawLine(double x1, double y1, double x2, double y2) {
36                 _ss.drawLine(x1, -y1, x2, -y2, _thickness);
37         }
38         
39         public void drawCircle(double x, double y, double r) {
40                 _ss.drawCircle(x+0.5*r, -y-0.5*r, 0.5*r, _thickness);
41         }
42
43         public void drawRect(double x, double y, double w, double h) {
44                 // TODO Auto-generated method stub
45                 
46         }
47         
48         public void drawRoundRect(double x, double y, double w, double h,
49                         double rx, double ry) {
50                 // TODO Auto-generated method stub
51                 
52         }
53
54         public void drawStringCentered(String res, double x, double y) {
55                 _ss.drawText(x, -y, res);
56         }
57
58         public void fill(GeneralPath s) {
59                 _ss.fillPolygon(s, getColor());
60         }
61         
62         public void fillCircle(double x, double y, double r) {
63                 _ss.fillCircle(x+0.5*r, -y-0.5*r, 0.5*r,  _thickness, _ss.getCurrentColor());
64         }
65
66         public void fillRect(double x, double y, double w, double h) {
67                 // TODO Auto-generated method stub
68                 
69         }
70
71         public void fillRoundRect(double x, double y, double w, double h,
72                         double rx, double ry) {
73                 // TODO Auto-generated method stub
74                 
75         }
76         public Color getColor() {
77                 return _ss.getCurrentColor();
78         }
79         
80         public Dimension getStringDimension(String s) {
81                 // TODO Auto-generated method stub
82                 return null;
83         }
84
85         public void setColor(Color c) {
86                 _ss.setColor(c);
87         }
88         
89         public void setSelectionStroke() {
90                 // TODO Auto-generated method stub
91                 
92         }
93         
94         public void setFont(Font f) {
95                 //System.out.println("Font "+f.getSize2D());
96                 _ss.setFont(_ss.FONT_HELVETICA_BOLD,f.getSize2D());
97         }
98
99         public void setPlainStroke() {
100                 // TODO Auto-generated method stub
101                 
102         }
103
104         public void setStrokeThickness(double t) {
105                 _thickness = t;
106         }
107         
108         public void saveToDisk(String path) throws ExceptionWritingForbidden
109         {
110                 FileWriter fout;
111                 try {
112                         fout = new FileWriter(path);
113                         fout.write(_ss.export());
114                         fout.close();
115                 } catch (IOException e) {
116                         throw new ExceptionWritingForbidden(e.getMessage());
117                 }
118         }
119 }