Example usage for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel.

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.CustomControlDemo.java

License:Apache License

public CustomControlDemo() {

    VerticalPanel vertPanel = new VerticalPanel();
    vertPanel.setStyleName("hm-panel");

    actionListBox = new ListBox();
    for (ControlDemos cd : ControlDemos.values()) {
        actionListBox.addItem(cd.valueOf());
    }//  w w  w . j av  a 2 s.com

    actionListBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            displayCustomControl();
        }
    });

    HorizontalPanel horizPanel = new HorizontalPanel();
    horizPanel.add(new Label("Choose Action:"));
    horizPanel.add(actionListBox);
    horizPanel.setSpacing(10);
    vertPanel.add(horizPanel);

    map = new MapWidget(LatLng.newInstance(37.441944, -122.141944), 13);
    map.setSize("500px", "300px");
    map.addMapType(MapType.getNormalMap());
    map.addMapType(MapType.getSatelliteMap());
    map.addMapType(MapType.getMarsVisibleMap());
    map.addMapType(MapType.getMarsElevationMap());
    map.addMapType(MapType.getMarsInfraredMap());
    vertPanel.add(map);

    new Timer() {
        public void run() {
            displayCustomControl();
        }
    }.schedule(250);

    initWidget(vertPanel);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java

License:Apache License

/**
 * Create the toolbar above the map. Note that the map must be initialized
 * before this method is called./*from   ww  w .  j av a  2 s .  c  o m*/
 */
private Widget makeToolbar() {
    DockPanel p = new DockPanel();
    p.setWidth("100%");

    HorizontalPanel buttonPanel = new HorizontalPanel();

    Button addButton = new Button("Draw new object");
    addButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (addPolyDialog == null) {
                addPolyDialog = makeAddPolyDialog();
            }
            addPolyDialog.center();
            addPolyDialog.show();
            if (lastPolygon != null) {
                lastPolygon.setEditingEnabled(false);
            }
            if (lastPolyline != null) {
                lastPolyline.setEditingEnabled(false);
            }
        }
    });
    buttonPanel.add(addButton);

    editPolylineButton.setEnabled(false);
    editPolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            editPolyline();
        }
    });
    buttonPanel.add(editPolylineButton);

    editPolygonButton.setEnabled(false);
    editPolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            editPolygon();
        }
    });
    buttonPanel.add(editPolygonButton);

    p.add(buttonPanel, DockPanel.EAST);

    return p;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java

License:Apache License

private DialogBox makeAddPolyDialog() {

    DialogBox dialog = new DialogBox();
    dialog.setTitle("Add Polyline");

    Grid grid = new Grid(2, 4);

    VerticalPanel vp = new VerticalPanel();
    grid.setHTML(0, 0, "<b>Opacity</b>");
    // The drop down lists for setting the style
    final ListBox opacityBox = new ListBox();
    for (int i = 100; i > 0; i -= 10) {
        opacityBox.addItem(i + "%");
    }/* ww  w .  ja  v a2s  .co  m*/
    opacityBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            String val = opacityBox.getItemText(opacityBox.getSelectedIndex());
            opacity = Double.parseDouble(val.replace("%", "")) / 100.0;
        }
    });
    grid.setWidget(1, 0, opacityBox);

    grid.setHTML(0, 1, "<b>Weight</b>");
    final ListBox weightBox = new ListBox();
    weightBox.addItem("1 pixel");
    weightBox.addItem("2 pixels");
    weightBox.addItem("3 pixels");
    weightBox.addItem("5 pixels");
    weightBox.addItem("10 pixels");
    weightBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            String val = weightBox.getItemText(weightBox.getSelectedIndex());
            val = val.replace(" pixel", "");
            val = val.replace("s", "");
            weight = Integer.parseInt(val);
        }
    });
    grid.setWidget(1, 1, weightBox);

    grid.setHTML(0, 2, "<b>Color</b>");
    final ListBox colorBox = new ListBox();
    colorBox.addItem("#FF0000 red");
    colorBox.addItem("#FFFF00 yellow");
    colorBox.addItem("#00FF00 green");
    colorBox.addItem("#00FFFF cyan");
    colorBox.addItem("#0000FF blue");
    colorBox.addItem("#FF00FF violet");
    colorBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            color = colorBox.getItemText(colorBox.getSelectedIndex()).substring(0, 7);
        }
    });
    grid.setWidget(1, 2, colorBox);

    grid.setHTML(0, 3, "<b>Fill Polygon</b>");
    final CheckBox fillCheckBox = new CheckBox("");
    fillCheckBox.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            fillFlag = fillCheckBox.isChecked();
        }

    });
    grid.setWidget(1, 3, fillCheckBox);

    Button addPolylineButton = new Button("Make Polyline");
    addPolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            message1.setText("opacity=" + opacity + " color=" + color + " weight=" + weight + " polygon="
                    + makePolygon + " center=" + map.getCenter() + " zoom=" + map.getZoomLevel());
            addPolyDialog.hide();
            createPolyline();
            editPolylineButton.setEnabled(true);
        }
    });

    Button addPolygonButton = new Button("Make Polygon");
    addPolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            message1.setText(
                    "Opacity=" + opacity + " color=" + color + "weight=" + weight + "polygon = " + makePolygon
                            + "Center=" + map.getCenter() + " zoom=" + map.getZoomLevel() + "fill=" + fillFlag);
            addPolyDialog.hide();
            createPolygon();
            editPolygonButton.setEnabled(true);
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            addPolyDialog.hide();
        }
    });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    buttonPanel.add(addPolylineButton);
    buttonPanel.add(addPolygonButton);
    buttonPanel.add(cancelButton);
    vp.add(grid);
    vp.add(buttonPanel);
    dialog.add(vp);

    return dialog;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.GeocoderDemo.java

License:Apache License

private Panel buildLatLngPanel() {
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(new Label("Lat:"));
    latLabel = new Label();
    horiz.add(latLabel);//from   w w w  .j  a  v  a2 s . c  o m
    horiz.add(new Label("Long:"));
    lngLabel = new Label();
    horiz.add(lngLabel);
    horiz.setSpacing(10);
    return horiz;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.HelloMaps.java

License:Apache License

public void onModuleLoad() {

    if (!Maps.isLoaded()) {
        Window.alert("The Maps API is not installed."
                + "  The <script> tag that loads the Maps API may be missing or your Maps key may be wrong.");
        return;/*www  . ja va2 s.c o  m*/
    }

    if (!Maps.isBrowserCompatible()) {
        Window.alert("The Maps API is not compatible with this browser.");
        return;
    }

    // Load all the MapsDemos.
    loadMapsDemos();

    innerPanel.setStylePrimaryName("hm-mapinnerpanel");
    innerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    HorizontalPanel horizPanel = new HorizontalPanel();
    list.setStylePrimaryName("hm-demolistbox");
    horizPanel.add(new Label("Select Demo: "));
    horizPanel.add(list);
    innerPanel.add(horizPanel);
    innerPanel.add(description);
    innerPanel.setSpacing(10);

    History.addHistoryListener(this);

    outerPanel.setStylePrimaryName("hm-outerpanel");
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);
    outerPanel.insertRow(0);

    outerPanel.addCell(0);
    outerPanel.addCell(1);
    outerPanel.addCell(2);
    outerPanel.addCell(3);
    outerPanel.addCell(4);

    outerPanel.setWidget(0, 0,
            new HTML("This Maps-enabled application was built using the Google " + "API Library for GWT, "
                    + "<a href=\"http://code.google.com/p/gwt-google-apis/\">"
                    + "http://code.google.com/p/gwt-google-apis/</a>. "
                    + "The drop down list below allows you to select a scenario that "
                    + "demonstrates a particular capability of the Maps support."));

    outerPanel.setWidget(1, 0, innerPanel);

    DecoratorPanel decorator = new DecoratorPanel();
    decorator.add(outerPanel);

    RootPanel.get("hm-map").add(decorator);

    // Show the initial screen.
    String initToken = History.getToken();
    if (initToken.length() > 0) {
        onHistoryChanged(initToken);
    } else {
        showInfo();
    }
}

From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java

License:Apache License

public InfoWindowDemo() {

    VerticalPanel vertPanel = new VerticalPanel();
    vertPanel.setStyleName("hm-panel");

    map = new MapWidget(ATLANTA, 13);
    vertPanel.add(map);// ww w.ja  va  2 s .  c  o m

    actionListBox = new ListBox();
    actionListBox.addItem(TEST_DEFAULT);
    actionListBox.addItem(TEST_IMAGE);
    actionListBox.addItem(TEST_NO_CLICK);
    actionListBox.addItem(TEST_TABS);
    actionListBox.addItem(TEST_MAX_CONTENT);
    actionListBox.addItem(TEST_MAX_TITLE_CONTENT_WIDGET);
    actionListBox.addItem(TEST_MAP_BLOWUP);

    actionListBox.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            displayInfoWindow();
        }
    });

    map.setSize("500px", "450px");

    HorizontalPanel horizPanel = new HorizontalPanel();
    horizPanel.add(new Label("Choose Action:"));
    horizPanel.add(actionListBox);
    horizPanel.setSpacing(10);

    vertPanel.add(horizPanel);

    vertPanel.add(map);
    initWidget(vertPanel);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java

License:Apache License

private InfoWindowContent displayInfoWindowMaxWidget() {
    final InfoWindowContent content = new InfoWindowContent("There's more to see (hit the maximize button)");
    content.setMaxTitle(new HTML("<i>Maximized Italic Boots</i>"));
    VerticalPanel panel = new VerticalPanel();
    panel.add(new Image("boot.jpg"));
    Button b = new Button("Click for Message");
    final Label l = new Label();
    HorizontalPanel hp = new HorizontalPanel();
    hp.add(b);/*from  w  w  w .j  a v a 2 s  . c  o  m*/
    hp.add(l);
    l.getElement().getStyle().setPropertyPx("margin", 7);
    b.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            GWT.log("Got click in maximized window.", null);
            if (l.getText().equals("")) {
                l.setText("Hello World!");
            } else {
                l.setText("");
            }
        }
    });
    panel.add(hp);
    panel.setSpacing(10);
    content.setMaxContent(panel);
    return content;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java

License:Apache License

public MapEventDemo() {
    VerticalPanel vp = new VerticalPanel();

    // Center the new map on Midtown Atlanta
    map = new MapWidget(ATLANTA, 13);
    map.setSize("500px", "300px");
    map.addControl(new SmallMapControl());
    map.addControl(new MapTypeControl());

    MarkerOptions opt = MarkerOptions.newInstance();
    opt.setDraggable(true);/*from  w w w  .  jav  a2 s  . c  o m*/
    marker = new Marker(ATLANTA, opt);

    Panel hp1 = createActionButtons();

    HorizontalPanel hp2 = createListenerListBox();

    // Make a spacer
    HorizontalPanel hp3 = new HorizontalPanel();
    hp3.add(new Label(" "));
    hp3.setSize("1em", "1em");

    handlerTable = new FlexTable();
    clearListenerTable();

    vp.add(map);
    vp.add(hp1);
    vp.add(hp2);
    vp.add(hp3);
    vp.add(handlerTable);

    initWidget(vp);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java

License:Apache License

/**
 * Create a panel of buttons to use to perform various actions on the marker.
 *//*from www  . j av a2  s . co m*/
private Panel createActionButtons() {
    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);

    vp.add(hp);

    // Create a button to hide/show the marker
    final Button hideButton = new Button("Hide Marker");
    hideButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !marker.isVisible();
            marker.setVisible(state);
            if (state) {
                hideButton.setText("Hide Marker");
            } else {
                hideButton.setText("Show Marker");
            }
        }
    });
    hp.add(hideButton);

    // Create a button to remove the marker from the map.
    final Button removeButton = new Button("Remove Marker");
    removeButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!markerRemoved) {
                map.removeOverlay(marker);
                removeButton.setText("Add Marker");
            } else {
                map.addOverlay(marker);
                removeButton.setText("Remove Marker");
            }
            hideButton.setEnabled(markerRemoved);
            markerRemoved = !markerRemoved;
        }
    });
    hp.add(removeButton);

    // Create a button to hide/show the polygon
    final Button hidePolygonButton = new Button("Hide Polygon");
    hidePolygonButton.setEnabled(false);
    hidePolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !polygon.isVisible();
            polygon.setVisible(state);
            if (state) {
                hidePolygonButton.setText("Hide Polygon");
            } else {
                hidePolygonButton.setText("Show Polygon");
            }
        }
    });
    hp.add(hidePolygonButton);

    // Create a button to remove the polygon from the map.
    final Button removePolygonButton = new Button("Add Polygon");
    removePolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!polygonRemoved) {
                map.removeOverlay(polygon);
                removePolygonButton.setText("Add Polygon");
            } else {
                map.addOverlay(polygon);
                removePolygonButton.setText("Remove Polygon");
            }
            hidePolygonButton.setEnabled(polygonRemoved);
            polygonRemoved = !polygonRemoved;
        }
    });
    hp.add(removePolygonButton);

    // Create a button to hide/show the polyline
    final Button hidePolylineButton = new Button("Hide Polyline");
    hidePolylineButton.setEnabled(false);
    hidePolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !polyline.isVisible();
            polyline.setVisible(state);
            if (state) {
                hidePolylineButton.setText("Hide Polyline");
            } else {
                hidePolylineButton.setText("Show Polyline");
            }
        }
    });
    hp.add(hidePolylineButton);

    // Create a button to remove the polyline from the map.
    final Button removePolylineButton = new Button("Add Polyline");
    removePolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!polylineRemoved) {
                map.removeOverlay(polyline);
                removePolylineButton.setText("Add Polyline");
            } else {
                map.addOverlay(polyline);
                removePolylineButton.setText("Remove Polyline");
            }
            hidePolylineButton.setEnabled(polylineRemoved);
            polylineRemoved = !polylineRemoved;
        }
    });
    hp.add(removePolylineButton);

    final Button clearOverlaysButton = new Button("Clear Overlays");
    clearOverlaysButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            map.clearOverlays();
        }
    });

    hp.add(clearOverlaysButton);

    hp = new HorizontalPanel();
    hp.setSpacing(10);
    vp.add(hp);

    final Button infoWindowButton = new Button("Show InfoWindow");
    infoWindowButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            InfoWindow info = map.getInfoWindow();
            InfoWindowContent content = new InfoWindowContent("Hello Maps!");
            content.setMaxContent("Hello Maps - more content");
            content.setMaxTitle("Hello Maps");
            info.open(map.getCenter(), content);
        }
    });
    hp.add(infoWindowButton);

    final Button mInfoWindowButton = new Button("Marker InfoWindow");
    mInfoWindowButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            InfoWindow info = map.getInfoWindow();
            InfoWindowContent content = new InfoWindowContent("Hello Maps!");
            content.setMaxContent("Hello Maps - more content");
            content.setMaxTitle("Hello Maps");
            info.open(marker, content);
        }
    });
    hp.add(mInfoWindowButton);

    final Button mapTypeButton = new Button("Add Map Type");
    mapTypeButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            if (!mapTypeRemoved) {
                map.addMapType(MapType.getSkyVisibleMap());
                mapTypeButton.setText("Remove MapType");
            } else {
                map.removeMapType(MapType.getSkyVisibleMap());
                mapTypeButton.setText("Add MapType");
            }
            mapTypeRemoved = !mapTypeRemoved;
        }

    });
    hp.add(mapTypeButton);

    // Create a button to clear out the table.
    final Button clearTableButton = new Button("Clear Table");
    clearTableButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            clearListenerTable();
        }
    });
    hp.add(clearTableButton);

    return vp;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java

License:Apache License

/**
 * Create a drop down list that shows all the different types of listeners
 * that can be added.//from w ww . ja v a  2s  .  c  o m
 * 
 * @return a ListBox populated with the ListenerActions values
 */
private HorizontalPanel createListenerListBox() {
    HorizontalPanel h = new HorizontalPanel();

    final ListBox listenerBox = new ListBox();
    for (HandlerActions a : HandlerActions.values()) {
        listenerBox.addItem(a.valueOf());
    }
    h.add(listenerBox);

    Button b = new Button("Add Handler");
    b.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            int selectedIndex = listenerBox.getSelectedIndex();
            HandlerActions a = HandlerActions.values()[selectedIndex];
            addListenerToMarker(a);
        }

    });
    h.add(b);

    return h;
}