org.eclipse.swt.graphics.Image Java Examples

The following examples show how to use org.eclipse.swt.graphics.Image. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphModelDialog.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 7 votes vote down vote up
private java.util.List<Point> getNodeSizes() {
  java.util.List<Point> sizes = new ArrayList<>();

  Image image = new Image( shell.getDisplay(), 100, 100 );
  GC gc = new GC( image );
  gc.setFont( GUIResource.getInstance().getFontMediumBold() );

  for ( GraphNode node : graphModel.getNodes() ) {
    Point textExtent = gc.textExtent( node.getName() );

    int width = textExtent.x + 2 * 10; // 10 : margin
    int height = textExtent.y + 2 * 10;

    sizes.add( new Point( width, height ) );
  }
  gc.dispose();
  image.dispose();

  return sizes;
}
 
Example #2
Source File: PathResourceEntry.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Image getImage( )
{
	if ( isFile( ) )
	{
		String path = getURL( ).toString( ).toLowerCase( );
		if ( path.endsWith( ".rptdesign" ) ) //$NON-NLS-1$
			return ReportPlatformUIImages.getImage( IReportGraphicConstants.ICON_REPORT_FILE );
		if ( path.endsWith( ".rpttemplate" ) ) //$NON-NLS-1$
			return ReportPlatformUIImages.getImage( IReportGraphicConstants.ICON_TEMPLATE_FILE );
		if ( path.endsWith( ".rptdocument" ) ) //$NON-NLS-1$
			return ReportPlatformUIImages.getImage( IReportGraphicConstants.ICON_DOCUMENT_FILE );
		
		Object adapter = ElementAdapterManager.getAdapter( this, Image.class );
		if ( adapter instanceof Image )
		{
			return (Image) adapter;
		}
	}
	if ( this.isFolder || this.isRoot )
		return ReportPlatformUIImages.getImage( ISharedImages.IMG_OBJ_FOLDER );
	return super.getImage( );
}
 
Example #3
Source File: OccurrencesSearchLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Image getImage(Object element) {
	if (element instanceof JavaElementLine) {
		int flags= ((JavaElementLine) element).getFlags();
		if ((flags & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) {
			return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_WRITEACCESS);
		}
		if ((flags & IOccurrencesFinder.F_READ_OCCURRENCE) != 0) {
			return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_READACCESS);
		}
		if ((flags & IOccurrencesFinder.F_EXCEPTION_DECLARATION) != 0) {
			return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
		}
	}
	return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
}
 
Example #4
Source File: AbstractSelectTreeViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the legend image for a entry's ID
 *
 * @param id
 *            the entry's unique ID
 * @return the correctly dimensioned image if there is a legend image provider
 * @since 6.0
 */
protected Image getLegendImage(@NonNull Long id) {
    /* If the image height match the row height, row height will increment */
    ILegendImageProvider legendImageProvider = fLegendImageProvider;
    int legendColumnIndex = fLegendIndex;
    if (legendImageProvider != null && legendColumnIndex >= 0) {
        Tree tree = getTreeViewer().getTree();
        int imageWidth = tree.getColumn(legendColumnIndex).getWidth();
        int imageHeight = tree.getItemHeight() - 1;
        if (imageHeight > 0 && imageWidth > 0) {
            return legendImageProvider.getLegendImage(imageHeight, imageWidth, id);
        }
    }
    return null;
}
 
Example #5
Source File: ImageBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void preview( String uri )
{
	if ( uri == null || uri.trim( ).length( ) == 0 )
	{
		clearPreview( );
		return;
	}

	try
	{
		Image image;
		if ( selectedType == URI_TYPE )
		{
			image = ImageManager.getInstance( )
					.getURIImage( inputImage.getModuleHandle( ), uri );
		}
		else
		{
			image = ImageManager.getInstance( )
					.loadImage( inputImage.getModuleHandle( ), uri );
		}
		previewCanvas.loadImage( image );
	}
	catch ( Exception e )
	{
		clearPreview( );
		logger.log( Level.WARNING, e.getLocalizedMessage( ) );
	}
}
 
Example #6
Source File: MessageWizardPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite result = new Composite(parent, SWT.NONE);
    setControl(result);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN) * 3 / 2;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING) * 2;
    layout.numColumns = 2;
    result.setLayout(layout);

    Image image = getMessageImage();
    if (image != null) {
        Label label = new Label(result, SWT.NULL);
        image.setBackground(label.getBackground());
        label.setImage(image);
        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
    }

    String message = getMessageString();
    if (message != null) {
        Label messageLabel = new Label(result, SWT.WRAP);
        messageLabel.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_BEGINNING);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageLabel.setLayoutData(data);
        messageLabel.setFont(result.getFont());
    }
    Dialog.applyDialogFont(result);
}
 
Example #7
Source File: IntermediateErrorCatchEventLabel3EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void setLabelIconHelper(IFigure figure, Image icon) {
	if (figure instanceof WrappingLabel) {
		((WrappingLabel) figure).setIcon(icon);
		return;
	} else if (figure instanceof Label) {
		((Label) figure).setIcon(icon);
		return;
	} else {
		getLabelDelegate().setIcon(icon, 0);
	}
}
 
Example #8
Source File: StockEntryLabelProvider.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Image getColumnImage(Object element, int columnIndex){
	if (element instanceof IStockEntry && columnIndex == 0) {
		IStockEntry se = (IStockEntry) element;
		IOrderEntry order = OrderServiceHolder.get().findOpenOrderEntryForStockEntry(se);
		if (order != null) {
			return Images.IMG_BAGGAGE_CART_BOX.getImage();
		}
	}
	return null;
}
 
Example #9
Source File: MinimapOverviewRuler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public Parameters(GC gc, Color styledTextForeground, Point size,
        int lineCount, int marginCols, Color marginColor, int spacing, int imageHeight, Transform transform,
        Image tmpImage) {
    this.gc = gc;
    this.styledTextForeground = styledTextForeground;
    this.size = size;
    this.lineCount = lineCount;
    this.marginCols = marginCols;
    this.marginColor = marginColor;
    this.spacing = spacing;
    this.imageHeight = imageHeight;
    this.transform = transform;
    this.tmpImage = tmpImage;
}
 
Example #10
Source File: GridColumn_Test.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGetHeaderImage() {
  Image image = loadImage( display, Fixture.IMAGE1 );

  column.setImage( image );

  assertSame( image, column.getImage() );
}
 
Example #11
Source File: SwtDirectGc.java    From hop with Apache License 2.0 5 votes vote down vote up
@Override public void drawImage( SvgFile svgFile, int x, int y, int desiredWidth, int desiredHeight, float magnification, double angle ) throws HopException {
  //
  SvgCacheEntry cacheEntry = SvgCache.loadSvg( svgFile );
  SwtUniversalImageSvg imageSvg = new SwtUniversalImageSvg( new SvgImage(cacheEntry.getSvgDocument()) );

  Image img = imageSvg.getAsBitmapForSize( gc.getDevice(), Math.round( desiredWidth * magnification ), Math.round( desiredHeight * magnification ), angle );
  Rectangle bounds = img.getBounds();
  int hx = Math.round( bounds.width / magnification );
  int hy = Math.round( bounds.height / magnification );
  gc.drawImage( img, 0, 0, bounds.width, bounds.height, x - hx / 2, y - hy / 2, hx, hy );
}
 
Example #12
Source File: DialogLogoCmp.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置Logo图标
 * @param logo 图标;
 */
public void setLogo(Image logo){
	if(rightLogoCmp != null && !rightLogoCmp.isDisposed()){
		rightLogoCmp.setBackgroundImage(logo);
		if(this.logo != null){
			logo.dispose();
		}
		this.logo = logo;
		rightLogoCmp.getParent().layout();
	}
}
 
Example #13
Source File: SequenceFlowNameEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void setLabelIconHelper(IFigure figure, Image icon) {
	if (figure instanceof WrappingLabel) {
		((WrappingLabel) figure).setIcon(icon);
		return;
	} else if (figure instanceof Label) {
		((Label) figure).setIcon(icon);
		return;
	} else {
		getLabelDelegate().setIcon(icon, 0);
	}
}
 
Example #14
Source File: BoundaryMessageEventLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void setLabelIconHelper(IFigure figure, Image icon) {
	if (figure instanceof WrappingLabel) {
		((WrappingLabel) figure).setIcon(icon);
		return;
	} else if (figure instanceof Label) {
		((Label) figure).setIcon(icon);
		return;
	} else {
		getLabelDelegate().setIcon(icon, 0);
	}
}
 
Example #15
Source File: ViewList.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
   * Dynamically creates an image with the given color
   * @param color
   * @return
   */
  private Image getSymbol(Color color) {
      
      // Check cache
      if (symbols.containsKey(color)) {
          return symbols.get(color);
      }
      
      // Define
      final int WIDTH = 16;
      final int HEIGHT = 16;

      // "Fix" for Bug #50163
      Image image = IS_LINUX ? getTransparentImage(table.getDisplay(), WIDTH, HEIGHT) : 
                               new Image(table.getDisplay(), WIDTH, HEIGHT);
      
      // Prepare
      GC gc = new GC(image);
      gc.setBackground(color);

      // Render
if (!IS_LINUX) {
	gc.fillRectangle(0, 0, WIDTH, HEIGHT);
} else {
	gc.setAntialias(SWT.ON);
	gc.fillOval(0, 0, WIDTH, HEIGHT);
	gc.setAntialias(SWT.OFF);
}

// Cleanup
      gc.dispose();
      
      // Store in cache and return
      symbols.put(color, image);
      return image;
  }
 
Example #16
Source File: ResourceManager.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an {@link Image} based on a {@link Bundle} and resource entry path.
 * 
 * @param symbolicName
 *            the symbolic name of the {@link Bundle}.
 * @param path
 *            the path of the resource entry.
 * @return the {@link Image} stored in the file at the specified path.
 */
public static Image getPluginImage(String symbolicName, String path) {
	try {
		URL url = getPluginImageURL(symbolicName, path);
		if (url != null) {
			return getPluginImageFromUrl(url);
		}
	} catch (Throwable e) {
		// Ignore any exceptions
	}
	return null;
}
 
Example #17
Source File: ModulaSymbolImages.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static Image getProcedureImage(IProcedureSymbol symbol) {
    Image image;
    if (symbol.isAttributeSet(SymbolAttribute.EXTERNAL)) {
        image = ImageUtils.getImage(ImageUtils.OBJ_PROCEDURE_EXT_16x16);
    }
    else if (symbol.isAttributeSet(SymbolAttribute.PUBLIC)) {
        image = ImageUtils.getImage(ImageUtils.OBJ_PROCEDURE_PUB_16x16);
    }
    else {
        image = ImageUtils.getImage(ImageUtils.OBJ_PROCEDURE_16x16);
    }
    return image;
}
 
Example #18
Source File: SwtUniversalImageSvg.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
protected Image renderRotated( Device device, int width, int height, double angleRadians ) {
  BufferedImage doubleArea = SwingUniversalImage.createDoubleBitmap( width, height );

  Graphics2D gc = SwingUniversalImage.createGraphics( doubleArea );
  SwingUniversalImageSvg.render( gc, svgGraphicsNode, svgGraphicsSize, doubleArea.getWidth() / 2, doubleArea
      .getHeight() / 2, width, height, angleRadians );

  gc.dispose();

  return swing2swt( device, doubleArea );
}
 
Example #19
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
public Image getPipelineImage( Device device, int x, int y, float magnificationFactor ) {

    IGc gc = new SwtGc( device, new Point( x, y ), iconsize );

    int gridSize =
      PropsUi.getInstance().isShowCanvasGridEnabled() ? PropsUi.getInstance().getCanvasGridSize() : 1;

    PipelinePainter pipelinePainter = new PipelinePainter( gc, pipelineMeta, new Point( x, y ), new SwtScrollBar( horizontalScrollBar ), new SwtScrollBar( verticalScrollBar ),
      candidate, drop_candidate, selectionRegion, areaOwners,
      PropsUi.getInstance().getIconSize(), PropsUi.getInstance().getLineWidth(), gridSize,
      PropsUi.getInstance().getNoteFont().getName(), PropsUi.getInstance()
      .getNoteFont().getHeight(), pipeline, PropsUi.getInstance().isIndicateSlowPipelineTransformsEnabled(), PropsUi.getInstance().getZoomFactor(), outputRowsMap );

    // correct the magnification with the overall zoom factor
    //
    float correctedMagnification = (float) ( magnificationFactor * PropsUi.getInstance().getZoomFactor() );

    pipelinePainter.setMagnification( correctedMagnification );
    pipelinePainter.setTransformLogMap( transformLogMap );
    pipelinePainter.setStartHopTransform( startHopTransform );
    pipelinePainter.setEndHopLocation( endHopLocation );
    pipelinePainter.setNoInputTransform( noInputTransform );
    pipelinePainter.setEndHopTransform( endHopTransform );
    pipelinePainter.setCandidateHopType( candidateHopType );
    pipelinePainter.setStartErrorHopTransform( startErrorHopTransform );

    try {
      pipelinePainter.buildPipelineImage();
    } catch(Exception e) {
      new ErrorDialog( hopGui.getShell(), "Error", "Error building pipeline image", e );
    }
    Image img = (Image) gc.getImage();

    gc.dispose();
    return img;
  }
 
Example #20
Source File: XYChartLegendImageProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Deprecated
@Override
public Image getLegendImage(int imageHeight, int imageWidth, @NonNull String name) {
    /*
     * If series exists in chart, then image legend match that series. Image will
     * make sense if series exists in chart. If it does not exists, an image will
     * still be created.
     */
    IYAppearance appearance = fChartViewer.getSeriesAppearance(name);
    RGBAColor rgb = appearance.getColor();
    Color lineColor = new Color(Display.getDefault(), rgb.getRed(), rgb.getGreen(), rgb.getBlue());
    Color background = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);

    PaletteData palette = new PaletteData(background.getRGB(), lineColor.getRGB());
    ImageData imageData = new ImageData(imageWidth, imageHeight, 8, palette);
    imageData.transparentPixel = 0;
    Image image = new Image(Display.getDefault(), imageData);
    GC gc = new GC(image);

    gc.setBackground(background);
    gc.fillRectangle(0, 0, imageWidth, imageHeight);
    drawStyleLine(gc, lineColor, imageWidth, imageHeight, appearance.toOutputElementStyle());

    drawStyledDot(gc, lineColor, imageWidth, imageHeight, appearance.toOutputElementStyle());

    gc.dispose();
    lineColor.dispose();
    return image;
}
 
Example #21
Source File: ModifierChangeCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ModifierChangeCorrectionProposal(String label, ICompilationUnit targetCU, IBinding binding, ASTNode node, int includedModifiers, int excludedModifiers, int relevance, Image image) {
	super(label, targetCU, null, relevance, image);
	fBinding= binding;
	fNode= node;
	fIncludedModifiers= includedModifiers;
	fExcludedModifiers= excludedModifiers;
}
 
Example #22
Source File: ScriptTaskLabelEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Image getLabelIconHelper(IFigure figure) {
	if (figure instanceof WrappingLabel) {
		return ((WrappingLabel) figure).getIcon();
	} else if (figure instanceof Label) {
		return ((Label) figure).getIcon();
	} else {
		return getLabelDelegate().getIcon(0);
	}
}
 
Example #23
Source File: RootNode.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public TreeNode create( AbstractMeta abstractMeta, Image image, boolean expanded ) {
  TreeNode treeNode = new TreeNode( abstractMeta.getName(), image, expanded );
  addChild( treeNode );
  addAbstractMeta( abstractMeta, treeNode );
  treeFolderProviders.forEach( treeFolderProvider -> treeFolderProvider.create( abstractMeta, treeNode ) );
  return treeNode;
}
 
Example #24
Source File: IntermediateThrowMessageEventLabel2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Image getLabelIconHelper(IFigure figure) {
	if (figure instanceof WrappingLabel) {
		return ((WrappingLabel) figure).getIcon();
	} else if (figure instanceof Label) {
		return ((Label) figure).getIcon();
	} else {
		return getLabelDelegate().getIcon(0);
	}
}
 
Example #25
Source File: AccordionLabel.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Compute the minimum size.
 */
private Point getTotalSize( Image image, String text )
{
	Point size = new Point( 0, 0 );

	if ( image != null )
	{
		Rectangle r = image.getBounds( );
		size.x += r.width;
		size.y += r.height;
	}

	GC gc = new GC( this );
	if ( text != null && text.length( ) > 0 )
	{
		Point e = gc.textExtent( text, DRAW_FLAGS );
		size.x += e.x;
		size.y = Math.max( size.y, e.y );
		if ( image != null )
			size.x += GAP;
	}
	else
	{
		size.y = Math.max( size.y, gc.getFontMetrics( ).getHeight( ) );
	}
	gc.dispose( );

	return size;
}
 
Example #26
Source File: CreateCamelBean.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public CreateCamelBean() {
    super();
    this.setText(CREATE_LABEL);
    this.setToolTipText(CREATE_LABEL);

    Image folderImg = ImageProvider.getImage(ECamelCoreImage.BEAN_ICON);
    this.setImageDescriptor(OverlayImageProvider.getImageWithNew(folderImg));
}
 
Example #27
Source File: TagCloud.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private ImageData createImageData(final Word word, Font font, Point stringExtent, final double sin,
		final double cos, int x, int y, Color color) {
	Image img = new Image(null, x, y);
	word.width = x;
	word.height = y;
	word.stringExtent = stringExtent;
	GC g = new GC(img);
	g.setAntialias(antialias);
	g.setForeground(color);
	Transform t = new Transform(img.getDevice());
	if (word.angle < 0) {
		t.translate(0, img.getBounds().height - (int) (cos * stringExtent.y));
	} else {
		t.translate((int) (sin * stringExtent.y), 0);
	}
	t.rotate(word.angle);
	g.setTransform(t);
	g.setFont(font);
	// Why is drawString so slow? between 30 and 90 percent of the whole
	// draw time...
	g.drawString(word.string, 0, 0, false);
	int max = Math.max(x, y);
	int tmp = maxSize;
	while (max < tmp) {
		tmp = tmp / 2;
	}
	tmp = tmp * 2;
	SmallRect root = new SmallRect(0, 0, tmp, tmp);
	word.tree = new RectTree(root, accuracy);
	final ImageData id = img.getImageData();
	g.dispose();
	img.dispose();
	return id;
}
 
Example #28
Source File: TypeNameEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected Image getLabelIcon() {
	EObject parserElement = getParserElement();
	if (parserElement == null) {
		return null;
	}
	return CrossflowElementTypes.getImage(parserElement.eClass());
}
 
Example #29
Source File: GeneralView.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
private Image obfuscatedImage(Image image) {
		if (fileName == null) {
			return image;
		}
		UIDebugGenerator.obfuscateArea(image, (Control) fileName.getWidget(),
				manager == null ? "" : UIDebugGenerator.obfuscateDownloadName( manager ));
		UIDebugGenerator.obfuscateArea(image, (Control) saveIn.getWidget(),
				Debug.secretFileName(saveIn.getText()));
		return image;
}
 
Example #30
Source File: HTMLContentAssistProcessor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * addProposal
 * 
 * @param proposals
 * @param name
 * @param icon
 * @param userAgents
 * @param offset
 */
private void addProposal(List<ICompletionProposal> proposals, String name, Image image, String description,
		String[] userAgentIds, String fileLocation, int offset)
{
	if (isActiveByUserAgent(userAgentIds))
	{
		CommonCompletionProposal proposal = createProposal(name, image, description, userAgentIds, fileLocation,
				offset);
		// add it to the list
		proposals.add(proposal);
	}
}