Revision 39161
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/lang/StringUtilsTestParent.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 {{Company}} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.lang; |
|
28 |
|
|
29 |
import java.util.Arrays; |
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import junit.framework.TestCase; |
|
33 |
|
|
34 |
/** |
|
35 |
* Parent class for Unit tests for {@link org.gvsig.compat.lang.StringUtils} |
|
36 |
* implementations. |
|
37 |
* |
|
38 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
39 |
*/ |
|
40 |
public abstract class StringUtilsTestParent extends TestCase { |
|
41 |
|
|
42 |
private StringUtils utils; |
|
43 |
|
|
44 |
protected void setUp() throws Exception { |
|
45 |
super.setUp(); |
|
46 |
utils = createUtils(); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Return a new instance of an implementation of the StringUtils interface. |
|
51 |
* |
|
52 |
* @return a new StringUtils instance |
|
53 |
*/ |
|
54 |
protected abstract StringUtils createUtils(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Test method for |
|
58 |
* {@link org.gvsig.compat.se.lang.StandardStringUtils#split(java.lang.String, java.lang.String)} |
|
59 |
* . |
|
60 |
*/ |
|
61 |
public void testSplitString() { |
|
62 |
// Check the result is the same as the returned with the String.split |
|
63 |
// method. |
|
64 |
List list1; |
|
65 |
List list2; |
|
66 |
|
|
67 |
String testString = "En un lugar de la Mancha"; |
|
68 |
String regex = " "; |
|
69 |
|
|
70 |
list1 = Arrays.asList(new String[] { "En", "un", "lugar", "de", "la", |
|
71 |
"Mancha" }); |
|
72 |
|
|
73 |
list2 = Arrays.asList(utils.split(testString, regex)); |
|
74 |
|
|
75 |
assertEquals(list1, list2); |
|
76 |
|
|
77 |
list1 = Arrays.asList(new String[] { "En", "un lugar de la Mancha" }); |
|
78 |
|
|
79 |
list2 = Arrays.asList(utils.split(testString, regex, 2)); |
|
80 |
|
|
81 |
assertEquals(list1, list2); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Test method for |
|
86 |
* {@link org.gvsig.compat.se.lang.StandardStringUtils#replaceAll(java.lang.String, java.lang.String, java.lang.String)} |
|
87 |
* . |
|
88 |
*/ |
|
89 |
public void testReplaceAll() { |
|
90 |
// Check the result is the same as the returned with the |
|
91 |
// String.replaceAll method. |
|
92 |
String testString = "En un lugar de la Mancha"; |
|
93 |
String regex = " "; |
|
94 |
String replacement = "_"; |
|
95 |
|
|
96 |
assertEquals("En_un_lugar_de_la_Mancha", |
|
97 |
utils.replaceAll(testString, regex, replacement)); |
|
98 |
|
|
99 |
// Check replaceFirst |
|
100 |
assertEquals("En_un lugar de la Mancha", |
|
101 |
utils.replaceFirst(testString, regex, replacement)); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Test method for |
|
106 |
* {@link org.gvsig.compat.se.lang.StandardStringUtils#compare(String, String, boolean)} |
|
107 |
* . |
|
108 |
*/ |
|
109 |
public void testCompare() { |
|
110 |
String avion = "Avi?n"; |
|
111 |
String avionaccent = "Avion"; |
|
112 |
String barco = "Barco"; |
|
113 |
|
|
114 |
// Same value |
|
115 |
assertEquals(avion + " is not equal to " + avion, 0, |
|
116 |
utils.compare(avion, avion, false)); |
|
117 |
assertEquals(avion + " is not equal to " + avion, 0, |
|
118 |
utils.compare(avion, avion, true)); |
|
119 |
|
|
120 |
// Non localized comparison |
|
121 |
assertTrue(utils.compare(avion, barco, false) < 0); |
|
122 |
assertTrue(utils.compare(avion, avionaccent, false) > 0); |
|
123 |
assertTrue(utils.compare(barco, avion, false) > 0); |
|
124 |
assertTrue(utils.compare(avionaccent, avion, false) < 0); |
|
125 |
|
|
126 |
// Localized comparison, so accents must not be taken into account |
|
127 |
assertTrue(utils.compare(avion, barco, true) < 0); |
|
128 |
assertEquals(0, utils.compare(avion, avionaccent, true)); |
|
129 |
assertTrue(utils.compare(barco, avion, true) > 0); |
|
130 |
assertEquals(0, utils.compare(avionaccent, avion, true)); |
|
131 |
} |
|
132 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/lang/MathUtilsTestParent.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 PRODEVELOP S.L. Main Development |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.lang; |
|
28 |
|
|
29 |
import junit.framework.TestCase; |
|
30 |
|
|
31 |
/** |
|
32 |
* Parent class for Unit tests for {@link org.gvsig.compat.lang.MathUtils} |
|
33 |
* implementations. |
|
34 |
* |
|
35 |
* @author <a href="mailto:jcarrasco@prodevelop.es">Javier Carrasco</a> |
|
36 |
*/ |
|
37 |
public abstract class MathUtilsTestParent extends TestCase{ |
|
38 |
|
|
39 |
private MathUtils utils; |
|
40 |
|
|
41 |
protected void setUp() throws Exception { |
|
42 |
super.setUp(); |
|
43 |
utils = createUtils(); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Return a new instance of an implementation of the MathUtils interface. |
|
48 |
* |
|
49 |
* @return a new MathUtils instance |
|
50 |
*/ |
|
51 |
protected abstract MathUtils createUtils(); |
|
52 |
|
|
53 |
/** |
|
54 |
* Test method for |
|
55 |
* {@link org.gvsig.compat.se.lang.MathUtils#log10(double)} |
|
56 |
* . |
|
57 |
*/ |
|
58 |
public void testLog10() { |
|
59 |
assertEquals(utils.log10(1000),3.0,0.00000000001); |
|
60 |
} |
|
61 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/se/SECompatLibraryTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 {DiSiD Technologies} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se; |
|
28 |
|
|
29 |
import junit.framework.TestCase; |
|
30 |
|
|
31 |
import org.gvsig.compat.CompatLocator; |
|
32 |
import org.gvsig.compat.se.lang.StandardStringUtils; |
|
33 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
34 |
|
|
35 |
/** |
|
36 |
* Unit tests for the {@link SECompatLibrary} class. |
|
37 |
* |
|
38 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
39 |
*/ |
|
40 |
public class SECompatLibraryTest extends TestCase { |
|
41 |
|
|
42 |
/** |
|
43 |
* Test method for {@link org.gvsig.compat.se.SECompatLibrary#initialize()}. |
|
44 |
*/ |
|
45 |
public void testInitialize() { |
|
46 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
47 |
|
|
48 |
// Check if the correct implementation is returned |
|
49 |
assertEquals(StandardStringUtils.class, CompatLocator.getStringUtils() |
|
50 |
.getClass()); |
|
51 |
} |
|
52 |
|
|
53 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/se/lang/StandardStringUtilsTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 {{Company}} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se.lang; |
|
28 |
|
|
29 |
import org.gvsig.compat.lang.StringUtils; |
|
30 |
import org.gvsig.compat.lang.StringUtilsTestParent; |
|
31 |
|
|
32 |
/** |
|
33 |
* Unit tests for the {@link org.gvsig.compat.se.lang.StandardStringUtils} |
|
34 |
* class. |
|
35 |
* |
|
36 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
37 |
*/ |
|
38 |
public class StandardStringUtilsTest extends StringUtilsTestParent { |
|
39 |
|
|
40 |
protected StringUtils createUtils() { |
|
41 |
return new StandardStringUtils(); |
|
42 |
} |
|
43 |
|
|
44 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/se/lang/SEMathUtilsTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 PRODEVELOP S.L. Main Development |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se.lang; |
|
28 |
|
|
29 |
import org.gvsig.compat.lang.MathUtils; |
|
30 |
import org.gvsig.compat.lang.MathUtilsTestParent; |
|
31 |
|
|
32 |
public class SEMathUtilsTest extends MathUtilsTestParent{ |
|
33 |
|
|
34 |
protected MathUtils createUtils() { |
|
35 |
return new SEMathUtils(); |
|
36 |
} |
|
37 |
|
|
38 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src-test/org/gvsig/compat/CompatLibraryTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 {DiSiD Technologies} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.compat; |
|
28 |
|
|
29 |
import junit.framework.TestCase; |
|
30 |
|
|
31 |
import org.gvsig.tools.library.Library; |
|
32 |
|
|
33 |
/** |
|
34 |
* Unit tests for the {@link CompatLibrary} class. |
|
35 |
* |
|
36 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
37 |
*/ |
|
38 |
public class CompatLibraryTest extends TestCase { |
|
39 |
|
|
40 |
/** |
|
41 |
* Test method for {@link org.gvsig.compat.se.SECompatLibrary#initialize()}. |
|
42 |
*/ |
|
43 |
public void testInitialize() { |
|
44 |
Library api = new CompatLibrary(); |
|
45 |
|
|
46 |
// 1: Initialize the Library |
|
47 |
api.initialize(); |
|
48 |
|
|
49 |
// 2: postInitialize them |
|
50 |
// as we don't initialize an implementation library, |
|
51 |
// the postInitialization must throw an Exception |
|
52 |
try { |
|
53 |
api.postInitialize(); |
|
54 |
fail("Library postInitialization is not checking " |
|
55 |
+ "for implementation availability"); |
|
56 |
} catch (Exception ex) { |
|
57 |
// Good |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/resources-test/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
5 |
|
|
6 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
7 |
<layout class="org.apache.log4j.PatternLayout"> |
|
8 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
9 |
</layout> |
|
10 |
</appender> |
|
11 |
|
|
12 |
<category name="org.gvsig.tools"> |
|
13 |
<priority value="DEBUG" /> |
|
14 |
</category> |
|
15 |
<category name="org.gvsig.compat"> |
|
16 |
<priority value="DEBUG" /> |
|
17 |
</category> |
|
18 |
|
|
19 |
<root> |
|
20 |
<priority value="INFO" /> |
|
21 |
<appender-ref ref="CONSOLE" /> |
|
22 |
</root> |
|
23 |
</log4j:configuration> |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/lang/GraphicsUtils.java | ||
---|---|---|
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 |
} |
|
0 | 84 |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/lang/StringUtils.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 DiSiD Technologies Extract interface for the StringUtils utility |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.lang; |
|
28 |
|
|
29 |
/** |
|
30 |
* String Utilities used for Java SE-ME compatibility. |
|
31 |
* |
|
32 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
33 |
*/ |
|
34 |
public interface StringUtils { |
|
35 |
|
|
36 |
/** |
|
37 |
* Compatible implementation of the String.split(regexp) method. |
|
38 |
* @see String#split(String) |
|
39 |
*/ |
|
40 |
String[] split(String input, String regex); |
|
41 |
|
|
42 |
/** |
|
43 |
* Compatible implementation of the String.split(regexp, limit) method. |
|
44 |
* @see String#split(String, int) |
|
45 |
*/ |
|
46 |
String[] split(String input, String regex, int limit); |
|
47 |
|
|
48 |
/** |
|
49 |
* Compatible implementation of the String.replaceAll(regexp, replacement) |
|
50 |
* method. |
|
51 |
* |
|
52 |
* @see String#replaceAll(String, String) |
|
53 |
*/ |
|
54 |
String replaceAll(String input, String regex, |
|
55 |
String replacement); |
|
56 |
|
|
57 |
/** |
|
58 |
* Compatible implementation of the String.replaceFirst(regexp, replacement) |
|
59 |
* method. |
|
60 |
* |
|
61 |
* @see String#replaceFirst(String, String) |
|
62 |
*/ |
|
63 |
String replaceFirst(String input, String regex, |
|
64 |
String replacement); |
|
65 |
|
|
66 |
/** |
|
67 |
* Compares two Strings, maybe taking into account the current locale. |
|
68 |
* |
|
69 |
* @param source |
|
70 |
* the source text |
|
71 |
* @param target |
|
72 |
* the target text to compare to |
|
73 |
* @param localized |
|
74 |
* if the comparison must be made with the current locale (ex: if |
|
75 |
* making a difference between accented characters or not). |
|
76 |
* @return Returns an integer value. Value is less than zero if source is |
|
77 |
* less than target, value is zero if source and target are equal, |
|
78 |
* value is greater than zero if source is greater than target. |
|
79 |
*/ |
|
80 |
int compare(String source, String target, boolean localized); |
|
81 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/lang/MathUtils.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 PRODEVELOP S.L. Main Development |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.lang; |
|
28 |
|
|
29 |
/** |
|
30 |
* Math Utilities used for Java SE-ME compatibility. |
|
31 |
* |
|
32 |
* @author <a href="mailto:jcarrasco@prodevelop.es">Javier Carrasco</a> |
|
33 |
*/ |
|
34 |
public interface MathUtils { |
|
35 |
/** |
|
36 |
* Compatible implementation of the Math.log10(double) method. |
|
37 |
* @see Math#log10(double) |
|
38 |
*/ |
|
39 |
double log10(double value); |
|
40 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/net/Downloader.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.compat.net; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.net.ConnectException; |
|
27 |
import java.net.URL; |
|
28 |
import java.net.UnknownHostException; |
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author gvSIG Team |
|
34 |
* @version $Id$ |
|
35 |
* |
|
36 |
*/ |
|
37 |
public interface Downloader { |
|
38 |
/** |
|
39 |
* Downloads an URL into a temporary file that is removed the next time the |
|
40 |
* tempFileManager class is called, which means the next time gvSIG is launched. |
|
41 |
* |
|
42 |
* @param url |
|
43 |
* @param name |
|
44 |
* @return |
|
45 |
* @throws IOException |
|
46 |
* @throws ServerErrorResponseException |
|
47 |
* @throws ConnectException |
|
48 |
* @throws UnknownHostException |
|
49 |
*/ |
|
50 |
public File downloadFile(URL url, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException; |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* Downloads a URL using the HTTP Post protocol |
|
55 |
* @param url |
|
56 |
* The server URL |
|
57 |
* @param data |
|
58 |
* The data to send in the request |
|
59 |
* @param name |
|
60 |
* A common name for all the retrieved files |
|
61 |
* @param cancel |
|
62 |
* Used to cancel the downloads |
|
63 |
* @return |
|
64 |
* The retrieved file |
|
65 |
* @throws IOException |
|
66 |
* @throws ConnectException |
|
67 |
* @throws UnknownHostException |
|
68 |
*/ |
|
69 |
public File downloadFile(URL url, String data, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException; |
|
70 |
|
|
71 |
public void removeURL(URL url); |
|
72 |
|
|
73 |
public void removeURL(Object url); |
|
74 |
|
|
75 |
/** |
|
76 |
* Cleans every temporal file previously downloaded. |
|
77 |
*/ |
|
78 |
public void cleanUpTempFiles(); |
|
79 |
|
|
80 |
|
|
81 |
} |
|
0 | 82 |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/net/ICancellable.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: ICancellable.java 29658 2009-06-29 17:10:19Z jpiera $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-05-24 16:37:34 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package org.gvsig.compat.net; |
|
52 |
|
|
53 |
/** |
|
54 |
* <p>When a task is accessing to remote data, takes an indeterminate time, and occasionally gets locked. That's |
|
55 |
* the reason a task should support to be cancelable.</p> |
|
56 |
* <p><code>ICancellable</code> interface is designed for getting information about the cancellation of a |
|
57 |
* task of downloading remote information.</p> |
|
58 |
*/ |
|
59 |
public interface ICancellable { |
|
60 |
/** |
|
61 |
* <p>Returns <code>true</code> if a download or a group of downloads tasks has been canceled.</p> |
|
62 |
* |
|
63 |
* @return <code>true</code> if a download or a group of downloads tasks has been canceled, otherwise <code>false</code> |
|
64 |
*/ |
|
65 |
public boolean isCanceled(); |
|
66 |
|
|
67 |
/** |
|
68 |
* <p>Used to cancel only a group of downloads tasks with the same identifier.</p> |
|
69 |
* |
|
70 |
* @return the identifier |
|
71 |
*/ |
|
72 |
public Object getID(); |
|
73 |
} |
|
0 | 74 |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/CompatLocator.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 DiSiD Technologies Create initial base implementation |
|
26 |
*/ |
|
27 |
package org.gvsig.compat; |
|
28 |
|
|
29 |
import org.gvsig.compat.lang.GraphicsUtils; |
|
30 |
import org.gvsig.compat.lang.MathUtils; |
|
31 |
import org.gvsig.compat.lang.StringUtils; |
|
32 |
import org.gvsig.compat.net.Downloader; |
|
33 |
import org.gvsig.tools.locator.BaseLocator; |
|
34 |
import org.gvsig.tools.locator.Locator; |
|
35 |
import org.gvsig.tools.locator.LocatorException; |
|
36 |
|
|
37 |
/** |
|
38 |
* Locator for the libCompat Library. Returns references to the library's main |
|
39 |
* utilities. |
|
40 |
* |
|
41 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
42 |
*/ |
|
43 |
public class CompatLocator extends BaseLocator { |
|
44 |
|
|
45 |
/** |
|
46 |
* The name of the StringUtils reference. |
|
47 |
*/ |
|
48 |
public static final String STRINGUTILS_NAME = "StringUtils"; |
|
49 |
|
|
50 |
/** |
|
51 |
* The name of the MathUtils reference. |
|
52 |
*/ |
|
53 |
public static final String MATHUTILS_NAME = "MathUtils"; |
|
54 |
public static final String GRAPHICSUTILS_NAME = "GraphicsUtils"; |
|
55 |
|
|
56 |
/** |
|
57 |
* The description of the StringUtils reference. |
|
58 |
*/ |
|
59 |
private static final String STRINGUTILS_DESCRIPTION = "Compatible implementation for String Utilities"; |
|
60 |
|
|
61 |
/** |
|
62 |
* The description of the MathUtils reference. |
|
63 |
*/ |
|
64 |
private static final String MATHUTILS_DESCRIPTION = "Compatible implementation for Math Utilities"; |
|
65 |
private static final String GRAPHICSUTILS_DESCRIPTION = "Compatible implementation for Graphics Utilities"; |
|
66 |
|
|
67 |
/** |
|
68 |
* The name and the description for the {@link Downloader} reference. |
|
69 |
*/ |
|
70 |
public static final String DOWNLOADER_NAME = "Downloader"; |
|
71 |
public static final String DOWNLOADER_DESCRIPTION = "Downloader descripction"; |
|
72 |
|
|
73 |
/** |
|
74 |
* Unique instance. |
|
75 |
*/ |
|
76 |
private static final CompatLocator instance = new CompatLocator(); |
|
77 |
|
|
78 |
/** |
|
79 |
* Return the singleton instance. |
|
80 |
* |
|
81 |
* @return the singleton instance |
|
82 |
*/ |
|
83 |
public static CompatLocator getInstance() { |
|
84 |
return instance; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Return a reference to StringUtils. |
|
89 |
* |
|
90 |
* @return a reference to StringUtils |
|
91 |
* @throws LocatorException |
|
92 |
* if there is no access to the class or the class cannot be |
|
93 |
* instantiated |
|
94 |
* @see Locator#get(String) |
|
95 |
*/ |
|
96 |
public static StringUtils getStringUtils() throws LocatorException { |
|
97 |
return (StringUtils) getInstance().get(STRINGUTILS_NAME); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Return a reference to MathUtils. |
|
102 |
* |
|
103 |
* @return a reference to MathUtils |
|
104 |
* @throws LocatorException |
|
105 |
* if there is no access to the class or the class cannot be |
|
106 |
* instantiated |
|
107 |
* @see Locator#get(String) |
|
108 |
*/ |
|
109 |
public static MathUtils getMathUtils() throws LocatorException { |
|
110 |
return (MathUtils) getInstance().get(MATHUTILS_NAME); |
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
/** |
|
115 |
* Registers the Class implementing the MathUtils interface. |
|
116 |
* |
|
117 |
* @param clazz |
|
118 |
* implementing the MathUtils interface |
|
119 |
*/ |
|
120 |
public static void registerMathUtils(Class clazz) { |
|
121 |
getInstance() |
|
122 |
.register(MATHUTILS_NAME, MATHUTILS_DESCRIPTION, clazz); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Registers the Class implementing the StringUtils interface. |
|
127 |
* |
|
128 |
* @param clazz |
|
129 |
* implementing the StringUtils interface |
|
130 |
*/ |
|
131 |
public static void registerStringUtils(Class clazz) { |
|
132 |
getInstance() |
|
133 |
.register(STRINGUTILS_NAME, STRINGUTILS_DESCRIPTION, clazz); |
|
134 |
} |
|
135 |
|
|
136 |
// ============================================================ |
|
137 |
// ============================================================ |
|
138 |
// ============================================================ |
|
139 |
|
|
140 |
/** |
|
141 |
* Return a reference to GraphicsUtils. |
|
142 |
* |
|
143 |
* @return a reference to GraphicsUtils |
|
144 |
* @throws LocatorException |
|
145 |
* if there is no access to the class or the class cannot be |
|
146 |
* instantiated |
|
147 |
* @see Locator#get(String) |
|
148 |
*/ |
|
149 |
public static GraphicsUtils getGraphicsUtils() throws LocatorException { |
|
150 |
return (GraphicsUtils) getInstance().get(GRAPHICSUTILS_NAME); |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
/** |
|
155 |
* Registers the Class implementing the GraphicsUtils interface. |
|
156 |
* |
|
157 |
* @param clazz |
|
158 |
* implementing the GraphicsUtils interface |
|
159 |
*/ |
|
160 |
public static void registerGraphicsUtils(Class clazz) { |
|
161 |
getInstance() |
|
162 |
.register(GRAPHICSUTILS_NAME, GRAPHICSUTILS_DESCRIPTION, clazz); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Return a reference to GraphicsUtils. |
|
167 |
* |
|
168 |
* @return a reference to GraphicsUtils |
|
169 |
* @throws LocatorException |
|
170 |
* if there is no access to the class or the class cannot be |
|
171 |
* instantiated |
|
172 |
* @see Locator#get(String) |
|
173 |
*/ |
|
174 |
public static Downloader getDownloader() throws LocatorException { |
|
175 |
return (Downloader) getInstance().get(DOWNLOADER_NAME); |
|
176 |
} |
|
177 |
|
|
178 |
|
|
179 |
/** |
|
180 |
* Registers the Class implementing the GraphicsUtils interface. |
|
181 |
* |
|
182 |
* @param clazz |
|
183 |
* implementing the GraphicsUtils interface |
|
184 |
*/ |
|
185 |
public static void registerDownloader(Class clazz) { |
|
186 |
getInstance() |
|
187 |
.register(DOWNLOADER_NAME, DOWNLOADER_DESCRIPTION, clazz); |
|
188 |
} |
|
189 |
|
|
190 |
|
|
191 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/print/SePrintAttributes.java | ||
---|---|---|
1 |
package org.gvsig.compat.se.print; |
|
2 |
|
|
3 |
import org.gvsig.compat.print.PrintAttributes; |
|
4 |
|
|
5 |
/** |
|
6 |
* JSE (Desktop Java) implementation of {@link PrintAttributes} |
|
7 |
* |
|
8 |
* @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es |
|
9 |
* |
|
10 |
* @see PrintAttributes |
|
11 |
* |
|
12 |
*/ |
|
13 |
public class SePrintAttributes implements PrintAttributes{ |
|
14 |
|
|
15 |
int pq = 0; |
|
16 |
|
|
17 |
public int getPrintQuality() { |
|
18 |
return pq; |
|
19 |
} |
|
20 |
|
|
21 |
public void setPrintQuality(int pq) { |
|
22 |
this.pq=pq; |
|
23 |
|
|
24 |
} |
|
25 |
|
|
26 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/SECompatLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 DiSiD Technologies Create initial base implementation |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se; |
|
28 |
|
|
29 |
import org.gvsig.compat.CompatLibrary; |
|
30 |
import org.gvsig.compat.CompatLocator; |
|
31 |
import org.gvsig.compat.se.lang.SEGraphUtils; |
|
32 |
import org.gvsig.compat.se.lang.SEMathUtils; |
|
33 |
import org.gvsig.compat.se.lang.StandardStringUtils; |
|
34 |
import org.gvsig.compat.se.net.SEDownloader; |
|
35 |
import org.gvsig.tools.library.AbstractLibrary; |
|
36 |
import org.gvsig.tools.library.LibraryException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Initialization of the libCompat library, Java Standard Edition |
|
40 |
* implementation. |
|
41 |
* |
|
42 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
43 |
*/ |
|
44 |
public class SECompatLibrary extends AbstractLibrary { |
|
45 |
|
|
46 |
public void doRegistration() { |
|
47 |
registerAsImplementationOf(CompatLibrary.class); |
|
48 |
} |
|
49 |
|
|
50 |
protected void doInitialize() throws LibraryException { |
|
51 |
CompatLocator.registerStringUtils(StandardStringUtils.class); |
|
52 |
CompatLocator.registerMathUtils(SEMathUtils.class); |
|
53 |
CompatLocator.registerGraphicsUtils(SEGraphUtils.class); |
|
54 |
CompatLocator.registerDownloader(SEDownloader.class); |
|
55 |
} |
|
56 |
|
|
57 |
protected void doPostInitialize() throws LibraryException { |
|
58 |
} |
|
59 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/lang/SEMathUtils.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 PRODEVELOP S.L. Main Development |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se.lang; |
|
28 |
|
|
29 |
import org.gvsig.compat.lang.MathUtils; |
|
30 |
|
|
31 |
/** |
|
32 |
* JSE (Desktop Java) implementation of {@link MathUtils} |
|
33 |
* |
|
34 |
* @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es |
|
35 |
* |
|
36 |
* @see MathUtils |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class SEMathUtils implements MathUtils{ |
|
40 |
|
|
41 |
public double log10(double value) { |
|
42 |
return Math.log10(value); |
|
43 |
} |
|
44 |
|
|
45 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/lang/StandardStringUtils.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 DiSiD Technologies Create initial implementation of StringUtils for Java SE. |
|
26 |
*/ |
|
27 |
package org.gvsig.compat.se.lang; |
|
28 |
|
|
29 |
import java.text.Collator; |
|
30 |
|
|
31 |
import org.gvsig.compat.lang.StringUtils; |
|
32 |
|
|
33 |
/** |
|
34 |
* String utilities implementation for Java Standard Edition. |
|
35 |
* |
|
36 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
37 |
*/ |
|
38 |
public class StandardStringUtils implements StringUtils { |
|
39 |
|
|
40 |
public String[] split(String input, String regex) { |
|
41 |
return input == null ? null : input.split(regex); |
|
42 |
} |
|
43 |
|
|
44 |
public String[] split(String input, String regex, int limit) { |
|
45 |
return input == null ? null : input.split(regex, limit); |
|
46 |
} |
|
47 |
|
|
48 |
public String replaceAll(String input, String regex, String replacement) { |
|
49 |
return input == null ? null : input.replaceAll(regex, replacement); |
|
50 |
} |
|
51 |
|
|
52 |
public String replaceFirst(String input, String regex, String replacement) { |
|
53 |
return input == null ? null : input.replaceFirst(regex, replacement); |
|
54 |
} |
|
55 |
|
|
56 |
public int compare(String source, String target, boolean localized) { |
|
57 |
if (localized) { |
|
58 |
Collator collator = Collator.getInstance(); |
|
59 |
collator.setStrength(Collator.PRIMARY); |
|
60 |
return collator.compare(source, target); |
|
61 |
} else { |
|
62 |
return source.compareTo(target); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/lang/SEGraphUtils.java | ||
---|---|---|
1 |
package org.gvsig.compat.se.lang; |
|
2 |
|
|
3 |
import java.awt.Font; |
|
4 |
import java.awt.Graphics2D; |
|
5 |
import java.awt.RenderingHints; |
|
6 |
import java.awt.Toolkit; |
|
7 |
import java.awt.image.BufferedImage; |
|
8 |
import java.awt.image.WritableRaster; |
|
9 |
import java.util.prefs.Preferences; |
|
10 |
|
|
11 |
import org.gvsig.compat.lang.GraphicsUtils; |
|
12 |
import org.gvsig.compat.print.PrintAttributes; |
|
13 |
import org.gvsig.compat.se.print.SePrintAttributes; |
|
14 |
|
|
15 |
/** |
|
16 |
* JSE (Desktop Java) implementation of {@link GraphicsUtils} |
|
17 |
* |
|
18 |
* @author Juan Lucas Dominguez Rubio jldominguez at prodevelop.es |
|
19 |
* |
|
20 |
* @see GraphicsUtils |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class SEGraphUtils implements GraphicsUtils{ |
|
24 |
|
|
25 |
public BufferedImage copyBufferedImage(BufferedImage img) { |
|
26 |
|
|
27 |
BufferedImage image = new BufferedImage(img.getWidth(), img.getHeight(), img.getType()); |
|
28 |
WritableRaster w = image.getRaster(); |
|
29 |
img.copyData(w); |
|
30 |
return image; |
|
31 |
} |
|
32 |
|
|
33 |
public BufferedImage createBufferedImage(int w, int h, int type) { |
|
34 |
BufferedImage res = new BufferedImage( |
|
35 |
w, |
|
36 |
h, |
|
37 |
type); |
|
38 |
return res; |
|
39 |
} |
|
40 |
|
|
41 |
public PrintAttributes createPrintAttributes() { |
|
42 |
return new SePrintAttributes(); |
|
43 |
} |
|
44 |
|
|
45 |
public Font deriveFont(Font srcfont, float newheight) { |
|
46 |
return srcfont.deriveFont(newheight); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Tries to use DPI value from gvSIG preferences. If this does not exist, gets |
|
51 |
* value from Java Toolkit. |
|
52 |
*/ |
|
53 |
public int getScreenDPI() { |
|
54 |
|
|
55 |
Preferences prefsResolution = Preferences.userRoot().node("gvsig.configuration.screen"); |
|
56 |
Toolkit kit = Toolkit.getDefaultToolkit(); |
|
57 |
int dpi = prefsResolution.getInt("dpi", kit.getScreenResolution()); |
|
58 |
return dpi; |
|
59 |
} |
|
60 |
|
|
61 |
public void translate(Graphics2D g, double x, double y) { |
|
62 |
g.translate(x, y); |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
public void setRenderingHintsForDrawing(Graphics2D g) { |
|
67 |
|
|
68 |
RenderingHints renderHints = new RenderingHints( |
|
69 |
RenderingHints.KEY_ANTIALIASING, |
|
70 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
71 |
renderHints.put(RenderingHints.KEY_RENDERING, |
|
72 |
RenderingHints.VALUE_RENDER_QUALITY); |
|
73 |
renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, |
|
74 |
RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
|
75 |
g.setRenderingHints(renderHints); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
public void setRenderingHintsForPrinting(Graphics2D g) { |
|
80 |
|
|
81 |
RenderingHints renderHints = new RenderingHints( |
|
82 |
RenderingHints.KEY_ANTIALIASING, |
|
83 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
84 |
renderHints.put(RenderingHints.KEY_RENDERING, |
|
85 |
RenderingHints.VALUE_RENDER_QUALITY); |
|
86 |
g.setRenderingHints(renderHints); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
} |
tags/v2_0_0_Build_2057/libraries/libCompat/src/org/gvsig/compat/se/net/SEDownloader.java | ||
---|---|---|
1 |
package org.gvsig.compat.se.net; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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 2 |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
|
|
43 |
import java.io.BufferedOutputStream; |
|
44 |
import java.io.DataInputStream; |
|
45 |
import java.io.DataOutputStream; |
|
46 |
import java.io.File; |
|
47 |
import java.io.FileNotFoundException; |
|
48 |
import java.io.FileOutputStream; |
|
49 |
import java.io.IOException; |
|
50 |
import java.io.OutputStreamWriter; |
|
51 |
import java.net.ConnectException; |
|
52 |
import java.net.HttpURLConnection; |
|
53 |
import java.net.URL; |
|
54 |
import java.net.UnknownHostException; |
|
55 |
import java.security.KeyManagementException; |
|
56 |
import java.security.NoSuchAlgorithmException; |
|
57 |
import java.util.Hashtable; |
|
58 |
import java.util.prefs.Preferences; |
|
59 |
|
|
60 |
import javax.net.ssl.HttpsURLConnection; |
|
61 |
import javax.net.ssl.SSLContext; |
|
62 |
import javax.net.ssl.TrustManager; |
|
63 |
import javax.net.ssl.X509TrustManager; |
|
64 |
|
|
65 |
import org.slf4j.Logger; |
|
66 |
import org.slf4j.LoggerFactory; |
|
67 |
|
|
68 |
import org.gvsig.compat.net.ICancellable; |
|
69 |
|
|
70 |
|
|
71 |
/** |
|
72 |
* Clase con m?todos de utilidad en el protocolo WMS |
|
73 |
* |
|
74 |
* @authors Laura D?az, jaume dominguez faus |
|
75 |
*/ |
|
76 |
public class SEDownloader implements org.gvsig.compat.net.Downloader{ |
|
77 |
String characters; |
|
78 |
boolean canceled; |
|
79 |
final long latency = 500; |
|
80 |
private static int count = 0; |
|
81 |
private static Logger LOG = LoggerFactory.getLogger(SEDownloader.class); |
|
82 |
|
|
83 |
/** |
|
84 |
* Used to cancel a group of files |
|
85 |
* <b>key</b>: Group id, <b>value</b>: Boolean (true if |
|
86 |
* the group has to be canceled. Otherwise it is |
|
87 |
* false) |
|
88 |
*/ |
|
89 |
Hashtable canceledGroup = new Hashtable(); |
|
90 |
/** |
|
91 |
* <b>key</b>: URL, <b>value</b>: path to the downloaded file. |
|
92 |
*/ |
|
93 |
Hashtable downloadedFiles; |
|
94 |
Exception downloadException; |
|
95 |
final String tempDirectoryPath = System.getProperty("java.io.tmpdir")+"/tmp-andami"; |
|
96 |
|
|
97 |
public SEDownloader() { |
|
98 |
super(); |
|
99 |
characters = ""; |
|
100 |
for (int j = 32; j<=127; j++){ |
|
101 |
characters += (char) j; |
|
102 |
} |
|
103 |
characters += "?????????????????????????????????????????????????\n\r\f\t??"; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Return the content of a file that has been created |
|
108 |
* from a URL using the HTTP GET protocol |
|
109 |
* @param url |
|
110 |
* The URL |
|
111 |
* @return |
|
112 |
* File containing this URL's content or null if no file was found. |
|
113 |
*/ |
|
114 |
private File getPreviousDownloadedURL(URL url){ |
|
115 |
return getPreviousDownloaded(url); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Return the content of a file that has been created |
|
120 |
* from a URL using the HTTP POST protocol |
|
121 |
* @param url |
|
122 |
* The URL |
|
123 |
* @param data |
|
124 |
* The data to send on the query |
|
125 |
* @return |
|
126 |
* File containing this URL's content or null if no file was found. |
|
127 |
*/ |
|
128 |
private File getPreviousDownloadedURL(URL url, String data) { |
|
129 |
if(data == null) |
|
130 |
return getPreviousDownloaded(url); |
|
131 |
return getPreviousDownloaded(url + data); |
|
132 |
} |
Also available in: Unified diff