List of usage examples for com.google.gwt.user.client.ui LayoutPanel setWidgetLeftWidth
public void setWidgetLeftWidth(IsWidget child, double left, Unit leftUnit, double width, Unit widthUnit)
From source file:cc.kune.initials.AvatarComposite.java
License:GNU Affero Public License
public AvatarComposite(final Builder builder, final int[][] sizes, final int[] fontSizes, final List<IsWidget> widgets) { final LayoutPanel panel = new LayoutPanel(); final int fullSize = builder.getSize(); panel.setSize(fullSize + "px", fullSize + "px"); for (int i = 0; i < widgets.size(); i++) { final int top = sizes[i][0]; final int height = sizes[i][1]; final int left = sizes[i][2]; final int width = sizes[i][3]; final int finalWidth = width - left; final int finalHeight = height - top; final IsWidget widget = widgets.get(i); IsWidget wrap = widget;/*w ww.j a v a2 s. c o m*/ if (widget instanceof InitialLabel) { ((InitialLabel) widget).setStyle(height, fontSizes[i]); } else if (widget instanceof Image) { // If is an image, we crop/resize in the center of the image wrap = ImagesHelper.cropResize((Image) widget, fullSize, finalWidth, finalHeight); } panel.add(wrap); panel.setWidgetTopHeight(wrap, top, PX, height, PX); panel.setWidgetLeftWidth(wrap, left, PX, width, PX); } initWidget(panel); }
From source file:com.google.gwt.examples.LayoutPanelExample.java
License:Apache License
public void onModuleLoad() { // Attach two child widgets to a LayoutPanel, laying them out horizontally, // splitting at 50%. Widget childOne = new HTML("left"), childTwo = new HTML("right"); LayoutPanel p = new LayoutPanel(); p.add(childOne);/*from w w w .j a v a 2 s.c o m*/ p.add(childTwo); p.setWidgetLeftWidth(childOne, 0, PCT, 50, PCT); p.setWidgetRightWidth(childTwo, 0, PCT, 50, PCT); // Attach the LayoutPanel to the RootLayoutPanel. The latter will listen for // resize events on the window to ensure that its children are informed of // possible size changes. RootLayoutPanel rp = RootLayoutPanel.get(); rp.add(p); }
From source file:com.google.gwt.sample.stockwatcher.client.Panels.java
private Widget loadLayouPanel() { Widget child0 = new Label("Test 1"); Widget child1 = new Label("Test 2"); Widget child2 = new Label("Test 3"); LayoutPanel p = new LayoutPanel(); p.add(child0);//from w w w. j a v a 2 s . c o m p.add(child1); p.add(child2); p.setWidgetLeftWidth(child0, 0, PCT, 50, PCT); // Left panel p.setWidgetRightWidth(child1, 0, PCT, 50, PCT); // Right panel p.setWidgetLeftRight(child2, 5, EM, 5, EM); // Center panel p.setWidgetTopBottom(child2, 5, EM, 5, EM); return p; }
From source file:com.moesol.gwt.maps.client.Driver.java
License:Open Source License
private void doMapPanel(RootPanel mapPanel) { mapPanel.setHeight("100%"); mapPanel.setWidth("100%"); DOM.setInnerHTML(mapPanel.getElement(), ""); final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX); dockPanel.setHeight("420px"); dockPanel.setWidth("600px"); mapPanel.add(dockPanel);/*w w w. j av a2 s. c om*/ // loadLayerConfigsFromServer(); loadLayerConfigsFromClient(); //VerticalPanel vp = new VerticalPanel(); MapPanel mapFillPanel = new MapPanel(m_map); m_map.setDpi(m_scrnDpi); m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS); //new EdgeHoverPanControl(m_map, MAP_EDGE_HOVER_RADIUS_PIXELS, // MAP_EDGE_HOVER_PAN_INTERVAL, // MAP_EDGE_HOVER_MAX_PAN_PER_INTERVAL_PIXELS); // m_map.getController().addHoverHandler(new HoverHandler() { // BubbleControl bc = new BubbleControl(m_map); // // @Override // public void onHover(HoverEvent e) { // ViewCoords m_vc = new ViewCoords(e.getX(), e.getY()); // GeodeticCoords gc = m_map.getProjection().viewToGeodetic(m_vc); // bc.getHtml().setHTML("Hover: " + gc.toString()); // bc.animateShow(e.getClientX(), e.getClientY()); // } // }); if (isTrue("showSomeIcons", false)) { addSomeIcons(); } m_map.updateView(); // Button left = new Button("Left", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goLeft(); // } // }); // Button right = new Button("Right", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goRight(); // }}); // Button up = new Button("Up", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goUp(); // }}); // Button down = new Button("Down", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goDown(); // }}); // // Button in = new Button("In", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goIn(); // }}); // Button out = new Button("Out", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // goOut(); // }}); Button removeIcons = new Button("Remove Icons", new ClickHandler() { @Override public void onClick(ClickEvent event) { removeIcons(); } }); Button moveIcons = new Button("Move Icons", new ClickHandler() { @Override public void onClick(ClickEvent event) { moveIcons(); } }); Button resizeMap = new Button("Fill Viewport", new ClickHandler() { @Override public void onClick(ClickEvent event) { dockPanel.setHeight("100%"); dockPanel.setWidth("100%"); } }); MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); oracle.add("0"); oracle.add("01"); oracle.add("1"); oracle.add("3"); m_levelBox = new SuggestBox(); m_map.addChangeListener(new ChangeListener() { @Override public void onChange(Widget sender) { mapChanged(); } }); HorizontalPanel bar = new HorizontalPanel(); // bar.add(left); // bar.add(right); // bar.add(up); // bar.add(down); // bar.add(in); // bar.add(out); bar.add(removeIcons); bar.add(moveIcons); bar.add(resizeMap); // bar.add(m_centerLabel); dockPanel.addNorth(bar, 20); //bar.add(m_levelBox); // if (false) { // // Show debug grid // bar.add(m_tiles); // } //vp.add(bar); LayoutPanel hp = new LayoutPanel(); dockPanel.add(hp); //hp.setHeight("500px"); //hp.setWidth("500px"); //vp.add(hp); if (isTrue("showLayerPanel", false)) { addTileMapServiceView(hp); // eventBus.addHandler(TileMapAddEvent.TYPE, new TileMapAddEvent.Handler() { // @Override // public void onTileMapAdd(TileMapAddEvent event) { // LayerSet layerSet = new LayerSet(); // TileMapMetadata tileMapMetadata = event.getTileMapMetadata(); // layerSet.setServer(tileMapMetadata.getUrl()); // layerSet.setData(""); // layerSet.setUrlPattern("{server}/{level}/{x}/{y}." + tileMapMetadata.getTileImageFormat()); // m_map.addLayer(layerSet); // } // }); } // The map viewport hp.add(mapFillPanel); //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT); // The map controls MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 100); mapControls.getElement().getStyle().setZIndex(100000); hp.add(mapControls); hp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX); hp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX); //The mouse position label; PositionControl mousePosLabel = new PositionControl(m_map); hp.add(mousePosLabel); hp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX); hp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX); // Map dimmer control MapDimmerControl dimmer = new MapDimmerControl(m_map, true); hp.add(dimmer); hp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 35, Style.Unit.PX); hp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 22, Style.Unit.PX); SearchControl flyToControl = new SearchControl(); hp.add(flyToControl); hp.setWidgetRightWidth(flyToControl, 0, Style.Unit.PX, 160, Style.Unit.PX); hp.setWidgetTopHeight(flyToControl, 0, Style.Unit.PX, 50, Style.Unit.PX); flyToControl.addSearchHandler(new FlyToController(m_map)); // Layer a transparent dialog... if (isTrue("showTestDialog", false)) { DialogBox db = new DialogBox(); db.setHTML("<a href='' onclick='false'>x</a>"); db.setPopupPosition(100, 10); db.setPixelSize(100, 100); db.show(); } }
From source file:com.moesol.gwt.milmap.client.Driver.java
License:Open Source License
private void doMap(RootPanel mapPanel) { //doMap(mapPanel); mapPanel.setHeight("100%"); mapPanel.setWidth("100%"); DOM.setInnerHTML(mapPanel.getElement(), ""); final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX); dockPanel.setHeight("100%"); dockPanel.setWidth("100%"); //dockPanel.setHeight("420px"); //dockPanel.setWidth("600px"); mapPanel.add(dockPanel);//w w w .jav a 2 s .c om // loadLayerConfigsFromServer(); m_map = new MapView(); loadLayerConfigsFromClient(); MapPanel mapFillPanel = new MapPanel(m_map); m_map.setDpi(m_scrnDpi); m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS); m_map.setDeclutterLabels(true); //new EdgeHoverPanControl(m_map, MAP_EDGE_HOVER_RADIUS_PIXELS, // MAP_EDGE_HOVER_PAN_INTERVAL, // MAP_EDGE_HOVER_MAX_PAN_PER_INTERVAL_PIXELS); // m_map.getController().addHoverHandler(new HoverHandler() { // BubbleControl bc = new BubbleControl(m_map); // // @Override // public void onHover(HoverEvent e) { // ViewCoords m_vc = new ViewCoords(e.getX(), e.getY()); // GeodeticCoords gc = m_map.getProjection().viewToGeodetic(m_vc); // bc.getHtml().setHTML("Hover: " + gc.toString()); // bc.animateShow(e.getClientX(), e.getClientY()); // } // }); if (isTrue("showSomeIcons", false)) { addSomeIcons(); } m_map.updateView(); //Button removeIcons = new Button("Remove Icons", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // removeIcons(); // }}); //Button moveIcons = new Button("Move Icons", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // moveIcons(); // }}); //Button showLeaders = new Button("Show Leaders", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // showLeaders(); // } //}); //Button benchmarks = new Button("Benchmarks", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // runBenchmarks(); // }}); //Button stats = new Button("Stats", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // stats(); // }}); //Button memoryTest = new Button("Memory Test", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // memoryTest(); // }}); //Button declutter = new Button("Declutter", new ClickHandler() { // @Override // public void onClick(ClickEvent event) { // declutterTest(); // }}); MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); oracle.add("0"); oracle.add("01"); oracle.add("1"); oracle.add("3"); m_levelBox = new SuggestBox(); m_map.addChangeListener(new ChangeListener() { @Override public void onChange(Widget sender) { mapChanged(); } }); // removing button bar for demo purposes //HorizontalPanel bar = new HorizontalPanel(); // bar.add(removeIcons); // bar.add(moveIcons); // bar.add(showLeaders); // bar.add(declutter); // bar.add(benchmarks); // bar.add(stats); // bar.add(memoryTest); // dockPanel.addNorth(bar, 20); LayoutPanel lp = new LayoutPanel(); dockPanel.add(lp); if (isTrue("showLayerPanel", false)) { addTileMapServiceView(lp); } // The map viewport lp.add(mapFillPanel); //count = hp.getWidgetCount(); //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT); // The map controls MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 10); mapControls.getElement().getStyle().setZIndex(100000); lp.add(mapControls); lp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX); lp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX); //The mouse position label; PositionControl mousePosLabel = new PositionControl(m_map); lp.add(mousePosLabel); lp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX); lp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX); //The Text control; m_textControl = new TextControl(); lp.add(m_textControl); lp.setWidgetLeftWidth(m_textControl, 10, Style.Unit.PX, 500, Style.Unit.PX); lp.setWidgetBottomHeight(m_textControl, 10, Style.Unit.PX, 20, Style.Unit.PX); // Map dimmer control MapDimmerControl dimmer = new MapDimmerControl(m_map, true); lp.add(dimmer); lp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 60, Style.Unit.PX); lp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 34, Style.Unit.PX); // Map tag control TagControl tag = new TagControl(m_map, true); lp.add(tag); lp.setWidgetRightWidth(tag, 10, Style.Unit.PX, 35, Style.Unit.PX); lp.setWidgetBottomHeight(tag, 60, Style.Unit.PX, 22, Style.Unit.PX); SearchControl flyToControl = new SearchControl(); lp.add(flyToControl); lp.setWidgetRightWidth(flyToControl, 10, Style.Unit.PX, 160, Style.Unit.PX); lp.setWidgetTopHeight(flyToControl, 10, Style.Unit.PX, 50, Style.Unit.PX); flyToControl.addSearchHandler(new FlyToController(m_map)); // Layer a transparent dialog... if (isTrue("showTestDialog", false)) { DialogBox db = new DialogBox(); db.setHTML("<a href='' onclick='false'>x</a>"); db.setPopupPosition(100, 10); db.setPixelSize(100, 100); db.show(); } }
From source file:com.moesol.mapsample.client.MapSample.java
License:Open Source License
private void doMap(RootPanel mapPanel) { //doMap(mapPanel); mapPanel.setHeight("100%"); mapPanel.setWidth("100%"); DOM.setInnerHTML(mapPanel.getElement(), ""); final DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX); dockPanel.setHeight("100%"); dockPanel.setWidth("100%"); mapPanel.add(dockPanel);//from ww w .j av a 2 s . co m // loadLayerConfigsFromServer(); m_map = new MapView(); loadLayerConfigsFromClient(); MapPanel mapFillPanel = new MapPanel(m_map); m_map.setDpi(m_scrnDpi); m_map.getController().withHoverDelayMillis(MAP_HOVER_DELAY_MILLIS); m_map.setDeclutterLabels(true); if (isTrue("showSomeIcons", false)) { addSomeIcons(); } m_map.updateView(); MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); oracle.add("0"); oracle.add("01"); oracle.add("1"); oracle.add("3"); m_levelBox = new SuggestBox(); m_map.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { mapChanged(); } }); LayoutPanel lp = new LayoutPanel(); dockPanel.add(lp); // The map viewport lp.add(mapFillPanel); //count = hp.getWidgetCount(); //hp.setWidgetLeftWidth(mapFillPanel,0, Style.Unit.PCT, 100, Style.Unit.PCT); // The map controls MapPanZoomControl mapControls = new MapPanZoomControl(m_map, 15, 10); mapControls.getElement().getStyle().setZIndex(100000); lp.add(mapControls); lp.setWidgetLeftWidth(mapControls, 0, Style.Unit.PX, 56, Style.Unit.PX); lp.setWidgetTopHeight(mapControls, 0, Style.Unit.PX, 121, Style.Unit.PX); //The mouse position label; PositionControl mousePosLabel = new PositionControl(m_map); lp.add(mousePosLabel); lp.setWidgetRightWidth(mousePosLabel, 10, Style.Unit.PX, 500, Style.Unit.PX); lp.setWidgetTopHeight(mousePosLabel, 10, Style.Unit.PX, 20, Style.Unit.PX); //The Text control; m_textControl = new TextControl(); lp.add(m_textControl); lp.setWidgetLeftWidth(m_textControl, 10, Style.Unit.PX, 500, Style.Unit.PX); lp.setWidgetBottomHeight(m_textControl, 10, Style.Unit.PX, 20, Style.Unit.PX); // Map dimmer control MapDimmerControl dimmer = new MapDimmerControl(m_map, true); lp.add(dimmer); lp.setWidgetRightWidth(dimmer, 10, Style.Unit.PX, 60, Style.Unit.PX); lp.setWidgetBottomHeight(dimmer, 10, Style.Unit.PX, 34, Style.Unit.PX); // Map tag control TagControl tag = new TagControl(m_map, true); lp.add(tag); lp.setWidgetRightWidth(tag, 10, Style.Unit.PX, 35, Style.Unit.PX); lp.setWidgetBottomHeight(tag, 60, Style.Unit.PX, 22, Style.Unit.PX); SearchControl flyToControl = new SearchControl(); lp.add(flyToControl); lp.setWidgetRightWidth(flyToControl, 10, Style.Unit.PX, 160, Style.Unit.PX); lp.setWidgetTopHeight(flyToControl, 10, Style.Unit.PX, 50, Style.Unit.PX); flyToControl.addSearchHandler(new FlyToController(m_map)); // Layer a transparent dialog... if (isTrue("showTestDialog", false)) { DialogBox db = new DialogBox(); db.setHTML("<a href='' onclick='false'>x</a>"); db.setPopupPosition(100, 10); db.setPixelSize(100, 100); db.show(); } }
From source file:com.puzzlebazar.client.ui.AspectRatioLayoutPanel.java
License:Apache License
@Override public void onResize() { LayoutPanel parent = (LayoutPanel) getParent(); // Compute width and height available for inside area int parentWidth = parent.getOffsetWidth(); int parentHeight = parent.getOffsetHeight(); int availableWidth = parentWidth - 2 * border; int availableHeight = parentHeight - 2 * border; if (availableWidth > 0 && availableHeight > 0) { float parentRatio = (float) availableWidth / (float) availableHeight; if (parentRatio < aspectRatio) { // availableWidth/availableHeight < desiredWidth/desiredHeight // Set desiredWidth = availableWidth ==> availableHeight > desiredHeight (good!) // Then desiredHeight = availableWidth / aspectRatio int desiredHeight = (int) (availableWidth / aspectRatio); parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetTopHeight(this, (parentHeight - desiredHeight) / 2 - border, Unit.PX, desiredHeight + 2 * border, Unit.PX); } else {//from w w w. j ava2 s .c om // availableWidth/availableHeight > desiredWidth/desiredHeight // Set desiredHeight = availableHeight ==> availableWidth > desiredWidth (good!) // Then desiredWidth = availableHeight * aspectRatio int desiredWidth = (int) (availableHeight * aspectRatio); parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetLeftWidth(this, (parentWidth - desiredWidth) / 2 - border, Unit.PX, desiredWidth + 2 * border, Unit.PX); } } else { // Not enough room for inside area, border takes up everything. if (parentWidth < parentHeight) { // parentWidth is smaller, allocate parentWidth x parentWidth parent.setWidgetLeftRight(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetTopHeight(this, (parentHeight - parentWidth) / 2, Unit.PX, parentWidth, Unit.PX); } else { // parentHeight is smaller, allocate parentHeight x parentHeight parent.setWidgetTopBottom(this, 0, Unit.PX, 0, Unit.PX); parent.setWidgetLeftWidth(this, (parentWidth - parentHeight) / 2, Unit.PX, parentHeight, Unit.PX); } } super.onResize(); }
From source file:com.spinque.gwt.utils.client.widgets.VerticalTabLayoutPanel.java
License:Apache License
/** * Creates an empty tab panel.// w w w . j av a 2 s . c om * * @param barHeight the size of the tab bar * @param barUnit the unit in which the tab bar size is specified */ public VerticalTabLayoutPanel(double barHeight, Unit barUnit) { LayoutPanel panel = new LayoutPanel(); initWidget(panel); // Add the tab bar to the panel. panel.add(tabBar); panel.setWidgetTopBottom(tabBar, 0, Unit.PX, 0, Unit.PX); panel.setWidgetLeftWidth(tabBar, 0, Unit.PX, barHeight, barUnit); panel.setWidgetHorizontalPosition(tabBar, Alignment.END); // Add the deck panel to the panel. deckPanel.addStyleName(CONTENT_CONTAINER_STYLE); panel.add(deckPanel); panel.setWidgetTopBottom(deckPanel, 0, Unit.PX, 0, Unit.PX); panel.setWidgetLeftRight(deckPanel, barHeight, barUnit, 0, Unit.PX); // Make the tab bar extremely wide so that tabs themselves never wrap. // (Its layout container is overflow:hidden) // tabBar.getElement().getStyle().setWidth(BIG_ENOUGH_TO_NOT_WRAP, Unit.PX); tabBar.setStyleName("gwt-TabLayoutPanelTabs"); setStyleName("gwt-TabLayoutPanel"); }
From source file:de.mkristian.ixtlan.translations.client.TranslationsApplication.java
License:Open Source License
@Override public void run() { LayoutPanel root = RootLayoutPanel.get(); root.add(notifierLabel);/*from ww w . j a va 2s . com*/ root.setWidgetLeftWidth(notifierLabel, 25, Unit.PCT, 50, Unit.PCT); root.add(this.asWidget()); }
From source file:hu.mapro.gwt.client.widget.MyTabLayoutPanel.java
License:Apache License
/** * Updates the size of the tabNavPanel.//from w w w . j a va2 s .c om */ private void setTabPanelSizes(int prev, int next) { LayoutPanel panel = getTabNavPanel(); Unit unit = Unit.PX; if (isRtl()) { panel.setWidgetRightWidth(previousButtonPanel, 0, unit, prev, unit); panel.setWidgetLeftWidth(nextButtonPanel, 0, unit, next, unit); panel.setWidgetLeftRight(tabBarAnimator, next, unit, prev, unit); } else { panel.setWidgetLeftWidth(previousButtonPanel, 0, unit, prev, unit); panel.setWidgetRightWidth(nextButtonPanel, 0, unit, next, unit); panel.setWidgetLeftRight(tabBarAnimator, prev, unit, next, unit); } panel.forceLayout(); }