position.getTopUnits().getSymbol(), position.getTopValue()); writePositionAttribute(childElement, ATTR_RIGHT, position.getRightUnits().getSymbol(), position.getRightValue()); writePositionAttribute(childElement, ATTR_BOTTOM, position.getBottomUnits().getSymbol(), position.getBottomValue()); writePositionAttribute(childElement, ATTR_LEFT, position.getLeftUnits().getSymbol(), position.getLeftValue()); if (position.getZIndex() >= 0) { childElement.attr(ATTR_Z_INDEX, String.valueOf(position.zIndex));
@Override public Object getValueAs(String value, Class<?> valueType, Component component) { if (component.getParent() instanceof AbsoluteLayout) { AbsoluteLayout outerInstance = (AbsoluteLayout) component .getParent(); try { // ComponentPosition is an inner class that requires // an instance of the outer class as a parameter. ComponentPosition position = ((ComponentPosition) valueType .getConstructors()[0].newInstance(outerInstance)); position.setCSSString(value); return position; } catch (Exception e) { throw new LayoutInflaterException( "Exception while processing ComponentPosition value: " + value, e); } } return null; }
ComponentPosition position = parent.getPosition(comp); float x = position.getLeftValue() + movex; float y = position.getTopValue() + movey; position.setLeft(x, Sizeable.UNITS_PIXELS); position.setTop(y, Sizeable.UNITS_PIXELS);
ComponentPosition position = parent.getPosition(comp); float x = position.getLeftValue() + movex; float y = position.getTopValue() + movey; position.setLeft(x, Sizeable.UNITS_PIXELS); position.setTop(y, Sizeable.UNITS_PIXELS);
ComponentPosition position = parent.getPosition(comp); if (position.getLeftValue() != null) { float x = position.getLeftValue() + movex; position.setLeft(x, Sizeable.UNITS_PIXELS); if (position.getRightValue() != null) { float x = position.getRightValue() - movex; position.setRight(x, Sizeable.UNITS_PIXELS); if (position.getTopValue() != null) { float y = position.getTopValue() + movey; position.setTop(y, Sizeable.UNITS_PIXELS); if (position.getBottomValue() != null) { float y = position.getBottomValue() - movey; position.setBottom(y, Sizeable.UNITS_PIXELS);
ComponentPosition position = parent.getPosition(comp); if (position.getLeftValue() != null) { float x = position.getLeftValue() + movex; position.setLeft(x, Sizeable.UNITS_PIXELS); if (position.getRightValue() != null) { float x = position.getRightValue() - movex; position.setRight(x, Sizeable.UNITS_PIXELS); if (position.getTopValue() != null) { float y = position.getTopValue() + movey; position.setTop(y, Sizeable.UNITS_PIXELS); if (position.getBottomValue() != null) { float y = position.getBottomValue() - movey; position.setBottom(y, Sizeable.UNITS_PIXELS);
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); // Get top-left pixel position int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); ComponentPosition position = layout.getPosition(component); position.setLeft((float) leftPixelPosition, Sizeable.UNITS_PIXELS); position.setTop((float) topPixelPosition, Sizeable.UNITS_PIXELS); }
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); // Get top-left pixel position int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); ComponentPosition position = layout.getPosition(component); position.setLeft((float) leftPixelPosition, Sizeable.UNITS_PIXELS); position.setTop((float) topPixelPosition, Sizeable.UNITS_PIXELS); }
/** * Adds a component to the layout. The component can be positioned by * providing a string formatted in CSS-format. * <p> * For example the string "top:10px;left:10px" will position the component * 10 pixels from the left and 10 pixels from the top. The identifiers: * "top","left","right" and "bottom" can be used to specify the position. * </p> * * @param c * The component to add to the layout * @param cssPosition * The css position string */ public void addComponent(Component c, String cssPosition) { ComponentPosition position = new ComponentPosition(); position.setCSSString(cssPosition); addComponent(c, position); }