Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.compat / org.gvsig.compat.api / src / main / java / org / gvsig / compat / lang / GraphicsUtils.java @ 40435

History | View | Annotate | Download (2.75 KB)

1
package org.gvsig.compat.lang;
2

    
3
import java.awt.Font;
4
import java.awt.Graphics2D;
5
import java.awt.Image;
6
import java.awt.image.BufferedImage;
7

    
8
import org.gvsig.compat.print.PrintAttributes;
9

    
10
/**
11
 * Multi-platform graphic utils interface.
12
 * This allows platforms with poor java.awt.Graphics2D implementations to
13
 * share most of the application source code.
14
 *   
15
 * @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
16
 *
17
 */
18
public interface GraphicsUtils {
19
        
20
        /**
21
         * Create a buffered Image of the given size and type.
22
         * In this context, buffered image means editable image (admits setRGB etc)
23
         *  
24
         * @param w width in pixels of the requested image
25
         * @param h height in pixels of the requested image
26
         * @param type image type (refers to bands, etc. see {@link Image}
27
         * @return a buffered (editable) image of the desired size and type
28
         */
29
        public BufferedImage createBufferedImage(int w, int h, int type);
30
        
31
        /**
32
         * Produces a copy of a buffered image with the same graphic content (pixel color)
33
         * @param img image to be copied
34
         * @return new instance of a BufferedImage (editable) with same size, type and graphic content.
35
         */
36
        public BufferedImage copyBufferedImage(BufferedImage img);
37
        
38
        /**
39
         * Returns an istance of Font which is the same as the one provided except for the size.
40
         * 
41
         * @param srcfont provided font to be used as model
42
         * @param newheight height in pixels of the new fonr 
43
         * @return the new font, same properties as the provided font, but different size
44
         */
45
        public Font deriveFont(Font srcfont, float newheight);
46
        
47
        /**
48
         * Returns device screen DPI (dots per inch)
49
         * 
50
         * @return number of pixels per inch in the current screen
51
         */
52
        public int getScreenDPI();
53

    
54
        /**
55
         * Adds a translation operation to the Graphics2D object's transformation matrix.
56
         *   
57
         * @param g Object whose transformation matrix has to be modified
58
         * @param x horizontal offset of the translation 
59
         * @param y vertical offset of the translation
60
         */
61
        public void translate(Graphics2D g, double x, double y);
62
        
63
        /**
64
         * Creates an object that implements the PrintAttributes interface with default/trivial values.
65
         * 
66
         * @return an object that implements the PrintAttributes interface with default/trivial values.
67
         */
68
        public PrintAttributes createPrintAttributes();
69
        
70
        /**
71
         * Sets the rendering hints to the Graphics2D object in a way that is suitable for drawing.
72
         *  
73
         * @param g the Graphics2D object whose rendering hints have to be set for drawing
74
         */
75
        public void setRenderingHintsForDrawing(Graphics2D g);
76
        
77
        /**
78
         * Sets the rendering hints to the Graphics2D object in a way that is suitable for printing.
79
         *  
80
         * @param g the Graphics2D object whose rendering hints have to be set for printing
81
         */
82
        public void setRenderingHintsForPrinting(Graphics2D g);
83
}