WeaponTitlePane.java
| Index Score | ||
|---|---|---|
![]() |
![]() |
plugin.charactersheet.gui |
![]() |
![]() |
PCGen |
View: Reasons, Metrics, Source Code
These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.
/*
* UnarmedPane.java
*
* Created on February 3, 2004, 3:23 PM
*/
package plugin.charactersheet.gui;
import gmgen.gui.GridBoxLayout;
import pcgen.core.Equipment;
import pcgen.core.PlayerCharacter;
import pcgen.io.exporttoken.WeaponToken;
import plugin.charactersheet.CharacterSheetUtils;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;
import java.awt.Font;
/**
* <code>WeaponTitlePane</code>.
*
* @author ddjone3
* @version $Revision: 1777 $
*/
public class WeaponTitlePane extends JPanel
{
private PlayerCharacter pc;
private Equipment eq;
private JPanel titleContainerPanel;
private JPanel weaponTitlePanel;
private JLabel weaponTitle;
private JTextArea weaponSubTitle;
private JPanel dataContainerPanel;
private JPanel currentHandPanel;
private JPanel typePanel;
private JPanel sizePanel;
private JPanel criticalPanel;
private JPanel currentHandDataPanel;
private JLabel currentHand;
private JPanel typeDataPanel;
private JLabel damageType;
private JPanel sizeDataPanel;
private JLabel weaponSize;
private JPanel criticalDataPanel;
private JLabel critical;
private static final String DIALOG = "Dialog";
private static final Font FONT_TEN = new Font(DIALOG, 1, 10);
private static final String CURR_HAND = "Current Hand";
private static final String TYPE = "Type";
private static final String SIZE = "Size";
private static final String CRITICAL = "Critical";
private static final String SPACE = " ";
private static final String BLANK = "";
private static final String STAR = "*";
/**
* Constructor
*/
public WeaponTitlePane()
{
initComponents();
setColor();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents()
{
titleContainerPanel = new JPanel();
weaponTitlePanel = new JPanel();
weaponTitle = new JLabel();
weaponSubTitle = new JTextArea();
dataContainerPanel = new JPanel();
currentHandPanel = new JPanel();
currentHandDataPanel = new JPanel();
currentHand = new JLabel();
typePanel = new JPanel();
typeDataPanel = new JPanel();
damageType = new JLabel();
sizePanel = new JPanel();
sizeDataPanel = new JPanel();
weaponSize = new JLabel();
criticalPanel = new JPanel();
criticalDataPanel = new JPanel();
critical = new JLabel();
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
titleContainerPanel.setLayout(new BoxLayout(titleContainerPanel,
BoxLayout.Y_AXIS));
weaponTitlePanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
weaponTitle.setFont(new java.awt.Font(DIALOG, 1, 16));
weaponTitlePanel.add(weaponTitle);
titleContainerPanel.add(weaponTitlePanel);
weaponSubTitle.setFont(FONT_TEN);
weaponSubTitle.setLineWrap(true);
weaponSubTitle.setWrapStyleWord(true);
titleContainerPanel.add(weaponSubTitle);
add(titleContainerPanel);
dataContainerPanel.setLayout(new GridBoxLayout(2, 4));
JLabel currentHandLabel = new JLabel();
currentHandPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
currentHandLabel.setFont(FONT_TEN);
currentHandLabel.setText(CURR_HAND);
currentHandPanel.add(currentHandLabel);
dataContainerPanel.add(currentHandPanel);
JLabel typeLabel = new JLabel();
typePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER,
1, 0));
typeLabel.setFont(FONT_TEN);
typeLabel.setText(TYPE);
typePanel.add(typeLabel);
dataContainerPanel.add(typePanel);
JLabel sizeLabel = new JLabel();
sizePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER,
1, 0));
sizeLabel.setFont(FONT_TEN);
sizeLabel.setText(SIZE);
sizePanel.add(sizeLabel);
dataContainerPanel.add(sizePanel);
JLabel criticalLabel = new JLabel();
criticalPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
criticalLabel.setFont(FONT_TEN);
criticalLabel.setText(CRITICAL);
criticalPanel.add(criticalLabel);
dataContainerPanel.add(criticalPanel);
currentHandDataPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
currentHand.setFont(FONT_TEN);
currentHand.setText(SPACE);
currentHandDataPanel.add(currentHand);
dataContainerPanel.add(currentHandDataPanel);
typeDataPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
damageType.setFont(FONT_TEN);
damageType.setText(SPACE);
typeDataPanel.add(damageType);
dataContainerPanel.add(typeDataPanel);
sizeDataPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
weaponSize.setFont(FONT_TEN);
weaponSize.setText(SPACE);
sizeDataPanel.add(weaponSize);
dataContainerPanel.add(sizeDataPanel);
criticalDataPanel.setLayout(new java.awt.FlowLayout(
java.awt.FlowLayout.CENTER, 1, 0));
critical.setFont(FONT_TEN);
critical.setText(SPACE);
criticalDataPanel.add(critical);
dataContainerPanel.add(criticalDataPanel);
add(dataContainerPanel);
}
/**
* Sets the background and border colour of the WeaponTitlePane and sub-components.
*/
public void setColor()
{
setBackground(CharacterPanel.border);
setBorder(new LineBorder(CharacterPanel.border));
titleContainerPanel.setBackground(CharacterPanel.header);
titleContainerPanel.setBorder(new LineBorder(CharacterPanel.border));
weaponTitlePanel.setBackground(CharacterPanel.header);
weaponSubTitle.setBackground(CharacterPanel.header);
weaponSubTitle.setBorder(null);
dataContainerPanel.setBackground(CharacterPanel.border);
currentHandPanel.setBackground(CharacterPanel.header);
currentHandPanel.setBorder(new LineBorder(CharacterPanel.border));
currentHandDataPanel.setBackground(CharacterPanel.bodyLight);
currentHandDataPanel.setBorder(new LineBorder(CharacterPanel.border));
typePanel.setBackground(CharacterPanel.header);
typePanel.setBorder(new LineBorder(CharacterPanel.border));
typeDataPanel.setBackground(CharacterPanel.bodyLight);
typeDataPanel.setBorder(new LineBorder(CharacterPanel.border));
sizePanel.setBackground(CharacterPanel.header);
sizePanel.setBorder(new LineBorder(CharacterPanel.border));
sizeDataPanel.setBackground(CharacterPanel.bodyLight);
sizeDataPanel.setBorder(new LineBorder(CharacterPanel.border));
criticalPanel.setBackground(CharacterPanel.header);
criticalPanel.setBorder(new LineBorder(CharacterPanel.border));
criticalDataPanel.setBackground(CharacterPanel.bodyLight);
criticalDataPanel.setBorder(new LineBorder(CharacterPanel.border));
}
/**
* Sets the weapon by setting a player character and equipment.
*
* @param pc player character.
* @param eq equipment.
*/
public void setWeapon(PlayerCharacter pc, Equipment eq)
{
this.pc = pc;
this.eq = eq;
refresh();
}
/**
* Refresh the weapon title pane
*/
public void refresh()
{
String star = BLANK;
if (eq.isEquipped())
{
star = STAR;
}
weaponTitle.setText(CharacterSheetUtils.getTitle(new StringBuffer(eq
.longName()).append(eq.getAppliedName()).toString(), star, BLANK));
weaponSubTitle.setText(CharacterSheetUtils
.getSubTitle(new StringBuffer(eq.longName()).append(
eq.getAppliedName()).toString()));
currentHand.setText(WeaponToken.getHandToken(eq));
weaponSize.setText(WeaponToken.getSizeToken(eq));
damageType.setText(WeaponToken.getTypeToken(eq));
StringBuffer sb = new StringBuffer();
critical.setText(sb.append(WeaponToken.getCritToken(pc, eq))
.append('/').append('x').append(WeaponToken.getMultToken(pc, eq))
.toString());
}
}
The table below shows all metrics for WeaponTitlePane.java.




