use of org.jfree.chart.axis.AxisSpace in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testCloning2.
/**
* Some more cloning checks.
*/
@Test
public void testCloning2() {
AxisSpace da1 = new AxisSpace();
AxisSpace ra1 = new AxisSpace();
CategoryPlot p1 = new CategoryPlot();
p1.setFixedDomainAxisSpace(da1);
p1.setFixedRangeAxisSpace(ra1);
CategoryPlot p2;
try {
p2 = (CategoryPlot) p1.clone();
} catch (CloneNotSupportedException e) {
fail("Cloning failed.");
return;
}
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
da1.setBottom(99.0);
assertFalse(p1.equals(p2));
p2.getFixedDomainAxisSpace().setBottom(99.0);
assertTrue(p1.equals(p2));
ra1.setBottom(11.0);
assertFalse(p1.equals(p2));
p2.getFixedRangeAxisSpace().setBottom(11.0);
assertTrue(p1.equals(p2));
}
use of org.jfree.chart.axis.AxisSpace in project SIMVA-SoS by SESoS.
the class XYPlot method calculateRangeAxisSpace.
/**
* Calculates the space required for the range axis/axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param space a carrier for the result (<code>null</code> permitted).
*
* @return The required space.
*/
protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) {
if (space == null) {
space = new AxisSpace();
}
// reserve some space for the range axis...
if (this.fixedRangeAxisSpace != null) {
if (this.orientation == PlotOrientation.HORIZONTAL) {
space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), RectangleEdge.TOP);
space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), RectangleEdge.BOTTOM);
} else if (this.orientation == PlotOrientation.VERTICAL) {
space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), RectangleEdge.LEFT);
space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), RectangleEdge.RIGHT);
}
} else {
// reserve space for the range axes...
for (ValueAxis axis : this.rangeAxes.values()) {
if (axis != null) {
RectangleEdge edge = getRangeAxisEdge(findRangeAxisIndex(axis));
space = axis.reserveSpace(g2, this, plotArea, edge, space);
}
}
}
return space;
}
use of org.jfree.chart.axis.AxisSpace in project SIMVA-SoS by SESoS.
the class CategoryPlot method calculateDomainAxisSpace.
/**
* Calculates the space required for the domain axis/axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param space a carrier for the result (<code>null</code> permitted).
*
* @return The required space.
*/
protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) {
if (space == null) {
space = new AxisSpace();
}
// reserve some space for the domain axis...
if (this.fixedDomainAxisSpace != null) {
if (this.orientation.isHorizontal()) {
space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT);
space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), RectangleEdge.RIGHT);
} else if (this.orientation.isVertical()) {
space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), RectangleEdge.TOP);
space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), RectangleEdge.BOTTOM);
}
} else {
// reserve space for the primary domain axis...
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(getDomainAxisLocation(), this.orientation);
if (this.drawSharedDomainAxis) {
space = getDomainAxis().reserveSpace(g2, this, plotArea, domainEdge, space);
}
// reserve space for any domain axes...
for (CategoryAxis xAxis : this.domainAxes.values()) {
if (xAxis != null) {
int i = getDomainAxisIndex(xAxis);
RectangleEdge edge = getDomainAxisEdge(i);
space = xAxis.reserveSpace(g2, this, plotArea, edge, space);
}
}
}
return space;
}
use of org.jfree.chart.axis.AxisSpace in project SIMVA-SoS by SESoS.
the class CombinedDomainXYPlot method draw.
/**
* Draws the plot within the specified area on a graphics device.
*
* @param g2 the graphics device.
* @param area the plot area (in Java2D space).
* @param anchor an anchor point in Java2D space (<code>null</code>
* permitted).
* @param parentState the state from the parent plot, if there is one
* (<code>null</code> permitted).
* @param info collects chart drawing information (<code>null</code>
* permitted).
*/
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
// set up info collection...
if (info != null) {
info.setPlotArea(area);
}
// adjust the drawing area for plot insets (if any)...
RectangleInsets insets = getInsets();
insets.trim(area);
setFixedRangeAxisSpaceForSubplots(null);
AxisSpace space = calculateAxisSpace(g2, area);
Rectangle2D dataArea = space.shrink(area, null);
// set the width and height of non-shared axis of all sub-plots
setFixedRangeAxisSpaceForSubplots(space);
// draw the shared axis
ValueAxis axis = getDomainAxis();
RectangleEdge edge = getDomainAxisEdge();
double cursor = RectangleEdge.coordinate(dataArea, edge);
AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
if (parentState == null) {
parentState = new PlotState();
}
parentState.getSharedAxisStates().put(axis, axisState);
// draw all the subplots
for (int i = 0; i < this.subplots.size(); i++) {
XYPlot plot = (XYPlot) this.subplots.get(i);
PlotRenderingInfo subplotInfo = null;
if (info != null) {
subplotInfo = new PlotRenderingInfo(info.getOwner());
info.addSubplotInfo(subplotInfo);
}
plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo);
}
if (info != null) {
info.setDataArea(dataArea);
}
}
use of org.jfree.chart.axis.AxisSpace in project SIMVA-SoS by SESoS.
the class CombinedRangeXYPlot method draw.
/**
* Draws the plot within the specified area on a graphics device.
*
* @param g2 the graphics device.
* @param area the plot area (in Java2D space).
* @param anchor an anchor point in Java2D space (<code>null</code>
* permitted).
* @param parentState the state from the parent plot, if there is one
* (<code>null</code> permitted).
* @param info collects chart drawing information (<code>null</code>
* permitted).
*/
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
// set up info collection...
if (info != null) {
info.setPlotArea(area);
}
// adjust the drawing area for plot insets (if any)...
RectangleInsets insets = getInsets();
insets.trim(area);
AxisSpace space = calculateAxisSpace(g2, area);
Rectangle2D dataArea = space.shrink(area, null);
// this.axisOffset.trim(dataArea);
// set the width and height of non-shared axis of all sub-plots
setFixedDomainAxisSpaceForSubplots(space);
// draw the shared axis
ValueAxis axis = getRangeAxis();
RectangleEdge edge = getRangeAxisEdge();
double cursor = RectangleEdge.coordinate(dataArea, edge);
AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
if (parentState == null) {
parentState = new PlotState();
}
parentState.getSharedAxisStates().put(axis, axisState);
// draw all the charts
for (int i = 0; i < this.subplots.size(); i++) {
XYPlot plot = (XYPlot) this.subplots.get(i);
PlotRenderingInfo subplotInfo = null;
if (info != null) {
subplotInfo = new PlotRenderingInfo(info.getOwner());
info.addSubplotInfo(subplotInfo);
}
plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo);
}
if (info != null) {
info.setDataArea(dataArea);
}
}
Aggregations