Chart based on Graph library : Chart « Advanced Graphics « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Advanced Graphics » ChartScreenshots 
Chart based on Graph library
Chart based on Graph library
 
import java.awt.*;
import java.applet.*;
import java.net.URL;
import java.util.*;
import graph.*;

/*************************************************************************
**
**    Applet example3
**                                              Version 1.0   January 1996
**
**************************************************************************
**    Copyright (C) 1996 Leigh Brookshaw
**
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation; either version 2 of the License, or
**    (at your option) any later version.
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**************************************************************************
**
**    This applet demonstrates the interactive event handling of
**    the G2Dint class
**
*************************************************************************/

public class example3 extends Applet {

      LoadData dynamic;
      G2Dint graph;
      Label title;
      DataSet data1;
      Axis    xaxis;
      Axis    yaxis;


      public void init() {
        int i;
        int j;

/*
**      Get the title of the plot and the data URL as parsed parameters
*/
        String st = "TITLE";
        String data  = "elliptical.data";
/*
**      Instantiate the Graph class and the LoadData class
*/
        graph = new G2Dint();
        dynamic = new LoadData();

        graph.borderTop    = 30;
        graph.borderBottom = 10;
        graph.borderRight  = 40;
        graph.setDataBackground(new Color(50,50,200));
        graph.setGraphBackground(new Color(0,200,255));
/*
**      Build the title and place it at the top of the graph
*/
        graph.setFont(new Font("TimesRoman",Font.PLAIN,25));
        title = new Label(st, Label.CENTER);
        title.setFont(new Font("TimesRoman",Font.PLAIN,25));

        setLayoutnew BorderLayout() );
        add("North",  title);
        add("Center", graph);
/*
**      Start a new thread and load the data
*/
        try {
        data1 = dynamic.loadDataSet(this.getClass().getResource(data), graph);
        catch (Exception e) {
          System.out.println("Failed to load data file!");
        }
/*
**      Specify the data line color
*/
        data1.linecolor = new Color(255,255,0);
/*
**      Instantiate the xaxis and attach the dataset.
*/
        xaxis = graph.createXAxis();
        xaxis.attachDataSet(data1);
        xaxis.setTitleText("Wavelength_(angstroms)");
        xaxis.setTitleColor(Color.magenta);
        xaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
        xaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));


/*
**      Instantiate the yaxis and attach the dataset.
*/
        yaxis = graph.createYAxis();
        yaxis.attachDataSet(data1);
        yaxis.setTitleText("Flux");
        yaxis.setTitleColor(Color.magenta)
        yaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
        yaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));


      }
      public static void main(String[] a){
         javax.swing.JFrame f = new javax.swing.JFrame();
         Applet app = new example3();
         app.init();
         
         f.getContentPane().add (app);

         f.pack();
         f.setSize (new Dimension (500500));
         f.setVisible(true);
      }



}
           
         
  
Graph-Chart.zip( 255 k)
Related examples in the same category
1. Scroll ChartScroll Chart
2. Animation Line ChartAnimation Line Chart
3. Pie ChartPie Chart
4. A rudimentary chart libraryA rudimentary chart library
5. A rudimentary bar chart classA rudimentary bar chart class
6. bar-graph drawable
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.