List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth
@Override public int getOffsetWidth()
From source file:org.gems.ajax.client.connection.RectilinearConnection.java
License:Open Source License
protected int adjustXOffset(BasicConnectionLocation loc, Segment s, Widget w, int x, int dir) { double xoff = (s.isHorizontal()) ? loc.getConnectionLengthRelativeOffset() * s.getLength() : loc.getConnectionWidthRelativeOffset() * s.getOffsetWidth(); xoff += (s.isHorizontal()) ? loc.getDecorationLengthRelativeOffset() * w.getOffsetWidth() : loc.getDecorationWidthRelativeOffset() * w.getOffsetHeight(); if (dir == LEFT) x += (int) Math.rint(xoff); else if (dir == RIGHT) x -= (int) Math.rint(xoff); else// w w w . java2 s . c om x += (int) Math.rint(xoff); return x; }
From source file:org.gems.ajax.client.figures.AbstractDiagramElement.java
License:Open Source License
public Rectangle getBounds() { Widget w = getDiagramWidget(); Point p = Util.getDiagramLocation(w); int width = w.getOffsetWidth(); int height = w.getOffsetHeight(); return new Rectangle(p.x, p.y, width, height); }
From source file:org.gems.ajax.client.figures.FloatingWrapper.java
License:Open Source License
public void add(Widget widget, DockLayoutConstant direction) { int ww = widget.getOffsetWidth(); int wh = widget.getOffsetHeight(); if (direction == EAST) { int w = Math.max(ww, rightBounds_.width) - rightBounds_.width; rightBounds_.expand(w, wh + widgetSpread_); rightWidgets_.add(widget);/* w ww .java 2 s. c o m*/ right_.add(widget); } else if (direction == WEST) { int w = Math.max(ww, leftBounds_.width) - leftBounds_.width; leftBounds_.expand(w, wh + widgetSpread_); leftWidgets_.add(widget); left_.add(widget); } else if (direction == NORTH) { int h = Math.max(wh, topBounds_.height) - topBounds_.height; topBounds_.expand(ww + widgetSpread_, h); topWidgets_.add(widget); top_.add(widget); } else if (direction == SOUTH) { int h = Math.max(wh, bottomBounds_.height) - bottomBounds_.height; bottomBounds_.expand(ww + widgetSpread_, h); bottomWidgets_.add(widget); bottom_.add(widget); } else { super.add(widget, direction); } }
From source file:org.gems.ajax.client.figures.FloatingWrapper.java
License:Open Source License
public boolean remove(Widget widget) { if (leftWidgets_.remove(widget)) { int w = Math.max(widget.getOffsetWidth(), leftBounds_.width) - leftBounds_.width; leftBounds_.expand(-1 * w, -1 * (widget.getOffsetHeight() + widgetSpread_)); return left_.remove(widget); } else if (rightWidgets_.remove(widget)) { int w = Math.max(widget.getOffsetWidth(), rightBounds_.width) - rightBounds_.width; rightBounds_.expand(-1 * w, -1 * (widget.getOffsetHeight() + widgetSpread_)); return right_.remove(widget); } else if (topWidgets_.remove(widget)) { int h = Math.max(widget.getOffsetHeight(), topBounds_.height) - topBounds_.height; topBounds_.expand(-1 * (widget.getOffsetWidth() + widgetSpread_), -1 * h); return top_.remove(widget); } else if (bottomWidgets_.remove(widget)) { int h = Math.max(widget.getOffsetHeight(), bottomBounds_.height) - bottomBounds_.height; bottomBounds_.expand(-1 * (widget.getOffsetWidth() + widgetSpread_), -1 * h); return bottom_.remove(widget); } else {//from ww w. j a v a 2s . c o m return super.remove(widget); } }
From source file:org.gems.ajax.client.figures.FloatingWrapper.java
License:Open Source License
protected Dimension calculateBounds(ArrayList<Widget> widgets, boolean horizontal) { Dimension d = new Dimension(0, 0); for (Widget w : widgets) { if (horizontal) { d.height = Math.max(d.height, w.getOffsetHeight()); d.width += w.getOffsetWidth() + widgetSpread_; } else {// w w w. j av a 2 s . c o m d.width = Math.max(d.width, w.getOffsetWidth()); d.height += w.getOffsetHeight() + widgetSpread_; } } return d; }
From source file:org.gems.ajax.client.util.Util.java
License:Open Source License
public static int getOffsetWidth(Widget w) { if (w.getParent() == null) { RootPanel.get().add(w);/*from ww w . j a v a2 s .co m*/ int width = w.getOffsetWidth(); RootPanel.get().remove(w); return width; } else { return w.getOffsetWidth(); } }
From source file:org.geomajas.gwt2.plugin.corewidget.example.client.sample.map.MapLegendDropDown.java
License:Open Source License
private int calculateLeftInMap(int offsetWidth) { int left = calculateLeft(offsetWidth); int popupRight = left + popup.getOffsetWidth(); Widget widget = (Widget) mapPresenter.getWidgetPane(); int mapRight = widget.getAbsoluteLeft() + widget.getOffsetWidth(); if (popupRight > mapRight) { // Align right: int buttonRight = getAbsoluteLeft() + getOffsetWidth(); left = buttonRight - popup.getOffsetWidth(); }// w w w.j av a2 s.co m return left; }
From source file:org.gwm.client.impl.TopBar.java
License:Apache License
private void setMovingGuard() { parent.addFrameListener(new GFrameAdapter() { public void frameMoved(GFrameEvent evt) { if (evt.getGFrame() instanceof GInternalFrame) { GInternalFrame internalFrame = (GInternalFrame) evt.getGFrame(); Widget desktopPane = (Widget) internalFrame.getDesktopPane(); if (internalFrame.getTop() < 0) { internalFrame.setTop(0); }/*from w w w.j a v a 2s . c o m*/ if (internalFrame.getTop() > desktopPane.getOffsetHeight() - 40) { internalFrame.setTop(desktopPane.getOffsetHeight() - 100); } if (internalFrame.getLeft() + internalFrame.getWidth() < 0) { internalFrame.setLeft(-internalFrame.getWidth() + 100); } if (internalFrame.getLeft() > desktopPane.getOffsetWidth()) { internalFrame.setLeft(desktopPane.getOffsetWidth() - 20); } } else { if (evt.getGFrame().getTop() < 0) { evt.getGFrame().setTop(0); } if (evt.getGFrame().getTop() > Window.getClientHeight()) { evt.getGFrame().setTop(Window.getClientHeight() - 20); } if (evt.getGFrame().getLeft() + evt.getGFrame().getWidth() < 0) { evt.getGFrame().setLeft(-evt.getGFrame().getWidth() + 100); } if (evt.getGFrame().getLeft() > Window.getClientWidth()) { evt.getGFrame().setLeft(Window.getClientWidth() - 20); } } } }); }
From source file:org.gwm.splice.client.desktop.DesktopManager.java
License:Apache License
public boolean canDrop(Widget widget) { RootPanel rp = RootPanel.get();//from www . j a va2 s. c om int x = widget.getAbsoluteLeft(); int y = widget.getAbsoluteTop(); int h = widget.getOffsetHeight(); int w = widget.getAbsoluteLeft(); boolean overlapX = false; boolean overlapY = false; for (Iterator iter = rp.iterator(); iter.hasNext();) { Widget child = (Widget) iter.next(); if (child == widget) { continue; } int cx = child.getAbsoluteLeft(); int cy = child.getAbsoluteTop(); int ch = child.getOffsetHeight(); int cw = child.getOffsetWidth(); if (x == cx || y == cy) { return false; } if (x > cx) { if (x <= (cx + cw)) { overlapX = true; } } else if (x < cx) { if ((x + w) >= cx) { overlapX = true; } } if (y > cy) { if (y <= (cy + ch)) { overlapY = true; } } else if (y < cy) { if ((y + h) >= cy) { overlapY = true; } } if (overlapX && overlapY) { return false; } } return true; }
From source file:org.gwt.mosaic.ui.client.layout.CustomGridLayout.java
License:Apache License
/** * Lays out the specified {@link LayoutPanel} using this layout. * <p>/* w w w. ja v a 2 s . c o m*/ * The grid layout manager determines the size of individual widgets by * dividing the free space in the panel into equal-sized portions according to * the number of rows and columns in the layout. The container's free space * equals the container's size minus any margins and any specified horizontal * or vertical gap. * * @param layoutPanel the panel in which to do the layout * * @see org.gwt.mosaic.ui.client.layout.LayoutManager#layoutPanel(org.gwt.mosaic.ui.client.layout.LayoutPanel) */ public void layoutPanel(LayoutPanel layoutPanel) { try { if (layoutPanel == null || !init(layoutPanel)) { return; } final Dimension box = DOM.getClientSize(layoutPanel.getElement()); final int left = paddingLeftMeasure.sizeOf(layoutPanel); final int top = paddingTopMeasure.sizeOf(layoutPanel); int width = box.width - (left + paddingRightMeasure.sizeOf(layoutPanel)); int height = box.height - (top + paddingBottomMeasure.sizeOf(layoutPanel)); final int spacing = layoutPanel.getWidgetSpacing(); // adjust for spacing width -= ((cols - 1) * spacing); height -= ((rows - 1) * spacing); final int colWidth = width / cols; final int rowHeight = height / rows; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { Widget widget = widgetMatrix[c][r]; if (widget == null || widget == SPAN) { continue; } if (widget instanceof InternalDecoratorPanel) { widget = ((InternalDecoratorPanel) widget).getWidget(); } int cellWidth; int cellHeight; final GridLayoutData layoutData = (GridLayoutData) widget.getLayoutData(); final Widget parent = widget.getParent(); if (parent instanceof InternalDecoratorPanel) { final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent; final int borderSizes[] = decPanel.getBorderSizes(); final Dimension decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3], borderSizes[0] + borderSizes[0]); cellWidth = colWidth * layoutData.colspan - decPanelFrameSize.width + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan - decPanelFrameSize.height + spacing * (layoutData.rowspan - 1); } else { cellWidth = colWidth * layoutData.colspan + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan + spacing * (layoutData.rowspan - 1); } HorizontalAlignmentConstant hAlignment = layoutData.getHorizontalAlignment(); if (hAlignment == null) { hAlignment = getHorizontalAlignment(); } Dimension prefSize = null; if (hAlignment == null) { layoutData.targetLeft = left + (spacing + colWidth) * c; layoutData.targetWidth = cellWidth; } else { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_LEFT prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); if (HasHorizontalAlignment.ALIGN_LEFT == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c; } else if (HasHorizontalAlignment.ALIGN_CENTER == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c + (cellWidth / 2) - prefSize.width / 2; } else { layoutData.targetLeft = left + (spacing + colWidth) * c + cellWidth - prefSize.width; } layoutData.targetWidth = prefSize.width; } VerticalAlignmentConstant vAlignment = layoutData.getVerticalAlignment(); if (vAlignment == null) { vAlignment = getVerticalAlignment(); } if (vAlignment == null) { layoutData.targetTop = top + (spacing + rowHeight) * r; layoutData.targetHeight = cellHeight; } else { if (prefSize == null) { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_TOP prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); } if (HasVerticalAlignment.ALIGN_TOP == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r; } else if (HasVerticalAlignment.ALIGN_MIDDLE == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r + (cellHeight / 2) - prefSize.height / 2; } else { layoutData.targetTop = top + (spacing + rowHeight) * r + cellHeight - prefSize.height; } layoutData.targetHeight = prefSize.height; } if (layoutPanel.isAnimationEnabled()) { layoutData.setSourceLeft(widget.getAbsoluteLeft() - layoutPanel.getAbsoluteLeft()); layoutData.setSourceTop(widget.getAbsoluteTop() - layoutPanel.getAbsoluteTop()); layoutData.setSourceWidth(widget.getOffsetWidth()); layoutData.setSourceHeight(widget.getOffsetHeight()); } } } super.layoutPanel(layoutPanel); } catch (Exception e) { GWT.log(e.getMessage(), e); Window.alert(this.getClass().getName() + ".layoutPanel(): " + e.getLocalizedMessage()); } }