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 @ 43230

History | View | Annotate | Download (3.65 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.compat.lang;
25

    
26
import java.awt.Font;
27
import java.awt.Graphics2D;
28
import java.awt.image.BufferedImage;
29

    
30
import org.gvsig.compat.print.PrintAttributes;
31

    
32
/**
33
 * Multi-platform graphic utils interface.
34
 * This allows platforms with poor java.awt.Graphics2D implementations to
35
 * share most of the application source code.
36
 *
37
 * @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
38
 *
39
 */
40
public interface GraphicsUtils {
41
    
42
        /**
43
         * Create a buffered Image of the given size and type.
44
         * In this context, buffered image means editable image (admits setRGB etc)
45
         *  
46
         * @param w width in pixels of the requested image
47
         * @param h height in pixels of the requested image
48
         * @param type image type (refers to bands, etc. see {@link Image}
49
         * @return a buffered (editable) image of the desired size and type
50
         */
51
        public BufferedImage createBufferedImage(int w, int h, int type);
52

    
53
        /**
54
         * Produces a copy of a buffered image with the same graphic content (pixel color)
55
         * @param img image to be copied
56
         * @return new instance of a BufferedImage (editable) with same size, type and graphic content.
57
         */
58
        public BufferedImage copyBufferedImage(BufferedImage img);
59

    
60
        /**
61
         * Returns an istance of Font which is the same as the one provided except for the size.
62
         *
63
         * @param srcfont provided font to be used as model
64
         * @param newheight height in pixels of the new fonr
65
         * @return the new font, same properties as the provided font, but different size
66
         */
67
        public Font deriveFont(Font srcfont, float newheight);
68

    
69
        /**
70
         * Returns device screen DPI (dots per inch)
71
         *
72
         * @return number of pixels per inch in the current screen
73
         */
74
        public int getScreenDPI();
75

    
76
        /**
77
         * Adds a translation operation to the Graphics2D object's transformation matrix.
78
         *
79
         * @param g Object whose transformation matrix has to be modified
80
         * @param x horizontal offset of the translation
81
         * @param y vertical offset of the translation
82
         */
83
        public void translate(Graphics2D g, double x, double y);
84

    
85
        /**
86
         * Creates an object that implements the PrintAttributes interface with default/trivial values.
87
         *
88
         * @return an object that implements the PrintAttributes interface with default/trivial values.
89
         */
90
        public PrintAttributes createPrintAttributes();
91

    
92
        /**
93
         * Sets the rendering hints to the Graphics2D object in a way that is suitable for drawing.
94
         *
95
         * @param g the Graphics2D object whose rendering hints have to be set for drawing
96
         */
97
        public void setRenderingHintsForDrawing(Graphics2D g);
98

    
99
        /**
100
         * Sets the rendering hints to the Graphics2D object in a way that is suitable for printing.
101
         *
102
         * @param g the Graphics2D object whose rendering hints have to be set for printing
103
         */
104
        public void setRenderingHintsForPrinting(Graphics2D g);
105
}