private void showGraph() { final JFreeChart chart = ChartFactory.createScatterPlot( title, // chart title xValue, // x axis label yValue, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); DemoRenderer renderer = new DemoRenderer(); // renderer.setBasePaint(Color.blue); // renderer.setSeriesLinesVisible(0, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(640, 480)); final ApplicationFrame frame = new ApplicationFrame(title); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
/** * Starting point for the demonstration application. */ public static void showChart( String name, String xAxis, String yAxis1, XYDataset dataset1, String yAxis2, XYDataset dataset2 ) { final JFreeChart chart = createChart(name, xAxis, yAxis1, dataset1, yAxis2, dataset2); final ChartPanel chartPanel = createPanel(chart); final ApplicationFrame app = new ApplicationFrame(name); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); app.setContentPane(chartPanel); app.pack(); RefineryUtilities.centerFrameOnScreen(app); app.setVisible(true); }
@Override public void run(final String arg0) { // http://www.math.hu-berlin.de/~ccafm/lehre_BZQ_Numerik/allg/JAVA_Pakete/JFreeChart/JFreeChart-Tutorial.html final String title = "Contrast Transfer Function"; final XYSplineRenderer spline = new XYSplineRenderer(); spline.setSeriesPaint(0, Color.RED); spline.setSeriesPaint(1, Color.BLUE); spline.setSeriesShapesVisible(0, false); spline.setSeriesShapesVisible(1, false); final NumberAxis xax = new NumberAxis("q in 1/nm"); final NumberAxis yax = new NumberAxis("CTF"); final XYPlot plot = new XYPlot(createDataset(), xax, yax, spline); final JFreeChart chart = new JFreeChart(plot); final ChartPanel chartPanel = new ChartPanel(chart); final ApplicationFrame chartFrame = new ApplicationFrame(title); chartFrame.setContentPane(chartPanel); chartFrame.pack(); RefineryUtilities.centerFrameOnScreen(chartFrame); chartFrame.setVisible(true); }
public static JMenuBar getMenu( JFreeChart chart,ApplicationFrame jg ){ Action SaveAs = new SaveAs_Action(chart,"Save as...",null,"Save as..."); Action Quit = new Quit_Action(jg,"Quit",null,"Quit"); JMenuBar JMB = new JMenuBar(); JMenu file = new JMenu("File"); JMB.add(file); file.add(SaveAs);file.add(Quit); return JMB; }
public static JMenuBar getMenu( Chart3D chart,ApplicationFrame jg ){ Action SaveAs = new SaveAs_Action3D(chart,"Save as...",null,"Save as..."); Action Quit = new Quit_Action(jg,"Quit",null,"Quit"); JMenuBar JMB = new JMenuBar(); JMenu file = new JMenu("File"); JMB.add(file); file.add(SaveAs);file.add(Quit); return JMB; }
public Quit_Action(ApplicationFrame ed, String text, ImageIcon icon, String desc) { // String desc, Integer mnemonic) { like mnemomnic=KeyEvent.VK_AT // will be updated after "escape" command mode is introduced // (like in "vi") super(text, icon); TEdit = ed; putValue(SHORT_DESCRIPTION, desc); // putValue(MNEMONIC_KEY, mnemonic); //change it after "escape" is done }
/** * Displays a chart in a frame. * @param chart the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new Dimension(1024, 400)); // Application frame ApplicationFrame frame = new ApplicationFrame("Ta4j example - Buy and sell signals to chart"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Displays a chart in a frame. * @param chart the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new Dimension(1024, 400)); // Application frame ApplicationFrame frame = new ApplicationFrame("Ta4j example - Cash flow to chart"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Displays a chart in a frame. * @param chart the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new java.awt.Dimension(740, 300)); // Application frame ApplicationFrame frame = new ApplicationFrame("Ta4j example - Candlestick chart"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Displays a chart in a frame. * @param chart the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new java.awt.Dimension(500, 270)); // Application frame ApplicationFrame frame = new ApplicationFrame("Ta4j example - Indicators to chart"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Displays a chart in a frame. * * @param chart * the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new Dimension(1024, 400)); // Application frame ApplicationFrame frame = new ApplicationFrame("Ta4j example - Buy and sell signals to chart"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Displays a chart in a frame. * * @param chart the chart to be displayed */ private static void displayChart(JFreeChart chart) { // Chart panel ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new java.awt.Dimension(500, 270)); // Application frame ApplicationFrame frame = new ApplicationFrame("BTC/USD with Chande " + "Moving Oscillator"); frame.setContentPane(panel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
/** * Create State Transition Matrix. * * @param eList * list with possible events * @param seqList * list with sequences * @return JTable */ public static Container createStateTrans(final EventList eList, final List<EventList> seqList) { // Create frame final Dimension frameDimension = new Dimension( (int) (PageSize.A4.getWidth()), (int) (PageSize.A4.getHeight())); ApplicationFrame frame = new ApplicationFrame("Vidney"); frame.setSize(frameDimension); String[][] matrix = setUp(eList); String[][] matrixUse = fillMatrix(matrix, seqList); String[][] outputM = new String[matrixUse.length - 1][matrixUse.length]; for (int i = 1; i < matrixUse[0].length; i++) { for (int j = 0; j < matrixUse[1].length; j++) { outputM[i - 1][j] = matrixUse[i][j]; } } JTable table = new JTable(outputM, matrixUse[0]); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setColumnHeaderView(table.getTableHeader()); scrollPane.setPreferredSize(table.getPreferredSize()); JPanel p = new JPanel(new BorderLayout()); p.add(scrollPane, BorderLayout.CENTER); // Not a very clean way frame.setContentPane(p); frame.setVisible(true); frame.setVisible(false); return scrollPane; }
public static void display(JFreeChart plot) { ApplicationFrame frame = new ApplicationFrame(plot.getTitle().getText()); ChartPanel plotPanel = new ChartPanel(plot); plotPanel.setPreferredSize(new java.awt.Dimension(WIDTH, HEIGHT)); frame.setContentPane(plotPanel); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
public static void main(String[] args) throws IOException { final File inputcsv = new File("/Volumes/SSD/training_latlng"); final List<double[]> data = new ArrayList<double[]>(10000000); // read in images final BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line; int i = 0; br.readLine(); while ((line = br.readLine()) != null) { final String[] parts = line.split(" "); final double longitude = Double.parseDouble(parts[2]); final double latitude = Double.parseDouble(parts[1]); data.add(new double[] { longitude, latitude }); if (longitude >= -0.1 && longitude < 0 && latitude > 50 && latitude < 54) System.out.println(parts[0] + " " + latitude + " " + longitude); // if (i++ % 10000 == 0) // System.out.println(i); } br.close(); System.out.println("Done reading"); final float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = (float) data.get(i)[0]; dataArr[1][i] = (float) data.get(i)[1]; } final NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); final NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); final FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
@Override public void run(final String arg0) { // http://www.tutorialspoint.com/jfreechart/index.htm final ApplicationFrame chart = new ApplicationFrame("Angular aperture"); final JFreeChart xyChart = ChartFactory.createXYLineChart( "Angular aperture", "aperture diameter in µm", "delta in nm", createDataset(), PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(xyChart); chartPanel.setPreferredSize(new java.awt.Dimension(800, 600)); final XYPlot plot = xyChart.getXYPlot(); final ValueAxis axis = plot.getRangeAxis(); axis.setAutoRange(false); axis.setUpperBound(2.0); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.BLUE); renderer.setSeriesStroke(0, new BasicStroke(2f)); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesShapesVisible(2, false); plot.setRenderer(renderer); final double x_opt = mrad2µm(alpha_opt); final double y_opt = 0.9 * Math.pow(C_s * Math.pow(lambda, 3), 0.25) * 1e9; final XYLineAnnotation line = new XYLineAnnotation(0, y_opt, mrad2µm(Math .ceil(2 * alpha_opt)), y_opt); plot.addAnnotation(line); final XYPointerAnnotation pointer = new XYPointerAnnotation(String.format( "Smallest error disc: %.2g nm @ %.1f µm", y_opt, x_opt), x_opt, y_opt, 5.0 * Math.PI / 4.0); stylePointer(pointer); plot.addAnnotation(pointer); final double aperture_alpha = 0.5 * 20 * 1e-6 / fl; final XYPointerAnnotation resolution = new XYPointerAnnotation(String .format("Resolution with %.0f µm aperture: %.2f nm", mrad2µm( aperture_alpha * 1e3), delta(aperture_alpha) * 1e9), mrad2µm( aperture_alpha * 1e3), delta(aperture_alpha) * 1e9, 1.0 * Math.PI / 4.0); stylePointer(resolution); plot.addAnnotation(resolution); chart.setContentPane(chartPanel); chart.pack(); RefineryUtilities.centerFrameOnScreen(chart); chart.setVisible(true); }
/** * Create visualization for chart. * * @param chart * chart * @return JPanel */ public static JPanel visualBoxPlot(final JFreeChart chart) { final Dimension frameDimension = new Dimension(500, 500); ApplicationFrame frame = new ApplicationFrame("Vidney"); frame.setSize(frameDimension); final ChartPanel chartPanel = new ChartPanel(chart); frame.setContentPane(chartPanel); return chartPanel; }
/** * Visualizes the Histogram. * * @param chart * chart that should be visualized * @return JPanel */ public static JPanel visualHist(final JFreeChart chart) { final Dimension frameDimension = new Dimension(500, 500); ApplicationFrame frame = new ApplicationFrame("Vidney"); frame.setSize(frameDimension); final ChartPanel chartPanel = new ChartPanel(chart); frame.setContentPane(chartPanel); return chartPanel; }
/** * Creates new form ChartAndData */ public ChartAndData(String title, JFreeChart chart, Dimension dimension) { super(title); initComponents(); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(dimension); JFrame frame = new ApplicationFrame(title); frame.add(chartPanel); jpcharts.add(frame.getContentPane()); }