UIFrame extends UIElement { public void setAnchorRelative(final UIAnchorSide side, final String relative) { if (this.relative == DFLT_RELATIVE) { if (THIS.equalsIgnoreCase(relative)) { return; } this.relative = new String[] { THIS, THIS, THIS, THIS }; } this.relative[side.ordinal()] = THIS.equalsIgnoreCase(relative) ? THIS : StringInterner.intern(relative); if (THIS.equalsIgnoreCase(this.relative[0]) && THIS.equalsIgnoreCase(this.relative[1]) && THIS.equalsIgnoreCase(this.relative[2]) && THIS.equalsIgnoreCase(this.relative[3])) { this.relative = DFLT_RELATIVE; } } 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 setAnchorRelative() { final UIFrame frame = new UIFrame("UIFrameTest_setAnchor"); frame.setAnchorRelative(UIAnchorSide.BOTTOM, "$parent"); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$this", frame.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$parent", 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.setAnchorRelative(UIAnchorSide.BOTTOM, "$this"); 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)); }