svn-gvsig-desktop / trunk / extensions / extQuickInfo / src-test / org / gvsig / quickInfo / TestQuickInfoFLayerSelected.java @ 28223
History | View | Annotate | Download (2.99 KB)
1 | 27817 | ppiqueras | package org.gvsig.quickInfo; |
---|---|---|---|
2 | |||
3 | /* gvSIG. Geographic Information System of the Valencian Government
|
||
4 | *
|
||
5 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
6 | * of the Valencian Government (CIT)
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
21 | * MA 02110-1301, USA.
|
||
22 | *
|
||
23 | */
|
||
24 | |||
25 | import java.util.Arrays; |
||
26 | import java.util.HashMap; |
||
27 | import java.util.Vector; |
||
28 | |||
29 | import javax.swing.JOptionPane; |
||
30 | import javax.xml.transform.Result; |
||
31 | import javax.xml.transform.Source; |
||
32 | import javax.xml.transform.Transformer; |
||
33 | import javax.xml.transform.TransformerFactory; |
||
34 | import javax.xml.transform.dom.DOMSource; |
||
35 | import javax.xml.transform.stream.StreamResult; |
||
36 | |||
37 | import org.gvsig.quickInfo.i18n.Messages; |
||
38 | |||
39 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
40 | |||
41 | /**
|
||
42 | * <p>Tests the generation of an XML document of tool tip text according the style of the "quick information" tool.</p>
|
||
43 | *
|
||
44 | * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
||
45 | */
|
||
46 | public class TestQuickInfoFLayerSelected { |
||
47 | public static void main(String args[]) { |
||
48 | try {
|
||
49 | FLyrVect v = new FLyrVect();
|
||
50 | v.setName("CAPA VECTORIAL");
|
||
51 | |||
52 | QuickInfoFLayerSelected info = new QuickInfoFLayerSelected(v);
|
||
53 | HashMap lfields = info.getLayerFields();
|
||
54 | lfields.put("Campo1", new Vector(Arrays.asList(new String[]{"texto 1", "texto 4"}))); |
||
55 | lfields.put("Campo2", new Vector(Arrays.asList(new String[]{"texto 2", "texto 5"}))); |
||
56 | lfields.put("Campo3", new Vector(Arrays.asList(new String[]{"texto 3", "texto 6"}))); |
||
57 | info.setAnyLayerFieldAdded(true);
|
||
58 | |||
59 | HashMap clfields = info.getCalculatedLayerFields();
|
||
60 | clfields.put("CampoOp1", new Vector(Arrays.asList(new String[]{"texto 7", "texto 9"}))); |
||
61 | clfields.put("CampoOp2", new Vector(Arrays.asList(new String[]{"texto 8", "texto 10"}))); |
||
62 | info.getGeometryIDs().addAll(Arrays.asList(new GeometryIDInfo[]{new GeometryIDInfo("GID1"), new GeometryIDInfo("GID2")})); |
||
63 | info.setAnyCalculatedLayerFieldsAdded(true);
|
||
64 | |||
65 | TransformerFactory tranFactory = TransformerFactory.newInstance(); |
||
66 | Transformer aTransformer = tranFactory.newTransformer();
|
||
67 | |||
68 | Source src = new DOMSource(info.getToolTipStyledDocument()); |
||
69 | Result dest = new StreamResult(System.out); |
||
70 | aTransformer.transform(src, dest); |
||
71 | } catch(Exception e) { |
||
72 | e.printStackTrace(); |
||
73 | JOptionPane.showMessageDialog(null, Messages.getText("An_exception_happened"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
||
74 | } |
||
75 | } |
||
76 | } |