1 | /**
|
---|
2 | * Vector.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (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, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.gui;
|
---|
20 |
|
---|
21 | import java.text.NumberFormat;
|
---|
22 |
|
---|
23 | import org.expeditee.core.Colour;
|
---|
24 | import org.expeditee.core.Dimension;
|
---|
25 | import org.expeditee.core.Point;
|
---|
26 | import org.expeditee.items.Item;
|
---|
27 | import org.expeditee.items.UserAppliedPermission;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * TODO: Explain WTF this is. cts16
|
---|
31 | */
|
---|
32 | public class Vector extends Overlay {
|
---|
33 |
|
---|
34 | /** TODO: Comment. cts16 */
|
---|
35 | public Point Origin;
|
---|
36 |
|
---|
37 | /** TODO: Comment. cts16 */
|
---|
38 | public float Scale;
|
---|
39 |
|
---|
40 | /** TODO: Comment. cts16 */
|
---|
41 | public Colour Foreground;
|
---|
42 |
|
---|
43 | /** TODO: Comment. cts16 */
|
---|
44 | public Colour Background;
|
---|
45 |
|
---|
46 | /** TODO: Comment. cts16 */
|
---|
47 | public Item Source;
|
---|
48 |
|
---|
49 | /** TODO: Comment. cts16 */
|
---|
50 | public Dimension Size;
|
---|
51 |
|
---|
52 | /** TODO: Comment. cts16 */
|
---|
53 | public Vector(Frame overlay, UserAppliedPermission permission, Float scale, Item source)
|
---|
54 | {
|
---|
55 | super(overlay, permission);
|
---|
56 | Origin = source.getPosition();
|
---|
57 | Scale = scale;
|
---|
58 | Foreground = source.getColor();
|
---|
59 | Background = source.getBackgroundColor();
|
---|
60 | Source = source;
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public boolean equals(Object o)
|
---|
65 | {
|
---|
66 | if (o instanceof Vector) {
|
---|
67 | Vector v = (Vector) o;
|
---|
68 | return v.Frame == Frame &&
|
---|
69 | Origin.equals(v.Origin) &&
|
---|
70 | Scale == v.Scale &&
|
---|
71 | Foreground.equals(v.Foreground) &&
|
---|
72 | Background.equals(v.Background);
|
---|
73 | }
|
---|
74 |
|
---|
75 | return false;
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public int hashCode()
|
---|
81 | {
|
---|
82 | return 0;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /** Converts the given x position to be relative to the overlay frame. */
|
---|
86 | public float getX(int x)
|
---|
87 | {
|
---|
88 | return (x - Origin.getY()) / Scale;
|
---|
89 | }
|
---|
90 |
|
---|
91 | /** Converts the given y position to be relative to the overlay frame. */
|
---|
92 | public float getY(int y)
|
---|
93 | {
|
---|
94 | return (y - Origin.getY()) / Scale;
|
---|
95 | }
|
---|
96 |
|
---|
97 | /** TODO: Comment. cts16 */
|
---|
98 | public void setSize(int maxX, int maxY)
|
---|
99 | {
|
---|
100 | Size = new Dimension(maxX, maxY);
|
---|
101 | }
|
---|
102 |
|
---|
103 | /** TODO: Comment. cts16 */
|
---|
104 | public static NumberFormat getNumberFormatter()
|
---|
105 | {
|
---|
106 | NumberFormat nf = NumberFormat.getInstance();
|
---|
107 | nf.setMaximumFractionDigits(4);
|
---|
108 | return nf;
|
---|
109 | }
|
---|
110 | }
|
---|