root / trunk / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / NetworkUtils.java @ 8648
History | View | Annotate | Download (3.12 KB)
1 | 8567 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | package com.iver.cit.gvsig.graph; |
||
42 | |||
43 | 8646 | fjp | import java.io.File; |
44 | |||
45 | 8567 | fjp | import com.iver.cit.gvsig.fmap.MapControl; |
46 | 8646 | fjp | import com.iver.cit.gvsig.fmap.layers.FLayer; |
47 | 8567 | fjp | import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
48 | import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
||
49 | 8616 | fjp | import com.iver.cit.gvsig.graph.core.GvFlag; |
50 | 8648 | azabala | import com.iver.cit.gvsig.util.GvSession; |
51 | 8567 | fjp | |
52 | public class NetworkUtils { |
||
53 | public static void clearBarriersFromGraphics(MapControl mc) { |
||
54 | GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
||
55 | for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
||
56 | FGraphic aux = graphics.getGraphic(i); |
||
57 | if (aux.getTag() != null) |
||
58 | if (aux.getTag().equalsIgnoreCase("BARRIER")) |
||
59 | 8616 | fjp | graphics.removeGraphic(aux); |
60 | 8567 | fjp | } |
61 | } |
||
62 | |||
63 | public static void clearFlagsFromGraphics(MapControl mc) { |
||
64 | GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
||
65 | for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
||
66 | FGraphic aux = graphics.getGraphic(i); |
||
67 | if (aux.getTag() != null) |
||
68 | if (aux.getTag().equalsIgnoreCase("FLAG")) |
||
69 | 8616 | fjp | graphics.removeGraphic(aux); |
70 | 8567 | fjp | } |
71 | } |
||
72 | |||
73 | 8616 | fjp | public static void clearFlagFromGraphics(MapControl mc, GvFlag flag) { |
74 | GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
||
75 | FGraphic graphic = graphics.getGraphicByObjectTag(flag); |
||
76 | graphics.removeGraphic(graphic); |
||
77 | } |
||
78 | |||
79 | 8567 | fjp | public static void clearRouteFromGraphics(MapControl mc) { |
80 | GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
||
81 | for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
||
82 | FGraphic aux = graphics.getGraphic(i); |
||
83 | if (aux.getTag() != null) |
||
84 | if (aux.getTag().equalsIgnoreCase("ROUTE")) |
||
85 | 8616 | fjp | graphics.removeGraphic(aux); |
86 | 8567 | fjp | } |
87 | 8648 | azabala | GvSession.getInstance().delete(mc, "Route");
|
88 | 8567 | fjp | } |
89 | 8646 | fjp | |
90 | public static File getNetworkFile(FLayer lyr) { |
||
91 | String directoryName = System.getProperty("java.io.tmpdir"); |
||
92 | String aux = lyr.getName().replaceAll("\\Q.shp\\E", ".net"); |
||
93 | File newFile = new File(directoryName + |
||
94 | File.separator +
|
||
95 | aux); |
||
96 | return newFile;
|
||
97 | |||
98 | } |
||
99 | 8567 | fjp | } |