Search in sources :

Example 1 with Rule

use of pcgen.core.doomsdaybook.Rule in project pcgen by PCGen.

the class NameGenPanel method loadRule.

private String loadRule(Element rule, String id) throws DataConversionException {
    Rule dataRule = new Rule(allVars, id, id, rule.getAttribute("weight").getIntValue());
    java.util.List<?> elements = rule.getChildren();
    for (final Object element : elements) {
        Element child = (Element) element;
        String elementName = child.getName();
        if (elementName.equals("GETLIST")) {
            String listId = child.getAttributeValue("idref");
            dataRule.add(listId);
        } else if (elementName.equals("SPACE")) {
            SpaceRule sp = new SpaceRule();
            allVars.addDataElement(sp);
            dataRule.add(sp.getId());
        } else if (elementName.equals("HYPHEN")) {
            HyphenRule hy = new HyphenRule();
            allVars.addDataElement(hy);
            dataRule.add(hy.getId());
        } else if (elementName.equals("CR")) {
            CRRule cr = new CRRule();
            allVars.addDataElement(cr);
            dataRule.add(cr.getId());
        } else if (elementName.equals("GETRULE")) {
            String ruleId = child.getAttributeValue("idref");
            dataRule.add(ruleId);
        }
    }
    allVars.addDataElement(dataRule);
    return dataRule.getId();
}
Also used : SpaceRule(pcgen.core.doomsdaybook.SpaceRule) HyphenRule(pcgen.core.doomsdaybook.HyphenRule) CRRule(pcgen.core.doomsdaybook.CRRule) DataElement(pcgen.core.doomsdaybook.DataElement) Element(org.jdom2.Element) CRRule(pcgen.core.doomsdaybook.CRRule) HyphenRule(pcgen.core.doomsdaybook.HyphenRule) Rule(pcgen.core.doomsdaybook.Rule) SpaceRule(pcgen.core.doomsdaybook.SpaceRule)

Example 2 with Rule

use of pcgen.core.doomsdaybook.Rule in project pcgen by PCGen.

the class NameGenPanel method generate.

/**
	 * Generate a Rule
	 * @return new Rule
	 */
public Rule generate() {
    try {
        Rule rule;
        if (chkStructure.isSelected()) {
            RuleSet rs = (RuleSet) cbCatalog.getSelectedItem();
            rule = rs.getRule();
        } else {
            rule = (Rule) cbStructure.getSelectedItem();
        }
        ArrayList<DataValue> aName = rule.getData();
        setNameText(aName);
        setMeaningText(aName);
        setPronounciationText(aName);
        return rule;
    } catch (Exception e) {
        Logging.errorPrint(e.getMessage(), e);
        return null;
    }
}
Also used : RuleSet(pcgen.core.doomsdaybook.RuleSet) WeightedDataValue(pcgen.core.doomsdaybook.WeightedDataValue) DataValue(pcgen.core.doomsdaybook.DataValue) CRRule(pcgen.core.doomsdaybook.CRRule) HyphenRule(pcgen.core.doomsdaybook.HyphenRule) Rule(pcgen.core.doomsdaybook.Rule) SpaceRule(pcgen.core.doomsdaybook.SpaceRule) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 3 with Rule

use of pcgen.core.doomsdaybook.Rule in project pcgen by PCGen.

the class NameGenPanel method NameButtonActionPerformed.

private void NameButtonActionPerformed(ActionEvent evt) {
    try {
        NameButton nb = (NameButton) evt.getSource();
        DataElement element = nb.getDataElement();
        element.getData();
        Rule rule = this.lastRule;
        if (rule == null) {
            if (chkStructure.isSelected()) {
                RuleSet rs = (RuleSet) cbCatalog.getSelectedItem();
                rule = rs.getLastRule();
            } else {
                rule = (Rule) cbStructure.getSelectedItem();
            }
            this.lastRule = rule;
        }
        ArrayList<DataValue> aName = rule.getLastData();
        setNameText(aName);
        setMeaningText(aName);
        setPronounciationText(aName);
    } catch (Exception e) {
        Logging.errorPrint(e.getMessage(), e);
    }
}
Also used : DataElement(pcgen.core.doomsdaybook.DataElement) RuleSet(pcgen.core.doomsdaybook.RuleSet) WeightedDataValue(pcgen.core.doomsdaybook.WeightedDataValue) DataValue(pcgen.core.doomsdaybook.DataValue) CRRule(pcgen.core.doomsdaybook.CRRule) HyphenRule(pcgen.core.doomsdaybook.HyphenRule) Rule(pcgen.core.doomsdaybook.Rule) SpaceRule(pcgen.core.doomsdaybook.SpaceRule) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Aggregations

CRRule (pcgen.core.doomsdaybook.CRRule)3 HyphenRule (pcgen.core.doomsdaybook.HyphenRule)3 Rule (pcgen.core.doomsdaybook.Rule)3 SpaceRule (pcgen.core.doomsdaybook.SpaceRule)3 FileNotFoundException (java.io.FileNotFoundException)2 DataConversionException (org.jdom2.DataConversionException)2 DataElement (pcgen.core.doomsdaybook.DataElement)2 DataValue (pcgen.core.doomsdaybook.DataValue)2 RuleSet (pcgen.core.doomsdaybook.RuleSet)2 WeightedDataValue (pcgen.core.doomsdaybook.WeightedDataValue)2 Element (org.jdom2.Element)1