package jetbrains.mps.lang.editor.diagram.runtime.jetpad.views; /*Generated by MPS */ import jetbrains.jetpad.projectional.view.GroupView; import jetbrains.jetpad.model.property.Property; import jetbrains.jetpad.geometry.Rectangle; import jetbrains.jetpad.model.property.ValueProperty; import jetbrains.jetpad.mapper.Mapper; import jetbrains.jetpad.mapper.Synchronizers; import jetbrains.jetpad.model.collections.list.ObservableList; import jetbrains.jetpad.projectional.view.View; import jetbrains.jetpad.projectional.diagram.util.SubList; public abstract class AbstractExternalFrameView extends GroupView { public Property<Rectangle> internalsBounds = new ValueProperty<Rectangle>(new Rectangle(0, 0, 0, 0)); public Property<Integer> frameWidth = new ValueProperty<Integer>(1); protected Property<Rectangle> frameRectangle = new ValueProperty<Rectangle>(); public AbstractExternalFrameView() { new Mapper<AbstractExternalFrameView, AbstractExternalFrameView>(this, this) { @Override protected void registerSynchronizers(Mapper.SynchronizersConfiguration configuration) { super.registerSynchronizers(configuration); configuration.add(Synchronizers.forProperty(frameWidth, new Runnable() { public void run() { updateFrameRectangle(internalsBounds.get(), frameWidth.get()); } })); configuration.add(Synchronizers.forProperty(internalsBounds, new Runnable() { public void run() { updateFrameRectangle(internalsBounds.get(), frameWidth.get()); } })); } }.attachRoot(); } private void updateFrameRectangle(Rectangle bounds, int frameWidth) { frameRectangle.set(new Rectangle(bounds.origin.x - frameWidth, bounds.origin.y - frameWidth, bounds.dimension.x + frameWidth * 2, bounds.dimension.y + frameWidth * 2)); } protected static int getHalfWidth(int lineWidth) { return lineWidth - lineWidth / 2; } protected ObservableList<View> childSubList() { return new SubList<View>() { protected ObservableList<View> getBaseList() { return children(); } }; } }