当前位置: 首页>>代码示例>>Java>>正文


Java ChartViewer类代码示例

本文整理汇总了Java中org.jfree.chart.fx.ChartViewer的典型用法代码示例。如果您正苦于以下问题:Java ChartViewer类的具体用法?Java ChartViewer怎么用?Java ChartViewer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChartViewer类属于org.jfree.chart.fx包,在下文中一共展示了ChartViewer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
@Override 
public void start(Stage stage) throws Exception {
    PieDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);  
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: PieChartFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show(); 
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:12,代码来源:PieChartFXDemo1.java

示例2: start

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
@Override 
public void start(Stage stage) throws Exception {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: TimeSeriesFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show();
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:12,代码来源:TimeSeriesChartFXDemo1.java

示例3: start

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
/**
 * Adds a chart viewer to the stage and displays it.
 * 
 * @param stage  the stage.
 * @throws Exception if something goes wrong.
 */
@Override 
public void start(Stage stage) throws Exception {
    CategoryDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);
    viewer.addChartMouseListener(this);
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: BarChartFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show(); 
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:19,代码来源:BarChartFXDemo1.java

示例4: printChart

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
public static void printChart(ChartViewer chartNode) {

    // As of java 1.8.0_74, the JavaFX printing support seems to do poor
    // job. It creates pixelated, low-resolution print outs. For that
    // reason, we use the AWT PrinterJob class, until the JavaFX printing
    // support is improved.
    SwingUtilities.invokeLater(() -> {
      PrinterJob job = PrinterJob.getPrinterJob();
      PageFormat pf = job.defaultPage();
      PageFormat pf2 = job.pageDialog(pf);
      if (pf2 == pf)
        return;
      ChartPanel p = new ChartPanel(chartNode.getChart());
      job.setPrintable(p, pf2);
      if (!job.printDialog())
        return;
      try {
        job.print();
      } catch (PrinterException e) {
        e.printStackTrace();
        MZmineGUI.displayMessage("Error printing: " + e.getMessage());
      }
    });
  }
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:25,代码来源:JFreeChartUtils.java

示例5: MyDemoPane

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
public MyDemoPane() {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    this.chartViewer = new ChartViewer(chart);
    this.chartViewer.addChartMouseListener(this);
    getChildren().add(this.chartViewer);
   
    CrosshairOverlayFX crosshairOverlay = new CrosshairOverlayFX();
    this.xCrosshair = new Crosshair(Double.NaN, Color.GRAY, 
            new BasicStroke(0f));
    this.xCrosshair.setStroke(new BasicStroke(1.5f, 
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, 
            new float[]{2.0f, 2.0f}, 0));
    this.xCrosshair.setLabelVisible(true);
    this.yCrosshair = new Crosshair(Double.NaN, Color.GRAY, 
            new BasicStroke(0f));
    this.yCrosshair.setStroke(new BasicStroke(1.5f, 
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, 
            new float[] {2.0f, 2.0f}, 0));
    this.yCrosshair.setLabelVisible(true);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);
    
    Platform.runLater(() -> {
        this.chartViewer.getCanvas().addOverlay(crosshairOverlay);
    });
}
 
开发者ID:jfree,项目名称:jfree-fxdemos,代码行数:28,代码来源:CrosshairOverlayFXDemo1.java

示例6: start

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
@Override 
public void start(Stage stage) throws Exception {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);  
    
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: TimeSeriesFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show();
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:13,代码来源:TimeSeriesChartFXDemo1.java

示例7: exportToClipboard

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
public static void exportToClipboard(ChartViewer chartNode) {
  final Clipboard clipboard = Clipboard.getSystemClipboard();
  final ClipboardContent content = new ClipboardContent();
  final int width = (int) chartNode.getWidth();
  final int height = (int) chartNode.getHeight();
  WritableImage img = new WritableImage(width, height);
  SnapshotParameters params = new SnapshotParameters();
  chartNode.snapshot(params, img);
  content.putImage(img);
  clipboard.setContent(content);
}
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:12,代码来源:JFreeChartUtils.java

示例8: showSaveDialog

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
public static void showSaveDialog(ChartViewer chartNode, ImgFileType fileType) {
  FileChooser fileChooser = new FileChooser();
  switch (fileType) {

    case JPG:
      fileChooser.setTitle("Export to JPG");
      fileChooser.getExtensionFilters().add(new ExtensionFilter("JPEG", "*.jpg"));
      break;

    case PNG:
      fileChooser.setTitle("Export to PNG");
      fileChooser.getExtensionFilters()
          .add(new ExtensionFilter("Portable Network Graphics (PNG)", "*.png"));
      break;

    case SVG:
      fileChooser.setTitle("Export to SVG");
      fileChooser.getExtensionFilters()
          .add(new ExtensionFilter("Scalable Vector Graphics (SVG)", "*.svg"));
      break;

    case PDF:
      fileChooser.setTitle("Export to PDF");
      fileChooser.getExtensionFilters()
          .add(new ExtensionFilter("Portable Document Format (PDF)", "*.pdf"));
      break;

    case EMF:
      fileChooser.setTitle("Export to EMF");
      fileChooser.getExtensionFilters().add(new ExtensionFilter("EMF image", "*.emf"));
      break;

    case EPS:
      fileChooser.setTitle("Export to EPS");
      fileChooser.getExtensionFilters().add(new ExtensionFilter("EPS Image", "*.eps"));
      break;
  }

  // Remember last directory
  if (lastSaveDirectory != null && lastSaveDirectory.isDirectory())
    fileChooser.setInitialDirectory(lastSaveDirectory);

  // Show the file chooser
  File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow());

  // If nothing was chosen, quit
  if (file == null)
    return;

  // Save the last open directory
  lastSaveDirectory = file.getParentFile();

  // Do the export in a new thread
  final File finalFile = file;
  new Thread(() -> {
    exportToImageFile(chartNode, finalFile, fileType);
  }).start();
}
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:59,代码来源:JFreeChartUtils.java

示例9: exportToImageFile

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
public static void exportToImageFile(ChartViewer chartNode, File file, ImgFileType fileType) {

    final JFreeChart chart = chartNode.getChart();
    final int width = (int) chartNode.getWidth();
    final int height = (int) chartNode.getHeight();

    try {

      switch (fileType) {

        case JPG:
          ExportUtils.writeAsJPEG(chart, width, height, file);
          break;

        case PNG:
          ExportUtils.writeAsPNG(chart, width, height, file);
          break;

        case SVG:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsSVG(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case PDF:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsPDF(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EMF:
          FileOutputStream out2 = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EMFGraphics2D g2d2 = new EMFGraphics2D(out2, new Dimension(width, height));
          g2d2.startExport();
          chart.draw(g2d2, new Rectangle(width, height));
          g2d2.endExport();
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EPS:
          FileOutputStream out = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
          g2d.setGraphicContext(new GraphicContext());
          g2d.setupDocument(out, width, height);
          chart.draw(g2d, new Rectangle(width, height));
          g2d.finish();
          setDrawSeriesLineAsPath(chart, false);
          out.close();
          break;

      }

    } catch (IOException e) {
      MZmineGUI.displayMessage("Unable to save image: " + e.getMessage());
      e.printStackTrace();
    }
  }
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:60,代码来源:JFreeChartUtils.java

示例10: IntelligentItemLabelGenerator

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
/**
 * 
 * @param chartNode
 * @param plot
 * @param reservedPoints Number of screen pixels to reserve for each label, so that the labels do
 *        not overlap
 * @param underlyingGenerator
 */
public IntelligentItemLabelGenerator(ChartViewer chartNode, int reservedPixels,
    XYItemLabelGenerator underlyingGenerator) {
  this.chartNode = chartNode;

  this.reservedPixels = reservedPixels;
  this.underlyingGenerator = underlyingGenerator;
}
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:16,代码来源:IntelligentItemLabelGenerator.java

示例11: ZoomHandlerFX

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
/**
 * Creates a new instance with no modifier keys required.
 * 
 * @param id  the handler ID ({@code null} not permitted).
 * @param parent  the chart viewer.
 */
public ZoomHandlerFX(String id, ChartViewer parent) { 
    this(id, parent, false, false, false, false);
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:10,代码来源:ZoomHandlerFX.java

示例12: ZoomHandlerFX

import org.jfree.chart.fx.ChartViewer; //导入依赖的package包/类
/**
 * Creates a new instance with no modifier keys required.
 * 
 * @param id  the handler ID (<code>null</code> not permitted).
 * @param parent  the chart viewer.
 */
public ZoomHandlerFX(String id, ChartViewer parent) { 
    this(id, parent, false, false, false, false);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:10,代码来源:ZoomHandlerFX.java


注:本文中的org.jfree.chart.fx.ChartViewer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。