List of usage examples for com.google.gwt.user.client.ui AbsolutePanel setWidgetPosition
public void setWidgetPosition(Widget w, int left, int top)
From source file:ca.upei.ic.timetable.client.CalendarPanel.java
License:Apache License
protected void reorganizePanel(AbsolutePanel panel) { Set<Widget> remaining = new HashSet<Widget>(); Set<Widget> processing = new HashSet<Widget>(); // add all widgets to remaining for (Widget w : panel) { remaining.add(w);/* w w w. j av a2 s .c o m*/ } // loop until no remaining widgets while (remaining.size() > 0) { // get the first widget Widget first = remaining.iterator().next(); int top = panel.getWidgetTop(first); int bottom = panel.getWidgetTop(first) + first.getOffsetHeight(); remaining.remove(first); processing.add(first); // find out the overlapping widgets from the first one boolean continueProcessing = true; while (continueProcessing) { // default to terminate the processing // this is a hack because no goto statement is supported in // Java. boolean terminateProcessing = true; // iterate all widgets until one overlapping widget is found. for (Widget widget : remaining) { int widgetTop = panel.getWidgetTop(widget); int widgetBottom = panel.getWidgetTop(widget) + widget.getOffsetHeight(); // found if (top < widgetBottom && widgetTop < bottom) { // add to processing set, remove from remaining set processing.add(widget); remaining.remove(widget); // reset top and bottom if necessary if (top > widgetTop) top = widgetTop; if (bottom < widgetBottom) bottom = widgetBottom; // don't terminate processing terminateProcessing = false; break; } } // really want to terminate the process? if (terminateProcessing) continueProcessing = false; } // all processing widgets found, try to reposition/resize the // widgets int count = processing.size(); int index = 0; for (Widget widget : processing) { int widgetWidth = (panel.getOffsetWidth() - 2) / count; int widgetTop = panel.getWidgetTop(widget); int widgetLeft = index * widgetWidth; widget.setWidth(Integer.toString(widgetWidth) + "px"); panel.setWidgetPosition(widget, widgetLeft, widgetTop); index++; } // clear the processing set processing.clear(); } }
From source file:ch.unifr.pai.twice.dragndrop.standalone.client.DragNDropStandalone.java
License:Apache License
@Override public void onModuleLoad() { // Enable multicursor support MultiCursorController c = GWT.create(MultiCursorController.class); c.start();/* w w w .j av a 2 s . com*/ DockLayoutPanel mainpanel = new DockLayoutPanel(Unit.PX); final AbsolutePanel p = new AbsolutePanel(); DraggableLabel l = new DraggableLabel(); l.setText("DRAG ME"); mainpanel.add(p); RootLayoutPanel.get().add(mainpanel); p.add(l); final FocusPanel drop = new FocusPanel(); drop.setWidth("500px"); drop.setHeight("400px"); drop.getElement().getStyle().setBackgroundColor("green"); p.add(drop); p.setWidgetPosition(drop, 400, 200); // define the green focus panel to be a drop target handler DragNDrop.setDropHandler(drop, new DropTargetHandler() { @Override public void onHoverEnd(String deviceId, Widget widget, Element dragProxy, Event event) { drop.getElement().getStyle().setBackgroundColor("yellow"); } @Override public void onHover(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { drop.getElement().getStyle().setBackgroundColor("red"); } @Override public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { Window.alert("Dropped"); return false; } @Override public Priority getPriority() { return Priority.NORMAL; } }, true); // Make the label draggable DragNDrop.makeDraggable(l, DragConfiguration.withProxy(new DragNDropHandler() { @Override public void onStartDrag(String deviceId, Widget draggedWidget) { // TODO Auto-generated method stub } @Override public void onEndOfDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop, Event event) { // TODO Auto-generated method stub } @Override public boolean onDrop(String deviceId, Widget draggedWidget, int dragProxyLeft, int dragProxyTop, Event event, DropTargetHandler dropTarget, boolean outOfBox) { p.setWidgetPosition(draggedWidget, dragProxyLeft - p.getAbsoluteLeft(), dragProxyTop - p.getAbsoluteTop()); return true; } })); }
From source file:cl.uai.client.marks.Mark.java
License:Open Source License
public static void showIcons(Mark mark, int mouseLeft) { // Gets the absolute panel which contains the mark to calculate its coordinates AbsolutePanel abspanel = (AbsolutePanel) mark.getParent(); int topdiff = -Mark.editIcon.getOffsetHeight(); // Calculates basic left, top position for icons int top = mark.getAbsoluteTop() - abspanel.getAbsoluteTop() + (topdiff); int left = mouseLeft > 0 && mark instanceof HighlightMark ? mouseLeft : mark.getAbsoluteLeft(); if (top < 0) { top += mark.getOffsetHeight();/*w ww . jav a 2 s . com*/ } // Check if icons and popup are already added in the panel, if not adds them if (abspanel.getWidgetIndex(Mark.editIcon) < 0) abspanel.add(Mark.editIcon, left, top); if (abspanel.getWidgetIndex(Mark.deleteIcon) < 0) abspanel.add(Mark.deleteIcon, left, top); if (abspanel.getWidgetIndex(Mark.regradeIcon) < 0) abspanel.add(Mark.regradeIcon, left, top); if (abspanel.getWidgetIndex(Mark.minimizeIcon) < 0) abspanel.add(Mark.minimizeIcon, left, top); if (abspanel.getWidgetIndex(Mark.markPopup) < 0) abspanel.add(Mark.markPopup, left, top); // Make sure no other icons are left Mark.hideIcons(); // If we are in grading mode, show delete and edit icons if (!EMarkingConfiguration.isReadonly()) { // Edit icon is only for comments and rubrics abspanel.setWidgetPosition(Mark.editIcon, left, top); Mark.editIcon.setVisible(true); Mark.editIcon.setMark(mark); left += Mark.editIcon.getOffsetWidth() + 5; top -= 1; // Delete icon abspanel.setWidgetPosition(Mark.deleteIcon, left, top); Mark.deleteIcon.setVisible(true); Mark.deleteIcon.setMark(mark); } // If the user owns the submission and the dates are ok we show the regrade icon if (EMarkingConfiguration.isOwnDraft() && MarkingInterface.submissionData.isRegradingAllowed() && !EMarkingConfiguration.isFormativeFeedbackOnly()) { // Edit icon is only for comments and rubrics if (mark instanceof RubricMark) { abspanel.setWidgetPosition(Mark.regradeIcon, left, top); Mark.regradeIcon.setVisible(true); Mark.regradeIcon.setMark(mark); } } // Highlight the rubric interface if the mark is a RubricMark if (EMarkingConfiguration.getRubricMarkType() != EMarkingConfiguration.EMARKING_RUBRICMARK_TEXTBOX) { Mark.markPopup.setHTML(mark.getMarkPopupHTML()); Mark.markPopup.setVisible(true); top += 50; abspanel.setWidgetPosition(Mark.markPopup, left, top); EMarkingWeb.reloadMathJax(); } }
From source file:cl.uai.client.marks.RubricMark.java
License:Open Source License
public void updatePositionCollaborativeButtons() { if (collaborativeMarks == null) return;/*from ww w .j a v a2 s . co m*/ AbsolutePanel abspanel = (AbsolutePanel) this.getParent(); abspanel.setWidgetPosition(collaborativeMarks, abspanel.getWidgetLeft(this), abspanel.getWidgetTop(this) + this.height - 10); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.window.WindowPanel.java
License:Apache License
public void moveBy(int right, int down) { AbsolutePanel parent = (AbsolutePanel) getParent(); Location location = new WidgetLocation(this, parent); int left = location.getLeft() + right; int top = location.getTop() + down; parent.setWidgetPosition(this, left, top); }
From source file:com.moesol.gwt.maps.client.DivPanel.java
License:Open Source License
public void makePanelSmall(AbsolutePanel panel, int width, int height) { super.setPixelSize(width, height); panel.setWidgetPosition(this, 0, 0); }
From source file:com.moesol.gwt.maps.client.DivPanel.java
License:Open Source License
public void placeInViewPanel(AbsolutePanel panel) { IProjection mp = m_map.getProjection(); ViewWorker vw = m_map.getViewport().getVpWorker(); ViewCoords tl = m_divWorker.computeDivLayoutInView(mp, vw, m_scaledDims); m_tl = tl;/*from w w w .j a v a2s.c om*/ super.setPixelSize(m_scaledDims.getWidth(), m_scaledDims.getHeight()); panel.setWidgetPosition(this, tl.getX(), tl.getY()); }
From source file:com.moesol.gwt.maps.client.MCOP.java
License:Open Source License
private void doMapPanel(RootPanel mapPanel) { DOM.setInnerHTML(mapPanel.getElement(), ""); TouchPanel touchPanel = makeTouchPanel(); AbsolutePanel controlsAndMap = new AbsolutePanel(); m_msg = new Label("msg..."); m_map = new MapView(); loadLayerConfigsFromClient();// w w w . j a va2 s .c om int w = Window.getClientWidth() - 20; int h = Window.getClientHeight() - 20; controlsAndMap.setPixelSize(w, h); m_map.setPixelSize(w, h); m_map.updateView(); bindListeners(touchPanel, m_map); Button in = new Button(" + ", new ClickHandler() { @Override public void onClick(ClickEvent event) { goIn(); } }); Button out = new Button(" - ", new ClickHandler() { @Override public void onClick(ClickEvent event) { goOut(); } }); HorizontalPanel bar = new HorizontalPanel(); bar.add(in); bar.add(out); bar.add(m_msg); touchPanel.setWidget(m_map); controlsAndMap.add(touchPanel); controlsAndMap.add(bar); controlsAndMap.setWidgetPosition(bar, 10, 10); mapPanel.add(controlsAndMap); // Layer a tranparent dialog... // DialogBox db = new DialogBox(); // VerticalPanel dbPanel = new VerticalPanel(); // db.setHTML("<a href='' onclick='false'>x</a>"); // db.setPopupPosition(100, 10); // db.setPixelSize(100, 100); // db.show(); }
From source file:com.mycompany.client.MyApplication2.java
License:Apache License
/** * Deferred initialization method, called from {@link #onModuleLoad()}. */// w w w .j a v a2s .com private void onModuleLoad2() { // Create a boundary panel to constrain all drag operations AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setPixelSize(400, 300); boundaryPanel.addStyleName("getting-started-blue"); // Create a drop target on which we can drop labels AbsolutePanel targetPanel = new AbsolutePanel(); targetPanel.setPixelSize(300, 200); targetPanel.addStyleName("getting-started-blue"); // Add both panels to the root panel RootPanel.get().add(boundaryPanel); boundaryPanel.add(targetPanel, 40, 40); // Create a DragController for each logical area where a set of draggable // widgets and drop targets will be allowed to interact with one another. PickupDragController dragController = new PickupDragController(boundaryPanel, true); // Positioner is always constrained to the boundary panel // Use 'true' to also constrain the draggable or drag proxy to the boundary panel dragController.setBehaviorConstrainedToBoundaryPanel(false); // Allow multiple widgets to be selected at once using CTRL-click dragController.setBehaviorMultipleSelection(true); // create a DropController for each drop target on which draggable widgets // can be dropped DropController dropController = new AbsolutePositionDropController(targetPanel); // Don't forget to register each DropController with a DragController dragController.registerDropController(dropController); // create a few randomly placed draggable labels for (int i = 1; i <= 5; i++) { // create a label and give it style Label label = new Label("Label #" + i, false); label.addStyleName("getting-started-label"); // add it to the DOM so that offset width/height becomes available targetPanel.add(label, 0, 0); // determine random label location within target panel int left = Random.nextInt(DOMUtil.getClientWidth(targetPanel.getElement()) - label.getOffsetWidth()); int top = Random.nextInt(DOMUtil.getClientHeight(targetPanel.getElement()) - label.getOffsetHeight()); // move the label targetPanel.setWidgetPosition(label, left, top); // make the label draggable dragController.makeDraggable(label); } }
From source file:com.risevision.ui.client.common.dnd.WindowPanel.java
License:Apache License
public void moveBy(int right, int down) { AbsolutePanel parent = (AbsolutePanel) getParent(); Location location = new WidgetLocation(this, parent); int left = location.getLeft() + right; int top = location.getTop() + down; parent.setWidgetPosition(this, left, top); if (getPreviewWidget() != null) { parent.setWidgetPosition(getPreviewWidget(), left + 5, top + 5); }/*from w w w.ja va 2s . c om*/ }