UIFrame extends UIElement { @Override public Object deepCopy() { final int attrSize = attributes != null ? attributes.size() : 0; final int childrenSize = children != null ? children.size() : 0; final UIFrame clone = new UIFrame(getName(), attrSize, childrenSize); clone.type = type; if (childrenSize > 0) { for (int i = 0; i < childrenSize; i++) { clone.children.add((UIElement) children.get(i).deepCopy()); } } if (attrSize > 0) { for (int i = 0; i < attrSize; i++) { clone.attributes.add((UIAttribute) attributes.get(i).deepCopy()); } } if (relative != DFLT_RELATIVE) { clone.relative = new String[4]; System.arraycopy(relative, 0, clone.relative, 0, 4); } if (offset != DFLT_OFFSET) { clone.offset = new String[4]; System.arraycopy(offset, 0, clone.offset, 0, 4); } if (pos != DFLT_POS) { clone.pos = new String[4]; System.arraycopy(pos, 0, clone.pos, 0, 4); } return clone; } 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 deepCopy() { final UIFrame frame = new UIFrame("UIFrameTest_setAnchor"); frame.setAnchor("$parent", "0"); assertEquals("$parent", frame.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$parent", frame.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$parent", frame.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$parent", 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)); final UIFrame frame2 = (UIFrame) frame.deepCopy(); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.RIGHT)); assertEquals("MIN", frame2.getAnchorPos(UIAnchorSide.TOP)); assertEquals("MIN", frame2.getAnchorPos(UIAnchorSide.LEFT)); assertEquals("MAX", frame2.getAnchorPos(UIAnchorSide.BOTTOM)); assertEquals("MAX", frame2.getAnchorPos(UIAnchorSide.RIGHT)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.TOP)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.LEFT)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.BOTTOM)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.RIGHT)); frame2.setAnchor(UIAnchorSide.BOTTOM, "$Minimap", "mid", "11"); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.TOP)); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.LEFT)); assertEquals("$Minimap", frame2.getAnchorRelative(UIAnchorSide.BOTTOM)); assertEquals("$parent", frame2.getAnchorRelative(UIAnchorSide.RIGHT)); assertEquals("MIN", frame2.getAnchorPos(UIAnchorSide.TOP)); assertEquals("MIN", frame2.getAnchorPos(UIAnchorSide.LEFT)); assertEquals("mid", frame2.getAnchorPos(UIAnchorSide.BOTTOM)); assertEquals("MAX", frame2.getAnchorPos(UIAnchorSide.RIGHT)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.TOP)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.LEFT)); assertEquals("11", frame2.getAnchorOffset(UIAnchorSide.BOTTOM)); assertEquals("0", frame2.getAnchorOffset(UIAnchorSide.RIGHT)); }