/*
   * (non-Javadoc)
   *
   * @see net.refractions.udig.style.sld.SLDEditorPart#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  protected Control createPartControl(Composite parent) {
    myparent = parent;
    RowLayout layout = new RowLayout();
    myparent.setLayout(layout);
    layout.pack = false;
    layout.wrap = true;
    layout.type = SWT.HORIZONTAL;

    /* Border Opacity */
    Group borderOpacityArea = new Group(myparent, SWT.NONE);
    borderOpacityArea.setLayout(new GridLayout(2, false));
    borderOpacityArea.setText("Raster Opacity"); // $NON-NLS-1$

    opacityScale = new Scale(borderOpacityArea, SWT.HORIZONTAL);
    opacityScale.setMinimum(0);
    opacityScale.setMaximum(100);
    opacityScale.setPageIncrement(10);
    opacityScale.setBounds(0, 0, 10, SWT.DEFAULT);
    opacityScale.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            opacityText.setText(String.valueOf(opacityScale.getSelection()) + "%"); // $NON-NLS-1$
            opacityText.pack(true);
          }
        });
    opacityScale.addSelectionListener(this);

    opacityText = new Text(borderOpacityArea, SWT.BORDER | SWT.READ_ONLY);
    opacityText.pack(true);

    return parent;
  }
 private void testPreserveControlProperties(Scale scale) {
   // bound
   Rectangle rectangle = new Rectangle(10, 10, 10, 10);
   scale.setBounds(rectangle);
   Fixture.preserveWidgets();
   IWidgetAdapter adapter = WidgetUtil.getAdapter(scale);
   assertEquals(rectangle, adapter.getPreserved(Props.BOUNDS));
   Fixture.clearPreserved();
   // enabled
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(true);
   // visible
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   scale.setVisible(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   // menu
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(null, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   Menu menu = new Menu(scale);
   MenuItem item = new MenuItem(menu, SWT.NONE);
   item.setText("1 Item");
   scale.setMenu(menu);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(menu, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   // foreground background font
   Color background = Graphics.getColor(122, 33, 203);
   scale.setBackground(background);
   Color foreground = Graphics.getColor(211, 178, 211);
   scale.setForeground(foreground);
   Font font = Graphics.getFont("font", 12, SWT.BOLD);
   scale.setFont(font);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(background, adapter.getPreserved(Props.BACKGROUND));
   assertEquals(foreground, adapter.getPreserved(Props.FOREGROUND));
   assertEquals(font, adapter.getPreserved(Props.FONT));
   Fixture.clearPreserved();
 }
Пример #3
0
  /** Create contents of the window. */
  protected void createContents() {
    splitImageShell = new Shell();
    splitImageShell.setSize(500, 500);
    splitImageShell.setText("Image Mosaic");

    Log.print("Opening the split image GUI.");

    Group splitImageGroup = new Group(splitImageShell, SWT.NONE);
    splitImageGroup.setText("Split Main Image");
    splitImageGroup.setBounds(10, 10, 464, 400);

    numYCompSpinner = new Spinner(splitImageGroup, SWT.BORDER);
    numYCompScale = new Scale(splitImageGroup, SWT.VERTICAL);
    numXCompScale = new Scale(splitImageGroup, SWT.NONE);
    numXCompSpinner = new Spinner(splitImageGroup, SWT.BORDER);
    mainImageLabel = new Label(splitImageGroup, SWT.NONE);

    numYCompSpinner.setBounds(10, 20, 47, 22);
    numYCompSpinner.setMaximum(150);
    numYCompSpinner.setMinimum(1);
    numYCompSpinner.setSelection(1);
    numYCompSpinner.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            numYCompScale.setSelection(numYCompSpinner.getSelection());
            dispImage =
                outlineSplitImage(
                    image, numXCompSpinner.getSelection(), numYCompScale.getSelection());
            final Image swtMainImage =
                new Image(Display.getDefault(), ImageManipulator.convertAWTImageToSWT(dispImage));
            mainImageLabel.setImage(swtMainImage);
          }
        });

    numYCompScale.setBounds(10, 48, 42, 300);
    numYCompScale.setMaximum(150);
    numYCompScale.setMinimum(1);
    numYCompScale.setSelection(1);
    numYCompScale.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            numYCompSpinner.setSelection(numYCompScale.getSelection());
            dispImage =
                outlineSplitImage(
                    image, numXCompSpinner.getSelection(), numYCompSpinner.getSelection());
            final Image swtMainImage =
                new Image(Display.getDefault(), ImageManipulator.convertAWTImageToSWT(dispImage));
            mainImageLabel.setImage(swtMainImage);
          }
        });

    numXCompScale.setMaximum(150);
    numXCompScale.setMinimum(1);
    numXCompScale.setSelection(1);
    numXCompScale.setBounds(41, 348, 360, 42);
    numXCompScale.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            numXCompSpinner.setSelection(numXCompScale.getSelection());
            dispImage =
                outlineSplitImage(
                    image, numXCompSpinner.getSelection(), numYCompSpinner.getSelection());
            final Image swtMainImage =
                new Image(Display.getDefault(), ImageManipulator.convertAWTImageToSWT(dispImage));
            mainImageLabel.setImage(swtMainImage);
          }
        });

    numXCompSpinner.setMaximum(150);
    numXCompSpinner.setMinimum(1);
    numXCompSpinner.setSelection(1);
    numXCompSpinner.setBounds(407, 357, 47, 22);
    numXCompSpinner.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            numXCompScale.setSelection(numXCompSpinner.getSelection());
            dispImage =
                outlineSplitImage(
                    image, numXCompScale.getSelection(), numYCompSpinner.getSelection());
            final Image swtMainImage =
                new Image(Display.getDefault(), ImageManipulator.convertAWTImageToSWT(dispImage));
            mainImageLabel.setImage(swtMainImage);
          }
        });

    int mainImageLabelWidth = 391;
    int mainImageLabelHeight = 328;
    mainImageLabel.setBounds(63, 20, mainImageLabelWidth, mainImageLabelHeight);
    this.image = ImageManipulator.fitImage(this.image, mainImageLabelWidth, mainImageLabelHeight);
    dispImage =
        outlineSplitImage(
            this.image, numXCompSpinner.getSelection(), numYCompSpinner.getSelection());
    final Image swtMainImage =
        new Image(Display.getDefault(), ImageManipulator.convertAWTImageToSWT(dispImage));
    mainImageLabel.setImage(swtMainImage);

    Button cancelButton = new Button(splitImageShell, SWT.NONE);
    cancelButton.setBounds(399, 427, 75, 25);
    cancelButton.setText("Cancel");
    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Log.print("Cancelled splitting image. Closing split image GUI.");
            splitImageShell.dispose();
          }
        });

    Button okayButton = new Button(splitImageShell, SWT.NONE);
    okayButton.setBounds(318, 427, 75, 25);
    okayButton.setText("Okay");
    okayButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            numXSubcomponents = numXCompSpinner.getSelection();
            numYSubcomponents = numYCompSpinner.getSelection();

            Log.print("Image split has been confirmed.");

            splitImageShell.dispose();
          }
        });
  }