コード例 #1
0
  /*
   * (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;
  }
コード例 #2
0
  private void setStylingElements(RasterSymbolizer symbolizer) {
    double number = SLDs.rasterOpacity(symbolizer);
    int opacity = (new Double(number * 100)).intValue();

    opacityScale.setSelection(opacity);
    opacityText.setText(Integer.toString(opacity) + "%"); // $NON-NLS-1$
    opacityText.pack(true);
  }
コード例 #3
0
ファイル: demo64.java プロジェクト: XiuyeLee/Java-Demo
 public static void main(String args[]) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(null);
   Text hello = new Text(shell, SWT.MULTI);
   shell.setText("Java应用程序");
   shell.setSize(200, 100);
   Color color = new Color(Display.getCurrent(), 255, 255, 255);
   shell.setBackground(color);
   hello.setText("Hello,SWT World!\n\n你好,SWT世界!");
   hello.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   display.dispose();
 }
コード例 #4
0
ファイル: Line.java プロジェクト: yairgd/verilogDesign
  public void initText(String name) {

    //	Point pp1 = shell.getDisplay().map(shell, null,p1.getP().x, p1.getP().y);// new origin
    // Point pp2 = shell.getDisplay().map(shell, null,p2.getP().x, p2.getP().y);

    final Line line = this;
    setName(name);
    if (text != null) {
      text.setText(name);
      return;
    }
    text = new Text(shell, 0);
    text.setText(name);
    FontData[] fD = text.getFont().getFontData();
    fD[0].setHeight(8);
    fD[0].setStyle(SWT.NORMAL);
    text.setFont(new Font(shell.getDisplay(), fD[0]));
    text.setOrientation(SWT.LEFT_TO_RIGHT);
    text.pack();
    text.setText(name);
    textPos = new Point(p1.getP().x, p1.getP().y);
    text.setLocation(textPos);
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            if (text.getText().isEmpty()) text.setText("undefined");
            // calcRegion();
          }
        });

    Listener l_text =
        new Listener() {
          Point origin;

          public void handleEvent(Event e) {
            // System.out.printf("%d %d\n",(e.stateMask & SWT.CTRL),e.button);
            if (e.button != 1 & (e.stateMask & SWT.CTRL) == 0) return;
            switch (e.type) {
              case SWT.MouseEnter:
                break;
              case SWT.MouseDown:
                origin =
                    line.getShell().getDisplay().map(line.getShell(), null, e.x, e.y); // new origin
                break;
              case SWT.MouseUp:
                origin = null;
                break;
              case SWT.MouseMove:
                if (origin != null) {
                  Point p = line.getShell().getDisplay().map(line.text, null, e.x, e.y);
                  ((Line) line).getTextPos().x = (p.x - origin.x);
                  ((Line) line).getTextPos().y = (p.y - origin.y);
                  ((Line) line).getText().setLocation(textPos.x, textPos.y);
                  ((Line) line).getText().pack();
                }
                break;
            }
          }
        };

    text.addListener(SWT.MouseDown, l_text);
    text.addListener(SWT.MouseUp, l_text);
    text.addListener(SWT.MouseMove, l_text);
  }
コード例 #5
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.swt.widgets.Control#pack()
  */
 @Override
 public void pack() {
   text.pack();
   super.pack();
 }