Exemplo n.º 1
0
  private LayoutContainer getChart() {
    FieldSet fs = new FieldSet();
    fs.setHeading("Chart");
    fs.setLayout(new FitLayout());

    String url = !Examples.isExplorer() ? "../../" : "";
    url += "gxt/chart/open-flash-chart.swf";

    final Chart chart = new Chart(url);
    chart.setBorders(true);
    fs.add(chart, new FitData(0, 0, 20, 0));
    updateCmd =
        new Command() {
          public void execute() {
            chart.setChartModel(example.getChartModel(numSegments));
          }
        };

    adjustUpdateSpeed(updateSpeed);
    return fs;
  }
Exemplo n.º 2
0
  private LayoutContainer getDetails() {
    LayoutContainer lc = new LayoutContainer();
    VBoxLayout vLayout = new VBoxLayout();
    vLayout.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH);
    lc.setLayout(vLayout);

    FieldSet controls = new FieldSet();
    controls.setHeading("Controls");
    FormLayout fl = new FormLayout();
    fl.setLabelWidth(125);
    controls.setLayout(fl);

    Slider segments = new Slider();
    segments.setMaxValue(12);
    segments.setMinValue(1);
    segments.setIncrement(1);
    segments.setValue(numSegments);
    segments.addListener(
        Events.Change,
        new Listener<SliderEvent>() {
          public void handleEvent(SliderEvent be) {
            numSegments = be.getNewValue();
            adjustUpdateSpeed(updateSpeed);
          }
        });
    SliderField segFld = new SliderField(segments);
    segFld.setFieldLabel("Segments (#)");
    controls.add(segFld);

    final Slider update =
        new Slider() {
          @Override
          protected String onFormatValue(int value) {
            if (value == 0) return "Off";
            return super.onFormatValue(value);
          }
        };
    update.setMinValue(0);
    update.setMaxValue(3000);
    update.setIncrement(100);
    update.setValue(updateSpeed);
    update.setMessage("{0}ms");
    update.addListener(
        Events.Change,
        new Listener<SliderEvent>() {
          public void handleEvent(SliderEvent se) {
            adjustUpdateSpeed(se.getNewValue());
          }
        });
    SliderField updFld = new SliderField(update);
    updFld.setFieldLabel("Update Interval (ms)");
    controls.add(updFld);

    lc.add(controls);

    FieldSet gallery = new FieldSet();
    gallery.setHeading("Gallery");
    gallery.setLayout(new FitLayout());

    ListStore<GalleryChartModel> store = new ListStore<GalleryChartModel>();
    store.add(new GalleryChartModel("Area", "area.gif", new AreaChartExample()));
    store.add(new GalleryChartModel("Pie", "pie.gif", new PieChartExample()));
    store.add(new GalleryChartModel("Filled Bar", "filled.gif", new FilledBarChartExample()));
    store.add(new GalleryChartModel("Bar - Glass", "barglass.gif", new BarGlassChartExample()));
    store.add(new GalleryChartModel("Bar - 3D", "bar3d.gif", new Bar3DChartExample()));
    store.add(new GalleryChartModel("Radar", "radar.gif", new RadarChartExample()));
    store.add(
        new GalleryChartModel("Horizontal Bar", "horizontalbar.gif", new HorizontalChartExample()));
    store.add(new GalleryChartModel("Cylinder", "cylinder.gif", new CylinderChartExample()));
    store.add(new GalleryChartModel("Sketch Bar", "sketchbar.gif", new SketchChartExample()));

    ListView<GalleryChartModel> view =
        new ListView<GalleryChartModel>() {
          @Override
          protected GalleryChartModel prepareData(GalleryChartModel model) {
            String s = model.get("name");
            model.set("shortName", Format.ellipse(s, 15));
            return model;
          }
        };
    view.setId("img-chooser-view");
    view.setTemplate(getTemplate(!Examples.isExplorer() ? "../../" : ""));
    view.setStore(store);
    view.setItemSelector("div.thumb-wrap");
    view.getSelectionModel().select(0, false);
    view.getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<GalleryChartModel>>() {

              public void handleEvent(SelectionChangedEvent<GalleryChartModel> be) {
                example = be.getSelectedItem().getExample();
                adjustUpdateSpeed(updateSpeed);
              }
            });
    gallery.add(view, new FitData(0, 0, 20, 0));

    VBoxLayoutData vFlex = new VBoxLayoutData();
    vFlex.setFlex(1);
    lc.add(gallery, vFlex);
    return lc;
  }