动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Java教程 ]的信息



本月文章推荐
.html-Cancel标签应用注意事项篇.
.Canvas中使用Font.
.使用jmx对weblogic进行动态的配置.
.使用Java Swing 创建一个XML编辑.
.JAVA 和.NET在安全功能的比较.
.实战J2EE?开发购物网站(一).
.如何实现真正的J2EE便携式应用.
.在JSE环境使用Hibernate En.
.我的JAVA工具.
.提高Java代码的性能.
.JavaMail常见问题之servlet 的 J.
.J2ME学习笔记(4)—用MIDP API开发.
.getUTCDate 方法.
.Java入门-关于字符串分割的两种方.
.Eclipse开发平台编程溯源寻根.
.最大化J2EE和数据库交互操作的性.
.探讨 J2SE 1.4 发行版中的安全性.
.Struts开发指南之J2EE n层结构.
.一个简单的Timer Service.
.用软引用阻止内存泄漏.

A Java Advanced Imaging program

发表日期:2008-1-5 |



  // This program has two parts , it can invert a image, and compare with the original one in a frame.You need download and install Java Advanced Imaging before you use it!!!

// compile:
javac "###1&2.java"
//run:
java "###2" "image file name.jpg" <return>


// now, here is the code:

//part one:

import java.awt.GridLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.image.RenderedImage;

import javax.media.jai.PlanarImage;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
* This class represents a Panel which contains two instances of
* DisplayJAIWithPixelInfo.
* The scrolling bars of both images are synchronized so scrolling one image
* will automatically scroll the other.
*/
public class DisplayTwoSynchronizedImages extends JPanel
implements AdjustmentListener
{
/** The DisplayJAIWithPixelInfo for the first image. */
protected DisplayJAIWithPixelInfo dj1;
/** The DisplayJAIWithPixelInfo for the second image. */
protected DisplayJAIWithPixelInfo dj2;
/** The JScrollPane which will contain the first of the images */
protected JScrollPane jsp1;
/** The JScrollPane which will contain the second of the images */
protected JScrollPane jsp2;

/**
* ConstrUCts an instance of this class, setting the components? layout,
* creating two instances of DisplayJAI for the two images and creating/
* registering event handlers for the scroll bars.
* @param im1 the first image (left side)
* @param im2 the second image (right side)
*/
public DisplayTwoSynchronizedImages(PlanarImage im1,PlanarImage im2)
{
super();
setLayout(new GridLayout(1,2));
dj1 = new DisplayJAIWithPixelInfo(im1); // Instances of DisplayJAI for the
dj2 = new DisplayJAIWithPixelInfo(im2); // two images
jsp1 = new JScrollPane(dj1); // JScrollPanes for the both
jsp2 = new JScrollPane(dj2); // instances of DisplayJAI
add(jsp1);
add(jsp2);
// Retrieve the scroll bars of the images and registers adjustment
// listeners to them.
// Horizontal scroll bar of the first image.
jsp1.getHorizontalScrollBar().addAdjustmentListener(this);
// Vertical scroll bar of the first image.
jsp1.getVerticalScrollBar().addAdjustmentListener(this);
// Horizontal scroll bar of the second image.
jsp2.getHorizontalScrollBar().addAdjustmentListener(this);
// Vertical scroll bar of the second image.
jsp2.getVerticalScrollBar().addAdjustmentListener(this);
}

/**
* This method changes the first image to be displayed.
* @param newImage the new first image.
*/
public void setImage1(PlanarImage newimage)
{
dj1.set(newimage);
repaint();
}

/**
* This method changes the second image to be displayed.
* @param newImage the new second image.
*/
public void setImage2(PlanarImage newimage)
{
dj2.set(newimage);
repaint();
}

/**
* This method returns the first image.
* @return the first image.
*/
public RenderedImage getImage1()
{
return dj1.getSource();
}

/**
* This method returns the second image.
* @return the second image.
*/
public RenderedImage getImage2()
{
return dj2.getSource();
}

/**
* This method returns the first DisplayJAI component.
* @return the first DisplayJAI component.
*/
public DisplayJAIWithPixelInfo getDisplayJAIComponent1()
{
return dj1;
}

/**
* This method returns the second DisplayJAI component.
* @return the second DisplayJAI component.
*/
public DisplayJAIWithPixelInfo getDisplayJAIComponent2()
{
return dj2;
}

/**
* This method will be called when any of the scroll bars of the instances of
* DisplayJAI are changed. The method will adjust the scroll bar of the other
* DisplayJAI as needed.
* @param e the AdjustmentEvent that ocurred (meaning that one of the scroll
* bars position has changed.
*/
public void adjustmentValueChanged(AdjustmentEvent e)
{
// If the horizontal bar of the first image was changed...
if (e.getSource() == jsp1.getHorizontalScrollBar())
{
// We change the position of the horizontal bar of the second image.
jsp2.getHorizontalScrollBar().setValue(e.getValue());
}
// If the vertical bar of the first image was changed...
if (e.getSource() == jsp1.getVerticalScrollBar())
{
// We change the position of the vertical bar of the second image.
jsp2.getVerticalScrollBar().setValue(e.getValue());
}
// If the horizontal bar of the second image was changed...
if (e.getSource() == jsp2.getHorizontalScrollBar())
{
// We change the position of the horizontal bar of the first image.
jsp1.getHorizontalScrollBar().setValue(e.getValue());
}
// If the vertical bar of the second image was changed...
if (e.getSource() == jsp2.getVerticalScrollBar())
{
// We change the position of the vertical bar of the first image.
jsp1.getVerticalScrollBar().setValue(e.getValue());
}
}

}




//Ok, now is the main function , part two:

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.JFrame;


/**
* This class demonstrates the use of the invert operator.
*/
public class Invert
{
/**
* The application entry point.
* @param args the command line arguments.
*/
public static void main(String[] args)
{
// We need one argument: the image filename.
if (args.length != 1)
{
System.err.println("Usage: java operators.Invert image");
System.exit(0);
}
// Read the image.
PlanarImage input = JAI.create("fileload", args[0]);
// Invert the image.
PlanarImage output = JAI.create("invert", input);
// Create a JFrame for displaying the results.
JFrame frame = new JFrame();
frame.setTitle("Invert image "+args[0]);
// Add to the JFrame?s ContentPane an instance of DisplayTwoSynchronized-
// Images, which will contain the original and processed image.
frame.getContentPane().add(new DisplayTwoSynchronizedImages(input,output));
// Set the closing operation so the application is finished.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); // adjust the frame size using preferred dimensions.
frame.setVisible(true); // show the frame.
}

}
上一篇:a Socket编程中的一个秘密类 人气:304
下一篇:Apache 1.3.14主要变化 人气:325
浏览全部Java的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-25 WikyBlog v1.7.0.1 多国语言版
2008-7-25 乐彼网上开店系统(56770 Eshop)
2008-7-25 赛特网站管理系统sitecms v3.6.0
2008-7-25 Modoer多功能点评系统 v1.0.1 Bu
2008-7-25 Shangducms Teamsuit! v1.1.0 开
2008-7-25 幻影动漫网视频系统(Ppdong) v1.
2008-7-25 acteecompany企业网站建设系统 v
2008-7-25 恒浪整合管理系统 ims v4.1 ACCE
2008-7-25 艺术图库系统 v1.0 beta
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号