org.jfree.chart.plot.Plot类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(16.1k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中org.jfree.chart.plot.Plot类的一些代码示例,展示了Plot类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plot类的具体详情如下:
包路径:org.jfree.chart.plot.Plot
类名称:Plot

Plot介绍

[英]The base class for all plots in JFreeChart. The JFreeChart class delegates the drawing of axes and data to the plot. This base class provides facilities common to most plot types.
[中]JFreeChart中所有绘图的基类。JFreeChart类将轴和数据的图形委托给绘图。该基类提供了大多数绘图类型通用的工具。

代码示例

代码示例来源:origin: jenkinsci/jenkins

private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) {
  String w = req.getParameter("width");
  if(w==null)     w=String.valueOf(defaultW);
  String h = req.getParameter("height");
  if(h==null)     h=String.valueOf(defaultH);
  Color graphBg = stringToColor(req.getParameter("graphBg"));
  Color plotBg = stringToColor(req.getParameter("plotBg"));
  if (graph==null)    graph = createGraph();
  graph.setBackgroundPaint(graphBg);
  Plot p = graph.getPlot();
  p.setBackgroundPaint(plotBg);
  return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info);
}

代码示例来源:origin: fossasia/neurolab-desktop

this.trackGraphics.setColor(Color.BLACK);
lineChart.getTitle().setFont(new Font("Ubuntu", Font.PLAIN, 20));
lineChart.getPlot().setOutlineStroke(new BasicStroke(3));
lineChart.getCategoryPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3));
lineChart.getCategoryPlot().getRenderer().setSeriesStroke(1, new BasicStroke(3));

代码示例来源:origin: jfree/jfreechart

/**
 * Sets the insets for the plot and sends a {@link PlotChangeEvent} to
 * all registered listeners.
 *
 * @param insets  the new insets ({@code null} not permitted).
 *
 * @see #getInsets()
 * @see #setInsets(RectangleInsets, boolean)
 */
public void setInsets(RectangleInsets insets) {
  setInsets(insets, true);
}

代码示例来源:origin: jfree/jfreechart

int rendererIndex, PlotRenderingInfo info) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
    plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
    plot.getRangeAxisLocation(), orientation);
double transX0 = domainAxis.valueToJava2D(this.x0, dataArea,
    domainEdge);
double transY0 = rangeAxis.valueToJava2D(this.y0, dataArea, rangeEdge);
double transX1 = domainAxis.valueToJava2D(this.x1, dataArea,
    domainEdge);
double transY1 = rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge);
  box = new Rectangle2D.Double(transY0, transX1, transY1 - transY0,
      transX0 - transX1);
  box = new Rectangle2D.Double(transX0, transY1, transX1 - transX0,
      transY0 - transY1);
  g2.setPaint(this.fillPaint);
  g2.fill(box);
  g2.setPaint(this.outlinePaint);
  g2.setStroke(this.stroke);
  g2.draw(box);

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

CategoryAxis domainAxis, ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
    plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
    plot.getRangeAxisLocation(), orientation);
CategoryDataset dataset = plot.getDataset();
int catIndex = dataset.getColumnIndex(getCategory());
double j2DX = domainAxis.getCategoryMiddle(catIndex, catCount,
    dataArea, domainEdge);
double j2DY = rangeAxis.valueToJava2D(getValue(), dataArea, rangeEdge);
if (orientation == PlotOrientation.HORIZONTAL) {
  double temp = j2DX;
arrow.closePath();
g2.setStroke(this.arrowStroke);
g2.setPaint(this.arrowPaint);
Line2D line = new Line2D.Double(startX, startY, endX, endY);
g2.draw(line);
g2.fill(arrow);

代码示例来源:origin: jfree/jfreechart

double base = this.axis.getLowerBound();
double increment = this.axis.getRange().getLength() / this.subdivisions;
Rectangle2D r = new Rectangle2D.Double();
  RectangleEdge axisEdge = Plot.resolveRangeAxisLocation(
      this.axisLocation, PlotOrientation.HORIZONTAL);
  if (axisEdge == RectangleEdge.TOP) {
      double v = base + (i * increment);
      Paint p = this.scale.getPaint(v);
      double vv0 = this.axis.valueToJava2D(v, target,
      r.setRect(Math.min(vv0, vv1), target.getMaxY()
          - this.stripWidth, ww, this.stripWidth);
      g2.setPaint(p);
      g2.draw(new Rectangle2D.Double(target.getMinX(),
          target.getMaxY() - this.stripWidth,
          target.getWidth(), this.stripWidth));
      g2.draw(new Rectangle2D.Double(target.getMinX(),
          target.getMinY(), target.getWidth(),
          this.stripWidth));
  RectangleEdge axisEdge = Plot.resolveRangeAxisLocation(
      this.axisLocation, PlotOrientation.VERTICAL);
  if (axisEdge == RectangleEdge.LEFT) {

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

CategoryAxis domainAxis, ValueAxis rangeAxis) {
CategoryDataset dataset = plot.getDataset();
int catIndex1 = dataset.getColumnIndex(this.category1);
int catIndex2 = dataset.getColumnIndex(this.category2);
double lineX2 = 0.0f;
double lineY2 = 0.0f;
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
  plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
  plot.getRangeAxisLocation(), orientation);
    CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea,
    domainEdge);
  lineY1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge);
  lineX2 = domainAxis.getCategoryJava2DCoordinate(
    CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea,
  lineY2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge);
g2.setPaint(this.paint);
g2.setStroke(this.stroke);
g2.drawLine((int) lineX1, (int) lineY1, (int) lineX2, (int) lineY2);

代码示例来源:origin: jfree/jfreechart

PlotRenderingInfo info) {
PlotOrientation orientation = plot.getOrientation();
AxisLocation xAxisLocation = plot.getDomainAxisLocation();
AxisLocation yAxisLocation = plot.getRangeAxisLocation();
RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation,
    orientation);
RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation,
    orientation);
float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge);
float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge);
float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w,
    dataArea, xEdge);
float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h,
g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1),
    (int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null);
String toolTip = getToolTipText();

代码示例来源:origin: jfree/jfreechart

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 displayArea = new Rectangle2D.Double(
    j2DX - this.displayWidth / 2.0,
    j2DY - this.displayHeight / 2.0, this.displayWidth,
AffineTransform savedTransform = g2.getTransform();
Rectangle2D drawArea = new Rectangle2D.Double(0.0, 0.0,
    this.displayWidth * this.drawScaleFactor,
    this.displayHeight * this.drawScaleFactor);
g2.scale(1 / this.drawScaleFactor, 1 / this.drawScaleFactor);
g2.translate((j2DX - this.displayWidth / 2.0) * this.drawScaleFactor,
    (j2DY - this.displayHeight / 2.0) * this.drawScaleFactor);
this.drawable.draw(g2, drawArea);

代码示例来源:origin: jfree/jfreechart

CategoryAxis domainAxis, ValueAxis rangeAxis) {
CategoryDataset dataset = plot.getDataset();
int catIndex = dataset.getColumnIndex(this.category);
int catCount = dataset.getColumnCount();
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
    plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
    plot.getRangeAxisLocation(), orientation);
      this.categoryAnchor, catIndex, catCount, dataArea,
      domainEdge);
  anchorX = (float) rangeAxis.valueToJava2D(this.value, dataArea,
      rangeEdge);
      this.categoryAnchor, catIndex, catCount, dataArea,
      domainEdge);
  anchorY = (float) rangeAxis.valueToJava2D(this.value, dataArea,
      rangeEdge);
g2.setFont(getFont());
g2.setPaint(getPaint());
TextUtils.drawRotatedString(getText(), g2, anchorX, anchorY,
    getTextAnchor(), getRotationAngle(), getRotationAnchor());

代码示例来源:origin: no.uib/jsparklines

CategoryPlot plot = chart.getCategoryPlot();
  plot.getDomainAxis().setUpperMargin(0);
  plot.getDomainAxis().setLowerMargin(0);
    plot.addRangeMarker(new ValueMarker(currentReferenceLine.getValue(), currentReferenceLine.getLineColor(), new BasicStroke(currentReferenceLine.getLineWidth())));
    plot.getRangeAxis().setRange(minValue, maxValue);
  plot.getRangeAxis().setVisible(false);
  plot.getDomainAxis().setVisible(false);
  plot.setRangeGridlinesVisible(false);
  XYPlot plot = chart.getXYPlot();
  plot.getDomainAxis().setUpperMargin(0);
  plot.getDomainAxis().setLowerMargin(0);
chart.getPlot().setOutlineVisible(false);
  chart.getPlot().setBackgroundPaint(backgroundColor);
  chart.setBackgroundPaint(backgroundColor);
} else {
  chart.getPlot().setBackgroundPaint(c.getBackground());
  chart.setBackgroundPaint(c.getBackground());

代码示例来源:origin: no.uib/jsparklines

CategoryPlot plot = chart.getCategoryPlot();
plot.getDomainAxis().setUpperMargin(0);
plot.getDomainAxis().setLowerMargin(0);
plot.getRangeAxis().setUpperMargin(0);
plot.getRangeAxis().setLowerMargin(0);
plot.getRangeAxis().setVisible(false);
plot.getDomainAxis().setVisible(false);
plot.setRangeGridlinesVisible(false);
chart.getPlot().setOutlineVisible(false);
  chart.getPlot().setBackgroundPaint(backgroundColor);
  chart.setBackgroundPaint(backgroundColor);
} else {
  chart.getPlot().setBackgroundPaint(c.getBackground());
  chart.setBackgroundPaint(c.getBackground());

代码示例来源:origin: datacleaner/DataCleaner

public static void applyStyles(final JFreeChart chart) {
  final TextTitle title = chart.getTitle();
  if (title != null) {
    title.setFont(WidgetUtils.FONT_HEADER1);
  for (int i = 0; i < chart.getSubtitleCount(); i++) {
    final Title subtitle = chart.getSubtitle(i);
    if (subtitle instanceof TextTitle) {
      ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
  final Plot plot = chart.getPlot();
  plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d));
  plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
  plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
  plot.setOutlineVisible(true);
    categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK);
    xyPlot.setDrawingSupplier(new DCDrawingSupplier());
    xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL);
    xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);
    xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
    xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL);

代码示例来源:origin: org.zkoss.zk/zkex

Plot plot = (Plot) jfchart.getPlot();
float alpha = (float)(((float)chart.getFgAlpha()) / 255);
plot.setForegroundAlpha(alpha);
plot.setBackgroundAlpha(alpha);
  plot.setBackgroundPaint(new Color(bgRGB[0], bgRGB[1], bgRGB[2], chart.getBgAlpha()));
  jfchart.setBackgroundPaint(new Color(paneRGB[0], paneRGB[1], paneRGB[2], chart.getPaneAlpha()));
  jfchart.getTitle().setFont(tfont);
  cplot.setRangeGridlinePaint(new Color(0xc0, 0xc0, 0xc0));
  final Font xtkfont = chart.getXAxisTickFont();
  if (xlbfont != null) {
    cplot.getDomainAxis().setLabelFont(xlbfont);
    cplot.getDomainAxis().setTickLabelFont(xtkfont);
  final Font ytkfont = chart.getYAxisTickFont();
  if (ylbfont != null) {
    cplot.getRangeAxis().setLabelFont(ylbfont);
    cplot.getRangeAxis().setTickLabelFont(ytkfont);
  xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
  xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);

代码示例来源:origin: senbox-org/snap-desktop

private Shape createShape() {
  XYPlot plot = chartPanel.getChart().getXYPlot();
  Rectangle2D dataArea = chartPanel.getScreenDataArea();
  PlotOrientation orientation = plot.getOrientation();
  RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation);
  RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation);
  double vx1 = areaType == AreaType.Y_RANGE ? dataArea.getX() : point1.x;
  double vy1 = areaType == AreaType.X_RANGE ? dataArea.getY() : point1.y;
  double vx2 = areaType == AreaType.Y_RANGE ? dataArea.getX() + dataArea.getWidth() : point2.x;
  double vy2 = areaType == AreaType.X_RANGE ? dataArea.getY() + dataArea.getHeight() : point2.y;
  double x1 = plot.getDomainAxis().java2DToValue(vx1, dataArea, domainEdge);
  double x2 = plot.getDomainAxis().java2DToValue(vx2, dataArea, domainEdge);
  double y1 = plot.getRangeAxis().java2DToValue(vy1, dataArea, rangeEdge);
  double y2 = plot.getRangeAxis().java2DToValue(vy2, dataArea, rangeEdge);
  double dx = abs(x2 - x1);
  double dy = abs(y2 - y1);
  final Shape shape;
  if (areaType == AreaType.ELLIPSE) {
    shape = new Ellipse2D.Double(x1 - dx, y1 - dy, 2.0 * dx, 2.0 * dy);
  } else if (areaType == AreaType.RECTANGLE) {
    shape = new Rectangle2D.Double(x1 - dx, y1 - dy, 2.0 * dx, 2.0 * dy);
  } else if (areaType == AreaType.X_RANGE || areaType == AreaType.Y_RANGE) {
    shape = new Rectangle2D.Double(min(x1, x2), min(y1, y2), dx, dy);
  } else {
    throw new IllegalStateException("areaType = " + areaType);
  }
  return shape;
}

代码示例来源:origin: no.uib/jsparklines

XYPlot plot = chart.getXYPlot();
  plot.getDomainAxis().setUpperMargin(0);
  plot.getDomainAxis().setLowerMargin(0);
    plot.addDomainMarker(new ValueMarker(currentReferenceLine.getValue(), currentReferenceLine.getLineColor(), new BasicStroke(currentReferenceLine.getLineWidth())));
  plot.getDomainAxis().setRange(minXValue, maxXValue);
  plot.getRangeAxis().setRange(minYValue, maxYValue);
chart.getPlot().setOutlineVisible(false);
chart.getPlot().setBackgroundPaint(c.getBackground());
chart.setBackgroundPaint(c.getBackground());

代码示例来源:origin: no.uib/jsparklines

plot = ((PiePlot) chart.getPlot());
  ((PiePlot) plot).setCircular(true);
  ((PiePlot) plot).setLabelGenerator(null);
  ((PiePlot) plot).setSectionPaint("D", labelD);
  plot.setOutlineStroke(new BasicStroke(20));
  chart.getPlot().setOutlineVisible(false);
  dataset2.addSeries("Series 1", tempXYZData);
  plot = new XYPlot(dataset2, xAxis, yAxis, renderer);
  plot.setBackgroundPaint(Color.WHITE);
  ((XYPlot) plot).setDomainGridlinePaint(Color.white);
  ((XYPlot) plot).setRangeGridlinePaint(Color.white);
  ((XYPlot) plot).getRangeAxis().setVisible(false);
  ((XYPlot) plot).getDomainAxis().setVisible(false);
  ((XYPlot) plot).setRangeGridlinesVisible(false);
  ((XYPlot) plot).setDomainGridlinesVisible(false);
  plot.setOutlineStroke(new BasicStroke(20));
JFreeChart tempChart = new JFreeChart(null, plot);
tempChart.removeLegend();
tempChart.setBackgroundPaint(Color.white);

代码示例来源:origin: jfree/jfreechart

plot.setOutlinePaint(getOutlinePaint());
plot.setOutlineStroke(getOutlineStroke());
plot.setBackgroundPaint(getBackgroundPaint());
plot.setInsets(getPlotInsets());
  if (plot instanceof CategoryPlot) {
    CategoryPlot p = (CategoryPlot) plot;
    domainAxis = p.getDomainAxis();
    domainAxis = p.getDomainAxis();
  if (plot instanceof CategoryPlot) {
    CategoryPlot p = (CategoryPlot) plot;
    rangeAxis = p.getRangeAxis();
    rangeAxis = p.getRangeAxis();
  if (plot instanceof CategoryPlot) {
    CategoryPlot p = (CategoryPlot) plot;
    p.setOrientation(this.plotOrientation);
    p.setOrientation(this.plotOrientation);

代码示例来源:origin: no.uib/jsparklines

CategoryPlot plot = chart.getCategoryPlot();
plot.getRangeAxis().setRange(minValue, maxValue * 1.02);
plot.getDomainAxis().setUpperMargin(0);
plot.getDomainAxis().setLowerMargin(0);
plot.getRangeAxis().setUpperMargin(0);
plot.getRangeAxis().setLowerMargin(0);
  plot.setBackgroundPaint(plotBackgroundColor);
  chartPanel.setBackground(plotBackgroundColor);
  chart.setBackgroundPaint(plotBackgroundColor);
} else {
  plot.setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
  chartPanel.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
  chart.setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
  this.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
  chart.getPlot().setBackgroundPaint(plotBackgroundColor);
  chart.setBackgroundPaint(plotBackgroundColor);
} else {
  chart.getPlot().setBackgroundPaint(c.getBackground());
  chart.setBackgroundPaint(c.getBackground());

代码示例来源:origin: pentaho/pentaho-platform

private static void updatePlot( final Plot plot, final ChartDefinition chartDefinition ) {
 plot.setBackgroundPaint( chartDefinition.getPlotBackgroundPaint() );
 plot.setBackgroundImage( chartDefinition.getPlotBackgroundImage() );
 plot.setNoDataMessage( chartDefinition.getNoDataMessage() );
      DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
      DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE );
  plot.setDrawingSupplier( drawingSupplier );
 plot.setOutlineStroke( null ); // TODO define outline stroke
  categoryPlot.setOrientation( categoryDatasetChartDefintion.getOrientation() );
  CategoryAxis domainAxis = categoryPlot.getDomainAxis();
  if ( domainAxis != null ) {
   domainAxis.setLabel( categoryDatasetChartDefintion.getDomainTitle() );
  NumberAxis numberAxis = (NumberAxis) categoryPlot.getRangeAxis();
  if ( numberAxis != null ) {
   numberAxis.setLabel( categoryDatasetChartDefintion.getRangeTitle() );
   ValueAxis rangeAxis = xyPlot.getRangeAxis();
   if ( rangeAxis != null ) {
    rangeAxis.setLabel( xySeriesCollectionChartDefintion.getRangeTitle() );

相关文章