use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.
the class GenericWizardService method getNodeImage.
@Override
public Image getNodeImage(String typeName) {
InputStream imageStream = internalService.getComponentService().getWizardPngImage(typeName, WizardImageType.TREE_ICON_16X16);
if (imageStream == null) {
return null;
}
// node image
ImageData id = new ImageData(imageStream);
Image image = new Image(null, id);
return image;
}
use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method getItemsImage.
private Image getItemsImage(IImage iImage) {
if (iImage == null) {
iImage = EImage.DEFAULT_IMAGE;
}
Image image = cacheItemImages.get(iImage);
if (image == null) {
Image oImage = ImageProvider.getImage(iImage);
ImageData imageData = oImage.getImageData();
// enlarge image
final int larger = 4;
ImageData newData = imageData.scaledTo(imageData.width + larger, imageData.height + larger);
image = new Image(oImage.getDevice(), newData);
cacheItemImages.put(iImage, image);
}
return image;
}
use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.
the class ImageController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
// String fileName = (String) param.getValue();
// IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
// String filePath = service.getPathFileName(RepositoryConstants.IMG_DIRECTORY, fileName).toPortableString();
boolean hasScreenshots = false;
byte[] screenshot = null;
if (param.getElement() instanceof INode && ((INode) param.getElement()).getExternalNode() != null) {
String componentType = ((INode) param.getElement()).getComponent().getName();
if ("tMap".equals(componentType)) {
IProcess process = ((INode) param.getElement()).getProcess();
if (process instanceof IProcess2) {
IProcess2 processtmp = (IProcess2) process;
Item item = processtmp.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
screenshot = (byte[]) processItem.getProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
screenshot = (byte[]) jobletItem.getJobletProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
}
}
}
}
if (hasScreenshots) {
ImageDescriptor imageDesc = ImageUtils.createImageFromData(screenshot);
((INode) param.getElement()).getExternalNode().setScreenshot(imageDesc);
// ImageDescriptor imageDesc = ((INode) param.getElement()).getExternalNode().getScreenshot();
// File fileOrFolder = new java.io.File(filePath);
// if (!fileOrFolder.isFile() || !fileOrFolder.canRead()) {
// return lastControl;
// }
final Composite compositeImage = new Composite(subComposite, SWT.BORDER);
final Image image = imageDesc.createImage();
addResourceDisposeListener(compositeImage, image);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName() + " :");
FormData formDataLabel = new FormData();
labelLabel.setVisible(true);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
if (lastControl != null) {
formDataLabel.left = new FormAttachment(lastControl, 0);
} else {
formDataLabel.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
formDataLabel.top = new FormAttachment(0, top);
}
labelLabel.setLayoutData(formDataLabel);
compositeImage.setToolTipText(param.getDisplayName());
Point size = new Point(image.getImageData().width, image.getImageData().height);
FormData formData = new FormData((int) (size.x * 0.8), (int) (size.y * 0.8));
formData.top = new FormAttachment(0, top);
formData.left = new FormAttachment(labelLabel);
ImageData data = image.getImageData();
compositeImage.setLayoutData(formData);
data = data.scaledTo((int) (size.x * 0.8), (int) (size.y * 0.8));
Image im = new Image(image.getDevice(), data);
compositeImage.setBackgroundImage(im);
return compositeImage;
} else {
return lastControl;
}
}
use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.
the class ColorController method createColorImage.
private ImageData createColorImage(Button button, RGB color) {
int width = SIZE_X - 5;
int height = SIZE_Y - 5;
RGB black = new RGB(0, 0, 0);
PaletteData dataPalette = new PaletteData(new RGB[] { black, black, color });
ImageData data = new ImageData(width, height, 4, dataPalette);
data.transparentPixel = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (x == 0 || y == 0 || x == (width - 1) || y == (height - 1)) {
data.setPixel(x, y, 1);
} else {
data.setPixel(x, y, 2);
}
}
}
return data;
}
use of org.eclipse.swt.graphics.ImageData in project tdi-studio-se by Talend.
the class InsertionIndicator method addListeners.
/**
* DOC amaumont Comment method "addListeners".
*/
private void addListeners() {
Listener paintListener = new Listener() {
public void handleEvent(Event event) {
Composite composite = (Composite) event.widget;
Rectangle bounds = composite.getBounds();
// //////////////////////////////////////////////////////////
// draw image filled with transparent pixels
RGB transparentColor = new RGB(0, 255, 0);
PaletteData paletteData = new PaletteData(new RGB[] { transparentColor });
ImageData imageData = new ImageData(bounds.width, bounds.height, 1, paletteData);
int transparentPixelValue = imageData.palette.getPixel(transparentColor);
imageData.transparentPixel = transparentPixelValue;
GC gc = event.gc;
final Image image = new Image(gc.getDevice(), imageData);
gc.drawImage(image, 0, 0);
image.dispose();
// ////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////
// draw left arrow
int yCenter = bounds.height / 2;
int widthExternalArrow = 10;
gc.setBackground(colorIndicator);
gc.setForeground(colorIndicator);
if (composite == leftArrowDraggingIndicator) {
// external left arrow
Point leftCrossPoint = new Point(widthExternalArrow, yCenter);
gc.fillPolygon(new int[] { 0, 0, leftCrossPoint.x, leftCrossPoint.y, 0, bounds.height });
gc.drawLine(leftCrossPoint.x, leftCrossPoint.y, bounds.width, leftCrossPoint.y);
} else {
// external right arrow
Point rightCrossPoint = new Point(bounds.width - widthExternalArrow, yCenter);
gc.fillPolygon(new int[] { bounds.width, 0, rightCrossPoint.x, rightCrossPoint.y, bounds.width, bounds.height });
gc.drawLine(rightCrossPoint.x, rightCrossPoint.y, -bounds.width, rightCrossPoint.y);
}
}
};
leftArrowDraggingIndicator.addListener(SWT.Paint, paintListener);
rightArrowDraggingIndicator.addListener(SWT.Paint, paintListener);
}
Aggregations