Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/swt/widgets/ImageRegionInfo.java


1   package com.port80.swt.widgets;
2   
3   import org.eclipse.swt.graphics.Image;
4   import org.eclipse.swt.widgets.Display;
5   
6   /**
7    * A wrapper around an Image that duplicate a region in another Image.
8    * 
9    * @author chrisl
10   */
11  public class ImageRegionInfo {
12  
13    public boolean valid;
14    public int x;
15    public int y;
16    public int width;
17    public int height;
18    public Image image;
19  
20    public ImageRegionInfo(java.awt.geom.Rectangle2D rect) {
21      x = (int) rect.getX();
22      y = (int) rect.getY();
23      width = (int) (Math.round(rect.getWidth())) + 1;
24      height = (int) (Math.round(rect.getHeight())) + 1;
25      image=new Image(Display.getDefault(),width,height);
26    }
27  
28    public void dispose() {
29      if(image!=null && !image.isDisposed()) image.dispose();
30      image=null;
31    }
32  
33  }