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 @ 40559
History | View | Annotate | Download (3.69 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; |
29 |
import java.awt.image.BufferedImage; |
30 |
|
31 |
import org.gvsig.compat.print.PrintAttributes; |
32 |
|
33 |
/**
|
34 |
* Multi-platform graphic utils interface.
|
35 |
* This allows platforms with poor java.awt.Graphics2D implementations to
|
36 |
* share most of the application source code.
|
37 |
*
|
38 |
* @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
|
39 |
*
|
40 |
*/
|
41 |
public interface GraphicsUtils { |
42 |
|
43 |
/**
|
44 |
* Create a buffered Image of the given size and type.
|
45 |
* In this context, buffered image means editable image (admits setRGB etc)
|
46 |
*
|
47 |
* @param w width in pixels of the requested image
|
48 |
* @param h height in pixels of the requested image
|
49 |
* @param type image type (refers to bands, etc. see {@link Image}
|
50 |
* @return a buffered (editable) image of the desired size and type
|
51 |
*/
|
52 |
public BufferedImage createBufferedImage(int w, int h, int type); |
53 |
|
54 |
/**
|
55 |
* Produces a copy of a buffered image with the same graphic content (pixel color)
|
56 |
* @param img image to be copied
|
57 |
* @return new instance of a BufferedImage (editable) with same size, type and graphic content.
|
58 |
*/
|
59 |
public BufferedImage copyBufferedImage(BufferedImage img); |
60 |
|
61 |
/**
|
62 |
* Returns an istance of Font which is the same as the one provided except for the size.
|
63 |
*
|
64 |
* @param srcfont provided font to be used as model
|
65 |
* @param newheight height in pixels of the new fonr
|
66 |
* @return the new font, same properties as the provided font, but different size
|
67 |
*/
|
68 |
public Font deriveFont(Font srcfont, float newheight); |
69 |
|
70 |
/**
|
71 |
* Returns device screen DPI (dots per inch)
|
72 |
*
|
73 |
* @return number of pixels per inch in the current screen
|
74 |
*/
|
75 |
public int getScreenDPI(); |
76 |
|
77 |
/**
|
78 |
* Adds a translation operation to the Graphics2D object's transformation matrix.
|
79 |
*
|
80 |
* @param g Object whose transformation matrix has to be modified
|
81 |
* @param x horizontal offset of the translation
|
82 |
* @param y vertical offset of the translation
|
83 |
*/
|
84 |
public void translate(Graphics2D g, double x, double y); |
85 |
|
86 |
/**
|
87 |
* Creates an object that implements the PrintAttributes interface with default/trivial values.
|
88 |
*
|
89 |
* @return an object that implements the PrintAttributes interface with default/trivial values.
|
90 |
*/
|
91 |
public PrintAttributes createPrintAttributes();
|
92 |
|
93 |
/**
|
94 |
* Sets the rendering hints to the Graphics2D object in a way that is suitable for drawing.
|
95 |
*
|
96 |
* @param g the Graphics2D object whose rendering hints have to be set for drawing
|
97 |
*/
|
98 |
public void setRenderingHintsForDrawing(Graphics2D g); |
99 |
|
100 |
/**
|
101 |
* Sets the rendering hints to the Graphics2D object in a way that is suitable for printing.
|
102 |
*
|
103 |
* @param g the Graphics2D object whose rendering hints have to be set for printing
|
104 |
*/
|
105 |
public void setRenderingHintsForPrinting(Graphics2D g); |
106 |
} |