马利智能信息处理.docx

上传人:b****6 文档编号:6560533 上传时间:2023-01-07 格式:DOCX 页数:17 大小:305.35KB
下载 相关 举报
马利智能信息处理.docx_第1页
第1页 / 共17页
马利智能信息处理.docx_第2页
第2页 / 共17页
马利智能信息处理.docx_第3页
第3页 / 共17页
马利智能信息处理.docx_第4页
第4页 / 共17页
马利智能信息处理.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

马利智能信息处理.docx

《马利智能信息处理.docx》由会员分享,可在线阅读,更多相关《马利智能信息处理.docx(17页珍藏版)》请在冰豆网上搜索。

马利智能信息处理.docx

马利智能信息处理

南京信息工程大学实验(实习)报告

实验(实习)名称智能信息处理实验实验(实习)日期2015.6.12得分指导老师马利

系计算机与软件学院专业计算机科学与技术班级2姓名学号

一.实验目的:

使用java语言实现对智能信息处理学习内容的综合运用,通过使用eclipse编程工具设计出不同的气象信息页面,通过自己的动手实践,加强自己的编程能力。

二.实验内容:

1)三线图

1.创建三线图面板

publicsanxiantu(){

setBounds(100,100,1000,700);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

}

2.添加分裂面板

//滑块

privateJSlidergetJSlider(){

if(jSlider==null){

jSlider=newJSlider();

jSlider.setMaximum(1000);

jSlider.setValue(100);

jSlider.setMinimum

(1);

jSlider.addChangeListener(newjavax.swing.event.ChangeListener(){

publicvoidstateChanged(javax.swing.event.ChangeEvente){

canvas.repaint();}//重新绘制

});

}

returnjSlider;

}

//设置画板

classMyCanvasextendsCanvas{

privatestaticfinallongserialVersionUID=5531859086294026557L;

privateToolkittk=Toolkit.getDefaultToolkit();

privateImagebackgroundImage;

publicMyCanvas(StringimgFile){

backgroundImage=tk.createImage(imgFile);}//构造函数

publicvoidsetBackgroundPanel(StringimgFile)

{backgroundImage=tk.createImage(imgFile);

repaint();}//重新绘制

publicvoidpaint(Graphicsg){

intnewW=0,newH=0;

intimgWidth=backgroundImage.getWidth(this);//获取宽度

intimgHeight=backgroundImage.getHeight(this);//获取高度

floatvalue=jSlider.getValue();

newW=(int)(imgWidth*value/100);

newH=(int)(imgHeight*value/100);

g.drawImage(backgroundImage,0,0,newW,newH,this);//按要求画出制定图片

}

}

publicsanxiantu(){

super();

setBounds(100,100,1000,700);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mySplitPane=newJSplitPane();//水平分割

labelRight=newJPanel();

JTabbedPanemyTabbedPane=newJTabbedPane();

mySplitPane.setRightComponent(labelRight);

labelRight.setLayout(newBorderLayout());

lab_color_change=newJLabel("20131308051金宸");

lab_color_change.setBounds(50,37,150,43);

labelRight.add(lab_color_change,BorderLayout.NORTH);

labelRight.add(getJSlider(),BorderLayout.SOUTH);

canvas=newMyCanvas("src/res/yiwei.jpg");

labelRight.add(canvas,BorderLayout.CENTER);

mySplitPane.setLeftComponent(myTabbedPane);

getContentPane().add(mySplitPane);

JPanellab_tuxingcaozuo=newJPanel();//选项卡一

JPanellab_beijingshezhi=newJPanel();//选项卡二

myTabbedPane.addTab("图形操作",lab_tuxingcaozuo);

3.对左侧选项卡一进行设计

//设置选项卡一

myTabbedPane.addTab("图形操作",lab_tuxingcaozuo);

lab_tuxingcaozuo.setLayout(null);

JTextPanetextPane=newJTextPane();

textPane.setBounds(45,15,100,80);

lab_tuxingcaozuo.add(textPane);

JButtonbtnNewButton_2=newJButton("长度");

btnNewButton_2.setBounds(21,117,70,43);

lab_tuxingcaozuo.add(btnNewButton_2);

JButtonbtnNewButton_3=newJButton("宽度");

btnNewButton_3.setBounds(111,117,70,43);

lab_tuxingcaozuo.add(btnNewButton_3);

JButtonbtn_color=newJButton("颜色");//按钮设置

btn_color.setBounds(60,170,70,43);

lab_tuxingcaozuo.add(btn_color);

btn_color.addActionListener(this);//事件监听,点击触发

 

JRadioButtonrdbtnNewRadioButton=newJRadioButton("时间轴向左");

rdbtnNewRadioButton.setBounds(37,475,121,23);

lab_tuxingcaozuo.add(rdbtnNewRadioButton);

JRadioButtonrdbtnNewRadioButton_1=newJRadioButton("时间轴向右");

rdbtnNewRadioButton_1.setBounds(37,500,121,23);

lab_tuxingcaozuo.add(rdbtnNewRadioButton_1);

JLabellblNewLabel=newJLabel("时间间隔");

lblNewLabel.setBounds(31,400,60,15);

lab_tuxingcaozuo.add(lblNewLabel);

textField=newJTextField();

textField.setBounds(94,395,33,21);

lab_tuxingcaozuo.add(textField);

textField.setColumns(10);

JLabellblNewLabel_1=newJLabel("小时");

lblNewLabel_1.setBounds(138,400,43,15);

lab_tuxingcaozuo.add(lblNewLabel_1);

JCheckBoxchckbxNewCheckBox=newJCheckBox("只填风");

chckbxNewCheckBox.setBounds(37,450,103,23);

lab_tuxingcaozuo.add(chckbxNewCheckBox);

JCheckBoxchckbxNewOne=newJCheckBox("只填雨");

chckbxNewOne.setBounds(37,425,103,23);

lab_tuxingcaozuo.add(chckbxNewOne);

JLabellblNewLabel_2=newJLabel("起始值");

lblNewLabel_2.setBounds(70,250,106,15);

lab_tuxingcaozuo.add(lblNewLabel_2);

textField_1=newJTextField();

textField_1.setBounds(37,270,106,23);

lab_tuxingcaozuo.add(textField_1);

textField_1.setColumns(10);

JLabellblNewLabel_3=newJLabel("结束值");

lblNewLabel_3.setBounds(70,300,106,15);

lab_tuxingcaozuo.add(lblNewLabel_3);

textField_2=newJTextField();

textField_2.setColumns(10);

textField_2.setBounds(37,320,106,23);

lab_tuxingcaozuo.add(textField_2);

JButtonbtnNewButton=newJButton("保存");

btnNewButton.setBounds(60,560,70,43);

lab_tuxingcaozuo.add(btnNewButton);

4.对左侧选项卡二进行设计

//选项卡二设置

myTabbedPane.addTab("背景设置",lab_beijingshezhi);

JButtonbtn_tupian=newJButton("选择图片");

btn_tupian.addActionListener(this);

lab_beijingshezhi.add(btn_tupian);

JButtonbtnZuoyi=newJButton("背景左移");

btnZuoyi.setBounds(60,170,70,43);

lab_beijingshezhi.add(btnZuoyi);

JButtonbtnYouyi=newJButton("背景右移");

btnYouyi.setBounds(60,200,70,43);

lab_beijingshezhi.add(btnYouyi);

JButtonbtnDaxiao=newJButton("改变大小");

btnDaxiao.setBounds(60,200,70,43);

lab_beijingshezhi.add(btnDaxiao);

JButtonbtnBaocun=newJButton("保存");

btnBaocun.setBounds(60,560,70,43);

lab_beijingshezhi.add(btnBaocun);

DimensionscrnDim=Toolkit.getDefaultToolkit().getScreenSize();

intx=(scrnDim.width-this.getSize().width)/2;

inty=(scrnDim.height-this.getSize().height)/2;

this.setLocation(x,y);

addComponentListener(newjava.awt.event.ComponentAdapter(){

publicvoidcomponentResized(java.awt.event.ComponentEventevt){

formComponentResized();

}

});

}

//调用窗体大小变化处理函数

privatevoidformComponentResized(){

mySplitPane.setDividerLocation((this.getSize().width/5)*1);

}

@Override

publicvoidstateChanged(ChangeEvente){

//事件触发后捕获

ColorselectedColor_background=jcc_background.getColor();

ColorselectedColor_text=jcc_text.getColor();

labelRight.setBackground(selectedColor_background);

lab_color_change.setForeground(selectedColor_text);

}

@Override

publicvoidactionPerformed(ActionEvente){

//时间被触发后进行捕获

StringevtCmd=e.getActionCommand();

if(evtCmd.equals("颜色")){

event_handle_color();}

elseif(evtCmd.equals("选择图片")){

envent_tupian();}

}

privatevoidenvent_tupian(){

StringfileName=null;

JFileChooserfileChooser=newJFileChooser();

//打开选择图片的选项页

fileChooser.setDialogTitle("图片地址");

fileChooser.setFileFilter(newFileNameExtensionFilter("图片文件(*.bmp,*.gif,*.jpg,*.jpeg,*.png)","bmp","gif","jpg","jpeg","png"));

if(fileChooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION)

{

fileName=fileChooser.getSelectedFile().getAbsolutePath();

if(fileName==null)return;

}

elsereturn;

setDefaultCloseOperation(EXIT_ON_CLOSE);

setSize(800,600);

setLocationRelativeTo(null);

canvas.setBackgroundPanel(fileName);

}

5.设计颜色按钮的事件监听

privatevoidevent_handle_color(){

JDialogdlg=newjavax.swing.JDialog();

dlg.setBounds(400,100,100,50);

dlg.setTitle("颜色");

jcc_background.getSelectionModel().addChangeListener(this);

jcc_text.getSelectionModel().addChangeListener(this);

Containerc=dlg.getContentPane();

JTabbedPanemyColorTabbedPane=newJTabbedPane();

JPanelbackground_Color=newJPanel();

JPaneltext_color=newJPanel();

myColorTabbedPane.addTab("背景颜色设置",background_Color);

myColorTabbedPane.addTab("文字颜色设置",text_color);

background_Color.add(jcc_background,BorderLayout.CENTER);

text_color.add(jcc_text,BorderLayout.CENTER);

c.add(myColorTabbedPane);

dlg.pack();

dlg.setVisible(true);

dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}

}

2)主面板

1.创建主面板窗口

publicclassMainFrame{

publicstaticvoidmain(String[]args){

newMicapsFrame();

}

}

classMicapsFrameextendsJFrame{

JDesktopPanedesktopPane;

publicMicapsFrame()

{

super();

DimensionscrnDim=Toolkit.getDefaultToolkit().getScreenSize();setBounds(200,100,(int)((1000.0/1280)*scrnDim.getWidth()),(int)((800.0/1024)*scrnDim.getHeight()));

//设置窗体大小和位置

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

setTitle("MICAPS3");

//给窗体命名

setVisible(true);

//设置窗体可见

java.awt.Containerc=getContentPane();

desktopPane=newJDesktopPane();

//创建桌面面板

desktopPane.setBounds(0,50,this.getSize().width,this.getSize().height-50);

//设置桌面面板大小和位置

c.setLayout(null);}

}

JMenuBarmenuBar;

//给窗体添加菜单组件

menuBar=newJMenuBar();

//设置菜单栏的属性

menuBar.setBounds(0,0,this.getSize().width,20);

//将菜单栏添加到容器中

c.add(menuBar);

2.添加一个按钮

JMenumenuFile=newJMenu("文件");

//将菜单栏的选项添加到菜单栏中

menuBar.add(menuFile);

JToolBartoolBar;

//添加工具栏

toolBar=newJToolBar();

//设置工具栏不可移动

toolBar.setFloatable(false);

//将工具栏添加到容器中

toolBar.setBounds(0,20,this.getSize().width,30);

c.add(toolBar);

3.添加工具栏按钮

JButtonbtn_1=newJButton(newImageIcon("res/新建.png"));

btn_1.setToolTipText("新建交互层");

//将按钮添加到工具栏中

toolBar.add(btn_1);

4.添加控件

JTabbedPanepaneLeft;

JPanelpanel;

panel=newJPanel();

panel.setBounds(0,0,(int)((200.0/1000)*this.getSize().width),this.getSize().height-50);

panel.setLayout(null);

paneLeft=newJTabbedPane(JTabbedPane.LEFT);

paneLeft.setBounds(0,0,(int)((200.0/1000)*this.getSize().width),this.getSize().height-50);

panel.add(paneLeft);

desktopPane.add(panel);

c.add(desktopPane);

 

5.添加分裂面板

JTabbedPanepaneLeft;

JPanelpanel;

JSplitPanesplitLeft;

panel=newJPanel();

panel.setBounds(0,0,(int)((200.0/1000)*this.getSize().width),this.getSize().height-50);

panel.setLayout(null);

//在桌面面板左边添加选项卡面板

paneLeft=newJTabbedPane(JTabbedPane

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 自然景观

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1