Debian Codegraph @

api_examples/CgviewTest2.java

raw symbols SCIP
1 import ca.ualberta.stothard.cgview.*;
2 import java.io.*;
3 import java.awt.*;
4
5 public class CgviewTest2 implements CgviewConstants {
6
7 public static void main( String args[] ) {
8
9 int length = 9000;
10 Cgview cgview = new Cgview(length);
11
12 //some optional settings
13 cgview.setWidth(600);
14 cgview.setHeight(600);
15 cgview.setBackboneRadius(140.0f);
16 cgview.setBackboneColor(Color.red);
17 cgview.setTitle("Example");
18 cgview.setLabelPlacementQuality(10);
19 cgview.setShowWarning(true);
20 cgview.setLabelLineLength(8.0d);
21 cgview.setLabelLineThickness(1.5f);
22 cgview.setRulerTextPadding(6.0f);
23
24 //create a FeatureSlot to hold sequence features
25 FeatureSlot featureSlot = new FeatureSlot(cgview, DIRECT_STRAND);
26
27 //create random sequence features
28 for (int i = 1; i <= 100; i = i + 1) {
29
30 int j = Math.round((float)((float)(length - 2) * Math.random())) + 1;
31
32 //a Feature to add to our FeatureSlot
33 Feature feature = new Feature(featureSlot, "label");
34 feature.setColor(Color.black);
35
36 //a single FeatureRange to add the Feature
37 FeatureRange featureRange = new FeatureRange (feature, j, j + 1);
38 featureRange.setDecoration(DECORATION_CLOCKWISE_ARROW);
39
40 }
41
42 try {
43 //create a PNG file
44 CgviewIO.writeToPNGFile(cgview, "output.png");
45
46 //create a zoomed in PNG file
47 //to draw a zoomed in version, use the setDesiredZoom(double)
48 //and setDesiredZoomCenter(int) methods before drawing.
49 cgview.setDesiredZoom(5.0d);
50 cgview.setDesiredZoomCenter(100);
51 cgview.setLabelLineLength(50.0d);
52 CgviewIO.writeToPNGFile(cgview, "output_zoomed.png");
53
54 //create a zoomed in SVGZ file
55 cgview.setDesiredZoom(5.0d);
56 cgview.setDesiredZoomCenter(4500);
57 cgview.setLabelLineLength(50.0d);
58 cgview.setWidth(750);
59 boolean embedFonts = true;
60 boolean useCompression = false; //creates SVG instead of SVGZ
61 CgviewIO.writeToSVGFile(cgview, "output_zoomed.svg", embedFonts, useCompression);
62 }
63 catch (Exception e) {
64 e.printStackTrace(System.err);
65 System.exit(1);
66 }
67 }
68 }