请高人指点。笨小弟实在不明白为什么。

jointree 2004-11-27 11:18:57
数日前,接手修改一网站。发现上面的图片产生水中波浪倒影是使用JAVA做的。但是水中倒影有时可以显示,有时却不行。经测试发现,如果在另外一台机器打开此网页则水中倒影显示正确。因为本人JAVA水平实在有够菜的。虽然反编译看到了源代码。仍然无法解决此问题。希望高人指点。笨小弟在这里多多感谢,多多给分~~~附上源代码,如下:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class Lake extends Applet implements Runnable
{Thread m_Lake;private Graphics m_Graphics;private Graphics m_WaveGraphics;private Image m_Image;private Image m_Overlay;private Image m_WaveImage;private int m_nCurrImage;private int m_nImgWidth;private int m_nImgHeight;private int m_nOvlWidth;private int m_nOvlHeight;private boolean m_fAllLoaded;private boolean m_tAnimate;private final int NUM_FRAMES = 12;private String m_ImageName;private String m_OverlayName;private URL m_HRef;private String m_Frame;private final String PARAM_image = "image";private final String PARAM_overlay = "overlay";private final String PARAM_href = "href";private final String PARAM_target = "target";
public void createAnimation()
{Image image = createImage(m_nImgWidth, m_nImgHeight + 1);
Graphics g = image.getGraphics();g.drawImage(m_Image, 0, 1, this);
for(int i = 0; i < m_nImgHeight >> 1; i++)
{g.copyArea(0, i, m_nImgWidth, 1, 0, m_nImgHeight - i);
g.copyArea(0, m_nImgHeight - 1 - i, m_nImgWidth, 1, 0, -m_nImgHeight + 1 + (i << 1));g.copyArea(0, m_nImgHeight, m_nImgWidth, 1, 0, -1 - i);}
m_WaveImage = createImage(13 * m_nImgWidth, m_nImgHeight);
m_WaveGraphics = m_WaveImage.getGraphics();
m_WaveGraphics.drawImage(image, 12 * m_nImgWidth, 0, this);
int j = 0;do{makeWaves(m_WaveGraphics, j);} while(++j < 12);
g.drawImage(m_Image, 0, 1, this);if(!"".equals(m_OverlayName))
{g.drawImage(m_Overlay, m_nImgWidth - m_nOvlWidth >> 1, m_nImgHeight - (m_nOvlHeight >> 1), this);} m_Image = image;}
public void start(){if(m_Lake == null)
{m_Lake = new Thread(this);m_Lake.start();}}
public String[][] getParameterInfo(){String as[][] = {{"image", "String", "JPG or GIF file to reflect"}, {"overlay", "String", "JPG or GIF file to use as overlay"},{"href", "URL", "URL to link to"}, {"target", "String", "Target frame"}};return as;}
public void stop(){if(m_Lake != null){m_Lake.stop();m_Lake = null;}}
private void displayImage(Graphics g){if(!m_fAllLoaded){return;}if(m_WaveImage != null)
{g.drawImage(m_WaveImage, -m_nCurrImage * m_nImgWidth, m_nImgHeight, this);
g.drawImage(m_WaveImage, (12 - m_nCurrImage) * m_nImgWidth, m_nImgHeight, this);}
g.drawImage(m_Image, 0, -1, this);}public String getAppletInfo(){return "Name: Lake v3.0\r\n" + "Author: David Griffiths\r\n" + "Created with Microsoft Visual J++ Version 1.0";}
public boolean mouseUp(Event event, int i, int j){super.mouseUp(event, i, j);
if(m_HRef == null){m_tAnimate = !m_tAnimate;} else{showStatus("" + m_HRef);getAppletContext().showDocument(m_HRef, m_Frame);}return true;}
public void run()
{
m_nCurrImage = 0;
if(!m_fAllLoaded)
{
repaint();
m_Graphics = getGraphics();
MediaTracker mediatracker = new MediaTracker(this);
m_Image = getImage(getDocumentBase(), m_ImageName);
if(!"".equals(m_OverlayName))
{
m_Overlay = getImage(getDocumentBase(), m_OverlayName);
}
mediatracker.addImage(m_Image, 0);
if(!"".equals(m_OverlayName))
{
mediatracker.addImage(m_Overlay, 1);
}
try
{
mediatracker.waitForAll();
m_fAllLoaded = !mediatracker.isErrorAny();
}
catch(InterruptedException _ex) { }
if(!m_fAllLoaded)
{
stop();
m_Graphics.drawString("Error loading images!", 10, 40);
return;
}
m_nImgWidth = m_Image.getWidth(this);
m_nImgHeight = m_Image.getHeight(this);
if(!"".equals(m_OverlayName))
{
m_nOvlWidth = m_Overlay.getWidth(this);
m_nOvlHeight = m_Overlay.getHeight(this);
}
createAnimation();
}
repaint();
do
{
try
{
while(m_tAnimate)
{
displayImage(m_Graphics);
if(++m_nCurrImage == 12)
{
m_nCurrImage = 0;
}
Thread.sleep(50L);
}
Thread.sleep(500L);
}
catch(InterruptedException _ex)
{
stop();
}
} while(true);
}

public void makeWaves(Graphics g, int i)
{
double d = (6.2831853071795862D * (double)i) / 12D;
int j = (12 - i) * m_nImgWidth;
for(int l = 0; l < m_nImgHeight; l++)
{
int k = (int)(((double)(m_nImgHeight / 14) * ((double)l + 28D) * Math.sin((double)((m_nImgHeight / 14) * (m_nImgHeight - l)) / (double)(l + 1) + d)) / (double)m_nImgHeight);
if(l < -k)
{
g.copyArea(12 * m_nImgWidth, l, m_nImgWidth, 1, -j, 0);
} else
{
g.copyArea(12 * m_nImgWidth, l + k, m_nImgWidth, 1, -j, -k);
}
}

if(!"".equals(m_OverlayName))
{
g.drawImage(m_Overlay, i * m_nImgWidth + (m_nImgWidth - m_nOvlWidth >> 1), -m_nOvlHeight >> 1, this);
}
}

public Lake()
{
m_tAnimate = true;
m_ImageName = "";
m_OverlayName = "";
m_Frame = "_self";
}
public void destroy()
{}
public void init()
{String s = getParameter("image");
if(s != null)
{m_ImageName = s;}
s = getParameter("overlay");
if(s != null)
{m_OverlayName = s;}
s = getParameter("href");
if(s != null)
{try
{ m_HRef = new URL(getDocumentBase(), s);}
catch(MalformedURLException _ex)
{
getAppletContext().showStatus("Bad URL: " + s);
return;}}
s = getParameter("target");
if(s != null)
{m_Frame = s;}}

public void paint(Graphics g)
{
if(m_fAllLoaded)
{
displayImage(g);
return;
} else
{
g.drawString("Loading images...", 10, 20);
return;
}
}
}
上面就是源代码了,你们可以去参看下网页。http://www.goldcurve.cn上面的水中倒影(可能无法显示)但是http://www.goldcurve.cn/newproduct.htm 里的水中倒影却是对的。
如果直接打开http://www.goldcurve.cn/newproduct.htm 水中倒影却又不对了。请高手帮帮了。。谢谢了。。急用啊。。。。哎。。。能解决问题多多给分,有捧场者也少少给分。。。谢了。。
...全文
154 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jointree 2004-12-05
  • 打赏
  • 举报
回复
由于笨小弟现在没有编程环境,请高手解决后。顺便帮帮打成类包。。急用啊。联系方式QQ:5848526
Email:demiapl@sina.com
问题解决后马上结分。400分结贴。。
jointree 2004-12-05
  • 打赏
  • 举报
回复
不知道能不能解决这个问题。。
zh_baiyu 2004-12-03
  • 打赏
  • 举报
回复
高手阿。
vcvj 2004-12-03
  • 打赏
  • 举报
回复
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;

public class Example
extends Applet
implements Runnable {
Thread m_Lake;
private Graphics m_Graphics;
private Graphics m_WaveGraphics;
private Image m_Image;
private Image m_Overlay;
private Image m_WaveImage;
private int m_nCurrImage;
private int m_nImgWidth;
private int m_nImgHeight;
private int m_nOvlWidth;
private int m_nOvlHeight;
private boolean m_fAllLoaded;
private boolean m_tAnimate;
private final int NUM_FRAMES = 12;
private String m_ImageName;
private String m_OverlayName;
private URL m_HRef;
private String m_Frame;
private final String PARAM_image = "image";
private final String PARAM_overlay = "overlay";
private final String PARAM_href = "href";
private final String PARAM_target = "target";
public void createAnimation() {
Image image = createImage(m_nImgWidth, m_nImgHeight + 1);
Graphics g = image.getGraphics();
g.drawImage(m_Image, 0, 1, this);
for (int i = 0; i < m_nImgHeight >> 1; i++) {
g.copyArea(0, i, m_nImgWidth, 1, 0, m_nImgHeight - i);
g.copyArea(0, m_nImgHeight - 1 - i, m_nImgWidth, 1, 0,
-m_nImgHeight + 1 + (i << 1));
g.copyArea(0, m_nImgHeight, m_nImgWidth, 1, 0, -1 - i);
}
m_WaveImage = createImage(13 * m_nImgWidth, m_nImgHeight);
m_WaveGraphics = m_WaveImage.getGraphics();
m_WaveGraphics.drawImage(image, 12 * m_nImgWidth, 0, this);
int j = 0;
do {
makeWaves(m_WaveGraphics, j);
}
while (++j < 12);
g.drawImage(m_Image, 0, 1, this);
if (!"".equals(m_OverlayName)) {
g.drawImage(m_Overlay, m_nImgWidth - m_nOvlWidth >> 1,
m_nImgHeight - (m_nOvlHeight >> 1), this);
}
m_Image = image;
}

public void start() {
if (m_Lake == null) {
m_Lake = new Thread(this);
m_Lake.start();
}
}

public String[][] getParameterInfo() {
String as[][] = {
{
"image", "String", "JPG or GIF file to reflect"}
, {
"overlay", "String", "JPG or GIF file to use as overlay"}
, {
"href", "URL", "URL to link to"}
, {
"target", "String", "Target frame"}
};
return as;
}

public void stop() {
if (m_Lake != null) {
m_Lake.stop();
m_Lake = null;
}
}

private void displayImage(Graphics g) {
if (!m_fAllLoaded) {
return;
}
if (m_WaveImage != null) {
g.drawImage(m_WaveImage, -m_nCurrImage * m_nImgWidth, m_nImgHeight, this);
g.drawImage(m_WaveImage, (12 - m_nCurrImage) * m_nImgWidth, m_nImgHeight, this);
}
if(m_Image!=null)
g.drawImage(m_Image, 0, -1, this);
}

public String getAppletInfo() {
return "Name: Lake v3.0\r\n" + "Author: David Griffiths\r\n" +
"Created with Microsoft Visual J++ Version 1.0";
}

public boolean mouseUp(Event event, int i, int j) {
super.mouseUp(event, i, j);
if (m_HRef == null) {
m_tAnimate = !m_tAnimate;
}
else {
showStatus("" + m_HRef);
getAppletContext().showDocument(m_HRef, m_Frame);
}
return true;
}

public void run() {
m_nCurrImage = 0;
if (!m_fAllLoaded) {
repaint();
m_Graphics = getGraphics();
MediaTracker mediatracker = new MediaTracker(this);
m_Image = getImage(getDocumentBase(), m_ImageName);
if (!"".equals(m_OverlayName)) {
m_Overlay = getImage(getDocumentBase(), m_OverlayName);
}
mediatracker.addImage(m_Image, 0);
if (!"".equals(m_OverlayName)) {
mediatracker.addImage(m_Overlay, 1);
}
try {
mediatracker.waitForAll();
m_fAllLoaded = !mediatracker.isErrorAny();
}
catch (InterruptedException _ex) {}
if (!m_fAllLoaded) {
stop();
m_Graphics.drawString("Error loading images!", 10, 40);
return;
}
m_nImgWidth = m_Image.getWidth(this);
m_nImgHeight = m_Image.getHeight(this);
if (!"".equals(m_OverlayName)) {
m_nOvlWidth = m_Overlay.getWidth(this);
m_nOvlHeight = m_Overlay.getHeight(this);
}
createAnimation();
}
repaint();
do {
try {
while (m_tAnimate) {
displayImage(m_Graphics);
if (++m_nCurrImage == 12) {
m_nCurrImage = 0;
}
Thread.sleep(50L);
}
Thread.sleep(500L);
}
catch (InterruptedException _ex) {
stop();
}
}
while (true);
}

public void makeWaves(Graphics g, int i) {
double d = (6.2831853071795862D * (double) i) / 12D;
int j = (12 - i) * m_nImgWidth;
for (int l = 0; l < m_nImgHeight; l++) {
int k = (int) ( ( (double) (m_nImgHeight / 14) * ( (double) l + 28D) *
Math.sin( (double) ( (m_nImgHeight / 14) *
(m_nImgHeight - l)) /
(double) (l + 1) + d)) / (double) m_nImgHeight);
if (l < -k) {
g.copyArea(12 * m_nImgWidth, l, m_nImgWidth, 1, -j, 0);
}
else {
g.copyArea(12 * m_nImgWidth, l + k, m_nImgWidth, 1, -j, -k);
}
}

if (!"".equals(m_OverlayName)) {
g.drawImage(m_Overlay, i * m_nImgWidth + (m_nImgWidth - m_nOvlWidth >> 1),
-m_nOvlHeight >> 1, this);
}
}

public void init() {
m_tAnimate = true;
m_ImageName = "";
m_OverlayName = "";
m_Frame = "_self";
String s = getParameter("image");
if (s != null) {
m_ImageName = s;
}
s = getParameter("overlay");
if (s != null) {
m_OverlayName = s;
}
s = getParameter("href");
if (s != null) {
try {
m_HRef = new URL(getDocumentBase(), s);
}
catch (MalformedURLException _ex) {
getAppletContext().showStatus("Bad URL: " + s);
return;
}
}
s = getParameter("target");
if (s != null) {
m_Frame = s;
}
m_fAllLoaded=true;
}

public void paint(Graphics g) {
if (m_fAllLoaded) {
displayImage(g);
return;
}
else {
g.drawString("Loading images...", 10, 20);
return;
}
}
}
tom2005 2004-12-03
  • 打赏
  • 举报
回复
学习
黑马 2004-12-03
  • 打赏
  • 举报
回复
收藏,关注
红楼梦魇 2004-12-03
  • 打赏
  • 举报
回复
你看看客户端的java控制台,上面有输出的。不能显示的机器可能是applet加载失败了
Eddie005 2004-11-28
  • 打赏
  • 举报
回复
学习~
jointree 2004-11-28
  • 打赏
  • 举报
回复
可以通过mouse的左右键来停止水纹的。但是我不明白为什么必须页面开两次才能出现水纹,是不是IIS服务器对这个不太支持还是代码有问题,必须创建一个实例后,再次引用才能实现。
[苦行僧] 2004-11-27
  • 打赏
  • 举报
回复
小弟发现你的网页 用鼠标点一下(不分左右键)水纹动,在点一下水纹又不动了!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧