%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.portlets.layout.LayoutCoordinate |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.portlets.layout; |
|
18 | ||
19 | import java.io.Serializable; |
|
20 | ||
21 | /** |
|
22 | * |
|
23 | * Simple class that holds an x,y (column,row) coordinate. |
|
24 | * |
|
25 | * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a> |
|
26 | * |
|
27 | */ |
|
28 | public final class LayoutCoordinate implements Comparable, Serializable |
|
29 | { |
|
30 | private final int x; |
|
31 | private final int y; |
|
32 | ||
33 | public LayoutCoordinate(int x, class="keyword">int y) |
|
34 | 0 | { |
35 | 0 | this.x = x; |
36 | 0 | this.y = y; |
37 | 0 | } |
38 | ||
39 | /** |
|
40 | * @return the x axis (column) value of this coordinate. |
|
41 | */ |
|
42 | public int getX() |
|
43 | { |
|
44 | 0 | return x; |
45 | } |
|
46 | ||
47 | /** |
|
48 | * @return the y axis (row) value of this coordinate. |
|
49 | */ |
|
50 | public int getY() |
|
51 | { |
|
52 | 0 | return y; |
53 | } |
|
54 | ||
55 | /** |
|
56 | * Two LayoutCoordinates are equal if thier respective x and y values are equal. |
|
57 | */ |
|
58 | public boolean equals(Object obj) |
|
59 | { |
|
60 | 0 | if(obj instanceof LayoutCoordinate) |
61 | { |
|
62 | 0 | LayoutCoordinate coordinate = (LayoutCoordinate) obj; |
63 | 0 | return x == coordinate.x && y == coordinate.y; |
64 | } |
|
65 | else |
|
66 | { |
|
67 | 0 | return false; |
68 | } |
|
69 | } |
|
70 | ||
71 | public int hashCode() |
|
72 | { |
|
73 | 0 | return toString().hashCode(); |
74 | } |
|
75 | ||
76 | public String toString() |
|
77 | { |
|
78 | 0 | return x+","+y; |
79 | } |
|
80 | ||
81 | public int compareTo(Object obj) |
|
82 | { |
|
83 | 0 | LayoutCoordinate coordinate = (LayoutCoordinate) obj; |
84 | 0 | if(!coordinate.equals(this)) |
85 | { |
|
86 | 0 | if(y == coordinate.y) |
87 | { |
|
88 | 0 | return x > coordinate.x ? 1 : -1; |
89 | } |
|
90 | else |
|
91 | { |
|
92 | 0 | return y > coordinate.y ? 1 : -1; |
93 | } |
|
94 | ||
95 | } |
|
96 | else |
|
97 | { |
|
98 | 0 | return 0; |
99 | } |
|
100 | } |
|
101 | ||
102 | ||
103 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |