carfield.com.hk
Graph.class
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
Graph.java
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">
import javax.swing.*;
import java.awt.*;
/**
* Title: Graph<p>
* Description: Simple program to produce a graph for the book<p>
* Copyright: Copyright (c) Mark Watson<p>
* Company: <p>
* @author Mark Watson
* @version 1.0
*/
public class Graph extends JFrame {
GraphPanel jPanel1;
float [] data;
public Graph() {
try {
int size = 500;
data = new float[size];
float xmin = 0;
float xmax = 10;
for (int i=0; i<size; i++) {
float x = i;
x = xmin + x * (xmax - xmin) / (float)size;
if (i==190) System.out.println("x="+x);
float x1 = (float)Math.sin(x);
float x2 = (float)Math.sin(x * 0.4f);
float x3 = (float)Math.sin(x * 3.0f);
data[i] = x1 * x2 * x3;
}
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Graph untitled11 = new Graph();
}
private void jbInit() throws Exception {
jPanel1 = new GraphPanel(data);
jPanel1.setBackground(Color.white);
this.setDefaultCloseOperation(3);
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
setSize(550, 500);
jPanel1.setVisible(true);
setVisible(true);
}
}</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
GraphPanel.class
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
GraphPanel.java
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">/**
* Title: <p>
* Description: <p>
* Copyright: Copyright (c) <p>
* Company: <p>
* @author
* @version 1.0
*/
import javax.swing.*;
import java.awt.*;
public class GraphPanel extends java.awt.Canvas { // JPanel {
public GraphPanel(float [] data) {
super();
this.data = data;
}
Color black = new Color(0, 0, 0);
float [] data;
public void paint(Graphics g) {
if (data == null) return;
int width = this.getWidth();
int height = this.getHeight();
System.out.println("height="+height);
float min = 99999999.9f;
float max = -min;
int maxindex = 0;
float maxval = 0.0f;
for (int i=0; i<data.length; i++) {
if (min > data[i]) min = data[i];
if (max < data[i]) {
max = data[i];
maxindex = i;
maxval = max;
}
}
System.out.println("min=" + min +", max=" + max +
", max index="+maxindex + ", max val="+maxval);
g.setColor(black);
for (int i=0; i<data.length - 1; i++) {
float y1 = height - 5 - 0.95f *height * ((data[i] - min) / (max - min));
float y2 = height - 5 - 0.95f *height * ((data[i+1] - min) / (max - min));
//System.out.println("data["+i+"]="+data[i]+", y1="+y1+", y2="+y2);
g.drawLine(i+20, (int)y1, i+21, (int)y2);
}
float yzero = height - 5 - 0.95f *height * ((0.0f - min) / (max - min));
g.drawLine(20, (int)yzero, data.length + 19, (int)yzero);
}
}
</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
UnnamedPackage.dependency
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
dependency cache.dfPackage
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
graph.jpr
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z
misc.dfPackage
2000-06-15T16:00:00Z
2000-06-15T16:00:00Z
<br/><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
2000-06-15T16:00:00Z