本文整理汇总了Java中org.jfree.chart.plot.Plot类的典型用法代码示例。如果您正苦于以下问题:Java Plot类的具体用法?Java Plot怎么用?Java Plot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Plot类属于org.jfree.chart.plot包,在下文中一共展示了Plot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTimeSeriesBarRender
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
public static void setTimeSeriesBarRender(Plot plot, boolean isShowDataLabels) {
XYPlot xyplot = (XYPlot) plot;
xyplot.setNoDataMessage(NO_DATA_MSG);
XYBarRenderer xyRenderer = new XYBarRenderer(0.1D);
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
if (isShowDataLabels) {
xyRenderer.setBaseItemLabelsVisible(true);
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
}
StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);
setXY_XAixs(xyplot);
setXY_YAixs(xyplot);
}
示例2: setPieRender
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
public static void setPieRender(Plot plot) {
plot.setNoDataMessage(NO_DATA_MSG);
plot.setInsets(new RectangleInsets(10, 10, 5, 10));
PiePlot piePlot = (PiePlot) plot;
piePlot.setInsets(new RectangleInsets(0, 0, 0, 0));
piePlot.setCircular(true);
piePlot.setLabelGap(0.01);
piePlot.setInteriorGap(0.05D);
piePlot.setLegendItemShape(new Rectangle(10, 10));
piePlot.setIgnoreNullValues(true);
piePlot.setLabelBackgroundPaint(null);
piePlot.setLabelShadowPaint(null);
piePlot.setLabelOutlinePaint(null);
piePlot.setShadowPaint(null);
// 0:category 1:value:2 :percentage
piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{2}"));
}
示例3: shrinkSelectionOnCenter
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Zooms in on an anchor point (specified in screen coordinate space).
*
* @param x
* the x value (in screen coordinates).
* @param y
* the y value (in screen coordinates).
*/
public void shrinkSelectionOnCenter(double x, double y, MouseEvent selectionEvent) {
Plot plot = this.chart.getPlot();
if (plot == null) {
return;
}
// here we tweak the notify flag on the plot so that only
// one notification happens even though we update multiple
// axes...
boolean savedNotify = plot.isNotify();
plot.setNotify(false);
shrinkSelectionOnDomain(x, y, selectionEvent);
shrinkSelectionOnRange(x, y, selectionEvent);
plot.setNotify(savedNotify);
}
示例4: restoreAutoBounds
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Restores the auto-range calculation on both axes.
*/
@Override
public void restoreAutoBounds() {
Plot plot = this.chart.getPlot();
if (plot == null) {
return;
}
// here we tweak the notify flag on the plot so that only
// one notification happens even though we update multiple
// axes...
boolean savedNotify = plot.isNotify();
plot.setNotify(false);
selectCompleteDomainBounds();
selectCompleteRangeBounds();
plot.setNotify(savedNotify);
}
示例5: plotTradeBubblesOnChart
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
switch(j)
{
case 0:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
break;
case 1:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
break;
case 2:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
break;
case 3:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
break;
}
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++)
{
series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
}
*/
XYDataset dataSet = new TimeSeriesCollection(series);
plot.setDataset(k, dataSet);
XYItemRenderer ir = new XYShapeRenderer();
//ir.s
plot.setRenderer(k, ir);
}
示例6: handleZoomable
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable,
ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (canvas.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (canvas.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
plot.setNotify(notifyState); // this generates the change event too
}
}
示例7: draw
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Draws the annotation.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param rendererIndex the renderer index.
* @param info if supplied, this info object will be populated with
* entity information.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
ValueAxis domainAxis, ValueAxis rangeAxis,
int rendererIndex,
PlotRenderingInfo info) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
plot.getRangeAxisLocation(), orientation);
float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea,
domainEdge);
float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea,
rangeEdge);
Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0,
j2DY - this.height / 2.0, this.width, this.height);
this.drawable.draw(g2, area);
String toolTip = getToolTipText();
String url = getURL();
if (toolTip != null || url != null) {
addEntity(info, area, rendererIndex, toolTip, url);
}
}
示例8: reserveSpace
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Estimates the space required for the axis, given a specific drawing area.
*
* @param g2 the graphics device (used to obtain font information).
* @param plot the plot that the axis belongs to.
* @param plotArea the area within which the axis should be drawn.
* @param edge the axis location (top or bottom).
* @param space the space already reserved.
*
* @return The space required to draw the axis.
*/
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea,
RectangleEdge edge, AxisSpace space) {
// create a new space object if one wasn't supplied...
if (space == null) {
space = new AxisSpace();
}
// if the axis is not visible, no additional space is required...
if (!isVisible()) {
return space;
}
space = super.reserveSpace(g2, plot, plotArea, edge, space);
double maxdim = getMaxDim(g2, edge);
if (RectangleEdge.isTopOrBottom(edge)) {
space.add(maxdim, edge);
}
else if (RectangleEdge.isLeftOrRight(edge)) {
space.add(maxdim, edge);
}
return space;
}
示例9: draw
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Draws the annotation.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
ValueAxis domainAxis, ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(),
orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(),
orientation);
float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0,
j2DY - this.height / 2.0,
this.width, this.height);
this.drawable.draw(g2, area);
}
示例10: reserveSpace
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Estimates the space required for the axis, given a specific drawing area.
*
* @param g2 the graphics device (used to obtain font information).
* @param plot the plot that the axis belongs to.
* @param plotArea the area within which the axis should be drawn.
* @param edge the axis location (top or bottom).
* @param space the space already reserved.
*
* @return The space required to draw the axis.
*/
public AxisSpace reserveSpace(Graphics2D g2, Plot plot,
Rectangle2D plotArea,
RectangleEdge edge, AxisSpace space) {
// create a new space object if one wasn't supplied...
if (space == null) {
space = new AxisSpace();
}
// if the axis is not visible, no additional space is required...
if (!isVisible()) {
return space;
}
space = super.reserveSpace(g2, plot, plotArea, edge, space);
double maxdim = getMaxDim(g2, edge);
if (RectangleEdge.isTopOrBottom(edge)) {
space.add(maxdim, edge);
}
else if (RectangleEdge.isLeftOrRight(edge)) {
space.add(maxdim, edge);
}
return space;
}
示例11: autoAdjustRange
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Rescales the axis to ensure that all data is visible.
*/
protected void autoAdjustRange() {
Plot plot = getPlot();
if (plot == null) {
return; // no plot, no data
}
if (plot instanceof ValueAxisPlot) {
ValueAxisPlot vap = (ValueAxisPlot) plot;
Range r = vap.getDataRange(this);
if (r == null) {
r = getDefaultAutoRange();
}
long upper = Math.round(r.getUpperBound());
long lower = Math.round(r.getLowerBound());
this.first = createInstance(this.autoRangeTimePeriodClass,
new Date(lower), this.timeZone);
this.last = createInstance(this.autoRangeTimePeriodClass,
new Date(upper), this.timeZone);
setRange(r, false, false);
}
}
示例12: setTimeSeriesRender
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) {
XYPlot xyplot = (XYPlot) plot;
xyplot.setNoDataMessage(NO_DATA_MSG);
xyplot.setInsets(new RectangleInsets(10, 10, 5, 10));
XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
xyRenderer.setBaseShapesVisible(false);
if (isShowData) {
xyRenderer.setBaseItemLabelsVisible(true);
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
}
xyRenderer.setBaseShapesVisible(isShapesVisible);
DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
domainAxis.setAutoTickUnitSelection(false);
DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM"));
domainAxis.setTickUnit(dateTickUnit);
StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);
setXY_XAixs(xyplot);
setXY_YAixs(xyplot);
}
示例13: makePlot
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
@Override
protected Plot makePlot(final JFreeChartBuilder.PlotParameters parameters) {
final DefaultKeyedValues2DDataset tmpDataset = this.getDataset();
final CategoryAxis tmpCategoryAxis = this.makeCategoryAxis(domain);
final ValueAxis tmpValueAxis = this.makeValueAxis(range);
final StackedBarRenderer tmpRenderer = new StackedBarRenderer();
tmpRenderer.setBarPainter(new StandardBarPainter());
tmpRenderer.setShadowVisible(false);
if (this.isTooltips()) {
tmpRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
}
if (this.isUrls()) {
tmpRenderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
}
this.setColours(tmpRenderer, tmpDataset);
final CategoryPlot retVal = new CategoryPlot(tmpDataset, tmpCategoryAxis, tmpValueAxis, tmpRenderer);
retVal.setOrientation(parameters.getOrientation());
retVal.setBackgroundPaint(parameters.getBackground());
retVal.setOutlinePaint(parameters.getOutline());
return retVal;
}
示例14: checkChart
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
/**
* Test that the chart is using an xy plot with time as the domain axis.
*
* @param chart the chart.
*/
private void checkChart(JFreeChart chart) {
Plot plot = chart.getPlot();
if (!(plot instanceof PolarPlot)) {
throw new IllegalArgumentException("plot is not a PolarPlot");
}
}
示例15: resolveYAxis
import org.jfree.chart.plot.Plot; //导入依赖的package包/类
@Override
public Collection<String> resolveYAxis(int axisIndex) {
Plot p = chart.getPlot();
Collection<String> names = new LinkedList<>();
if (p instanceof XYPlot) {
XYPlot plot = (XYPlot) p;
for (int i = 0; i < plot.getRangeAxisCount(); i++) {
ValueAxis domain = plot.getRangeAxis(i);
names.add(domain.getLabel());
}
}
return names;
}