示例#1
0
  public void addRenderer(String klass, Map<String, String> props, String uniqueId) {
    WaveletViewRenderer renderer = null;
    try {
      renderer = RendererRegistry.findRenderer(klass);
    } catch (Exception ex) {
      LOGGER.error("Cannot find renderer " + klass);
      LOGGER.error("  message: " + ex.getMessage());
    }
    if (renderer == null) {
      return;
    }

    // set the data entity to be rendered and add renderer to viewer
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    Map<String, Object> results =
        ServiceProvider.getRepository().get(new EntityUniqueIdSpecification(uniqueId));
    Object[] objects = results.values().toArray();
    renderer.setData(shell, WaveletViewer.this, objects, false);
    // Put wavelet info on the tool bar
    Wavelet wavelet = (Wavelet) renderer.getRenderedObjects()[0];
    IPlotPolyline waveletPolyline = (IPlotPolyline) renderer.getShapes()[0];
    _legendToolbar.addLabel(wavelet.getDisplayName() + ":");
    _legendToolbar.addColorRectangle(waveletPolyline.getLineColor());
    // set the renderer's model properties
    Model model = renderer.getSettingsModel();
    // Note: if model is null, renderer is TraceSectionRenderer (at least)
    if (model != null) {
      model.unpickle(props);
    }
  }
示例#2
0
 @Override
 protected void initializeToolBars() {
   // Add the help action to the shared toolbar.
   SharedToolBar sharedToolbar = getSharedToolBar();
   sharedToolbar.addPushButton(new HelpAction("org.geocraft.ui.waveletviewer.WaveletPlot"));
   _legendToolbar = addCustomToolBar();
   _legendToolbar.addLabel("");
 }
  public VolumeViewToolBar(
      final SimpleToolBar toolbar,
      final VolumeViewer viewer,
      final ViewCanvasImplementor viewCanvas) {
    _viewer = viewer;
    _viewCanvas = viewCanvas;

    // Add a color selector for choosing the background color.
    // _colorSelector = toolbar.addColorSelector(_viewer.getBackgroundViewColor());
    // _colorSelector.getButton().setToolTipText("Select background color");
    // _colorSelector.addListener(new IPropertyChangeListener() {
    //
    //  /**
    //   * Invoked when a color is chosen in the color selector.
    //   * @param event the property change event.
    //   */
    //  public void propertyChange(final PropertyChangeEvent event) {
    //    final RGB newColor = _colorSelector.getColorValue();
    //    _viewer.setBackgroundViewColor(newColor);
    //  }
    // });

    // Add a combo for selecting the z-domain.
    _zDomainCombo =
        toolbar.addCombo(
            "Domain",
            new String[] {VolumeViewZDomain.TIME.getText(), VolumeViewZDomain.DEPTH.getText()});
    _zDomainCombo.select(0);
    _zDomainCombo.addListener(
        SWT.Selection,
        new Listener() {

          public void handleEvent(final Event event) {
            final String zDomainStr = _zDomainCombo.getText();
            final VolumeViewZDomain zDomain = VolumeViewZDomain.lookup(zDomainStr);
            if (zDomain != null) {
              _viewer.setCurrentDomain(zDomain.getDomain());
            }
          }
        });

    // Add a combo for selecting the z-scaling.
    _zScalingCombo =
        toolbar.addCombo(
            "Z-Scaling",
            new String[] {".001", ".01", ".1", ".5", "1", "2", "5", "10", "20", "50", "100"});
    _zScalingCombo.select(4);
    _zScalingCombo.addListener(
        SWT.Selection,
        new Listener() {

          public void handleEvent(final Event event) {
            final String zScalingStr = _zScalingCombo.getText();
            final double zScaling = Double.parseDouble(zScalingStr);
            _viewer.setExaggeration(zScaling);
          }
        });

    // Add a toggle for setting the projection method.
    _setOrthographicProjection = new SetOrthgraphicProjection(_viewCanvas);
    _setPerspectiveProjection = new SetPerspectiveProjection(_viewCanvas);
    _projectionToggle =
        toolbar.addToggleButton(_setOrthographicProjection, _setPerspectiveProjection);

    // Add a toggle for turning on/off the pick location.
    _hidePickLoc = new ShowPickLocation(_viewCanvas, false);
    _showPickLoc = new ShowPickLocation(_viewCanvas, true);
    _showPickLocToggle = toolbar.addToggleButton(_showPickLoc, _hidePickLoc, false);

    // Add a button for editing the light source.
    final Action lightAction = new EditLightSource(_viewer);
    toolbar.addPushButton(lightAction);

    toolbar.addPushButton(
        new Action() {

          @Override
          public void run() {
            new LightSettingsDialog(_viewer).open();
          }
        });

    toolbar.getToolBar().pack(true);
  }