public void applyChanges() {
    annotation.setName(nameText.getText());
    if (snapToTrace.getSelection())
      annotation.setTrace(
          xyGraph.getPlotArea().getTraceList().get(xAxisOrTraceCombo.getSelectionIndex()));
    else
      annotation.setFree(
          xyGraph.getXAxisList().get(xAxisOrTraceCombo.getSelectionIndex()),
          xyGraph.getYAxisList().get(yAxisCombo.getSelectionIndex()));

    if (!useDefaultColorButton.getSelection())
      annotation.setAnnotationColor(
          XYGraphMediaFactory.getInstance().getColor(colorSelector.getColorValue()));
    else annotation.setAnnotationColor(null);
    annotation.setFont(font);
    annotation.setCursorLineStyle(CursorLineStyle.values()[cursorLineCombo.getSelectionIndex()]);
    annotation.setShowName(showNameButton.getSelection());
    annotation.setShowSampleInfo(showSampleInfoButton.getSelection());
    annotation.setShowPosition(showPositionButton.getSelection());
  }
  public void createPage(final Composite composite) {
    this.composite = composite;
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout(2, false));

    final Label nameLabel = new Label(composite, 0);
    nameLabel.setText(Messages.Annotation_Name);
    nameLabel.setLayoutData(new GridData());

    nameText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    nameText.setToolTipText(Messages.Annotation_NameTT);
    nameText.setLayoutData(new GridData(SWT.FILL, 0, true, false));

    snapToTrace = new Button(composite, SWT.CHECK);
    snapToTrace.setText(Messages.Annotation_Snap);
    snapToTrace.setToolTipText(Messages.Annotation_SnapTT);
    snapToTrace.setLayoutData(new GridData(0, 0, false, false, 2, 1));

    xAxisLabel = new Label(composite, 0);
    xAxisLabel.setLayoutData(new GridData());

    xAxisOrTraceCombo = new Combo(composite, SWT.DROP_DOWN);
    xAxisOrTraceCombo.setLayoutData(new GridData(SWT.FILL, 0, true, false));

    yAxisLabel = new Label(composite, 0);
    yAxisLabel.setText(Messages.Annotation_YAxis);
    yAxisLabel.setLayoutData(new GridData());

    yAxisCombo = new Combo(composite, SWT.DROP_DOWN);
    yAxisCombo.setToolTipText(Messages.Annotation_YAxisSnapTT);
    yAxisCombo.setLayoutData(new GridData(SWT.FILL, 0, true, false));

    // snapToTrace listener
    snapToTrace.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            if (snapToTrace.getSelection()) {
              xAxisLabel.setText(Messages.Annotation_Trace);
              xAxisOrTraceCombo.setToolTipText(Messages.Annotation_TraceSnapTT);
            } else {
              xAxisLabel.setText(Messages.Annotation_XAxis);
              xAxisOrTraceCombo.setToolTipText(Messages.Annotation_XAxisSnapTT);
            }

            xAxisOrTraceCombo.removeAll();
            if (snapToTrace.getSelection()) {
              for (Trace trace : xyGraph.getPlotArea().getTraceList())
                xAxisOrTraceCombo.add(trace.getName());
            } else {
              for (Axis axis : xyGraph.getXAxisList()) xAxisOrTraceCombo.add(axis.getTitle());
            }
            xAxisOrTraceCombo.select(0);
            if (annotation.isFree() && !snapToTrace.getSelection())
              xAxisOrTraceCombo.select(xyGraph.getXAxisList().indexOf(annotation.getXAxis()));
            else if (!annotation.isFree() && snapToTrace.getSelection())
              xAxisOrTraceCombo.select(
                  xyGraph.getPlotArea().getTraceList().indexOf(annotation.getTrace()));

            yAxisLabel.setVisible(!snapToTrace.getSelection());
            yAxisCombo.setVisible(!snapToTrace.getSelection());
            composite.layout(true, true);
          }
        });
    // annotation color
    useDefaultColorButton = new Button(composite, SWT.CHECK);
    useDefaultColorButton.setText(Messages.Annotation_ColorFromYAxis);
    useDefaultColorButton.setLayoutData(new GridData(SWT.FILL, 0, false, false, 2, 1));

    colorLabel = new Label(composite, 0);
    colorLabel.setText(Messages.Annotation_Color);
    colorLabel.setLayoutData(new GridData());

    colorSelector = new ColorSelector(composite);
    colorSelector.getButton().setLayoutData(new GridData());
    useDefaultColorButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            colorSelector.getButton().setVisible(!useDefaultColorButton.getSelection());
            colorLabel.setVisible(!useDefaultColorButton.getSelection());
          }
        });

    fontLabel = new Label(composite, 0);
    fontLabel.setLayoutData(new GridData());

    final Button fontButton = new Button(composite, SWT.PUSH);
    fontButton.setText(Messages.Annotation_ChangeFont);
    fontButton.setLayoutData(new GridData());
    fontButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FontDialog fontDialog = new FontDialog(composite.getShell());
            if (font != null) fontDialog.setFontList(font.getFontData());
            FontData fontData = fontDialog.open();
            if (fontData != null) {
              font = XYGraphMediaFactory.getInstance().getFont(fontData);
              fontLabel.setFont(font);
              fontLabel.setText(Messages.Annotation_Font + fontData.getName());
              composite.getShell().layout(true, true);
            }
          }
        });

    final Label cursorLineLabel = new Label(composite, 0);
    cursorLineLabel.setText(Messages.Annotation_Cursor);
    cursorLineLabel.setLayoutData(new GridData());

    cursorLineCombo = new Combo(composite, SWT.DROP_DOWN);
    cursorLineCombo.setItems(CursorLineStyle.stringValues());
    cursorLineCombo.setLayoutData(new GridData());

    showNameButton = new Button(composite, SWT.CHECK);
    showNameButton.setText(Messages.Annotation_ShowName);
    showNameButton.setLayoutData(new GridData(0, 0, false, false, 2, 1));

    showSampleInfoButton = new Button(composite, SWT.CHECK);
    showSampleInfoButton.setText(Messages.Annotation_ShowInfo);
    showSampleInfoButton.setLayoutData(new GridData(0, 0, false, false, 2, 1));

    showPositionButton = new Button(composite, SWT.CHECK);
    showPositionButton.setText(Messages.Annotation_ShowPosition);
    showPositionButton.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    initialize();
  }