Debian Codegraph @

api_examples/CgviewTest1.java

raw symbols SCIP
1 import ca.ualberta.stothard.cgview.*;
2 import java.io.*;
3 import java.awt.*;
4
5 public class CgviewTest1 implements CgviewConstants {
6
7 public static void main( String args[] ) {
8
9 int length = 12078;
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.setTitle("Example 2");
17 cgview.setLabelPlacementQuality(5);
18 cgview.setShowWarning(false);
19 cgview.setLabelLineLength(15.0d);
20 cgview.setLabelLineThickness(1.0f);
21 cgview.setUseInnerLabels(INNER_LABELS_SHOW);
22 cgview.setMoveInnerLabelsToOuter(true);
23 cgview.setMinimumFeatureLength(1.0d);
24
25 Legend legend = new Legend(cgview);
26 legend.setPosition(LEGEND_UPPER_CENTER);
27 LegendItem legendItem = new LegendItem(legend);
28 legendItem.setLabel("An example");
29 legendItem.setFont(new Font("SansSerif", Font.BOLD + Font.ITALIC, 22));
30
31 //create FeatureSlots to hold sequence features
32 FeatureSlot directSlot0 = new FeatureSlot(cgview, DIRECT_STRAND);
33 FeatureSlot directSlot1 = new FeatureSlot(cgview, DIRECT_STRAND);
34 FeatureSlot reverseSlot0 = new FeatureSlot(cgview, REVERSE_STRAND);
35
36 //Features to add to the FeatureSlots
37 Feature feature0 = new Feature(directSlot0, "A");
38 feature0.setColor(Color.blue);
39
40 Feature feature1 = new Feature(directSlot1, "B");
41 feature1.setColor(Color.red);
42
43 Feature feature2 = new Feature(reverseSlot0, "C");
44 feature2.setColor(Color.green);
45
46 //create random sequence features
47 for (int i = 1; i <= 100; i = i + 1) {
48
49 int j = Math.round((float)((float)(length - 2) * Math.random())) + 1;
50 int k = Math.round((float)((float)(length - 2) * Math.random())) + 1;
51 int l = Math.round((float)((float)(length - 2) * Math.random())) + 1;
52
53 //a single FeatureRange to add the Feature
54 FeatureRange featureRange0 = new FeatureRange (feature0, j, j + 1);
55 FeatureRange featureRange1 = new FeatureRange (feature1, k, k + 1);
56 FeatureRange featureRange2 = new FeatureRange (feature2, l, l + 1);
57 }
58
59 try {
60 //create a PNG file
61 CgviewIO.writeToPNGFile(cgview, "random_2.png");
62 }
63 catch (IOException e) {
64 e.printStackTrace(System.err);
65 System.exit(1);
66 }
67 }
68 }