/*
* (c) Copyright 2010-2011 AgileBirds
*
* This file is part of OpenFlexo.
*
* OpenFlexo 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.
*
* OpenFlexo 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 OpenFlexo. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.openflexo.fge.geom.area;
import java.awt.geom.AffineTransform;
import org.openflexo.fge.geom.FGEAbstractLine;
import org.openflexo.fge.geom.FGEGeometricObject.SimplifiedCardinalDirection;
import org.openflexo.fge.geom.FGEPoint;
import org.openflexo.fge.geom.FGERectangle;
import org.openflexo.fge.graphics.FGEGraphics;
public class FGEPlane implements FGEArea {
public FGEPlane() {
super();
}
@Override
public boolean containsPoint(FGEPoint p) {
return true;
}
@Override
public boolean containsArea(FGEArea a) {
return true;
}
@Override
public boolean containsLine(FGEAbstractLine l) {
return true;
}
@Override
public FGEArea exclusiveOr(FGEArea area) {
return new FGEEmptyArea();
}
@Override
public FGEArea intersect(FGEArea area) {
return area.clone();
}
@Override
public FGEArea substract(FGEArea area, boolean isStrict) {
return new FGESubstractionArea(this, area, isStrict);
}
@Override
public FGEArea union(FGEArea area) {
if (containsArea(area)) {
return clone();
}
if (area.containsArea(this)) {
return area.clone();
}
return clone();
}
/**
* Creates a new object of the same class and with the same contents as this object.
*
* @return a clone of this instance.
* @exception OutOfMemoryError
* if there is not enough memory.
* @see java.lang.Cloneable
* @since 1.2
*/
@Override
public FGEPlane clone() {
try {
return (FGEPlane) super.clone();
} catch (CloneNotSupportedException e) {
// cannot happen
e.printStackTrace();
return null;
}
}
@Override
public String toString() {
return "FGEPlane";
}
@Override
public FGEPlane transform(AffineTransform t) {
return clone();
}
@Override
public void paint(FGEGraphics g) {
// TODO
}
@Override
public FGEPoint getNearestPoint(FGEPoint aPoint) {
return aPoint.clone();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof FGEPlane) {
return true;
} else {
return super.equals(obj);
}
}
@Override
public FGEArea getOrthogonalPerspectiveArea(SimplifiedCardinalDirection orientation) {
return this;
}
@Override
public FGEArea getAnchorAreaFrom(SimplifiedCardinalDirection direction) {
return this;
}
/**
* This area is infinite, so always return false
*/
@Override
public final boolean isFinite() {
return false;
}
/**
* This area is infinite, so always return null
*/
@Override
public final FGERectangle getEmbeddingBounds() {
return null;
}
/**
* Return nearest point from point "from" following supplied orientation
*
* Returns null if no intersection was found
*
* @param from
* point from which we are coming to area
* @param orientation
* orientation we are coming from
* @return
*/
@Override
public FGEPoint nearestPointFrom(FGEPoint from, SimplifiedCardinalDirection orientation) {
return from.clone();
}
}