ResistancePanel.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package org.leumasjaffe.charsheet.view.summary;
  2. import javax.swing.JPanel;
  3. import org.leumasjaffe.charsheet.entity.AbilityScores;
  4. import org.leumasjaffe.charsheet.entity.DDCharacter;
  5. import java.awt.GridBagLayout;
  6. import java.awt.GridBagConstraints;
  7. import java.awt.Dimension;
  8. public class ResistancePanel extends JPanel {
  9. /**
  10. *
  11. */
  12. private static final long serialVersionUID = 1L;
  13. private ResistanceLine fortitude;
  14. private ResistanceLine reflex;
  15. private ResistanceLine will;
  16. public ResistancePanel() {
  17. setMaximumSize(new Dimension(400, 75));
  18. setMinimumSize(new Dimension(400, 74));
  19. setPreferredSize(new Dimension(400, 75));
  20. setOpaque(false);
  21. GridBagLayout gridBagLayout = new GridBagLayout();
  22. gridBagLayout.columnWidths = new int[]{0, 0};
  23. gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
  24. gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE};
  25. gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
  26. setLayout(gridBagLayout);
  27. fortitude = new ResistanceLine("FORTITUDE", DDCharacter::getFortSave, AbilityScores.Scores::getCon);
  28. GridBagConstraints gbc_fortitude = new GridBagConstraints();
  29. gbc_fortitude.fill = GridBagConstraints.BOTH;
  30. gbc_fortitude.gridx = 0;
  31. gbc_fortitude.gridy = 0;
  32. add(fortitude, gbc_fortitude);
  33. reflex = new ResistanceLine("REFLEX", DDCharacter::getRefSave, AbilityScores.Scores::getDex);
  34. GridBagConstraints gbc_reflex = new GridBagConstraints();
  35. gbc_reflex.fill = GridBagConstraints.BOTH;
  36. gbc_reflex.gridx = 0;
  37. gbc_reflex.gridy = 1;
  38. add(reflex, gbc_reflex);
  39. will = new ResistanceLine("WILL", DDCharacter::getWillSave, AbilityScores.Scores::getWis);
  40. GridBagConstraints gbc_will = new GridBagConstraints();
  41. gbc_will.fill = GridBagConstraints.BOTH;
  42. gbc_will.gridx = 0;
  43. gbc_will.gridy = 2;
  44. add(will, gbc_will);
  45. }
  46. public void setModel(DDCharacter model) {
  47. this.fortitude.setModel(model);
  48. this.reflex.setModel(model);
  49. this.will.setModel(model);
  50. }
  51. }