use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.
the class XYPlot method handleClick.
/**
* Handles a 'click' on the plot by updating the anchor values.
*
* @param x the x-coordinate, where the click occurred, in Java2D space.
* @param y the y-coordinate, where the click occurred, in Java2D space.
* @param info object containing information about the plot dimensions.
*/
@Override
public void handleClick(int x, int y, PlotRenderingInfo info) {
Rectangle2D dataArea = info.getDataArea();
if (dataArea.contains(x, y)) {
// set the anchor value for the horizontal axis...
ValueAxis xaxis = getDomainAxis();
if (xaxis != null) {
double hvalue = xaxis.java2DToValue(x, info.getDataArea(), getDomainAxisEdge());
setDomainCrosshairValue(hvalue);
}
// set the anchor value for the vertical axis...
ValueAxis yaxis = getRangeAxis();
if (yaxis != null) {
double vvalue = yaxis.java2DToValue(y, info.getDataArea(), getRangeAxisEdge());
setRangeCrosshairValue(vvalue);
}
}
}
use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.
the class XYPlot method clearRangeAxes.
/**
* Clears the range axes from the plot and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @see #clearDomainAxes()
*/
public void clearRangeAxes() {
for (ValueAxis axis : this.rangeAxes.values()) {
if (axis != null) {
axis.removeChangeListener(this);
}
}
this.rangeAxes.clear();
fireChangeEvent();
}
use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.
the class XYPlot method drawRangeMarkers.
/**
* Draws the range markers (if any) for a renderer and layer. This method
* is typically called from within the draw() method.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param index the renderer index.
* @param layer the layer (foreground or background).
*/
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) {
XYItemRenderer r = getRenderer(index);
if (r == null) {
return;
}
// matter if the dataset is null)
if (index >= getDatasetCount()) {
return;
}
Collection markers = getRangeMarkers(index, layer);
ValueAxis axis = getRangeAxisForDataset(index);
if (markers != null && axis != null) {
Iterator iterator = markers.iterator();
while (iterator.hasNext()) {
Marker marker = (Marker) iterator.next();
r.drawRangeMarker(g2, this, axis, marker, dataArea);
}
}
}
use of org.jfree.chart.axis.ValueAxis 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.ValueAxis in project SIMVA-SoS by SESoS.
the class XYPlot method zoomRangeAxes.
/**
* Multiplies the range on the range axis/axes by the specified factor.
*
* @param factor the zoom factor.
* @param info the plot rendering info.
* @param source the source point.
* @param useAnchor a flag that controls whether or not the source point
* is used for the zoom anchor.
*
* @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)
*
* @since 1.0.7
*/
@Override
public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) {
// perform the zoom on each range axis
for (ValueAxis yAxis : this.rangeAxes.values()) {
if (yAxis == null) {
continue;
}
if (useAnchor) {
// get the relevant source coordinate given the plot orientation
double sourceY = source.getY();
if (this.orientation == PlotOrientation.HORIZONTAL) {
sourceY = source.getX();
}
double anchorY = yAxis.java2DToValue(sourceY, info.getDataArea(), getRangeAxisEdge());
yAxis.resizeRange2(factor, anchorY);
} else {
yAxis.resizeRange(factor);
}
}
}
Aggregations