qasta / gwt-diagrams

Automatically exported from code.google.com/p/gwt-diagrams
0 stars 0 forks source link

Static positioning and UIObjectConnector.getLeft/Top #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Fabio wrote:

I think that you must change the if on the methods getleft and gettop on
UiObjectConnector because you've not considered the case in wich the panel
is shifted but the position is static

I've posted you my change code

public int getLeft() {
        int containerOffset = 0;
        Element parent = DOM.getParent(wrapped.getElement());
        while (parent != null) {
            if (("relative".equals( DOM.getStyleAttribute(parent,
"position")) || ("static"
                    .equalsIgnoreCase(DOM.getStyleAttribute(parent,
"position"))))) {
                containerOffset = DOM.getAbsoluteLeft (parent);
                break;
            }
            parent = DOM.getParent(parent);
        }
        return wrapped.getAbsoluteLeft() - containerOffset;
    }

    /**
     * @see pl.balon.gwt.diagrams.client.connector.Connector#getTop ()
     */
    public int getTop() {
        int containerOffset = 0;
        Element parent = DOM.getParent(wrapped.getElement());
        while (parent != null) {
            if (("relative".equals( DOM.getStyleAttribute(parent,
"position")) || ("static"
                    .equalsIgnoreCase(DOM.getStyleAttribute(parent,
"position"))))) {
                containerOffset = DOM.getAbsoluteTop (parent);
                break;
            }
            parent = DOM.getParent(parent);
        }
        return wrapped.getAbsoluteTop() - containerOffset;
    } 

Original issue reported on code.google.com by michal.b...@gmail.com on 24 Jan 2008 at 9:51