Contouring : Math Functions « Advanced Graphics « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Advanced Graphics » Math FunctionsScreenshots 
Contouring
Contouring

import java.awt.*;
import java.applet.*;
import java.net.URL;
import java.util.*;
import graph.*;
/*************************************************************************
**
**    Applet example6
**                                              Version 1.0   February 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 the contouring cababilities
**    of the Contour class
**
*************************************************************************/

public class example6 extends Applet {

      LoadData dynamic;
      Contour graph;
      Label title;
      Axis    xaxis;
      Axis    yaxis;


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

/*
**      Instantiate the Contour class and calculate the data
*/
        graph = new Contour();
        graph.setDataBackground(new Color(0.933f,0.914f,0.749f));
        graph.setContourColor(new Color(0.180f,0.545f,0.341f));
        graph.setLabelledContourColor(new Color(0.5f,.0f,0.0f));

        graph.setLabelPrecision(2);
        graph.setLabelSignificance(2);


//        this.showStatus("Creating Data to Contour!");

        createGrid(graph);

        graph.square       = true;
/*
**      Build the title and place it at the top of the graph
*/
        graph.setFont(new Font("TimesRoman",Font.PLAIN,25));
        title = new Label("Contouring Example", Label.CENTER);
        title.setFont(new Font("TimesRoman",Font.PLAIN,25));

        setLayoutnew BorderLayout() );
        add("North",  title);
        add("Center", graph);
/*
**      Instantiate the xaxis and attach the dataset.
*/
        xaxis = graph.createXAxis();
        xaxis.setTitleText("X_axis");
        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.setTitleText("Y_axis");
        yaxis.setTitleColor(Color.magenta)
        yaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
        yaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));


      }



      public void createGrid(Contour graph) {
         int i,j;
         int count;
         
         int nx = 50;
         int ny = 50;

         double xmin = -1.0;
         double xmax =  1.0;
         double ymax =  1.0;
         double ymin = -1.0;


         double array[] new double[nx*ny];
         double x, y, rad;

         double h1, h2, h3;

         h1 = 0.5*0.5;

         h2 = 0.75*0.75;

         h3 = 0.25*0.25;

         count = 0;

         for(j=0; j<ny; j++) {

             y = 2.0*(double)j/(double)(ny-11.0;

             for(i=0; i<nx; i++) {
                x = 2.0*(double)i/(double)(nx-11.0;

                rad = (x-0.5)*(x-0.5(y+0.5)*(y+0.5);
                array[count= Math.exp-rad/h1 );

                rad = (x+0.3)*(x+0.3(y-0.75)*(y-0.75);
                array[count+= Math.exp-rad/h2 );

                rad = (x+0.7)*(x+0.7(y+0.6)*(y+0.6);
                array[count+= Math.exp-rad/h3 );


                count++;  
        }
     }

           graph.setGrid(array,nx,ny);
           graph.setRange(xmin,xmax,ymin,ymax);
           graph.setLimitsToGrid(true);
           graph.setLabelLevels(3);
           graph.setNLevels(20);
      }
      public static void main(String[] a){
         javax.swing.JFrame f = new javax.swing.JFrame();
         Applet app = new example6();
         app.init();
         
         f.getContentPane().add (app);

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





           
       
Graph-Contouring.zip( 233 k)
Related examples in the same category
1. Math Function ChartMath Function Chart
2. Draw Your Own Contour FunctionDraw Your Own Contour Function
3. Draw Math Function Your OwnDraw Math Function Your Own
4. Draw Math Function In CorrdinateDraw Math Function In Corrdinate
5. Display the graph of a single function of one variableDisplay the graph of a single function of one variable
6. DerivativesDerivatives
7. Function CompositionFunction Composition
8. Draw the functionDraw the function
9. Math function graph 1Math function graph 1
10. Draw math function on the coordinateDraw math function on the coordinate
11. Calculate the arithmetic functionCalculate the arithmetic function
12. Math function and barMath function and bar
13. Science Parser
w___ww___.___j__a___v_a___2__s.__c__om__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.