Search in sources :

Example 11 with BooleanAttribute

use of doc.attributes.BooleanAttribute 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

BooleanAttribute (doc.attributes.BooleanAttribute)11 IntegerAttribute (doc.attributes.IntegerAttribute)9 ColorAttribute (doc.attributes.ColorAttribute)7 StringAttribute (doc.attributes.StringAttribute)4 AttributeException (doc.attributes.AttributeException)2 DoubleAttribute (doc.attributes.DoubleAttribute)2 GridPointAttribute (doc.attributes.GridPointAttribute)2 Font (java.awt.Font)2 Graphics2D (java.awt.Graphics2D)2 AttributedString (java.text.AttributedString)2 EnumeratedAttribute (doc.attributes.EnumeratedAttribute)1 MathObjectAttribute (doc.attributes.MathObjectAttribute)1 SelectionAttribute (doc.attributes.SelectionAttribute)1 Selection (doc_gui.graph.Selection)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 FontRenderContext (java.awt.font.FontRenderContext)1 LineBreakMeasurer (java.awt.font.LineBreakMeasurer)1 TextLayout (java.awt.font.TextLayout)1 AttributedCharacterIterator (java.text.AttributedCharacterIterator)1