安卓简易PDF阅读器的设计.doc

上传人:sccc 文档编号:4800225 上传时间:2023-05-15 格式:DOC 页数:41 大小:536.52KB
返回 下载 相关 举报
安卓简易PDF阅读器的设计.doc_第1页
第1页 / 共41页
安卓简易PDF阅读器的设计.doc_第2页
第2页 / 共41页
安卓简易PDF阅读器的设计.doc_第3页
第3页 / 共41页
安卓简易PDF阅读器的设计.doc_第4页
第4页 / 共41页
安卓简易PDF阅读器的设计.doc_第5页
第5页 / 共41页
点击查看更多>>
资源描述

《安卓简易PDF阅读器的设计.doc》由会员分享,可在线阅读,更多相关《安卓简易PDF阅读器的设计.doc(41页珍藏版)》请在三一办公上搜索。

1、电子商务移动开发技术大作业简易PDF阅读器1简易PDF阅读器摘 要在科技日益发达的今天,社会竞争越来越激烈,这要求人们不断的摄取信息来充实自己。要求人们能随时随地的了解并获取所需的信息。在这种情况下,电子书阅读器刚好满足了人们便捷地获取信息的需求。本文设计的简易PDF阅读器是基于Android平台设计的,Android平台是目前发展最快、最具市场前景的智能手机操作系统。本系统是根据GoogleAndroid平台用户的喜好和其平台的特性而设计的,在GoogleAndroid平台自带的SDK环境下,运用Eclipse,Photoshop等相关工具进行开发的。本文介绍了GoogleAndroid开发

2、的流程,讨论了基于Android平台应用程序开发的关键技术,对简易PDF阅读器做了详细的需求分析,并重点介绍了基于Android平台的手机电子书阅读器的总体设计,主要包括手机电子书阅读器的架构设计、各功能模块的设计与实现。本文设计的简易PDF阅读器通过了功能和性能方面的测试,证明了本文设计方案的可行性。通过对基于Android平台手机简易PDF阅读器的设计与实现的介绍,希望能为今后开发出功能更强大的阅读器提供有益的借鉴。关键词:android,PDF,SDK,PDF阅读器,SD卡读取4A SIMPLEPDF READERABSTRACT In science and technology in

3、creasingly developed today, society is more and more fierce competition, it requires people to constantly absorb information to enrich themselves. People can understand and get the required information anytime and anywhere. In this case, e-book readers just meet the needs of the people to obtain inf

4、ormation easily. This paper design the simplified PDF reader is designed based on the Android platform, the Android platform is the fastest growing, most market prospect of intelligent mobile phone operating system. This system is according to users preferences and Google Android platform is designe

5、d according to the features of its platform, bring on the Google Android platform SDK environment, using the Eclipse, Photoshop and other related tools for development. Google Android development process has been introduced in this paper, based on the Android platform application development is disc

6、ussed, the key technologies of simplified PDF reader demand analysis in detail, and introduced the overall design based on Android platform of mobile phone e-book reader, mainly includes the architecture design of mobile phone e-book reader, each function module design and implementation. Simple PDF

7、 reader design in this paper through the functional and performance testing, proved the feasibility of the design. Based on based on the Android platform mobile phone the introduction of the design and implementation of a simplified PDF reader, hope for the future to develop more powerful reader in

8、order to provide the beneficial reference. Keywords: Android, PDF, SDK, PDF reader, read SD card目 录摘 要1ABSTRACT2第一章 绪论51.1 概述51.2课题研究的目的和意义61.3本文的结构61.4 本章小结6第二章 研究现状72.1国内外研究现状72.2 本章小结7第三章 可行性分析83.1需求分析83.2 PDF阅读器功能需求83.3运行环境83.4 开发工具93.5 本章小结9参 考 文 献12致 谢13符号与标记(附录1)14 第一章 绪论1.1 概述手机已经成为了生活中不可缺少的

9、通讯设备,没有手机有时会让人觉得寸步难行。手机不仅具备传统的打电话、发短信等基本的功能,而且具有强大的处理能力和可扩展能力,能进行电子图书的阅览、基于3G网络实现高速数据传输、第三方浏览软件的运用等,越来越多的功能和业务将被开发出来并大规模的应用。正基于此,Google于2007年11月5日宣布推出基于Linux平台的开源手机操作系统,号称首个为移动终端打造的真正开放和完整的移动软件Android。二十世纪七十年代,著名软件工程师Andsan.Fandamu在美国布朗大学阐述通过计算机创建和阅读文件的时候首次提出了电子书1(electronicBook,eBook)这一术语。电子书是利用现代信

10、息技术创造的全新出版方式,将传统的书籍出版发行方式以数字的形式通过计算机网络实现。阅读器指的是一个设备,是专门用来看电子书的。随着数字化的不断兴起,电子阅读器市场的竞争变得越来越激烈。电子阅读现在是国家和业内非常重视的一个新兴产业,它与国家提倡的“自主创新,增强核心竞争力”、开展低碳、节能环保的社会环境相吻合,很多厂商、科研院所都将目光放到了这个原本没有足够重视的领域上。同时,手机电子书阅读器作为广大网民经常使用的一个工具,在手机阅读市场逐渐扩大的时候,人们对于阅读的方便性和各种功能设置都有了更高的要求。虽然现在手机电子书阅读器功能己经比较完善,但是离人们的期望还存在较大的距离,比如改善人们的

11、阅读环境,使人们读起来不感到疲倦而且充满乐趣,同时现在的阅读器多媒体性能还不够完善。因此,手机电子书阅读器的应用研究还大有潜力可挖。1.2课题研究的目的和意义当今社会手机是已经成为了生活中不可缺少的通讯设备,随着科技的发展手机的功能也越来越强大,手机电子阅读器是手机中的一种重要软件,其真正意义上指的是一个可以阅读设备,是专门用来阅读电子书的,随着二十一世纪数字信息化的不断兴起,电子阅读器的市场竞争也变得越来越激烈。时下社会的进步更是让人们的生活越来越忙碌,抱着厚厚的书本穿梭于大街小巷已经不再适应这个忙碌的时代。当人们奔波于不同的城市、出没在不同的场所、搭乘不同的交通工具的时候,手机电子阅读器就

12、可以为人们提供方便快捷的阅读平台,它的作用就像一座桥梁,在我们不方便利用书本或者网络的时候提供一个更快更方便的平台,让人们能随时的阅读自己喜欢的电子图书。就是因为手机电子阅读器方便快捷的优点,使得人们把用手机电子阅读器阅读阅读电子书当做当科技时代的一种时尚。这也让手机电子阅读器在人们的生活中扮演的角色越来越重要。1.3本文的结构本文介绍了作者从了解国内外发展现状,到配置开发环境以及需求分析之后完成项目并且调试成功的过程,展现了简易PDF阅读器的开发历程。1.4 本章小结本章主要初步介绍了android技术的起源与发展,简易PDF阅读器开发的意义和目的,和电子阅读器这个行业的背景。第二章 研究现

13、状2.1国内外研究现状最早出现在市场上的电子书阅读器是美国SoftBook公司的SoftBook和Nov.Media公司的RocketBook。它们都具有美观的外型形状像一本古典的精装书,存储容量分别为8MB和32MB的内存,分别可以容纳5,000和32,000多个电子页的信息,与计算机串口相连,可以从SoftBook和NuvoMedia的网上售书连锁店,下载书籍和期刊。2000年8月,美国微软公司发布了一个可供人们阅读电子书的应用软件MicrosoftReader,这种阅读器软件的核心技术是ClearType,微软称之为“对液晶显示屏具有革命性的变革”,它是一种能使文字在显示器上的显示效果像

14、印在纸上一样平滑清晰的字符显示技术,这种技术大大提高了屏幕的分辨率和清晰度,使读者能够获得最接近传统书的阅读效果。同时南开大学津科公司开发了一款阅读不耗电的电子书阅读器,该电子书阅读器已经面市并将投人大规模生产。它采用了华人科学家吴葆刚博士发明的“多稳态液晶显示器”,并在国际上首次实现了“翻页不耗电”阅读显示。除了上述几种电子书阅读器之外,Every Book,Librius,GlassBook等公司也都推出了自己的电子书阅读器和阅读软件,辽宁出版集团和美国秦通公司联手合作推出了中文电子“掌上书屋”。随着这些阅读器的出现,使得电子图书、期刊这些原本只能在PC上阅读的东西突然变得可以移动,电子书

15、籍与纸制书籍之间的距离缩短了一大步。同时,电子书阅读器更方便和灵活的使用功能也在不断地研究推出,例如,可以在阅读的时候加批注、书签、字体可缩放、旋转和支持声音播放等等。2.2 本章小结本章主要介绍了电子阅读器在国际国内上的发展现状,以及行业背景。第三章 可行性分析为了开发出真正满足用户需求的软件产品,需要对开发产品做出需求分析。对软件的需求的合理把握是软件开发周期中非常重要的一个环节,本章将对手机阅读器作较为全面的需求分析。3.1需求分析随着手机功能不断增强,手机阅读器已成为智能手机重要软件之一。开发一款符合广大用户需求的手机阅读器有很好的市场前景和意义。本软件的目标是开发一款基于Androi

16、d平台符合用户使用需求的手机电子书阅读器。本阅读器支持PDF格式的文件。用户可以通过PDF阅读器从SDCARD选择自己想要观看的PDF文件。本软件具有美观简洁便于用户使用的触摸界面,这也是Android操作系统不同于传统WindowsMobile和Symbian系统上应用软件的优势之一。3.2 PDF阅读器功能需求作为Android平台上开发的应用软件,它具有与用户交互的界面,界面简洁美观易于操作。因此,对手机阅读器的功能规定可以从手机阅读器的界面来划分。手机阅读器的用户操作界面分为一下四部分:读取界面,阅读界面。3.3运行环境1.系统要求Android系统2.2版本以上,对以后继续进行升级开

17、发有可延续性。2.灵活性软件基于Android操作系统,是基于组件的开发方式。3.时间特性的要求软件的速度要在用户可接受的范围能扩展需求。 4.软件特性要求软件运行速度要在用户可接受的范围之内,对流量、电量等消耗要在用户可接受范围之内。3.4 开发工具作者运用Myeclipse软件搭配android APK进行软件开发,操作系统为WIN7 64位,使用虚拟机为android 4.0 480*800的虚拟机。3.5 本章小结本章主要介绍了PDF阅读器的需求分析、PDF阅读器的功能需求和软件运行需要的环境和软件的开发环境。第四章 系统设计4.1 结构设计Android的架构是Linux内核、C/C

18、+函数库、Dalvik虚拟机、应用框架以及关键应用程序构成的,如图1所示,通过编译基于框架的应用程序可以降低开发负荷。应用软件原则上是在Dalvik VM上运行的。图1 Android的架构1 张鹏.Eclipse插件开发学习笔记Z.北京:电子工业出版社,2008关键应用程序Android平台内包含一些关键应用程序,如邮件收发客户端程序、短信收发程序、日历和网页浏览器等,开发者可以在其平台上开发更多有特色的应用程序。开发语言是Java。应用程序框架Android应用程序的开发基于框架和组件。Android本身已在其框架中提高了许多的组件供应用程序调用,当然开发者也开放新的组件,并将组件放入应用

19、程序框架中,以供自己和其它应用程序调用。C/C+函数库Android应用程序框架之下是一套C/C+函数库,它们服务于Android应用程序组件,其功能通过组件间接提供给开发者。这些函数库包括:标准C函数库、媒体功能库、浏览器引擎、2D和3D图形库、基于WEB应用的的安全协议SSL、用于点阵和矢量字体渲染的FreeType以及SQLite引擎等。Java程序运行环境Android的Java程序运行环境包含一组Java核心函数库及Dalvik虚拟机,它们有效地优化了Java程序的运行过程。所有的Android应用都运行在它自己的进程里,该进程是一个Dalvik虚拟机的实例,Dalvik被设计成能在

20、一台设备上高效的运行多个虚拟机实例。Dalvik虚拟机的可执行文件被封装成Dalvik可执行格式(.dex)。这是被优化过的最小内存依赖的格式。Java编译器(dx工具)将注册了的和运行时用到的类编译成.dex格式。Dalvik虚拟机依赖于底层Linux内核提供的功能,如线程机制,和内存管理机制等。Linux内核Android系统平台是基于优化了的Linux内核,是其系统平台的核心。它提供诸如内存管理、进程管理、设备驱动等服务,同时也是手机软硬件的连接层,提供了一个屏蔽层用于屏蔽硬件和上层软件。4.2 系统功能设计应用平台层是位于Android操作系统与应用层之间的,HomeScreen是用来

21、用用程序显示的,它是用来管理和开启应用程序的平台。最上层的是应用程序,该层包含手机上安装的各种应用程序,只要包括:日历,地图,联系人,短信,电话,闹钟等。本文设计的手机电子说阅读器就是属于应用层。图2-系统功能设计4.3 本章小结本章介绍了系统设计的概要。第五章 系统实现5.1 界面设计界面设计见图3、图4、图5、图6、图7。本阅读器的界面简单明了,使用户在最短时间内打开自己想要查看的PDF,省略花哨的界面只保留最有用的功能。图3-阅读器初始界面图4 阅读器打开PDF界面、图5-阅读器未找到PDF界面图6-阅读器查找PDF界面图7-阅读器在应用程序列表中的图标5.2 阅读PDF功能本功能可以在

22、android手机上将PDF文件以图片的形式打开,解决以往PDF文件在手机上无法查看的问题。部分代码如下:package com.sun.pdfview;import java.util.Iterator;import java.util.List;import net.sf.andpdf.utils.Utils;import android.graphics.Matrix;import android.graphics.PointF;import android.graphics.RectF;import android.util.Log;import com.sun.pdfview.fon

23、t.PDFFont;import com.sun.pdfview.font.PDFGlyph;public class PDFTextFormat implements Cloneable /* character spacing */ private float tc = 0; /* word spacing */ private float tw = 0; /* horizontal scaling */ private float th = 1; /* leading */ private float tl = 0; /* rise amount */ private float tr

24、= 0; /* text mode */ private int tm = PDFShapeCmd.FILL; /* text knockout */ private float tk = 0; /* current matrix transform */ private Matrix cur; /* matrix transform at start of line */ private Matrix line; /* font */ private PDFFont font; /* font size */ private float fsize = 1; /* are we betwee

25、n BT and ET? */ private boolean inuse = false; / private Object array= new Object1; /* build text rep of word */ private StringBuffer word = new StringBuffer(); / this is where we build and keep the word list for this page. /* start location of the hunk of text */ private PointF wordStart; /* locati

26、on of the end of the previous hunk of text */ private PointF prevEnd; /* * create a new PDFTextFormat, with initial values */ public PDFTextFormat() cur = new Matrix(); line = new Matrix(); wordStart = new PointF(-100, -100); prevEnd = new PointF(-100, -100); tc = tw = tr = tk = 0; tm = PDFShapeCmd.

27、FILL; th = 1; /* * reset the PDFTextFormat for a new run */ public void reset() cur.reset(); line.reset(); inuse = true; word.setLength(0); /* * end a span of text */ public void end() inuse = false; /* get the char spacing */ public float getCharSpacing() return tc; /* set the character spacing */

28、public void setCharSpacing(float spc) this.tc = spc; /* get the word spacing */ public float getWordSpacing() return tw; /* set the word spacing */ public void setWordSpacing(float spc) this.tw = spc; /* * Get the horizontal scale * return the horizontal scale, in percent */ public float getHorizont

29、alScale() return th * 100; /* * set the horizontal scale. * param scl the horizontal scale, in percent (100=normal) */ public void setHorizontalScale(float scl) this.th = scl / 100; /* get the leading */ public float getLeading() return tl; /* set the leading */ public void setLeading(float spc) thi

30、s.tl = spc; /* get the font */ public PDFFont getFont() return font; /* get the font size */ public float getFontSize() return fsize; /* set the font and size */ public void setFont(PDFFont f, float size) this.font = f; this.fsize = size; /* * Get the mode of the text */ public int getMode() return

31、tm; /* * set the mode of the text. The correspondence of m to mode is * show in the following table. m is a value from 0-7 in binary: * * 000 Fill * 001 Stroke * 010 Fill + Stroke * 011 Nothing * 100 Fill + Clip * 101 Stroke + Clip * 110 Fill + Stroke + Clip * 111 Clip * * Therefore: Fill correspond

32、s to the low bit being 0; Clip * corresponds to the hight bit being 1; and Stroke corresponds * to the middle xor low bit being 1. */ public void setMode(int m) int mode = 0; if (m & 0x1) = 0) mode |= PDFShapeCmd.FILL; if (m & 0x4) != 0) mode |= PDFShapeCmd.CLIP; if (m & 0x1) (m & 0x2) 1) != 0) mode

33、 |= PDFShapeCmd.STROKE; this.tm = mode; /* * Set the mode from another text format mode * * param mode the text render mode using the * codes from PDFShapeCmd and not the wacky PDF codes */ public void setTextFormatMode(int mode) this.tm = mode; /* * Get the rise */ public float getRise() return tr;

34、 /* * set the rise */ public void setRise(float spc) this.tr = spc; /* * perform a carriage return */ public void carriageReturn() carriageReturn(0, -tl); /* * perform a carriage return by translating by x and y. The next * carriage return will be relative to the new location. */ public void carriag

35、eReturn(float x, float y) Matrix trans = new Matrix(); trans.setTranslate(x, y); line.preConcat(trans); cur.set(line); /* * Get the current transform */ public Matrix getTransform() return cur; /* * set the transform matrix directly */ public void setMatrix(float matrix) line = new Matrix(); Utils.s

36、etMatValues(line, matrix); cur.set(line); /* * add some text to the page. * param cmds the PDFPage to add the commands to * param text the text to add */ public void doText(PDFPage cmds, String text) PointF zero = new PointF(); Matrix scale = new Matrix(); Utils.setMatValues(scale, fsize, 0, 0, fsiz

37、e * th, 0, tr); Matrix at = new Matrix(); List l = font.getGlyphs(text); for (Iterator i = l.iterator(); i.hasNext();) PDFGlyph glyph = (PDFGlyph) i.next(); at.set(cur); at.preConcat(scale); PointF advance = glyph.addCommands(cmds, at, tm); float advanceX = (advance.x * fsize) + tc; if (glyph.getCha

38、r() = ) advanceX += tw; advanceX *= th; cur.preTranslate(advanceX, advance.y); float src = zero.x, zero.y; float dst = new floatsrc.length; cur.mapPoints(dst, src); prevEnd.set(dst0, dst1); /* * add some text to the page. * param cmds the PDFPage to add the commands to * param ary an array of String

39、s and Doubles, where the Strings * represent text to be added, and the Doubles represent kerning * amounts. */ public void doText(PDFPage cmds, Object ary) throws PDFParseException for (int i = 0; i ary.length; i+) if (aryi instanceof String) doText(cmds, (String) aryi); else if (aryi instanceof Dou

40、ble) float val = (Double) aryi).floatValue() / 1000f; cur.preTranslate(-val * fsize * th, 0); else throw new PDFParseException(Bad element in TJ array); /* * finish any unfinished words. TODO: write this! */ public void flush() / TODO: finish any unfinished words /* * Clone the text format */ Overri

41、de public Object clone() PDFTextFormat newFormat = new PDFTextFormat(); / copy values newFormat.setCharSpacing(getCharSpacing(); newFormat.setWordSpacing(getWordSpacing(); newFormat.setHorizontalScale(getHorizontalScale(); newFormat.setLeading(getLeading(); newFormat.setTextFormatMode(getMode(); newFormat.setRise(getRise(); / copy immutable fields newFormat

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

当前位置:首页 > 建筑/施工/环境 > 农业报告


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号