package com.googlecode.gchart.gcharttestapp.client; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.VerticalPanel; import com.googlecode.gchart.client.GChart; import com.googlecode.gchart.client.HoverUpdateable; /** * This example uses a HoverUpdateable widget (a "hover * widget") to create a radio-button-based form that pops up whenever * the user hovers over a point on any curve, and that allows the user * to change that curve's color and symbol type.
* * As this example illustrates, a hoverWidget can do many of the same kinds * of things you might do with a popup. But not everything. For * example, it lacks the ability to be repositioned and remains open * only as long as the mouse is over it. It also requires that when the * hoverWidget is made invisible, all widgets launched/owned by it * become invisible, a requirement not satisfied by a nested * MenuBar-based menu system--so only a single-level MenuBar works * properly as a hoverWidget out of the box. Limit yourself to * traditional fixed-layout forms--such as the radio buttons of this * example--and steer clear of the more complex Widgets like MenuBar and * Tree, and you should be able to get away with using a hoverWidget as * if it were a popup, as we do here. * */ public class TestGChart37 extends GChart { final String[] color = {"red", "green", "blue"}; final String[] colorLabel = {"Red", "Green", "Blue"}; final SymbolType[] symbol = {SymbolType.VBAR_SOUTH, SymbolType.BOX_CENTER, SymbolType.PIE_SLICE_HATCHED_SHADING}; final String[] symbolLabel = {"Bar", "Box", "Pie"}; final TouchedPointUpdateOption updateOption; class CurveEditingForm extends VerticalPanel implements HoverUpdateable { CurveEditingForm() { setStyleName("gchartestapp-GChartExample19-CurveEditingForm"); add(new HTML()); // to hold label for color radio-group for (int i = 0; i < colorLabel.length; i++) { RadioButton radioButton = new RadioButton("color", colorLabel[i]); radioButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String label = ((RadioButton) event.getSource()).getText(); for (int i = 0; i < colorLabel.length; i++) if (label.equals(colorLabel[i])) getTouchedCurve().getSymbol().setBorderColor(color[i]); update(updateOption); } }); add(radioButton); } add(new HTML()); // to hold label for symbol radio-group for (int i = 0; i < symbolLabel.length; i++) { RadioButton radioButton = new RadioButton("symbol", symbolLabel[i]); radioButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String label = ((RadioButton) event.getSource()).getText(); for (int i = 0; i < symbolLabel.length; i++) if (label.equals(symbolLabel[i])) getTouchedCurve().getSymbol().setSymbolType(symbol[i]); update(updateOption); } }); add(radioButton); } } void loadCurveProperties(Curve c) { int iWidget = 0; ((HTML) getWidget(iWidget)).setHTML( "