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;
}
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;
}
}
}
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);
}
}
}
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;
}
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());
}
Aggregations