Exemplo n.º 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);
    }
  }
  @Override
  public void unpickle(final Map<String, String> parms) {
    super.unpickle(parms);

    for (String key : parms.keySet()) {
      if (key.equals(XAXIS_RANGE)) {
        _xAxisRange = parseAxisRange(parms.get(key));
      } else if (key.equals(YAXIS_RANGE)) {
        _yAxisRange = parseAxisRange(parms.get(key));
      } else if (key.equals(XAXIS_DEFAULT_RANGE)) {
        _xAxisDefaultRange = parseAxisRange(parms.get(key));
      } else if (key.equals(YAXIS_DEFAULT_RANGE)) {
        _yAxisDefaultRange = parseAxisRange(parms.get(key));
      }
    }
    // reset the model space
    _modelSpace.setViewableBounds(
        _xAxisRange.getStart(), _xAxisRange.getEnd(), _yAxisRange.getStart(), _yAxisRange.getEnd());
    _modelSpace.setDefaultBounds(
        _xAxisDefaultRange.getStart(),
        _xAxisDefaultRange.getEnd(),
        _yAxisDefaultRange.getStart(),
        _yAxisDefaultRange.getEnd());
  }