svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.compat / org.gvsig.compat.se / src / main / java / org / gvsig / compat / se / lang / SEGraphUtils.java @ 43228
History | View | Annotate | Download (3.23 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.se.lang; |
25 |
|
26 |
import java.awt.Font; |
27 |
import java.awt.Graphics2D; |
28 |
import java.awt.RenderingHints; |
29 |
import java.awt.Toolkit; |
30 |
import java.awt.image.BufferedImage; |
31 |
import java.util.prefs.Preferences; |
32 |
|
33 |
import org.gvsig.compat.lang.GraphicsUtils; |
34 |
import org.gvsig.compat.print.PrintAttributes; |
35 |
import org.gvsig.compat.se.print.SePrintAttributes; |
36 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
37 |
|
38 |
/**
|
39 |
* JSE (Desktop Java) implementation of {@link GraphicsUtils}
|
40 |
*
|
41 |
* @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es
|
42 |
*
|
43 |
* @see GraphicsUtils
|
44 |
*
|
45 |
*/
|
46 |
public class SEGraphUtils implements GraphicsUtils{ |
47 |
|
48 |
public BufferedImage copyBufferedImage(BufferedImage img) { |
49 |
BufferedImage newImage =
|
50 |
ToolsSwingLocator.getToolsSwingManager() |
51 |
.copyBufferedImage(img); |
52 |
return newImage;
|
53 |
} |
54 |
|
55 |
public PrintAttributes createPrintAttributes() {
|
56 |
return new SePrintAttributes(); |
57 |
} |
58 |
|
59 |
public Font deriveFont(Font srcfont, float newheight) { |
60 |
return srcfont.deriveFont(newheight);
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Tries to use DPI value from gvSIG preferences. If this does not exist, gets
|
65 |
* value from Java Toolkit.
|
66 |
*/
|
67 |
public int getScreenDPI() { |
68 |
|
69 |
Preferences prefsResolution = Preferences.userRoot().node("gvsig.configuration.screen"); |
70 |
Toolkit kit = Toolkit.getDefaultToolkit(); |
71 |
int dpi = prefsResolution.getInt("dpi", kit.getScreenResolution()); |
72 |
return dpi;
|
73 |
} |
74 |
|
75 |
public void translate(Graphics2D g, double x, double y) { |
76 |
g.translate(x, y); |
77 |
|
78 |
} |
79 |
|
80 |
public void setRenderingHintsForDrawing(Graphics2D g) { |
81 |
|
82 |
RenderingHints renderHints = new RenderingHints( |
83 |
RenderingHints.KEY_ANTIALIASING,
|
84 |
RenderingHints.VALUE_ANTIALIAS_ON);
|
85 |
renderHints.put(RenderingHints.KEY_RENDERING,
|
86 |
RenderingHints.VALUE_RENDER_QUALITY);
|
87 |
renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
|
88 |
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
89 |
g.setRenderingHints(renderHints); |
90 |
|
91 |
} |
92 |
|
93 |
public void setRenderingHintsForPrinting(Graphics2D g) { |
94 |
|
95 |
RenderingHints renderHints = new RenderingHints( |
96 |
RenderingHints.KEY_ANTIALIASING,
|
97 |
RenderingHints.VALUE_ANTIALIAS_ON);
|
98 |
renderHints.put(RenderingHints.KEY_RENDERING,
|
99 |
RenderingHints.VALUE_RENDER_QUALITY);
|
100 |
g.setRenderingHints(renderHints); |
101 |
|
102 |
} |
103 |
|
104 |
} |