use of org.jfree.chart.axis.AxisState in project processdash by dtuma.
the class DiscLegendAxis method drawAxisLine.
/**
* The superclass' drawAxisLine() method draws the axis line for the entire
* dataArea's length. Since we want the line to end at the height of the maximum
* shown tick, we create a new Rectangle2D with the appropriate dimensions.
*/
@Override
protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) {
// In the original flow of events, the refreshing of the ticks is made after
// drawing the axis line. Since this implementation needs the ticks to be
// set properly, we force a tick refresh.
AxisState state = new AxisState(cursor);
refreshTicks(g2, state, dataArea, edge);
double amountBetweenTicks = getTickUnit().getSize();
int tickCount = calculateVisibleTickCount() - 1;
double lowestTickValue = calculateLowestVisibleTickValue();
double minY = valueToJava2D(lowestTickValue + tickCount * amountBetweenTicks, dataArea, edge);
double maxY = valueToJava2D(lowestTickValue, dataArea, edge);
double height = maxY - minY;
Rectangle2D axisLineArea = new Rectangle2D.Double(dataArea.getX(), minY, dataArea.getWidth(), height);
super.drawAxisLine(g2, cursor, axisLineArea, edge);
}
use of org.jfree.chart.axis.AxisState 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.AxisState 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);
}
}
use of org.jfree.chart.axis.AxisState in project SIMVA-SoS by SESoS.
the class CategoryPlot method drawAxes.
/**
* A utility method for drawing the plot's axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param dataArea the data area.
* @param plotState collects information about the plot (<code>null</code>
* permitted).
*
* @return A map containing the axis states.
*/
protected Map drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) {
AxisCollection axisCollection = new AxisCollection();
// add domain axes to lists...
for (CategoryAxis xAxis : this.domainAxes.values()) {
if (xAxis != null) {
int index = getDomainAxisIndex(xAxis);
axisCollection.add(xAxis, getDomainAxisEdge(index));
}
}
// add range axes to lists...
for (ValueAxis yAxis : this.rangeAxes.values()) {
if (yAxis != null) {
int index = findRangeAxisIndex(yAxis);
axisCollection.add(yAxis, getRangeAxisEdge(index));
}
}
Map axisStateMap = new HashMap();
// draw the top axes
double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset(dataArea.getHeight());
Iterator iterator = axisCollection.getAxesAtTop().iterator();
while (iterator.hasNext()) {
Axis axis = (Axis) iterator.next();
if (axis != null) {
AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.TOP, plotState);
cursor = axisState.getCursor();
axisStateMap.put(axis, axisState);
}
}
// draw the bottom axes
cursor = dataArea.getMaxY() + this.axisOffset.calculateBottomOutset(dataArea.getHeight());
iterator = axisCollection.getAxesAtBottom().iterator();
while (iterator.hasNext()) {
Axis axis = (Axis) iterator.next();
if (axis != null) {
AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, plotState);
cursor = axisState.getCursor();
axisStateMap.put(axis, axisState);
}
}
// draw the left axes
cursor = dataArea.getMinX() - this.axisOffset.calculateLeftOutset(dataArea.getWidth());
iterator = axisCollection.getAxesAtLeft().iterator();
while (iterator.hasNext()) {
Axis axis = (Axis) iterator.next();
if (axis != null) {
AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, plotState);
cursor = axisState.getCursor();
axisStateMap.put(axis, axisState);
}
}
// draw the right axes
cursor = dataArea.getMaxX() + this.axisOffset.calculateRightOutset(dataArea.getWidth());
iterator = axisCollection.getAxesAtRight().iterator();
while (iterator.hasNext()) {
Axis axis = (Axis) iterator.next();
if (axis != null) {
AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.RIGHT, plotState);
cursor = axisState.getCursor();
axisStateMap.put(axis, axisState);
}
}
return axisStateMap;
}
use of org.jfree.chart.axis.AxisState in project SIMVA-SoS by SESoS.
the class CombinedRangeCategoryPlot method draw.
/**
* Draws the plot on a Java 2D graphics device (such as the screen or a
* printer). Will perform all the placement calculations for each
* sub-plots and then tell these to draw themselves.
*
* @param g2 the graphics device.
* @param area the area within which the plot (including axis labels)
* should be drawn.
* @param anchor the anchor point (<code>null</code> permitted).
* @param parentState the parent state.
* @param info collects information about the drawing (<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);
// calculate the data area...
AxisSpace space = calculateAxisSpace(g2, area);
Rectangle2D dataArea = space.shrink(area, null);
// set the width and height of non-shared axis of all sub-plots
setFixedDomainAxisSpaceForSubplots(space);
// draw the shared axis
ValueAxis axis = getRangeAxis();
RectangleEdge rangeEdge = getRangeAxisEdge();
double cursor = RectangleEdge.coordinate(dataArea, rangeEdge);
AxisState state = axis.draw(g2, cursor, area, dataArea, rangeEdge, info);
if (parentState == null) {
parentState = new PlotState();
}
parentState.getSharedAxisStates().put(axis, state);
// draw all the charts
for (int i = 0; i < this.subplots.size(); i++) {
CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
PlotRenderingInfo subplotInfo = null;
if (info != null) {
subplotInfo = new PlotRenderingInfo(info.getOwner());
info.addSubplotInfo(subplotInfo);
}
Point2D subAnchor = null;
if (anchor != null && this.subplotArea[i].contains(anchor)) {
subAnchor = anchor;
}
plot.draw(g2, this.subplotArea[i], subAnchor, parentState, subplotInfo);
}
if (info != null) {
info.setDataArea(dataArea);
}
}
Aggregations