Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Image


                if (imageDescriptor == null) {
                    return null;
                }

                Image icon = (Image) images.get(imageDescriptor);
                return icon;
            }

            public String getText(Object object) {
                Assert.isTrue(object instanceof IWorkingSet);
View Full Code Here


                if (imageDescriptor == null) {
                    return null;
                }

                Image icon = (Image) images.get(imageDescriptor);
                return icon;
            }
View Full Code Here

    if(element instanceof ISynchronizeModelElement) {
        ISynchronizeModelElement node = (ISynchronizeModelElement)element;
        if(node instanceof IAdaptable) {
          SyncInfo info = (SyncInfo)((IAdaptable)node).getAdapter(SyncInfo.class);
          if (info != null) {
            Image result = null;
            IResource resource = info.getLocal();
            result = _designFolderDecorator.decorateImage(image, element);           
            if (result != null) {
              result = _natureDecorator.decorateImage(result, element);
            }
View Full Code Here

 

  public Composite configSectionCreate(final Composite parent) {
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image imgOpenFolder = imageLoader.getImage("openFolderButton");     

    GridData gridData;
    GridLayout layout;

    Composite gLogging = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gLogging.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gLogging.setLayout(layout);
   
    int userMode = COConfigurationManager.getIntParameter("User Mode");

   
    BooleanParameter enable_logger = new BooleanParameter(gLogging, "Logger.Enabled", CFG_PREFIX + "loggerenable");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    enable_logger.setLayoutData(gridData);

    // row

    final BooleanParameter enableLogging =
      new BooleanParameter(gLogging,
                           "Logging Enable",
                           CFG_PREFIX + "enable");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    enableLogging.setLayoutData(gridData);

    Composite cArea = new Composite(gLogging, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 3;
    cArea.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    cArea.setLayoutData(gridData);


    // row

    Label lStatsPath = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(lStatsPath, CFG_PREFIX + "logdir"); //$NON-NLS-1$

    gridData = new GridData();
    gridData.widthHint = 150;
    final StringParameter pathParameter = new StringParameter(cArea, "Logging Dir"); //$NON-NLS-1$ //$NON-NLS-2$
    pathParameter.setLayoutData(gridData);
    Button browse = new Button(cArea, SWT.PUSH);
    browse.setImage(imgOpenFolder);
    imgOpenFolder.setBackground(browse.getBackground());
    browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
    browse.addListener(SWT.Selection, new Listener() {
      /* (non-Javadoc)
       * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
       */
 
View Full Code Here

            size
          });
          //nsImage.retain();
          invoke(nsImage, "retain");
          //Image image = Image.cocoa_new(Display.getCurrent(), SWT.BITMAP, nsImage);
          Image image = (Image) invoke(Image.class, null, "cocoa_new",
              new Class[] {
                Device.class,
                int.class,
                nsimageCls
              }, new Object[] {
View Full Code Here

      Label lStatsPath = new Label(gSecurity, SWT.NULL);
     
      Messages.setLanguageText(lStatsPath, "ConfigView.section.security.toolsdir"); //$NON-NLS-1$

      ImageLoader imageLoader = ImageLoader.getInstance();
      Image imgOpenFolder = imageLoader.getImage("openFolderButton");     
     
      gridData = new GridData();
     
      gridData.widthHint = 150;
     
      final StringParameter pathParameter = new StringParameter(gSecurity, "Security.JAR.tools.dir", ""); //$NON-NLS-1$ //$NON-NLS-2$
     
      pathParameter.setLayoutData(gridData);
     
      Button browse = new Button(gSecurity, SWT.PUSH);
     
      browse.setImage(imgOpenFolder);
     
      imgOpenFolder.setBackground(browse.getBackground());
     
      browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
     
      browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
View Full Code Here

    return REQUIRED_MODE;
  }


  public Composite configSectionCreate(final Composite parent) {
    Image imgOpenFolder = null;
    if (!Constants.isOSX) {
      ImageLoader imageLoader = ImageLoader.getInstance();
      imgOpenFolder = imageLoader.getImage("openFolderButton");     
    }

    GridData gridData;
    GridLayout layout;

    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL
        | GridData.HORIZONTAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    layout = new GridLayout();
    layout.marginWidth = 0;
    //layout.numColumns = 2;
    cSection.setLayout(layout);

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode < REQUIRED_MODE) {
      Label label = new Label(cSection, SWT.WRAP);
      gridData = new GridData();
      label.setLayoutData(gridData);

      final String[] modeKeys = {
        "ConfigView.section.mode.beginner",
        "ConfigView.section.mode.intermediate",
        "ConfigView.section.mode.advanced"
      };

      String param1, param2;
      if (REQUIRED_MODE < modeKeys.length)
        param1 = MessageText.getString(modeKeys[REQUIRED_MODE]);
      else
        param1 = String.valueOf(REQUIRED_MODE);

      if (userMode < modeKeys.length)
        param2 = MessageText.getString(modeKeys[userMode]);
      else
        param2 = String.valueOf(userMode);

      label.setText(MessageText.getString("ConfigView.notAvailableForMode",
          new String[] {
            param1,
            param2
          }));

      return cSection;
    }

    Composite cArea = new Composite(cSection, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 4;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanParameter d_play_sound = new BooleanParameter(cArea,
        "Play Download Finished", LBLKEY_PREFIX + "playdownloadfinished");

    // OS X counterpart for alerts (see below for what is disabled)
    if (Constants.isOSX) {
      // download info

      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 0;
      gridData.heightHint = 0;
      Composite d_filler = new Composite(cArea, SWT.NONE);
      d_filler.setSize(0, 0);
      d_filler.setLayoutData(gridData);

      final BooleanParameter d_speechEnabledParameter = new BooleanParameter(
          cArea, "Play Download Finished Announcement", LBLKEY_PREFIX
              + "playdownloadspeech");

      final StringParameter d_speechParameter = new StringParameter(cArea,
          "Play Download Finished Announcement Text");
      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 150;
      d_speechParameter.setLayoutData(gridData);
      ((Text) d_speechParameter.getControl()).setTextLimit(40);

      d_speechEnabledParameter.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          d_speechParameter.getControls()));

      final Label d_speechInfo = new Label(cArea, SWT.NONE);
      gridData = new GridData();
      gridData.horizontalSpan = 4;
      gridData.horizontalIndent = 24;
      d_speechInfo.setLayoutData(gridData);

      Messages.setLanguageText(d_speechInfo, LBLKEY_PREFIX
          + "playdownloadspeech.info");
    }

    //Option disabled on OS X, as impossible to make it work correctly
    if (!Constants.isOSX) {

      // download info

      gridData = new GridData(GridData.FILL_HORIZONTAL);

      final StringParameter d_pathParameter = new StringParameter(cArea,
          "Play Download Finished File", "");

      if (d_pathParameter.getValue().length() == 0) {

        d_pathParameter.setValue("<default>");
      }

      d_pathParameter.setLayoutData(gridData);

      Button d_browse = new Button(cArea, SWT.PUSH);

      d_browse.setImage(imgOpenFolder);

      imgOpenFolder.setBackground(d_browse.getBackground());

      d_browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));

      d_browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          FileDialog dialog = new FileDialog(parent.getShell(),
              SWT.APPLICATION_MODAL);
          dialog.setFilterExtensions(new String[] { "*.wav"
          });
          dialog.setFilterNames(new String[] { "*.wav"
          });

          dialog.setText(MessageText.getString(INTERFACE_PREFIX + "wavlocation"));

          final String path = dialog.open();

          if (path != null) {

            d_pathParameter.setValue(path);

            new AEThread("SoundTest") {
              public void runSupport() {
                try {
                  Applet.newAudioClip(new File(path).toURL()).play();

                  Thread.sleep(2500);

                } catch (Throwable e) {

                }
              }
            }.start();
          }
        }
      });

      Label d_sound_info = new Label(cArea, SWT.WRAP);
      Messages.setLanguageText(d_sound_info, INTERFACE_PREFIX
          + "wavlocation.info");
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.widthHint = 100;
      d_sound_info.setLayoutData(gridData);

      d_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          d_pathParameter.getControls()));
      d_play_sound.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          new Control[] {
            d_browse,
            d_sound_info
          }));

      //
    }

    BooleanParameter f_play_sound = new BooleanParameter(cArea,
        "Play File Finished", LBLKEY_PREFIX + "playfilefinished");

    // OS X counterpart for alerts (see below for what is disabled)

    if (Constants.isOSX) {

      // per-file info

      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 0;
      gridData.heightHint = 0;
      Composite f_filler = new Composite(cArea, SWT.NONE);
      f_filler.setSize(0, 0);
      f_filler.setLayoutData(gridData);

      final BooleanParameter f_speechEnabledParameter = new BooleanParameter(
          cArea, "Play File Finished Announcement", LBLKEY_PREFIX
              + "playfilespeech");

      final StringParameter f_speechParameter = new StringParameter(cArea,
          "Play File Finished Announcement Text");
      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.widthHint = 150;
      f_speechParameter.setLayoutData(gridData);
      ((Text) f_speechParameter.getControl()).setTextLimit(40);

      f_speechEnabledParameter.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
          f_speechParameter.getControls()));

      final Label speechInfo = new Label(cArea, SWT.NONE);
      gridData = new GridData();
      gridData.horizontalSpan = 4;
      gridData.horizontalIndent = 24;
      speechInfo.setLayoutData(gridData);

      Messages.setLanguageText(speechInfo, LBLKEY_PREFIX
          + "playfilespeech.info");
    }

    //Option disabled on OS X, as impossible to make it work correctly
    if (!Constants.isOSX) {

      // file info

      gridData = new GridData(GridData.FILL_HORIZONTAL);

      final StringParameter f_pathParameter = new StringParameter(cArea,
          "Play File Finished File", "");

      if (f_pathParameter.getValue().length() == 0) {

        f_pathParameter.setValue("<default>");
      }

      f_pathParameter.setLayoutData(gridData);

      Button f_browse = new Button(cArea, SWT.PUSH);

      f_browse.setImage(imgOpenFolder);

      imgOpenFolder.setBackground(f_browse.getBackground());

      f_browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));

      f_browse.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
View Full Code Here

    // Named infoObj so code can be copied easily to the other PiecesItem
    PEPeer infoObj = (PEPeer)cell.getDataSource();
    if (infoObj == null)
      return;

    Image img = (Image)infoObj.getData("PiecesImage");
    if (img != null && !img.isDisposed())
      img.dispose();

    infoObj.setData("PiecesImageBuffer", null);
    infoObj.setData("PiecesImage", null);
  }
View Full Code Here

    if (drawWidth < 10 || y1 < 3)
      return;
    int[] imageBuffer = (int [])infoObj.getData("PiecesImageBuffer");
    boolean bImageBufferValid = imageBuffer != null && imageBuffer.length == drawWidth;

    Image image = (Image)infoObj.getData("PiecesImage");
    GC gcImage;
    boolean bImageChanged;
    Rectangle imageBounds;
    if (image == null || image.isDisposed()) {
      bImageChanged = true;
    } else {
      imageBounds = image.getBounds();
      bImageChanged = imageBounds.width != newWidth ||
                      imageBounds.height != newHeight;
    }
    if (bImageChanged) {
      if (image != null && !image.isDisposed()) {
        image.dispose();
      }
      image = new Image(SWTThread.getInstance().getDisplay(),
                        newWidth, newHeight);
      imageBounds = image.getBounds();
      bImageBufferValid = false;

      // draw border
      gcImage = new GC(image);
      gcImage.setForeground(Colors.grey);
      if (borderHorizontalSize > 0) {
        if (borderVerticalSize > 0) {
          gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1);
        } else {
          gcImage.drawLine(0, 0, newWidth - 1, 0);
          gcImage.drawLine(0, newHeight -1, newWidth - 1, newHeight - 1);
        }
      } else if (borderVerticalSize > 0) {
        gcImage.drawLine(0, 0, 0, newHeight - 1);
        gcImage.drawLine(newWidth - 1, 0, newWidth - 1, newHeight - 1);
      }

      if (borderSplit > 0) {
        gcImage.setForeground(Colors.white);
        gcImage.drawLine(x0, completionHeight + borderHorizontalSize,
                         x1, completionHeight + borderHorizontalSize);
      }
    } else {
      gcImage = new GC(image);
    }

    final BitFlags peerHave = infoObj.getAvailable();
    boolean established = ((PEPeerTransport)infoObj).getConnectionState() == PEPeerTransport.CONNECTION_FULLY_ESTABLISHED;
   
    if (established && peerHave != null && peerHave.flags.length > 0) {
      if (imageBuffer == null || imageBuffer.length != drawWidth) {
        imageBuffer = new int[drawWidth];
      }
        final boolean available[] =peerHave.flags;
    try {
     
      int nbComplete = 0;
      int nbPieces = available.length;
     
      DiskManager disk_manager = infoObj.getManager().getDiskManager();
      DiskManagerPiece[]  pieces = disk_manager==null?null:disk_manager.getPieces();
                     
     
      int a0;
      int a1 = 0;
      for (int i = 0; i < drawWidth; i++) {
        if (i == 0) {
          // always start out with one piece
          a0 = 0;
          a1 = nbPieces / drawWidth;
          if (a1 == 0)
            a1 = 1;
        } else {
          // the last iteration, a1 will be nbPieces
          a0 = a1;
          a1 = ((i + 1) * nbPieces) / (drawWidth);
        }

        int index;
        int nbNeeded = 0;

        if (a1 <= a0) {
          index = imageBuffer[i - 1];
        } else {
          int nbAvailable = 0;
          for (int j = a0; j < a1; j++) {
            if (available[j]) {
              if (pieces==null || !pieces[j].isDone()) {
                nbNeeded++;
              }
              nbAvailable++;
            }
          }
          nbComplete += nbAvailable;
          index = (nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0);
          if (nbNeeded <= nbAvailable / 2)
            index += INDEX_COLOR_FADEDSTARTS;
        }

        if (imageBuffer[i] != index) {
          imageBuffer[i] = index;
          if (bImageBufferValid) {
            bImageChanged = true;
            if (imageBuffer[i] >= INDEX_COLOR_FADEDSTARTS)
              gcImage.setForeground(Colors.faded[index - INDEX_COLOR_FADEDSTARTS]);
            else
              gcImage.setForeground(Colors.blues[index]);
            gcImage.drawLine(i + x0, y0, i + x0, y1);
          }
        }
      }
      if (!bImageBufferValid) {
        if(established) {
          int iLastIndex = imageBuffer[0];
          int iWidth = 1;
          for (int i = 1; i < drawWidth; i++) {
            if (iLastIndex == imageBuffer[i]) {
              iWidth++;
            } else {
              if (iLastIndex >= INDEX_COLOR_FADEDSTARTS) {
                gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
              } else
                gcImage.setBackground(Colors.blues[iLastIndex]);
              gcImage.fillRectangle(i - iWidth + x0, y0, iWidth, y1 - y0 + 1);
              iWidth = 1;
              iLastIndex = imageBuffer[i];
            }
          }
          if (iLastIndex >= INDEX_COLOR_FADEDSTARTS)
            gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
          else
            gcImage.setBackground(Colors.blues[iLastIndex]);
          gcImage.fillRectangle(x1 - iWidth + 1, y0, iWidth, y1 - y0 + 1);
          bImageChanged = true;
        }
      }

      int limit = (drawWidth * nbComplete) / nbPieces;
      if (limit < drawWidth) {
        gcImage.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
        gcImage.fillRectangle(limit+x0, borderHorizontalSize,
                              x1-limit, completionHeight);
      }
      gcImage.setBackground(Colors.colorProgressBar);
      gcImage.fillRectangle(x0, borderHorizontalSize,
                            limit, completionHeight);
    } catch (Exception e) {
      System.out.println("Error Drawing PiecesItem");
      Debug.printStackTrace( e );
    } } else {
        gcImage.setForeground(Colors.grey);
        gcImage.setBackground(Colors.grey);
        gcImage.fillRectangle(x0,y0,newWidth,y1);
    }
    gcImage.dispose();

    Image oldImage = null;
    Graphic graphic = cell.getGraphic();
    if (graphic instanceof UISWTGraphic) {
      oldImage = ((UISWTGraphic) graphic).getImage();
    }
    if (bImageChanged || image != oldImage || !cell.isValid()) {
View Full Code Here

 
      Field fldHIcon = claSHFILEINFO.getField("hIcon");
      if (fldHIcon.getLong(shfi) == 0) {
        return null;
      }
      Image image = null;
      if (useLong) {
        image = (Image) mImage_win32_new.invoke(null, new Object[] {
          null,
          SWT.ICON,
          fldHIcon.getLong(shfi)
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.