Posts

Showing posts with the label color

Eclipse Editor: Partially editable/read-only editor Part 2

Image
Decorating read-only section by line background The second part of this series I am going to explain changing line background color for particular section of editor, in this case read-only code section. We had reached till restricting editing in read-only code section in previous post . After previous post changes, user won’t able to edit in read-only code section, but user should get some kind of feedback about not able to edit the particular section of file. It would be very informative to color the background with grey color so that user understand that greyed out section is read-only. This can be achieved by providing Line background color listen over source viewer. LineBackgroundListener lineBackgroundListener = new LineBackgroundListener(){ @Override public void lineGetBackground(LineBackgroundEvent event) { int offset = event.lineOffset; if (editorSupport.isInsideReadOnlyBlock(offset, 0)){ event.lineBackground = colorManager.getColor...

Image processing using SWT Image APIS

Eclipse SWT Image APIs provides great level of abstraction for all basic image processing operations like scaling , cropping etc.In this post I have provided code snippet to some of the most common image processing operations. There are main two classes in SWT ( org.eclipse.swt.graphics) Image API org.eclipse.swt.graphics.Image org.eclipse.swt.graphics.ImageData Instances of Image class are graphics which have been prepared for display on a specific device. Instances of ImageData class are device-independent descriptions of images. They are typically used as an intermediate format between loading from or writing to streams and creating an Image . Following code snippet shows creating Image reference as well as retrieving ImageData from image . /* creating Image reference using image path */ Image imageRef = new Image(Display.getCurrent(), "image.jpg" ); ImageData imageData = imageRef.getImageData(); //processing image data //.. //creating image using i...