OpenJDK / jdk / hs
changeset 8958:a9671f5efee8
7027688: /applets/SimpleGraph demo needs to be improved
Reviewed-by: rupashka
author | mrkam |
---|---|
date | Thu, 24 Mar 2011 18:07:40 +0100 |
parents | d49d5d85a183 |
children | fdeb815ed424 |
files | jdk/src/share/demo/applets/SimpleGraph/GraphApplet.java |
diffstat | 1 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/share/demo/applets/SimpleGraph/GraphApplet.java Thu Mar 24 18:03:09 2011 +0100 +++ b/jdk/src/share/demo/applets/SimpleGraph/GraphApplet.java Thu Mar 24 18:07:40 2011 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,22 +29,26 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - */ import java.awt.Graphics; + +@SuppressWarnings("serial") public class GraphApplet extends java.applet.Applet { + double f(double x) { - return (Math.cos(x/5) + Math.sin(x/7) + 2) * getSize().height / 4; + return (Math.cos(x / 5) + Math.sin(x / 7) + 2) * getSize().height / 4; } + @Override public void paint(Graphics g) { - for (int x = 0 ; x < getSize().width ; x++) { - g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1)); + for (int x = 0; x < getSize().width; x++) { + g.drawLine(x, (int) f(x), x + 1, (int) f(x + 1)); } } - public String getAppletInfo() { - return "Draws a sin graph."; - } + + @Override + public String getAppletInfo() { + return "Draws a sin graph."; + } }