1
2
3
4
5
6
7
8
9
10 package nl.javel.gisbeans.map;
11
12 /***
13 * An attribute.
14 * <p>
15 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
16 * University of Technology </a>, the Netherlands. <br>
17 * See for project information <a
18 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
19 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
20 * License (GPL) </a>, no warranty <br>
21 *
22 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
23 * Jacobs </a>
24 * @version 1.2 Jun 22, 2004
25 * @since 1.4
26 */
27 public class Attribute extends AbstractAttribute
28 {
29 /*** RADIANS */
30 public static final short RADIANS = 0;
31
32 /*** DEGREES */
33 public static final short DEGREES = 1;
34
35 /*** the angleColumn */
36 private int angleColumn = 0;
37
38 /*** the valueColumn */
39 private int valueColumn = 0;
40
41 /*** the mode of the angle */
42 private short mode = RADIANS;
43
44 /***
45 * constructs a new Attribute
46 *
47 * @param layer
48 * @param mode the mode (degrees or radians)
49 * @param angleColumn the angleColumn
50 * @param valueColumn the valueColumn
51 */
52 public Attribute(LayerInterface layer, short mode, int angleColumn,
53 int valueColumn)
54 {
55 super(layer);
56 this.angleColumn = angleColumn;
57 this.valueColumn = valueColumn;
58 }
59
60 /***
61 * @see nl.javel.gisbeans.map.AttributeInterface#getAngle(int)
62 */
63 public double getAngle(int shapeIndex)
64 {
65 if (this.angleColumn == -1)
66 {
67 return 0.0;
68 }
69 try
70 {
71 double angle = Double.parseDouble(super.layer.getDataSource()
72 .getAttributes()[shapeIndex][this.angleColumn]);
73 if (this.mode == DEGREES)
74 {
75 angle = Math.toRadians(angle);
76 }
77 return angle;
78 } catch (Exception exception)
79 {
80 exception.printStackTrace();
81 return 0.0;
82 }
83 }
84
85 /***
86 * @see nl.javel.gisbeans.map.AttributeInterface#getValue(int)
87 */
88 public String getValue(int shapeIndex)
89 {
90 try
91 {
92 return super.layer.getDataSource().getAttributes()[shapeIndex][this.valueColumn];
93 } catch (Exception exception)
94 {
95 exception.printStackTrace();
96 return "";
97 }
98 }
99 }