UIFrame extends UIElement { public void setAnchorPos(final UIAnchorSide side, final String pos) { if (this.pos == DFLT_POS) { if (DFLT_POS[side.ordinal()].equalsIgnoreCase(pos)) { return; } this.pos = new String[] { MIN, MIN, MAX, MAX }; } if (MAX.equalsIgnoreCase(pos)) { this.pos[side.ordinal()] = MAX; } else { this.pos[side.ordinal()] = MIN.equalsIgnoreCase(pos) ? MIN : StringInterner.intern(pos); } if (MIN.equals(this.pos[0]) && MIN.equals(this.pos[1]) && MAX.equals(this.pos[2]) && MAX.equals(this.pos[3])) { this.pos = DFLT_POS; } } 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 setAnchorPos() { final UIFrame frame = new UIFrame("UIFrameTest_setAnchor"); frame.setAnchorPos(UIAnchorSide.BOTTOM, "min"); 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("MIN", 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.setAnchorPos(UIAnchorSide.BOTTOM, "max"); 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.setAnchorPos(UIAnchorSide.BOTTOM, "mid"); 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("mid", 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.setAnchorPos(UIAnchorSide.BOTTOM, "0.123"); 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("0.123", 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)); }