/*
* Copyright (C) 2011 Alasdair C. Hamilton
*
* 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 <http://www.gnu.org/licenses/>
*/
package ket.display.box;
import geom.Offset;
import geom.Position;
import java.awt.geom.Arc2D;
import java.awt.*;
import ket.math.*;
import ket.display.ColourScheme;
public class BoxGap extends Box {
Box reference;
double scaleX;
double scaleY;
double shiftX;
double shiftY;
@Override
public Box cloneBox() {
return new BoxGap(getArgument(), getSettings(), reference, scaleX, scaleY, shiftX, shiftY);
}
public BoxGap(Argument argument, long settings, Box reference, double scaleX, double scaleY, double shiftX, double shiftY) {
super(argument, settings);
this.reference = reference;
this.scaleX = scaleX;
this.scaleY = scaleY;
this.shiftX = shiftX;
this.shiftY = shiftY;
}
@Override
protected void calcMinimumSize() {
reference.calcMinimumSize();
Offset inner = reference.getInnerRectangle();
double width = scaleX * inner.width + shiftX;
double height = scaleY * inner.height + shiftY;
this.innerRectangle = new Offset(width, height);
}
@Override
public void setupOuterRectangle(Offset actualSize) {
calcMinimumSize(); //? In case the inner rectangle of the reference object has since changed shape.
this.outerRectangle = new Offset(innerRectangle.width, innerRectangle.height);
super.setupOuterRectangle(actualSize);
}
@Override
public void draw(Graphics2D g2D, Position topLeft, ColourScheme colourScheme) {
// Do nothing
}
@Override
public String toString() {
return String.format("BoxGap:(%g, %g)*ref+(%g, %g) ", scaleX, scaleY, shiftX, shiftY);
}
@Override
public boolean withinInnerRectangle(Position p) {
return false;
}
}