SummaryTab.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package org.leumasjaffe.charsheet.view;
  2. import javax.swing.JPanel;
  3. import org.leumasjaffe.charsheet.model.DDCharacter;
  4. import org.leumasjaffe.charsheet.view.summary.AbilityPanel;
  5. import org.leumasjaffe.charsheet.view.summary.ArmorLine;
  6. import org.leumasjaffe.charsheet.view.summary.AttackLine;
  7. import org.leumasjaffe.charsheet.view.summary.DamageReductionLine;
  8. import org.leumasjaffe.charsheet.view.summary.DescriptionPanel;
  9. import org.leumasjaffe.charsheet.view.summary.HealthLine;
  10. import org.leumasjaffe.charsheet.view.summary.InitiativeLine;
  11. import org.leumasjaffe.charsheet.view.summary.ResistancePanel;
  12. import org.leumasjaffe.charsheet.view.summary.SpellResistanceLine;
  13. import lombok.AccessLevel;
  14. import lombok.experimental.FieldDefaults;
  15. import java.awt.GridBagLayout;
  16. import java.awt.GridBagConstraints;
  17. import java.awt.Insets;
  18. import java.awt.Color;
  19. import java.awt.Dimension;
  20. import java.awt.Component;
  21. import javax.swing.Box;
  22. @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
  23. public class SummaryTab extends JPanel {
  24. /**
  25. *
  26. */
  27. private static final long serialVersionUID = 1L;
  28. HealthLine healthLine;
  29. ArmorLine armorLine;
  30. ResistancePanel resistancePanel;
  31. AbilityPanel abilityPanel;
  32. DescriptionPanel descriptionPanel;
  33. InitiativeLine initiativeLine;
  34. SpellResistanceLine spellResistLine;
  35. DamageReductionLine damageReductionLine;
  36. AttackLine attackLine;
  37. public SummaryTab() {
  38. setBackground(Color.WHITE);
  39. GridBagLayout gridBagLayout = new GridBagLayout();
  40. gridBagLayout.columnWidths = new int[]{0, 0, 0};
  41. gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
  42. gridBagLayout.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
  43. gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
  44. setLayout(gridBagLayout);
  45. descriptionPanel = new DescriptionPanel();
  46. GridBagConstraints gbc_descriptionPanel = new GridBagConstraints();
  47. gbc_descriptionPanel.gridwidth = 2;
  48. gbc_descriptionPanel.insets = new Insets(0, 0, 5, 0);
  49. gbc_descriptionPanel.fill = GridBagConstraints.BOTH;
  50. gbc_descriptionPanel.gridx = 0;
  51. gbc_descriptionPanel.gridy = 0;
  52. add(descriptionPanel, gbc_descriptionPanel);
  53. abilityPanel = new AbilityPanel();
  54. GridBagConstraints gbc_abilityPanel = new GridBagConstraints();
  55. gbc_abilityPanel.insets = new Insets(0, 0, 5, 5);
  56. gbc_abilityPanel.fill = GridBagConstraints.BOTH;
  57. gbc_abilityPanel.gridx = 0;
  58. gbc_abilityPanel.gridy = 1;
  59. add(abilityPanel, gbc_abilityPanel);
  60. JPanel panel = new JPanel();
  61. panel.setOpaque(false);
  62. GridBagConstraints gbc_panel = new GridBagConstraints();
  63. gbc_panel.insets = new Insets(0, 0, 5, 0);
  64. gbc_panel.fill = GridBagConstraints.BOTH;
  65. gbc_panel.gridx = 1;
  66. gbc_panel.gridy = 1;
  67. add(panel, gbc_panel);
  68. GridBagLayout gbl_panel = new GridBagLayout();
  69. gbl_panel.columnWidths = new int[]{0, 0};
  70. gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
  71. gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
  72. gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
  73. panel.setLayout(gbl_panel);
  74. healthLine = new HealthLine();
  75. GridBagConstraints gbc_healthLine = new GridBagConstraints();
  76. gbc_healthLine.insets = new Insets(0, 0, 5, 0);
  77. gbc_healthLine.fill = GridBagConstraints.BOTH;
  78. gbc_healthLine.gridx = 0;
  79. gbc_healthLine.gridy = 0;
  80. panel.add(healthLine, gbc_healthLine);
  81. armorLine = new ArmorLine();
  82. GridBagConstraints gbc_armorLine = new GridBagConstraints();
  83. gbc_armorLine.insets = new Insets(0, 0, 5, 0);
  84. gbc_armorLine.fill = GridBagConstraints.BOTH;
  85. gbc_armorLine.gridx = 0;
  86. gbc_armorLine.gridy = 1;
  87. panel.add(armorLine, gbc_armorLine);
  88. resistancePanel = new ResistancePanel();
  89. GridBagConstraints gbc_resistancePanel = new GridBagConstraints();
  90. gbc_resistancePanel.fill = GridBagConstraints.BOTH;
  91. gbc_resistancePanel.gridx = 0;
  92. gbc_resistancePanel.gridy = 2;
  93. panel.add(resistancePanel, gbc_resistancePanel);
  94. JPanel panel_1 = new JPanel();
  95. panel_1.setOpaque(false);
  96. GridBagConstraints gbc_panel_1 = new GridBagConstraints();
  97. gbc_panel_1.gridwidth = 2;
  98. gbc_panel_1.insets = new Insets(0, 0, 0, 5);
  99. gbc_panel_1.fill = GridBagConstraints.BOTH;
  100. gbc_panel_1.gridx = 0;
  101. gbc_panel_1.gridy = 2;
  102. add(panel_1, gbc_panel_1);
  103. GridBagLayout gbl_panel_1 = new GridBagLayout();
  104. gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
  105. gbl_panel_1.rowHeights = new int[]{0, 0, 0};
  106. gbl_panel_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  107. gbl_panel_1.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
  108. panel_1.setLayout(gbl_panel_1);
  109. initiativeLine = new InitiativeLine();
  110. GridBagConstraints gbc_initiativeLine = new GridBagConstraints();
  111. gbc_initiativeLine.insets = new Insets(0, 0, 5, 5);
  112. gbc_initiativeLine.fill = GridBagConstraints.BOTH;
  113. gbc_initiativeLine.gridx = 0;
  114. gbc_initiativeLine.gridy = 0;
  115. panel_1.add(initiativeLine, gbc_initiativeLine);
  116. Component horizontalStrut = Box.createHorizontalStrut(20);
  117. horizontalStrut.setPreferredSize(new Dimension(40, 0));
  118. GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
  119. gbc_horizontalStrut.insets = new Insets(0, 0, 5, 5);
  120. gbc_horizontalStrut.gridx = 1;
  121. gbc_horizontalStrut.gridy = 0;
  122. panel_1.add(horizontalStrut, gbc_horizontalStrut);
  123. spellResistLine = new SpellResistanceLine();
  124. GridBagConstraints gbc_spellResistLine = new GridBagConstraints();
  125. gbc_spellResistLine.insets = new Insets(0, 0, 5, 5);
  126. gbc_spellResistLine.fill = GridBagConstraints.BOTH;
  127. gbc_spellResistLine.gridx = 2;
  128. gbc_spellResistLine.gridy = 0;
  129. panel_1.add(spellResistLine, gbc_spellResistLine);
  130. Component horizontalStrut_1 = Box.createHorizontalStrut(20);
  131. horizontalStrut_1.setPreferredSize(new Dimension(40, 0));
  132. GridBagConstraints gbc_horizontalStrut_1 = new GridBagConstraints();
  133. gbc_horizontalStrut_1.insets = new Insets(0, 0, 5, 5);
  134. gbc_horizontalStrut_1.gridx = 3;
  135. gbc_horizontalStrut_1.gridy = 0;
  136. panel_1.add(horizontalStrut_1, gbc_horizontalStrut_1);
  137. damageReductionLine = new DamageReductionLine();
  138. GridBagConstraints gbc_damageReductionLine = new GridBagConstraints();
  139. gbc_damageReductionLine.insets = new Insets(0, 0, 5, 0);
  140. gbc_damageReductionLine.fill = GridBagConstraints.BOTH;
  141. gbc_damageReductionLine.gridx = 4;
  142. gbc_damageReductionLine.gridy = 0;
  143. panel_1.add(damageReductionLine, gbc_damageReductionLine);
  144. attackLine = new AttackLine();
  145. GridBagConstraints gbc_attackLine = new GridBagConstraints();
  146. gbc_attackLine.gridwidth = 5;
  147. gbc_attackLine.fill = GridBagConstraints.BOTH;
  148. gbc_attackLine.gridx = 0;
  149. gbc_attackLine.gridy = 1;
  150. panel_1.add(attackLine, gbc_attackLine);
  151. }
  152. public void setModel(DDCharacter model) {
  153. this.descriptionPanel.setModel(model);
  154. this.abilityPanel.setModel(model.getAbilities());
  155. this.initiativeLine.setModel(model);
  156. this.attackLine.setModel(model);
  157. this.armorLine.setModel(model);
  158. this.resistancePanel.setModel(model);
  159. this.healthLine.setModel(model.getHealth());
  160. }
  161. }