UIFrame extends UIElement { public void setAnchorOffset(final UIAnchorSide side, final String offset) { if (this.offset == DFLT_OFFSET) { if (ZERO.equals(offset)) { return; } this.offset = new String[] { ZERO, ZERO, ZERO, ZERO }; } this.offset[side.ordinal()] = ZERO.equals(offset) ? ZERO : StringInterner.intern(offset); if (ZERO.equals(this.offset[0]) && ZERO.equals(this.offset[1]) && ZERO.equals(this.offset[2]) && ZERO.equals(this.offset[3])) { this.offset = DFLT_OFFSET; } } UIFrame();  UIFrame(final String name, final String type);  UIFrame(final String name, final int initialAttributesCapacity, final int initialChildrenCapacity);  UIFrame(final String name); @Override Object deepCopy(); String getType(); void setType(final String type); @Override List<UIElement> getChildren(); void setChildren(final List<UIElement> children); @Override List<UIElement> getChildrenRaw(); void addAttribute(final UIAttribute value); UIAttribute getValue(final String key); List<UIAttribute> getAttributes(); String getAnchorRelative(final UIAnchorSide side); String getAnchorOffset(final UIAnchorSide side); String getAnchorPos(final UIAnchorSide side); void setAnchor(final String relative, final String offset); void setAnchor(final UIAnchorSide side, final String relative, final String pos, final String offset); void setAnchorRelative(final UIAnchorSide side, final String relative); void setAnchorPos(final UIAnchorSide side, final String pos); void setAnchorOffset(final UIAnchorSide side, final String offset); @Override UIElement receiveFrameFromPath(final String path); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); static final String ZERO; }
@Test void setAnchorOffset() { final UIFrame frame = new UIFrame("UIFrameTest_setAnchor"); frame.setAnchorOffset(UIAnchorSide.BOTTOM, "11"); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.RIGHT)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.TOP)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.LEFT)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.BOTTOM)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.RIGHT)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.TOP)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.LEFT)); assertEquals("11", frame.getAnchorOffset(UIAnchorSide.BOTTOM)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.RIGHT)); frame.setAnchorOffset(UIAnchorSide.BOTTOM, "0"); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.RIGHT)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.TOP)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.LEFT)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.BOTTOM)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.RIGHT)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.TOP)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.LEFT)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.BOTTOM)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.RIGHT)); frame.setAnchorOffset(UIAnchorSide.BOTTOM, "-5.2"); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.RIGHT)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.TOP)); assertEquals("MIN", frame.getAnchorPos(UIAnchorSide.LEFT)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.BOTTOM)); assertEquals("MAX", frame.getAnchorPos(UIAnchorSide.RIGHT)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.TOP)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.LEFT)); assertEquals("-5.2", frame.getAnchorOffset(UIAnchorSide.BOTTOM)); assertEquals("0", frame.getAnchorOffset(UIAnchorSide.RIGHT)); }