/** * Vector.java * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package org.expeditee.gui; import java.text.NumberFormat; import org.expeditee.core.Colour; import org.expeditee.core.Dimension; import org.expeditee.core.Point; import org.expeditee.items.Item; import org.expeditee.items.UserAppliedPermission; /** * TODO: Explain WTF this is. cts16 */ public class Vector extends Overlay { /** TODO: Comment. cts16 */ public Point Origin; /** TODO: Comment. cts16 */ public float Scale; /** TODO: Comment. cts16 */ public Colour Foreground; /** TODO: Comment. cts16 */ public Colour Background; /** TODO: Comment. cts16 */ public Item Source; /** TODO: Comment. cts16 */ public Dimension Size; /** TODO: Comment. cts16 */ public Vector(Frame overlay, UserAppliedPermission permission, Float scale, Item source) { super(overlay, permission); Origin = source.getPosition(); Scale = scale; Foreground = source.getColor(); Background = source.getBackgroundColor(); Source = source; } @Override public boolean equals(Object o) { if (o instanceof Vector) { Vector v = (Vector) o; return v.Frame == Frame && Origin.equals(v.Origin) && Scale == v.Scale && Foreground.equals(v.Foreground) && Background.equals(v.Background); } return false; } @Override public int hashCode() { return 0; } /** Converts the given x position to be relative to the overlay frame. */ public float getX(int x) { return (x - Origin.getY()) / Scale; } /** Converts the given y position to be relative to the overlay frame. */ public float getY(int y) { return (y - Origin.getY()) / Scale; } /** TODO: Comment. cts16 */ public void setSize(int maxX, int maxY) { Size = new Dimension(maxX, maxY); } /** TODO: Comment. cts16 */ public static NumberFormat getNumberFormatter() { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4); return nf; } }