本文整理汇总了Java中org.jfree.chart.plot.XYPlot.getRangeAxisEdge方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.getRangeAxisEdge方法的具体用法?Java XYPlot.getRangeAxisEdge怎么用?Java XYPlot.getRangeAxisEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.getRangeAxisEdge方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _getPointForCandlestick
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private Point2D.Double _getPointForCandlestick(int plotIndex, int seriesIndex, int dataIndex) {
final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
final XYPlot plot = this.chartJDialog.getPlot(plotIndex);
final ValueAxis domainAxis = plot.getDomainAxis();
final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
final ValueAxis rangeAxis = plot.getRangeAxis();
final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
final org.jfree.data.xy.DefaultHighLowDataset defaultHighLowDataset = (org.jfree.data.xy.DefaultHighLowDataset)plot.getDataset(seriesIndex);
if (dataIndex >= defaultHighLowDataset.getItemCount(0)) {
/* Not ready yet. */
return null;
}
final double xValue = defaultHighLowDataset.getXDate(0, dataIndex).getTime();
final double yValue = defaultHighLowDataset.getCloseValue(0, dataIndex);
final Rectangle2D plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(plotIndex).getDataArea();
final double xJava2D = domainAxis.valueToJava2D(xValue, plotArea, domainAxisEdge);
final double yJava2D = rangeAxis.valueToJava2D(yValue, plotArea, rangeAxisEdge);
// Use Double version, to avoid from losing precision.
return new Point2D.Double(xJava2D, yJava2D);
}
示例2: drawItem
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color information etc).
* @param domainAxis the domain (horizontal) axis.
* @param rangeAxis the range (vertical) axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState crosshair information for the plot (<code>null</code> permitted).
* @param pass the pass index.
*/
public void drawItem(Graphics2D g2,
XYItemRendererState state,
Rectangle2D dataArea,
PlotRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset dataset,
int series,
int item,
CrosshairState crosshairState,
int pass) {
// get the data point...
Number xn = dataset.getX(series, item);
Number yn = dataset.getY(series, item);
if (yn != null) {
double x = xn.doubleValue();
double y = yn.doubleValue();
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
g2.setPaint(this.getItemPaint(series, item));
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
g2.drawRect((int) transY, (int) transX, 1, 1);
}
else if (orientation == PlotOrientation.VERTICAL) {
g2.drawRect((int) transX, (int) transY, 1, 1);
}
updateCrosshairValues(crosshairState, x, y, transX, transY, orientation);
}
}
示例3: _updateMainTraceInfoForCandlestick
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private boolean _updateMainTraceInfoForCandlestick(Point2D point) {
if (point == null) {
return false;
}
final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
// Top most plot.
final XYPlot plot = this.chartJDialog.getPlot();
final org.jfree.data.xy.DefaultHighLowDataset defaultHighLowDataset = (org.jfree.data.xy.DefaultHighLowDataset)plot.getDataset();
// I also not sure why. This is what are being done in Mouse Listener Demo 4.
//
// Don't use it. It will cause us to lose precision.
//final Point2D p2 = chartPanel.translateScreenToJava2D((Point)point);
/* Try to get correct main chart area. */
final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();
final ValueAxis domainAxis = plot.getDomainAxis();
final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
final ValueAxis rangeAxis = plot.getRangeAxis();
final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
// Don't use it. It will cause us to lose precision.
//final double coordinateX = domainAxis.java2DToValue(p2.getX(), _plotArea,
// domainAxisEdge);
final double coordinateX = domainAxis.java2DToValue(point.getX(), _plotArea,
domainAxisEdge);
//double coordinateY = rangeAxis.java2DToValue(mousePoint2.getY(), plotArea,
// rangeAxisEdge);
int low = 0;
int high = defaultHighLowDataset.getItemCount(0) - 1;
Date date = new Date((long)coordinateX);
final long time = date.getTime();
long bestDistance = Long.MAX_VALUE;
int bestMid = 0;
while (low <= high) {
int mid = (low + high) >>> 1;
final Date d = defaultHighLowDataset.getXDate(0, mid);
final long search = d.getTime();
final long cmp = search - time;
if (cmp < 0) {
low = mid + 1;
}
else if (cmp > 0) {
high = mid - 1;
}
else {
bestDistance = 0;
bestMid = mid;
break;
}
final long abs_cmp = Math.abs(cmp);
if (abs_cmp < bestDistance) {
bestDistance = abs_cmp;
bestMid = mid;
}
}
final double xValue = defaultHighLowDataset.getXDate(0, bestMid).getTime();
final double yValue = defaultHighLowDataset.getCloseValue(0, bestMid);
final double xJava2D = domainAxis.valueToJava2D(xValue, _plotArea, domainAxisEdge);
final double yJava2D = rangeAxis.valueToJava2D(yValue, _plotArea, rangeAxisEdge);
final int tmpIndex = bestMid;
// translateJava2DToScreen will internally convert Point2D.Double to Point.
final Point2D tmpPoint = chartPanel.translateJava2DToScreen(new Point2D.Double(xJava2D, yJava2D));
this.mainDrawArea.setRect(_plotArea);
if (this.mainDrawArea.contains(tmpPoint)) {
// 0 indicates main plot.
this.mainTraceInfo = TraceInfo.newInstance(tmpPoint, 0, 0, tmpIndex);
return true;
}
return false;
}
示例4: drawPrimaryLine
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Draws the item (first pass). This method draws the lines
* connecting the items.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param pass the pass.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
*/
protected void drawPrimaryLine(XYItemRendererState state,
Graphics2D g2,
XYPlot plot,
XYDataset dataset,
int pass,
int series,
int item,
ValueAxis domainAxis,
ValueAxis rangeAxis,
Rectangle2D dataArea) {
if (item == 0) {
return;
}
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
if (Double.isNaN(y1) || Double.isNaN(x1)) {
return;
}
double x0 = dataset.getXValue(series, item - 1);
double y0 = dataset.getYValue(series, item - 1);
if (Double.isNaN(y0) || Double.isNaN(x0)) {
return;
}
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
// only draw if we have good values
if (Double.isNaN(transX0) || Double.isNaN(transY0)
|| Double.isNaN(transX1) || Double.isNaN(transY1)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
state.workingLine.setLine(transY0, transX0, transY1, transX1);
}
else if (orientation == PlotOrientation.VERTICAL) {
state.workingLine.setLine(transX0, transY0, transX1, transY1);
}
if (state.workingLine.intersects(dataArea)) {
drawFirstPassShape(g2, pass, series, item, state.workingLine);
}
}
示例5: drawPrimaryLineAsPath
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Draws the item (first pass). This method draws the lines
* connecting the items. Instead of drawing separate lines,
* a GeneralPath is constructed and drawn at the end of
* the series painting.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param plot the plot (can be used to obtain standard color information
* etc).
* @param dataset the dataset.
* @param pass the pass.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataArea the area within which the data is being drawn.
*/
protected void drawPrimaryLineAsPath(XYItemRendererState state,
Graphics2D g2, XYPlot plot,
XYDataset dataset,
int pass,
int series,
int item,
ValueAxis domainAxis,
ValueAxis rangeAxis,
Rectangle2D dataArea) {
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
// get the data point...
double x1 = dataset.getXValue(series, item);
double y1 = dataset.getYValue(series, item);
double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
State s = (State) state;
// update path to reflect latest point
if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
float x = (float) transX1;
float y = (float) transY1;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
x = (float) transY1;
y = (float) transX1;
}
if (s.isLastPointGood()) {
s.seriesPath.lineTo(x, y);
}
else {
s.seriesPath.moveTo(x, y);
}
s.setLastPointGood(true);
}
else {
s.setLastPointGood(false);
}
// if this is the last item, draw the path ...
if (item == dataset.getItemCount(series) - 1) {
// draw path
drawFirstPassShape(g2, pass, series, item, s.seriesPath);
}
}
示例6: drawItem
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Draws the visual representation of a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area within which the data is being drawn.
* @param info collects information about the drawing.
* @param plot the plot (can be used to obtain standard color
* information etc).
* @param domainAxis the domain (horizontal) axis.
* @param rangeAxis the range (vertical) axis.
* @param dataset the dataset.
* @param series the series index (zero-based).
* @param item the item index (zero-based).
* @param crosshairState crosshair information for the plot
* (<code>null</code> permitted).
* @param pass the pass index.
*/
public void drawItem(Graphics2D g2,
XYItemRendererState state,
Rectangle2D dataArea,
PlotRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset dataset,
int series,
int item,
CrosshairState crosshairState,
int pass) {
// get the data point...
double x = dataset.getXValue(series, item);
double y = dataset.getYValue(series, item);
double adjx = (this.dotWidth - 1) / 2.0;
double adjy = (this.dotHeight - 1) / 2.0;
if (!Double.isNaN(y)) {
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX = domainAxis.valueToJava2D(x, dataArea,
xAxisLocation) - adjx;
double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)
- adjy;
g2.setPaint(getItemPaint(series, item));
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
g2.fillRect((int) transY, (int) transX, this.dotHeight,
this.dotWidth);
}
else if (orientation == PlotOrientation.VERTICAL) {
g2.fillRect((int) transX, (int) transY, this.dotWidth,
this.dotHeight);
}
int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
updateCrosshairValues(crosshairState, x, y, domainAxisIndex,
rangeAxisIndex, transX, transY, orientation);
}
}