Search in sources :

Example 11 with MathObjectAttribute

use of doc.attributes.MathObjectAttribute in project OpenNotebook by jaltekruse.

the class OldReader method readAttribute.

public void readAttribute(String uri, String name, String qName, Attributes atts) {
    MathObjectAttribute mAtt = null;
    boolean justAddedAttribute = false;
    if (qName.equals("BooleanAttribute")) {
        mAtt = new BooleanAttribute(atts.getValue(NAME));
        justAddedAttribute = true;
    } else if (qName.equals("DoubleAttribute")) {
        mAtt = new DoubleAttribute(atts.getValue(NAME));
        justAddedAttribute = true;
    } else if (qName.equals("GridPointAttribute")) {
        mAtt = new GridPointAttribute(atts.getValue(NAME));
        justAddedAttribute = true;
    } else if (qName.equals("IntegerAttribute")) {
        mAtt = new IntegerAttribute(atts.getValue(NAME));
        justAddedAttribute = true;
    } else if (qName.equals("StringAttribute")) {
        mAtt = new StringAttribute(atts.getValue(NAME));
        justAddedAttribute = true;
    } else {
        if (mObj == group) {
            return;
        }
        if (DEBUG) {
            System.out.println("bad attribute found! " + qName);
        }
    }
    if (justAddedAttribute) {
        try {
            mAtt.setValueWithString(atts.getValue(VALUE));
            mObj.addAttribute(mAtt);
            mObj.setAttributeValue(mAtt.getName(), mAtt.getValue());
        } catch (AttributeException e) {
            if (DEBUG) {
                System.out.println(e.getMessage());
            }
            hadAttributeError = true;
            attributeNameInError = atts.getValue(NAME);
            attributeValueInError = atts.getValue(VALUE);
            objectWithError = mObj.getClass().getSimpleName();
            justAddedAttribute = false;
            return;
        }
    } else {
        for (int i = 0; i < atts.getLength(); i++) {
            if (DEBUG) {
                System.out.println(atts.getValue(i).toString());
            }
        }
        hadAttributeError = true;
        attributeNameInError = atts.getValue(NAME);
        attributeValueInError = atts.getValue(VALUE);
        objectWithError = mObj.getClass().getSimpleName();
        justAddedAttribute = false;
        return;
    }
}
Also used : BooleanAttribute(doc.attributes.BooleanAttribute) MathObjectAttribute(doc.attributes.MathObjectAttribute) GridPointAttribute(doc.attributes.GridPointAttribute) StringAttribute(doc.attributes.StringAttribute) IntegerAttribute(doc.attributes.IntegerAttribute) AttributeException(doc.attributes.AttributeException) DoubleAttribute(doc.attributes.DoubleAttribute)

Aggregations

MathObjectAttribute (doc.attributes.MathObjectAttribute)11 ListAttribute (doc.attributes.ListAttribute)6 Insets (java.awt.Insets)4 AttributeException (doc.attributes.AttributeException)3 GridBagConstraints (java.awt.GridBagConstraints)3 JPanel (javax.swing.JPanel)3 StringAttribute (doc.attributes.StringAttribute)2 GridBagLayout (java.awt.GridBagLayout)2 JButton (javax.swing.JButton)2 JLabel (javax.swing.JLabel)2 BooleanAttribute (doc.attributes.BooleanAttribute)1 DoubleAttribute (doc.attributes.DoubleAttribute)1 GridPointAttribute (doc.attributes.GridPointAttribute)1 IntegerAttribute (doc.attributes.IntegerAttribute)1 ExpressionObject (doc.mathobjects.ExpressionObject)1 GraphObject (doc.mathobjects.GraphObject)1 MathObject (doc.mathobjects.MathObject)1 ProblemGenerator (doc.mathobjects.ProblemGenerator)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1