Search in sources :

Example 1 with LineStyleChooser

use of com.ramussoft.pb.frames.components.LineStyleChooser in project ramus by Vitaliy-Yakovchuk.

the class LineStyleAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private LineStyleChooser component;

        private Stroke stroke;

        {
            component = new LineStyleChooser();
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            stroke = pin.getSector().getStroke();
            component.setStroke(stroke);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            LineStyleAttributePlugin.this.apply(component.getStroke(), pin);
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public boolean isSaveAnyway() {
            return !stroke.equals(component.getStroke());
        }
    };
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) LineStyleChooser(com.ramussoft.pb.frames.components.LineStyleChooser) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Engine(com.ramussoft.common.Engine)

Aggregations

Attribute (com.ramussoft.common.Attribute)1 Element (com.ramussoft.common.Element)1 Engine (com.ramussoft.common.Engine)1 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)1 LineStyleChooser (com.ramussoft.pb.frames.components.LineStyleChooser)1 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)1 Pin (com.ramussoft.pb.idef.elements.PaintSector.Pin)1 BasicStroke (java.awt.BasicStroke)1 Stroke (java.awt.Stroke)1