Esempio n. 1
0
  private void updateColor(Display display, RGB color, boolean isBackground) {
    // Button.setBackgroundColor does not work (at least not on OSX) so
    // we instead have to use Button.setImage with an image of the given
    // color
    BufferedImage coloredImage = ImageUtils.createColoredImage(60, 20, color);
    Image image = SwtUtils.convertToSwt(display, coloredImage, false, -1);

    if (isBackground) {
      mBgColor = color;
      mBgButton.setImage(image);
    } else {
      mFgColor = color;
      mFgButton.setImage(image);
    }
  }
Esempio n. 2
0
  private void updatePreview() {
    Display display = mPreviewArea.getDisplay();

    for (Control c : mPreviewArea.getChildren()) {
      c.dispose();
    }

    if (!validatePage()) {
      return;
    }

    Map<String, Map<String, BufferedImage>> map = generateImages(true /*previewOnly*/);
    for (Entry<String, Map<String, BufferedImage>> categoryEntry : map.entrySet()) {
      String category = categoryEntry.getKey();
      if (category.length() > 0) {
        Label nameLabel = new Label(mPreviewArea, SWT.NONE);
        nameLabel.setText(String.format("%1$s:", category));
        RowData rowData = new RowData();
        nameLabel.setLayoutData(rowData);
        // Ensure these get their own rows
        rowData.width = PREVIEW_AREA_WIDTH;
      }

      Map<String, BufferedImage> images = categoryEntry.getValue();
      for (Entry<String, BufferedImage> entry : images.entrySet()) {
        BufferedImage image = entry.getValue();
        Image swtImage = SwtUtils.convertToSwt(display, image, true, -1);
        if (swtImage != null) {
          @SuppressWarnings("unused") // Has side effect
          ImageControl imageControl = new ImageControl(mPreviewArea, SWT.NONE, swtImage);
        }
      }
    }

    mPreviewArea.layout(true);
  }