Beispiel #1
0
  private void createRegionComposite(Composite regionComposite, RegionType regionType) {

    if (showName) {
      Composite nameComp = new Composite(regionComposite, SWT.NONE);
      nameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
      nameComp.setLayout(new GridLayout(2, false));

      final Label nameLabel = new Label(nameComp, SWT.NONE);
      nameLabel.setText("Region Name  ");
      nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));

      nameText = new Text(nameComp, SWT.BORDER | SWT.SINGLE);
      nameText.setToolTipText("Region name");
      nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      nameText.setEditable(false);
    }

    Group regionTableGroup = new Group(regionComposite, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.LEFT, true, true);
    regionTableGroup.setLayout(new GridLayout(1, false));
    regionTableGroup.setLayoutData(gridData);
    regionTableGroup.setText(tableTitle);
    roiViewer = new AxisPixelROIEditTable(regionTableGroup, plottingSystem);
    roiViewer.setIsProfileTable(isProfile);
    roiViewer.createControl();

    // Should be last
    if (showName) nameText.setText(getDefaultName(regionType.getIndex()));
    regionName = getDefaultName(regionType.getIndex());
  }
Beispiel #2
0
 private String getDefaultName(int sel) {
   if (countMap == null) countMap = new HashMap<Integer, Integer>(5);
   if (!countMap.containsKey(sel)) {
     countMap.put(sel, 0);
   }
   int count = countMap.get(sel);
   count++;
   LinkedList<String> regionTypeList = new LinkedList<String>();
   for (RegionType type : RegionType.ALL_TYPES) {
     regionTypeList.add(type.getName());
   }
   return regionTypeList.get(sel) + " " + count;
 }
  public AbstractSelectionRegion<?> createRegion() throws Exception {

    final AspectAxis xAxis = getAxis(xyGraph.getXAxisList(), xCombo.getSelectionIndex());
    final AspectAxis yAxis = getAxis(xyGraph.getYAxisList(), yCombo.getSelectionIndex());

    AbstractSelectionRegion<?> region = null;

    final String txt = nameText.getText();
    final Pattern pattern = Pattern.compile(".* (\\d+)");
    final Matcher matcher = pattern.matcher(txt);
    if (matcher.matches()) {
      final int count = Integer.parseInt(matcher.group(1));
      countMap.put(regionType.getSelectionIndex(), count);
    }

    region =
        xyGraph.createRegion(
            txt, xAxis, yAxis, RegionType.getRegion(regionType.getSelectionIndex()), true);
    region.setPlotType(plottingSystem.getPlotType());
    this.editingRegion = region;
    getEditingRegion();

    return region;
  }
  /**
   * Used internally
   *
   * @param parent
   * @param plottingSystem
   * @param style
   * @param xyGraph
   * @param defaultRegion
   * @param isImplicit Flag to tell whether the RegionComposite is used in a specific window with an
   *     apply button or part of a view where the changes are implicit
   */
  public RegionEditComposite(
      final Composite parent,
      final IPlottingSystem<?> plottingSystem,
      final int style,
      final XYRegionGraph xyGraph,
      final RegionType defaultRegion,
      final boolean isImplicit) {

    super(parent, SWT.NONE);

    this.setImplicit(isImplicit);

    this.xyGraph = xyGraph;
    this.plottingSystem = plottingSystem;

    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    setLayout(new org.eclipse.swt.layout.GridLayout(2, false));

    final Label nameLabel = new Label(this, SWT.NONE);
    nameLabel.setText("Name   ");
    nameLabel.setLayoutData(new GridData());

    nameText = new Text(this, SWT.BORDER | SWT.SINGLE);
    nameText.setToolTipText("Region name");
    nameText.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    if (isImplicit()) {
      nameText.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    final Label typeLabel = new Label(this, SWT.NONE);
    typeLabel.setText("Type");
    typeLabel.setLayoutData(new GridData());

    regionType = new CCombo(this, SWT.BORDER | SWT.NONE);
    regionType.setEditable(false);
    regionType.setToolTipText("Region type");
    regionType.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    for (RegionType type : RegionType.ALL_TYPES) {
      regionType.add(type.getName());
    }
    regionType.select(defaultRegion.getIndex());

    xCombo = createAxisChooser(this, "X Axis", xyGraph.getXAxisList());
    yCombo = createAxisChooser(this, "Y Axis", xyGraph.getYAxisList());

    Label colorLabel = new Label(this, 0);
    colorLabel.setText("Selection Color");
    colorLabel.setLayoutData(new GridData());

    colorSelector = new ColorSelector(this);
    colorSelector.getButton().setLayoutData(new GridData());
    colorSelector.setColorValue(defaultRegion.getDefaultColor().getRGB());
    if (isImplicit()) {
      colorSelector.addListener(
          new IPropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent event) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz2 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz2.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    Label alphaLabel = new Label(this, 0);
    alphaLabel.setText("Alpha level");
    alphaLabel.setLayoutData(new GridData());

    alpha = new Spinner(this, SWT.NONE);
    alpha.setToolTipText("Alpha transparency level of the shaded shape");
    alpha.setLayoutData(new GridData());
    alpha.setMinimum(0);
    alpha.setMaximum(255);
    alpha.setSelection(80);
    if (isImplicit()) {
      alpha.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.mobile = new Button(this, SWT.CHECK);
    mobile.setText("   Mobile   ");
    mobile.setToolTipText("When true, this selection can be resized and moved around the graph.");
    mobile.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    mobile.setSelection(true);
    if (isImplicit()) {
      mobile.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showPoints = new Button(this, SWT.CHECK);
    showPoints.setText("   Show vertex values");
    showPoints.setToolTipText(
        "When on this will show the actual value of the point in the axes it was added.");
    showPoints.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    if (isImplicit()) {
      showPoints.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.visible = new Button(this, SWT.CHECK);
    visible.setText("   Show region");
    visible.setToolTipText("You may turn off the visibility of this region.");
    visible.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    visible.setSelection(true);
    if (isImplicit()) {
      visible.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showLabel = new Button(this, SWT.CHECK);
    showLabel.setText("   Show name");
    showLabel.setToolTipText("Turn on to show the name of a selection region.");
    showLabel.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    showLabel.setSelection(true);
    if (isImplicit()) {
      showLabel.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.fillRegion = new Button(this, SWT.CHECK);
    fillRegion.setText("   Fill region");
    fillRegion.setToolTipText("Fill the body of an area region");
    fillRegion.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    fillRegion.setSelection(true);
    if (isImplicit()) {
      fillRegion.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label spacer = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    // We add a composite for setting the region location programmatically.
    final Label location = new Label(this, SWT.NONE);
    location.setText("Region Location");
    location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    this.roiViewer = new ROIEditTable();
    roiViewer.createPartControl(this);

    // Should be last
    nameText.setText(getDefaultName(defaultRegion.getIndex()));
  }