Search in sources :

Example 1 with SimpleAttributeConverter

use of com.ramussoft.core.attribute.simple.SimpleAttributeConverter in project ramus by Vitaliy-Yakovchuk.

the class StatusPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new SimpleAttributeConverter() {

        @Override
        protected Object toObject(Persistent persistent) {
            StatusPersistent p = (StatusPersistent) persistent;
            return new Status(p.getType(), p.getOtherName());
        }

        @Override
        protected Persistent toPersistent(Object value) {
            StatusPersistent p = new StatusPersistent();
            Status s = (Status) value;
            p.setOtherName(s.getAtherName());
            p.setType(s.getType());
            return p;
        }
    };
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Persistent(com.ramussoft.common.persistent.Persistent) SimpleAttributeConverter(com.ramussoft.core.attribute.simple.SimpleAttributeConverter)

Example 2 with SimpleAttributeConverter

use of com.ramussoft.core.attribute.simple.SimpleAttributeConverter in project ramus by Vitaliy-Yakovchuk.

the class FRectanglePlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new SimpleAttributeConverter() {

        @Override
        protected Object toObject(Persistent persistent) {
            FRectanglePersistent fp = (FRectanglePersistent) persistent;
            return new FRectangle(fp.getX(), fp.getY(), fp.getWidth(), fp.getHeight());
        }

        @Override
        protected Persistent toPersistent(Object value) {
            FRectanglePersistent e = new FRectanglePersistent();
            FRectangle rect = (FRectangle) value;
            e.setX(rect.getX());
            e.setY(rect.getY());
            e.setWidth(rect.getWidth());
            e.setHeight(rect.getHeight());
            return e;
        }
    };
}
Also used : FRectangle(com.dsoft.pb.types.FRectangle) Persistent(com.ramussoft.common.persistent.Persistent) SimpleAttributeConverter(com.ramussoft.core.attribute.simple.SimpleAttributeConverter)

Example 3 with SimpleAttributeConverter

use of com.ramussoft.core.attribute.simple.SimpleAttributeConverter in project ramus by Vitaliy-Yakovchuk.

the class FontPlugin method getAttributeConverter.

@Override
public AttributeConverter getAttributeConverter() {
    return new SimpleAttributeConverter() {

        @Override
        protected Object toObject(Persistent persistent) {
            FontPersistent p = (FontPersistent) persistent;
            return new Font(p.getName(), p.getStyle(), p.getSize());
        }

        @Override
        protected Persistent toPersistent(Object value) {
            Font f = (Font) value;
            FontPersistent p = new FontPersistent();
            p.setName(f.getName());
            p.setStyle(f.getStyle());
            p.setSize(f.getSize());
            return p;
        }
    };
}
Also used : Persistent(com.ramussoft.common.persistent.Persistent) Font(java.awt.Font) SimpleAttributeConverter(com.ramussoft.core.attribute.simple.SimpleAttributeConverter)

Aggregations

Persistent (com.ramussoft.common.persistent.Persistent)3 SimpleAttributeConverter (com.ramussoft.core.attribute.simple.SimpleAttributeConverter)3 Status (com.dsoft.pb.idef.elements.Status)1 FRectangle (com.dsoft.pb.types.FRectangle)1 Font (java.awt.Font)1