Search in sources :

Example 6 with ImageData

use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.

the class DBeaverIcons method getViewMenuImage.

public static synchronized Image getViewMenuImage() {
    if (viewMenuImage == null) {
        Display d = Display.getCurrent();
        Image viewMenu = new Image(d, 16, 16);
        Image viewMenuMask = new Image(d, 16, 16);
        Display display = Display.getCurrent();
        GC gc = new GC(viewMenu);
        GC maskgc = new GC(viewMenuMask);
        gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
        gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
        int[] shapeArray = new int[] { 6, 3, 15, 3, 11, 7, 10, 7 };
        gc.fillPolygon(shapeArray);
        gc.drawPolygon(shapeArray);
        Color black = display.getSystemColor(SWT.COLOR_BLACK);
        Color white = display.getSystemColor(SWT.COLOR_WHITE);
        maskgc.setBackground(black);
        maskgc.fillRectangle(0, 0, 16, 16);
        maskgc.setBackground(white);
        maskgc.setForeground(white);
        maskgc.fillPolygon(shapeArray);
        maskgc.drawPolygon(shapeArray);
        gc.dispose();
        maskgc.dispose();
        ImageData data = viewMenu.getImageData();
        data.transparentPixel = data.getPixel(0, 0);
        viewMenuImage = new Image(d, viewMenu.getImageData(), viewMenuMask.getImageData());
        viewMenu.dispose();
        viewMenuMask.dispose();
    }
    return viewMenuImage;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Color(org.eclipse.swt.graphics.Color) Image(org.eclipse.swt.graphics.Image) DBPImage(org.jkiss.dbeaver.model.DBPImage) GC(org.eclipse.swt.graphics.GC) Display(org.eclipse.swt.widgets.Display)

Example 7 with ImageData

use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.

the class OverlayImageDescriptor method drawTopLeft.

protected void drawTopLeft(ImageDescriptor[] overlays) {
    if (overlays == null)
        return;
    int length = overlays.length;
    int x = 0;
    for (int i = 0; i < 3; i++) {
        if (i < length && overlays[i] != null) {
            ImageData id = overlays[i].getImageData();
            drawImage(id, x, 0);
            x += id.width;
        }
    }
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Point(org.eclipse.swt.graphics.Point)

Example 8 with ImageData

use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.

the class OverlayImageDescriptor method drawBottomRight.

protected void drawBottomRight(ImageDescriptor[] overlays) {
    if (overlays == null)
        return;
    int length = overlays.length;
    int x = getSize().x;
    for (int i = 2; i >= 0; i--) {
        if (i < length && overlays[i] != null) {
            ImageData id = overlays[i].getImageData();
            x -= id.width;
            drawImage(id, x, getSize().y - id.height);
        }
    }
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Point(org.eclipse.swt.graphics.Point)

Example 9 with ImageData

use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.

the class ProgramInfo method getProgram.

public static ProgramInfo getProgram(IResource resource) {
    if (resource instanceof IFile) {
        final String fileExtension = CommonUtils.notEmpty(resource.getFileExtension());
        ProgramInfo programInfo = programMap.get(fileExtension);
        if (programInfo == null) {
            Program program = Program.findProgram(fileExtension);
            programInfo = new ProgramInfo(program);
            if (program != null) {
                final ImageData imageData = program.getImageData();
                if (imageData != null) {
                    programInfo.image = new DBIconBinary(program.getName(), imageData);
                }
            }
            programMap.put(fileExtension, programInfo);
        }
        return programInfo.program == null ? null : programInfo;
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Program(org.eclipse.swt.program.Program) ImageData(org.eclipse.swt.graphics.ImageData)

Example 10 with ImageData

use of org.eclipse.swt.graphics.ImageData in project dbeaver by serge-rider.

the class BookmarkStorage method serialize.

public ByteArrayInputStream serialize() throws IOException {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream(5000);
    XMLBuilder xml = new XMLBuilder(buffer, GeneralUtils.getDefaultFileEncoding());
    xml.startElement(TAG_BOOKMARK);
    xml.addAttribute(ATTR_TITLE, title);
    if (description != null) {
        xml.addAttribute(ATTR_DESCRIPTION, description);
    }
    xml.addAttribute(ATTR_DATA_SOURCE, dataSourceId);
    for (String path : dataSourcePath) {
        xml.startElement(TAG_PATH);
        xml.addText(path);
        xml.endElement();
    }
    {
        xml.startElement(TAG_IMAGE);
        Image realImage = DBeaverIcons.getImage(this.image);
        ImageLoader loader = new ImageLoader();
        loader.data = new ImageData[] { realImage.getImageData() };
        ByteArrayOutputStream imageBuffer = new ByteArrayOutputStream(5000);
        loader.save(imageBuffer, SWT.IMAGE_PNG);
        xml.addText(Base64.encode(imageBuffer.toByteArray()));
        xml.endElement();
    }
    xml.endElement();
    xml.flush();
    return new ByteArrayInputStream(buffer.toByteArray());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ImageData(org.eclipse.swt.graphics.ImageData) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Image(org.eclipse.swt.graphics.Image) DBPImage(org.jkiss.dbeaver.model.DBPImage) ImageLoader(org.eclipse.swt.graphics.ImageLoader) XMLBuilder(org.jkiss.utils.xml.XMLBuilder)

Aggregations

ImageData (org.eclipse.swt.graphics.ImageData)54 Image (org.eclipse.swt.graphics.Image)29 Point (org.eclipse.swt.graphics.Point)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)11 ByteArrayInputStream (java.io.ByteArrayInputStream)7 GC (org.eclipse.swt.graphics.GC)7 ImageLoader (org.eclipse.swt.graphics.ImageLoader)7 Display (org.eclipse.swt.widgets.Display)6 Composite (org.eclipse.swt.widgets.Composite)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 PaletteData (org.eclipse.swt.graphics.PaletteData)3 RGB (org.eclipse.swt.graphics.RGB)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Event (org.eclipse.swt.widgets.Event)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 Listener (org.eclipse.swt.widgets.Listener)3 EImage (org.talend.commons.ui.runtime.image.EImage)3 IImage (org.talend.commons.ui.runtime.image.IImage)3