ArmorPanel.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package org.leumasjaffe.charsheet.view.inventory;
  2. import javax.swing.JPanel;
  3. import java.awt.GridBagLayout;
  4. import java.awt.GridBagConstraints;
  5. import java.awt.Insets;
  6. import javax.swing.JLabel;
  7. import javax.swing.JTextField;
  8. import java.awt.Dimension;
  9. import java.awt.Font;
  10. import java.awt.Color;
  11. import javax.swing.SwingConstants;
  12. import org.leumasjaffe.charsheet.model.equip.DDItem;
  13. import org.leumasjaffe.charsheet.view.StringHelper;
  14. import java.awt.Component;
  15. import javax.swing.Box;
  16. public class ArmorPanel extends JPanel {
  17. /**
  18. *
  19. */
  20. private static final long serialVersionUID = 1L;
  21. private JTextField armorNameField;
  22. private JTextField armorTypeField;
  23. private JTextField armorBonusField;
  24. private JTextField armorDexField;
  25. private JTextField checkField;
  26. private JTextField spellField;
  27. private JTextField speedField;
  28. private JTextField weightField;
  29. private JTextField propField;
  30. public ArmorPanel(DDItem item) {
  31. setPreferredSize(new Dimension(280, 70));
  32. GridBagLayout gridBagLayout = new GridBagLayout();
  33. gridBagLayout.columnWidths = new int[]{0, 0};
  34. gridBagLayout.rowHeights = new int[]{0, 0, 0};
  35. gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
  36. gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
  37. setLayout(gridBagLayout);
  38. JPanel panel = new JPanel();
  39. GridBagConstraints gbc_panel = new GridBagConstraints();
  40. gbc_panel.insets = new Insets(0, 0, 0, 0);
  41. gbc_panel.fill = GridBagConstraints.BOTH;
  42. gbc_panel.gridx = 0;
  43. gbc_panel.gridy = 0;
  44. add(panel, gbc_panel);
  45. GridBagLayout gbl_panel = new GridBagLayout();
  46. gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0};
  47. gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
  48. gbl_panel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
  49. gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
  50. panel.setLayout(gbl_panel);
  51. JLabel lblArmorprotectiveItem = new JLabel("ARMOR/PROTECTIVE ITEM");
  52. lblArmorprotectiveItem.setHorizontalAlignment(SwingConstants.CENTER);
  53. lblArmorprotectiveItem.setForeground(Color.WHITE);
  54. lblArmorprotectiveItem.setOpaque(true);
  55. lblArmorprotectiveItem.setBackground(Color.BLACK);
  56. lblArmorprotectiveItem.setFont(new Font("Tahoma", Font.BOLD, 10));
  57. GridBagConstraints gbc_lblArmorprotectiveItem = new GridBagConstraints();
  58. gbc_lblArmorprotectiveItem.fill = GridBagConstraints.BOTH;
  59. gbc_lblArmorprotectiveItem.insets = new Insets(0, 0, 0, 1);
  60. gbc_lblArmorprotectiveItem.gridheight = 2;
  61. gbc_lblArmorprotectiveItem.gridx = 0;
  62. gbc_lblArmorprotectiveItem.gridy = 0;
  63. panel.add(lblArmorprotectiveItem, gbc_lblArmorprotectiveItem);
  64. Component verticalStrut = Box.createVerticalStrut(20);
  65. verticalStrut.setMinimumSize(new Dimension(0, 10));
  66. verticalStrut.setMaximumSize(new Dimension(32767, 10));
  67. verticalStrut.setPreferredSize(new Dimension(0, 10));
  68. GridBagConstraints gbc_verticalStrut = new GridBagConstraints();
  69. gbc_verticalStrut.insets = new Insets(0, 0, 0, 0);
  70. gbc_verticalStrut.gridx = 2;
  71. gbc_verticalStrut.gridy = 0;
  72. panel.add(verticalStrut, gbc_verticalStrut);
  73. JLabel lblType = new JLabel("TYPE");
  74. lblType.setHorizontalAlignment(SwingConstants.CENTER);
  75. lblType.setForeground(Color.WHITE);
  76. lblType.setOpaque(true);
  77. lblType.setBackground(Color.BLACK);
  78. lblType.setFont(new Font("Tahoma", Font.BOLD, 8));
  79. GridBagConstraints gbc_lblType = new GridBagConstraints();
  80. gbc_lblType.fill = GridBagConstraints.HORIZONTAL;
  81. gbc_lblType.insets = new Insets(0, 0, 0, 1);
  82. gbc_lblType.gridx = 1;
  83. gbc_lblType.gridy = 1;
  84. panel.add(lblType, gbc_lblType);
  85. JLabel lblAcBonus = new JLabel("AC BONUS");
  86. lblAcBonus.setHorizontalAlignment(SwingConstants.CENTER);
  87. lblAcBonus.setForeground(Color.WHITE);
  88. lblAcBonus.setOpaque(true);
  89. lblAcBonus.setBackground(Color.BLACK);
  90. lblAcBonus.setFont(new Font("Tahoma", Font.BOLD, 8));
  91. GridBagConstraints gbc_lblAcBonus = new GridBagConstraints();
  92. gbc_lblAcBonus.fill = GridBagConstraints.HORIZONTAL;
  93. gbc_lblAcBonus.insets = new Insets(0, 0, 0, 1);
  94. gbc_lblAcBonus.gridx = 2;
  95. gbc_lblAcBonus.gridy = 1;
  96. panel.add(lblAcBonus, gbc_lblAcBonus);
  97. JLabel lblMaxDex = new JLabel("MAX DEX");
  98. lblMaxDex.setHorizontalAlignment(SwingConstants.CENTER);
  99. lblMaxDex.setForeground(Color.WHITE);
  100. lblMaxDex.setOpaque(true);
  101. lblMaxDex.setBackground(Color.BLACK);
  102. lblMaxDex.setFont(new Font("Tahoma", Font.BOLD, 8));
  103. GridBagConstraints gbc_lblMaxDex = new GridBagConstraints();
  104. gbc_lblMaxDex.fill = GridBagConstraints.HORIZONTAL;
  105. gbc_lblMaxDex.insets = new Insets(0, 0, 0, 1);
  106. gbc_lblMaxDex.gridx = 3;
  107. gbc_lblMaxDex.gridy = 1;
  108. panel.add(lblMaxDex, gbc_lblMaxDex);
  109. armorNameField = new JTextField(item.getName());
  110. GridBagConstraints gbc_armorNameField = new GridBagConstraints();
  111. gbc_armorNameField.insets = new Insets(0, 0, 0, 0);
  112. gbc_armorNameField.fill = GridBagConstraints.HORIZONTAL;
  113. gbc_armorNameField.gridx = 0;
  114. gbc_armorNameField.gridy = 2;
  115. panel.add(armorNameField, gbc_armorNameField);
  116. armorNameField.setColumns(10);
  117. armorTypeField = new JTextField(item.getArmor().getType().toString());
  118. GridBagConstraints gbc_armorTypeField = new GridBagConstraints();
  119. gbc_armorTypeField.insets = new Insets(0, 0, 0, 0);
  120. gbc_armorTypeField.fill = GridBagConstraints.HORIZONTAL;
  121. gbc_armorTypeField.gridx = 1;
  122. gbc_armorTypeField.gridy = 2;
  123. panel.add(armorTypeField, gbc_armorTypeField);
  124. armorTypeField.setColumns(10);
  125. armorBonusField = new JTextField(StringHelper.toSignedString(item.getArmor().getBonus()));
  126. armorBonusField.setHorizontalAlignment(SwingConstants.CENTER);
  127. GridBagConstraints gbc_armorBonusField = new GridBagConstraints();
  128. gbc_armorBonusField.insets = new Insets(0, 0, 0, 0);
  129. gbc_armorBonusField.fill = GridBagConstraints.HORIZONTAL;
  130. gbc_armorBonusField.gridx = 2;
  131. gbc_armorBonusField.gridy = 2;
  132. panel.add(armorBonusField, gbc_armorBonusField);
  133. armorBonusField.setColumns(10);
  134. armorDexField = new JTextField(StringHelper.toSignedString(item.getArmor().getMaxDex()));
  135. armorDexField.setHorizontalAlignment(SwingConstants.CENTER);
  136. GridBagConstraints gbc_armorDexField = new GridBagConstraints();
  137. gbc_armorDexField.fill = GridBagConstraints.HORIZONTAL;
  138. gbc_armorDexField.gridx = 3;
  139. gbc_armorDexField.gridy = 2;
  140. panel.add(armorDexField, gbc_armorDexField);
  141. armorDexField.setColumns(10);
  142. JPanel panel_1 = new JPanel();
  143. GridBagConstraints gbc_panel_1 = new GridBagConstraints();
  144. gbc_panel_1.fill = GridBagConstraints.BOTH;
  145. gbc_panel_1.gridx = 0;
  146. gbc_panel_1.gridy = 1;
  147. add(panel_1, gbc_panel_1);
  148. GridBagLayout gbl_panel_1 = new GridBagLayout();
  149. gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
  150. gbl_panel_1.rowHeights = new int[]{0, 0, 0};
  151. gbl_panel_1.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
  152. gbl_panel_1.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
  153. panel_1.setLayout(gbl_panel_1);
  154. JLabel lblCheckPenalty = new JLabel("CHECK PENALTY");
  155. lblCheckPenalty.setHorizontalAlignment(SwingConstants.CENTER);
  156. lblCheckPenalty.setForeground(Color.WHITE);
  157. lblCheckPenalty.setOpaque(true);
  158. lblCheckPenalty.setBackground(Color.BLACK);
  159. lblCheckPenalty.setFont(new Font("Tahoma", Font.BOLD, 8));
  160. GridBagConstraints gbc_lblCheckPenalty = new GridBagConstraints();
  161. gbc_lblCheckPenalty.fill = GridBagConstraints.BOTH;
  162. gbc_lblCheckPenalty.insets = new Insets(0, 0, 0, 1);
  163. gbc_lblCheckPenalty.gridx = 0;
  164. gbc_lblCheckPenalty.gridy = 0;
  165. panel_1.add(lblCheckPenalty, gbc_lblCheckPenalty);
  166. JLabel lblSpellFailure = new JLabel("SPELL FAILURE");
  167. lblSpellFailure.setHorizontalAlignment(SwingConstants.CENTER);
  168. lblSpellFailure.setForeground(Color.WHITE);
  169. lblSpellFailure.setOpaque(true);
  170. lblSpellFailure.setBackground(Color.BLACK);
  171. lblSpellFailure.setFont(new Font("Tahoma", Font.BOLD, 8));
  172. GridBagConstraints gbc_lblSpellFailure = new GridBagConstraints();
  173. gbc_lblSpellFailure.fill = GridBagConstraints.BOTH;
  174. gbc_lblSpellFailure.insets = new Insets(0, 0, 0, 1);
  175. gbc_lblSpellFailure.gridx = 1;
  176. gbc_lblSpellFailure.gridy = 0;
  177. panel_1.add(lblSpellFailure, gbc_lblSpellFailure);
  178. JLabel lblSpeed = new JLabel("SPEED");
  179. lblSpeed.setHorizontalAlignment(SwingConstants.CENTER);
  180. lblSpeed.setForeground(Color.WHITE);
  181. lblSpeed.setOpaque(true);
  182. lblSpeed.setBackground(Color.BLACK);
  183. lblSpeed.setFont(new Font("Tahoma", Font.BOLD, 8));
  184. GridBagConstraints gbc_lblSpeed = new GridBagConstraints();
  185. gbc_lblSpeed.fill = GridBagConstraints.BOTH;
  186. gbc_lblSpeed.insets = new Insets(0, 0, 0, 1);
  187. gbc_lblSpeed.gridx = 2;
  188. gbc_lblSpeed.gridy = 0;
  189. panel_1.add(lblSpeed, gbc_lblSpeed);
  190. JLabel lblWeight = new JLabel("WEIGHT");
  191. lblWeight.setHorizontalAlignment(SwingConstants.CENTER);
  192. lblWeight.setForeground(Color.WHITE);
  193. lblWeight.setOpaque(true);
  194. lblWeight.setBackground(Color.BLACK);
  195. lblWeight.setFont(new Font("Tahoma", Font.BOLD, 8));
  196. GridBagConstraints gbc_lblWeight = new GridBagConstraints();
  197. gbc_lblWeight.fill = GridBagConstraints.BOTH;
  198. gbc_lblWeight.insets = new Insets(0, 0, 0, 1);
  199. gbc_lblWeight.gridx = 3;
  200. gbc_lblWeight.gridy = 0;
  201. panel_1.add(lblWeight, gbc_lblWeight);
  202. JLabel lblSpecialProperties = new JLabel("SPECIAL PROPERTIES");
  203. lblSpecialProperties.setHorizontalAlignment(SwingConstants.CENTER);
  204. lblSpecialProperties.setForeground(Color.WHITE);
  205. lblSpecialProperties.setOpaque(true);
  206. lblSpecialProperties.setBackground(Color.BLACK);
  207. lblSpecialProperties.setFont(new Font("Tahoma", Font.BOLD, 8));
  208. GridBagConstraints gbc_lblSpecialProperties = new GridBagConstraints();
  209. gbc_lblSpecialProperties.fill = GridBagConstraints.BOTH;
  210. gbc_lblSpecialProperties.insets = new Insets(0, 0, 0, 1);
  211. gbc_lblSpecialProperties.gridx = 4;
  212. gbc_lblSpecialProperties.gridy = 0;
  213. panel_1.add(lblSpecialProperties, gbc_lblSpecialProperties);
  214. checkField = new JTextField(StringHelper.toString(item.getArmor().getCheckPenalty()));
  215. checkField.setHorizontalAlignment(SwingConstants.CENTER);
  216. GridBagConstraints gbc_checkField = new GridBagConstraints();
  217. gbc_checkField.insets = new Insets(0, 0, 0, 0);
  218. gbc_checkField.fill = GridBagConstraints.HORIZONTAL;
  219. gbc_checkField.gridx = 0;
  220. gbc_checkField.gridy = 1;
  221. panel_1.add(checkField, gbc_checkField);
  222. checkField.setColumns(10);
  223. spellField = new JTextField(StringHelper.toString(item.getArmor().getSpellFailure()) + "%");
  224. spellField.setHorizontalAlignment(SwingConstants.CENTER);
  225. GridBagConstraints gbc_spellField = new GridBagConstraints();
  226. gbc_spellField.insets = new Insets(0, 0, 0, 0);
  227. gbc_spellField.fill = GridBagConstraints.HORIZONTAL;
  228. gbc_spellField.gridx = 1;
  229. gbc_spellField.gridy = 1;
  230. panel_1.add(spellField, gbc_spellField);
  231. spellField.setColumns(10);
  232. speedField = new JTextField(StringHelper.toString(item.getArmor().getSpeed()));
  233. speedField.setHorizontalAlignment(SwingConstants.CENTER);
  234. GridBagConstraints gbc_speedField = new GridBagConstraints();
  235. gbc_speedField.insets = new Insets(0, 0, 0, 0);
  236. gbc_speedField.fill = GridBagConstraints.HORIZONTAL;
  237. gbc_speedField.gridx = 2;
  238. gbc_speedField.gridy = 1;
  239. panel_1.add(speedField, gbc_speedField);
  240. speedField.setColumns(10);
  241. weightField = new JTextField();
  242. GridBagConstraints gbc_weightField = new GridBagConstraints();
  243. gbc_weightField.insets = new Insets(0, 0, 0, 0);
  244. gbc_weightField.fill = GridBagConstraints.HORIZONTAL;
  245. gbc_weightField.gridx = 3;
  246. gbc_weightField.gridy = 1;
  247. panel_1.add(weightField, gbc_weightField);
  248. weightField.setColumns(10);
  249. propField = new JTextField();
  250. GridBagConstraints gbc_propField = new GridBagConstraints();
  251. gbc_propField.fill = GridBagConstraints.HORIZONTAL;
  252. gbc_propField.gridx = 4;
  253. gbc_propField.gridy = 1;
  254. panel_1.add(propField, gbc_propField);
  255. propField.setColumns(10);
  256. // TODO Auto-generated constructor stub
  257. }
  258. }