gpt4 book ai didi

org.knowm.xchart.XChartPanel类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 14:34:40 26 4
gpt4 key购买 nike

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

XChartPanel介绍

[英]A Swing JPanel that contains a Chart

Right-click + Save As... or ctrl+S pops up a Save As dialog box for saving the chart as PNG, JPEG, etc. file.
[中]包含图表的Swing JPanel
右键单击+另存为。。。或者ctrl+S弹出另存为对话框,将图表另存为PNG、JPEG等文件。

代码示例

代码示例来源:origin: knowm/XChange

series.setMarker(SeriesMarkers.NONE);
return new XChartPanel(chart);

代码示例来源:origin: knowm/XChange

@Override
 public void run() {
  try {
   updateData();
   // update chart
   chart.updateXYSeries(BIDS_SERIES_NAME, xAxisBidData, yAxisBidData, null);
   chart.updateXYSeries(ASKS_SERIES_NAME, xAxisAskData, yAxisAskData, null);
   chartPanel.revalidate();
   chartPanel.repaint();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
};

代码示例来源:origin: knowm/XChart

/**
 * Constructor
 *
 * @param chart
 */
public XChartPanel(final T chart) {
 this.chart = chart;
 preferredSize = new Dimension(chart.getWidth(), chart.getHeight());
 // Right-click listener for saving chart
 this.addMouseListener(new PopUpMenuClickListener());
 // Mouse motion listener for data label popup
 ToolTips toolTips = chart.getToolTips();
 if (toolTips != null) {
  MouseMotionListener mml = toolTips.getMouseMotionListener();
  if (mml != null) {
   this.addMouseMotionListener(mml);
  }
 }
 // Control+S key listener for saving chart
 KeyStroke ctrlS =
   KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
 this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ctrlS, "save");
 this.getActionMap().put("save", new SaveAction());
 // Control+E key listener for saving chart
 KeyStroke ctrlE =
   KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
 this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ctrlE, "export");
 this.getActionMap().put("export", new ExportAction());
}

代码示例来源:origin: knowm/XChart

protected void repaintChart() {
 chartPanel.repaint();
}

代码示例来源:origin: org.knowm.xchart/xchart

/**
 * Constructor
 *
 * @param chart
 */
public XChartPanel(final T chart) {
 this.chart = chart;
 preferredSize = new Dimension(chart.getWidth(), chart.getHeight());
 // Right-click listener for saving chart
 this.addMouseListener(new PopUpMenuClickListener());
 // Mouse motion listener for data label popup
 ToolTips toolTips = chart.getToolTips();
 if (toolTips != null) {
  MouseMotionListener mml = toolTips.getMouseMotionListener();
  if (mml != null) {
   this.addMouseMotionListener(mml);
  }
 }
 // Control+S key listener for saving chart
 KeyStroke ctrlS =
   KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
 this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ctrlS, "save");
 this.getActionMap().put("save", new SaveAction());
 // Control+E key listener for saving chart
 KeyStroke ctrlE =
   KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
 this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ctrlE, "export");
 this.getActionMap().put("export", new ExportAction());
}

代码示例来源:origin: knowm/XChange

public XChartPanel<XYChart> buildPanel() throws IOException {
 System.out.println("fetching data...");
 updateData();
 // create chart
 chart =
   new XYChartBuilder()
     .width(800)
     .height(400)
     .title("Real-time Bitcoinium Order Book - BITSTAMP_BTC_USD")
     .xAxisTitle("BTC")
     .yAxisTitle("USD")
     .build();
 // Customize Chart
 chart.getStyler().setLegendPosition(LegendPosition.InsideNE);
 chart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Area);
 // add series
 XYSeries series = chart.addSeries(BIDS_SERIES_NAME, xAxisBidData, yAxisBidData);
 series.setMarker(SeriesMarkers.NONE);
 series = chart.addSeries(ASKS_SERIES_NAME, xAxisAskData, yAxisAskData);
 series.setMarker(SeriesMarkers.NONE);
 return new XChartPanel<>(chart);
}

代码示例来源:origin: knowm/XChange

@Override
 public void run() {
  try {
   BitcoiniumTicker bitcoiniumTicker =
     bitcoiniumMarketDataService.getBitcoiniumTicker("BTC", "BITSTAMP_USD");
   System.out.println(bitcoiniumTicker.toString());
   Date timestamp = new Date(bitcoiniumTicker.getTimestamp());
   float price = bitcoiniumTicker.getLast().floatValue();
   if (xAxisData.get(xAxisData.size() - 1).getTime() != timestamp.getTime()) {
    xAxisData.add(timestamp);
    yAxisData.add(price);
    XYSeries series = chart.updateXYSeries(SERIES_NAME, xAxisData, yAxisData, null);
    chartPanel.revalidate();
    chartPanel.repaint();
    System.out.println(series.getXData());
    System.out.println(series.getYData());
   } else {
    System.out.println("No new data.");
   }
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
};

代码示例来源:origin: knowm/XChart

protected void addCharts(JTabbedPane tabbedPane, Map<String, Chart> chartMap) {
 for (Entry<String, Chart> e : chartMap.entrySet()) {
  Chart chart = e.getValue();
  if (chart == null) {
   continue;
  }
  XChartPanel chartPanel = new XChartPanel(chart);
  tabbedPane.addTab(e.getKey(), chartPanel);
 }
}

代码示例来源:origin: knowm/XChart

/**
  * Repaint the XChartPanel given the provided index.
  *
  * @param index
  */
 public void repaintChart(int index) {

  chartPanels.get(index).revalidate();
  chartPanels.get(index).repaint();
 }
}

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  XChartPanel<T> chartPanel = new XChartPanel<T>(charts.get(0));
  chartPanels.add(chartPanel);
  frame.add(chartPanel);
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  realtimeChart02.updateData();
  chartPanel.revalidate();
  chartPanel.repaint();
 }
};

代码示例来源:origin: knowm/XChart

public XChartPanel<BubbleChart> buildPanel() {
 return new XChartPanel<BubbleChart>(getChart());
}

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  realtimeChart03.updateData();
  chartPanel.revalidate();
  chartPanel.repaint();
 }
};

代码示例来源:origin: knowm/XChart

public XChartPanel<XYChart> buildPanel() {
 return new XChartPanel<XYChart>(getChart());
}

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  realtimeChart06.updateData();
  chartPanel.revalidate();
  chartPanel.repaint();
 }
};

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().setLayout(new GridLayout(numRows, numColumns));
  for (T chart : charts) {
   if (chart != null) {
    XChartPanel<T> chartPanel = new XChartPanel<T>(chart);
    chartPanels.add(chartPanel);
    frame.add(chartPanel);
   } else {
    JPanel chartPanel = new JPanel();
    frame.getContentPane().add(chartPanel);
   }
  }
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  realtimeChart05.updateData();
  chartPanel.revalidate();
  chartPanel.repaint();
 }
};

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  // Create and set up the window.
  JFrame frame = new JFrame("Advanced Example");
  frame.setLayout(new BorderLayout());
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  // chart
  JPanel chartPanel = new XChartPanel<XYChart>(chart);
  frame.add(chartPanel, BorderLayout.CENTER);
  // label
  JLabel label = new JLabel("Blah blah blah.", SwingConstants.CENTER);
  frame.add(label, BorderLayout.SOUTH);
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});

代码示例来源:origin: knowm/XChart

@Override
 public void run() {
  realtimeChart01.updateData();
  chartPanel.revalidate();
  chartPanel.repaint();
 }
};

代码示例来源:origin: knowm/XChart

/**
 * Create the GUI and show it. For thread safety, this method should be invoked from the event
 * dispatch thread.
 */
private static void createAndShowGUI() {
 // Create and set up the window.
 JFrame frame = new JFrame("XChart Swing Demo");
 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 // Add content to the window.
 JPanel chartPanel = new XChartPanel(new AreaChart01().getChart());
 frame.add(chartPanel);
 // Display the window.
 frame.pack();
 frame.setVisible(true);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com