JAL-1807 Bob's first commit -- Applet loaded; needs image
[jalview.git] / src / javajs / swing / GridBagConstraints.java
1 package javajs.swing;
2
3 public class GridBagConstraints {
4
5         public static final int NONE = 0;
6         public static final int CENTER = 10;
7         public static final int WEST = 17;
8         public static final int EAST = 13;
9
10         public int gridx;
11         public int gridy;
12         public int gridwidth;
13         public int gridheight;
14         double weightx;
15         double weighty;
16         public int anchor;
17         public int fill;
18         Insets insets;
19         public int ipadx;
20         public int ipady;
21         
22         public GridBagConstraints(int gridx, int gridy, int gridwidth,
23                         int gridheight, double weightx, double weighty, int anchor, int fill,
24                         Insets insets, int ipadx, int ipady) {
25                 this.gridx = gridx;
26                 this.gridy = gridy;
27                 this.gridwidth = gridwidth;
28                 this.gridheight = gridheight;
29                 this.weightx = weightx;
30                 this.weighty = weighty;
31                 this.anchor = anchor;
32                 this.fill = fill;
33                 if (insets == null)
34                         insets = new Insets(0, 0, 0, 0);
35                 this.insets = insets;
36                 this.ipadx = ipadx;
37                 this.ipady = ipady;
38         }
39
40         String getStyle(boolean margins) {
41                 return "style='" + (margins ? 
42                                 "margin:" + insets.top + "px " + (ipady + insets.right) + "px "
43                                 + insets.bottom + "px " + (ipadx + insets.left) + "px;"
44                                 : "text-align:" + (anchor == EAST ? "right" : anchor == WEST? "left" : "center")) + "'";
45         }
46
47 }