List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setHorizontalAlignment
public void setHorizontalAlignment(HorizontalAlignmentConstant align)
From source file:com.nitrous.gwt.earth.client.demo.Api1009FeatureTestDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *//*from www. ja va2 s .c o m*/ private void onApiLoaded() { // construct the UI widget GoogleEarthWidget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { gePlugin = ge; // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); // tour visibility visibilityButton = new Button("Toggle Tour Control Visibility"); visibilityButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean isVisible = gePlugin.getTourPlayer().getControl().isVisible(); gePlugin.getTourPlayer().getControl().setVisibile(!isVisible); } }); // Get tour speed showSpeedButton = new Button("Get Tour Speed"); showSpeedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Tour speed = " + gePlugin.getTourPlayer().getCurrentSpeed()); } }); // Increase tour speed speedIncreaseButton = new Button("Speed++"); speedIncreaseButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { gePlugin.getTourPlayer().setCurrentSpeed(gePlugin.getTourPlayer().getCurrentSpeed() + 1); } }); // Decrease tour speed speedDecreaseButton = new Button("Speed--"); speedDecreaseButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { float speed = gePlugin.getTourPlayer().getCurrentSpeed(); speed = speed - 1; if (speed < 0) { speed = 0; } gePlugin.getTourPlayer().setCurrentSpeed(speed); } }); // Toggle loop loopCheck = new CheckBox("Loop"); loopCheck.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { gePlugin.getTourPlayer().setLoop(event.getValue()); } }); // get loop isLoopButton = new Button("Is Loop?"); isLoopButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Window.alert("Loop = " + gePlugin.getTourPlayer().getLoop()); } }); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); topPanel.add(visibilityButton); topPanel.add(showSpeedButton); topPanel.add(speedIncreaseButton); topPanel.add(speedDecreaseButton); topPanel.add(isLoopButton); topPanel.add(loopCheck); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 40D); layout.add(earth); RootLayoutPanel.get().add(layout); // disable the API testing buttons until the tour has been loaded enableButtons(false); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.BuildingDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *//* w w w .jav a2 s. c o m*/ private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button showButton = new Button("Show buildings"); showButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showBuildings(); } }); Button hideButton = new Button("Hide buildings"); hideButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hideBuildings(); } }); Button checkVisibleButton = new Button("Are Buildings Visible?"); checkVisibleButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { areBuildingsVisibleClick(); } }); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); topPanel.add(showButton); topPanel.add(hideButton); topPanel.add(checkVisibleButton); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 30D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.ClosingBalloonsDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *///from www .j ava 2 s . c o m private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button showButton = new Button("Show a balloon!"); showButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GEPlugin ge = earth.getGEPlugin(); GEHtmlStringBalloon balloon = ge.createHtmlStringBalloon(""); balloon.setFeature(placemark); // optional balloon.setMaxWidth(300); // Google logo. balloon.setContentString("<img src=\"http://www.google.com/intl/en_ALL/images/logo.gif\"><br>" + "<font size=20>Earth Plugin</font><br><font size=-2>sample info " + "window</font>"); ge.setBalloon(balloon); } }); Button closeButton = new Button("Close the balloon!"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // hide the balloon earth.getGEPlugin().setBalloon(null); } }); HorizontalPanel buttons = new HorizontalPanel(); buttons.add(showButton); buttons.add(closeButton); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setWidth("100%"); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); topPanel.add(buttons); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 40D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.DuskToDawnDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *//*from w ww . j a va2 s . c o m*/ private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button showSunButton = new Button("Show Sun (Dusk/Dawn)"); showSunButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showSun(); } }); Button hideSunButton = new Button("Hide Sun"); hideSunButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hideSun(); } }); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); topPanel.add(showSunButton); topPanel.add(hideSunButton); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 30D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.ExecuteBatchDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *//*w ww. j a v a2 s. c om*/ private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button runBatchedButton = new Button("Batched calls"); runBatchedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { runBatched(); } }); Button runUnbatchedButton = new Button("Unbatched calls"); runUnbatchedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { runUnbatched(); } }); Button clearButton = new Button("Clear map"); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { clear(); } }); batchedResult = new HTML(" "); unbatchedResult = new HTML(" "); FlexTable resultTable = new FlexTable(); resultTable.setBorderWidth(1); for (int row = 0; row < 2; row++) { for (int col = 0; col < 2; col++) { resultTable.getCellFormatter().setHeight(row, col, "20px"); resultTable.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_CENTER); } } resultTable.setWidget(0, 0, runUnbatchedButton); resultTable.setWidget(1, 0, unbatchedResult); resultTable.setWidget(0, 1, runBatchedButton); resultTable.setWidget(1, 1, batchedResult); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setWidth("100%"); topPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); topPanel.add(resultTable); topPanel.add(clearButton); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 80D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractive.java
License:Apache License
/** * The Google earth API has loaded, start the application *///from ww w . j a va2 s . c o m private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); kmlUrlBox = new TextBox(); kmlUrlBox.getElement().setAttribute("size", "70"); kmlUrlBox.setValue("http://earth-api-samples.googlecode.com/svn/trunk/examples/static/red.kml"); Button fetchKmlButton = new Button("Fetch KML!"); fetchKmlButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fetchKmlFromInput(); } }); HorizontalPanel urlPanel = new HorizontalPanel(); urlPanel.setSpacing(5); urlPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); urlPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); urlPanel.add(new Label("Fetch KML at this URL:")); urlPanel.add(kmlUrlBox); urlPanel.add(fetchKmlButton); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(urlPanel, 40); layout.add(earth); // add the widget to the DOM RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractiveCheckboxes.java
License:Apache License
/** * The Google earth API has loaded, start the application *//*from ww w . jav a 2s . com*/ private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); currentKmlObjects = new HashMap<String, KmlObject>(); checkBoxes = new HashMap<String, CheckBox>(); red = new CheckBox("Red Placemarks"); red.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { toggleKml("red"); } }); checkBoxes.put("red", red); yellow = new CheckBox("Yellow Placemarks"); yellow.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { toggleKml("yellow"); } }); checkBoxes.put("yellow", yellow); green = new CheckBox("Green Placemarks"); green.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { toggleKml("green"); } }); checkBoxes.put("green", green); HorizontalPanel header = new HorizontalPanel(); header.setSpacing(5); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); header.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); header.add(new HTML("<H1>Toggle KML Files:</H1>")); VerticalPanel checkBoxes = new VerticalPanel(); checkBoxes.setSpacing(5); checkBoxes.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); checkBoxes.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); checkBoxes.add(red); checkBoxes.add(yellow); checkBoxes.add(green); header.add(checkBoxes); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(header, 100); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.FrameEndDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *///from w w w.j a v a 2 s .co m private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button startButton = new Button("Start animation"); startButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!animRunning) { GEPlugin ge = earth.getGEPlugin(); ge.getOptions().setFlyToSpeed(ge.getFlyToSpeedTeleport()); animRunning = true; frameEndRegistration = ge.addFrameEndListener(new FrameEndListener() { @Override public void onFrameEnd() { tickAnimation(); } }); // start it off tickAnimation(); } } }); Button stopButton = new Button("Stop animation"); stopButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (animRunning) { frameEndRegistration.removeHandler(); animRunning = false; } } }); HorizontalPanel buttons = new HorizontalPanel(); buttons.add(startButton); buttons.add(stopButton); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setWidth("100%"); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); topPanel.add(buttons); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 40D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.GrayBuildingDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *///from w ww . jav a 2 s .c o m private void onApiLoaded() { // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); Button showButton = new Button("Show gray buildings"); showButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showBuildings(); } }); Button hideButton = new Button("Hide gray buildings"); hideButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hideBuildings(); } }); HorizontalPanel topPanel = new HorizontalPanel(); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); topPanel.add(showButton); topPanel.add(hideButton); DockLayoutPanel layout = new DockLayoutPanel(Unit.PX); layout.addNorth(topPanel, 30D); layout.add(earth); RootLayoutPanel.get().add(layout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.nitrous.gwt.earth.client.demo.MouseListenerDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application */// ww w . j a v a2 s.c o m private void onApiLoaded() { // the table that will be used to render mouse event information table = new CellTable<MouseEventInfo>(); TextColumn<MouseEventInfo> eventType = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { return object.getEventType(); } }; eventType.setSortable(false); TextColumn<MouseEventInfo> eventDetail = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { KmlMouseEvent event = object.getMouseEvent(); return "Button=" + event.getButton() + " Latitude=" + event.getLatitude() + " Longitude=" + event.getLongitude() + " X=" + event.getClientX() + " Y=" + event.getClientY(); } }; eventDetail.setSortable(false); TextColumn<MouseEventInfo> eventTime = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { return dateTimeFormat.format(object.getTimestamp()); } }; eventTime.setSortable(false); // add the columns table.addColumn(eventTime, "Time"); table.addColumn(eventType, "Type"); table.addColumn(eventDetail, "Detail"); table.setWidth("100%"); // set the data model into the table dataProvider = new ListDataProvider<MouseEventInfo>(); dataProvider.addDataDisplay(table); // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); scrollPanel = new ScrollPanel(); scrollPanel.setHeight("100%"); scrollPanel.add(table); HorizontalPanel header = new HorizontalPanel(); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); mouseLocation = new HTML(""); header.add(mouseLocation); SplitLayoutPanel split = new SplitLayoutPanel(); split.addWest(scrollPanel, 450); split.add(earth); DockLayoutPanel dockLayout = new DockLayoutPanel(Unit.PX); dockLayout.addNorth(header, 30D); dockLayout.add(split); RootLayoutPanel.get().add(dockLayout); // begin loading the Google Earth Plug-in earth.init(); }