1 | /************************************************************************************ |
---|
2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
3 | * All rights reserved. |
---|
4 | * Refer to LICENSE for terms and conditions of use. |
---|
5 | ***********************************************************************************/ |
---|
6 | package vnsim.vehicular.routePlan.selfRouted; |
---|
7 | |
---|
8 | |
---|
9 | import java.util.ArrayList; |
---|
10 | |
---|
11 | |
---|
12 | import java.io.Serializable; |
---|
13 | |
---|
14 | import vnsim.vehicular.simulator.RouteSegment; |
---|
15 | public class MajorRoadArea implements Serializable { |
---|
16 | |
---|
17 | /** <code>serialVersionUID</code> */ |
---|
18 | private static final long serialVersionUID = -5883719321862303634L; |
---|
19 | |
---|
20 | public String areaCodeString; |
---|
21 | |
---|
22 | public byte[] areaCodeByte; |
---|
23 | |
---|
24 | public ArrayList<RouteSegment> roads; |
---|
25 | |
---|
26 | public float[] color; |
---|
27 | |
---|
28 | public MajorRoadArea(AreaCode a) { |
---|
29 | this.areaCodeByte = new byte[a.code.length]; |
---|
30 | copyAreaCode(a.code, this.areaCodeByte); |
---|
31 | this.areaCodeString = new String(a.areaCodeToString()); |
---|
32 | this.roads = new ArrayList<RouteSegment>(); |
---|
33 | color = new float[3]; |
---|
34 | } |
---|
35 | |
---|
36 | public MajorRoadArea(MajorRoadArea a) { |
---|
37 | this.areaCodeByte = new byte[a.areaCodeByte.length]; |
---|
38 | copyAreaCode(a.areaCodeByte, this.areaCodeByte); |
---|
39 | this.areaCodeString = new String(a.areaCodeString); |
---|
40 | this.roads = new ArrayList<RouteSegment>(); |
---|
41 | color = a.color; |
---|
42 | } |
---|
43 | |
---|
44 | public void move(MajorRoadArea a) { |
---|
45 | copyAreaCode(a.areaCodeByte, this.areaCodeByte); |
---|
46 | this.areaCodeString = new String(a.areaCodeString); |
---|
47 | this.color = a.color; |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | public void constructArea() { |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | public void setColor(float c1, float c2, float c3) { |
---|
56 | this.color[0] = c1; |
---|
57 | this.color[1] = c2; |
---|
58 | this.color[2] = c3; |
---|
59 | } |
---|
60 | |
---|
61 | public void setStringValue() { |
---|
62 | this.areaCodeString = new String(); |
---|
63 | for (int i = 0; i < this.areaCodeByte.length; i++) { |
---|
64 | this.areaCodeString = this.areaCodeString + this.areaCodeByte[i] |
---|
65 | + " "; |
---|
66 | } |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | public boolean copyAreaCode(byte[] src, byte[] dest) { |
---|
71 | if (src == null || dest == null) { |
---|
72 | return false; |
---|
73 | } |
---|
74 | if (src.length != dest.length) { |
---|
75 | return false; |
---|
76 | } |
---|
77 | for (int i = 0; i < src.length; i++) { |
---|
78 | dest[i] = src[i]; |
---|
79 | } |
---|
80 | return true; |
---|
81 | } |
---|
82 | |
---|
83 | } |
---|