Now to make a package the pins are tiled in to a grid shape with some pins missing in the center.
01: public class TutorialExample4 extends Applet { 02: 03: public void init () { 04: setBackground(Color.gray); 05: 06: FigureStyle style = new FigureStyle(); 07: style.foreground = Color.yellow; 08: style.brushSize = 1; 09: 10: Glyph verticalBox = LayoutKit.vbox(); 11: 12: for (int row = 0; row < 8; row++) { 13: Glyph horizontalRow = LayoutKit.hbox(); 14: for (int col = 0; col < 8; col++) 15: if (row > 1 && row < 6 && col > 1 && col < 6) { 16: horizontalRow.append(LayoutKit.hspace(32)); 17: } 18: else { 19: horizontalRow.append( 20: LayoutKit.margin( 21: new Pin("FakeName", 20F), 22: 6 23: ) 24: ); 25: } 26: verticalBox.append(horizontalRow); 27: } 28: 29: SgraphicsAdapter adapter = new SgraphicsAdapter(verticalBox); 30: 31: add("Center", adapter); 32: } 33: }
This example uses both horizontal and vertical boxes to make a grid. There is one vertical box created on line 10. Line 12 loops through the 8 rows creating a horizontal box for each row on line 13, and looping through the 8 columns on line 14. The real trick is the space in the center of the grid. On line 16 a horizontal space of size 32 is created to fill the space where a pin would go. Because the horizontal space is the same size as the pin, the horizontal boxes line up columns properly.
For comments or questions contact Mike Jones (Mike.Jones@mass..com)