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

上传人:本田雅阁 文档编号:2173033 上传时间:2019-02-25 格式:DOC 页数:42 大小:536.53KB
返回 下载 相关 举报
安卓简易官阅读器的设计.doc_第1页
第1页 / 共42页
安卓简易官阅读器的设计.doc_第2页
第2页 / 共42页
安卓简易官阅读器的设计.doc_第3页
第3页 / 共42页
亲,该文档总共42页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

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

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

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

3、SDK,PDF 阅读器,SD 卡读取 3 A SIMPLE PDF READER ABSTRACT In science and technology increasingly 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

4、. In this case, e-book readers just meet the needs of the people to obtain information 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 s

5、ystem is according to users preferences and Google Android platform is designed 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 introduce

6、d in this paper, based on the Android platform application development is discussed, 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 p

7、hone e-book reader, each function module design and implementation. Simple PDF 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

8、simplified PDF reader, hope for the future to develop more powerful reader in order to provide the beneficial reference. Keywords: Android, PDF, SDK, PDF reader, read SD card 4 目目 录录 摘摘 要要.1 ABSTRACT .2 第一章第一章 绪论绪论.5 1.11.1 概述概述5 1.21.2 课题研究的目的和意义课题研究的目的和意义6 1.31.3 本文的结构本文的结构6 1.41.4 本章小结本章小结.6 第二章第

9、二章 研究现状研究现状.7 2.12.1 国内外研究现状国内外研究现状7 2.22.2 本章小结本章小结.7 第三章第三章 可行性分析可行性分析.8 3.13.1 需求分析需求分析8 3.23.2 PDFPDF 阅读器功能需求阅读器功能需求 8 3.33.3 运行环境运行环境8 3.43.4 开发工具开发工具.9 3.53.5 本章小结本章小结.9 参参 考考 文文 献献.12 致致 谢谢.13 符号与标记(附录符号与标记(附录 1 1)14 第 6 页 第一章第一章 绪论绪论 1.11.1 概述概述 手机已经成为了生活中不可缺少的通讯设备,没有手机有时会让人觉得寸步难 行。手机不仅具备传统的

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

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

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

13、没在不同的场所、 搭乘不同的交通工具的时候,手机电子阅读器就可以为人们提供方便快捷的阅读平 台,它的作用就像一座桥梁,在我们不方便利用书本或者网络的时候提供一个更快 更方便的平台,让人们能随时的阅读自己喜欢的电子图书。 就是因为手机电子阅读器方便快捷的优点,使得人们把用手机电子阅读器阅读 阅读电子书当做当科技时代的一种时尚。这也让手机电子阅读器在人们的生活中扮 演的角色越来越重要。 1.31.3 本文的结构本文的结构 本文介绍了作者从了解国内外发展现状,到配置开发环境以及需求分析之后完 成项目并且调试成功的过程,展现了简易 PDF 阅读器的开发历程。 1.41.4 本章小结本章小结 本章主要初

14、步介绍了 android 技术的起源与发展,简易 PDF 阅读器开发的意义 和目的,和电子阅读器这个行业的背景。 第 8 页 第第 2 章章 研究现状研究现状 2.12.1 国内外研究现状国内外研究现状 最早出现在市场上的电子书阅读器是美国 Soft Book 公司的 Soft Book 和 Nov.Media 公司的 RocketBook。它们都具有美观的外型形状像一本古典的精装书, 存储容量分别为 8MB 和 32MB 的内存,分别可以容纳 5,000 和 32,000 多个电子页的 信息,与计算机串口相连,可以从 Soft Book 和 Nuvo Media 的网上售书连锁店,下 载书籍

15、和期刊。2000 年 8 月, 美国微软公司发布了一个可供人们阅读电子书的应用软件 Microsoft Reader, 这种阅读器软件的核心技术是 Clear Type,微软称之为“对液晶显示屏具有革命性 的变革”,它是一种能使文字在显示器上的显示效果像印在纸上一样平滑清晰的字 符显示技术,这种技术大大提高了屏幕的分辨率和清晰度,使读者能够获得最接近 传统书的阅读效果。同时南开大学津科公司开发了一款阅读不耗电的电子书阅读器, 该电子书阅读器已经面市并将投人大规模生产。它采用了华人科学家吴葆刚博士发 明的“多稳态液晶显示器”,并在国际上首次实现了“翻页不耗电”阅读显示。除 了上述几种电子书阅读器

16、之外,Every Book,Librius,Glass Book 等公司也都推出 了自己的电子书阅读器和阅读软件,辽宁出版集团和美国秦通公司联手合作推出了 中文电子“掌上书屋”。随着这些阅读器的出现,使得电子图书、期刊这些原本只 能在 PC 上阅读的东西突然变得可以移动,电子书籍与纸制书籍之间的距离缩短了一 大步。同时,电子书阅读器更方便和灵活的使用功能也在不断地研究推出,例如, 可以在阅读的时候加批注、书签、字体可缩放、旋转和支持声音播放等等。 2.22.2 本章小结本章小结 本章主要介绍了电子阅读器在国际国内上的发展现状,以及行业背景。 第 9 页 第第 3 章章 可行性分析可行性分析 为

17、了开发出真正满足用户需求的软件产品,需要对开发产品做出需求分析。对 软件的需求的合理把握是软件开发周期中非常重要的一个环节,本章将对手机阅读 器作较为全面的需求分析。 3.13.1 需求分析需求分析 随着手机功能不断增强,手机阅读器已成为智能手机重要软件之一。开发一款 符合广大用户需求的手机阅读器有很好的市场前景和意义。 本软件的目标是开发一款基于 Android 平台符合用户使用需求的手机电子书阅 读器。本阅读器支持 PDF 格式的文件。用户可以通过 PDF 阅读器从 SDCARD 选择自己 想要观看的 PDF 文件。本软件具有美观简洁便于用户使用的触摸界面,这也是 Android 操作系统

18、不同于传统 Windows Mobile 和 Symbian 系统上应用软件的优势之 一。 3.23.2 PDFPDF 阅读器功能需求阅读器功能需求 作为 Android 平台上开发的应用软件,它具有与用户交互的界面,界面简洁美 观易于操作。因此,对手机阅读器的功能规定可以从手机阅读器的界面来划分。手 机阅读器的用户操作界面分为一下四部分:读取界面,阅读界面。 3.33.3 运行环境运行环境 1.系统要求 Android 系统 2.2 版本以上,对以后继续进行升级开发有可延续性。 第 10 页 2.灵活性 软件基于 Android 操作系统,是基于组件的开发方式。 3.时间特性的要求 软件的速

19、度要在用户可接受的范围能扩展需求。 4.软件特性要求 软件运行速度要在用户可接受的范围之内,对流量、电量等消耗要在用户可接 受范围之内。 3.43.4 开发工具开发工具 作者运用 Myeclipse 软件搭配 android APK 进行软件开发,操作系统为 WIN7 64 位,使用虚拟机为 android 4.0 480*800 的虚拟机。 3.53.5 本章小结本章小结 本章主要介绍了 PDF 阅读器的需求分析、PDF 阅读器的功能需求和软件运行需 要的环境和软件的开发环境。 第 11 页 第四章第四章 系统设计系统设计 4.14.1 结构设计结构设计 Android 的架构是 Linux

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

21、提高了许 多的组件供应用程序调用,当然开发者也开放新的组件,并将组件放入应用程序框 架中,以供自己和其它应用程序调用。 C/C+函数库 Android 应用程序框架之下是一套 C/C+函数库,它们服务于 Android 应用程序 组件,其功能通过组件间接提供给开发者。这些函数库包括:标准 C 函数库、媒体 功能库、浏览器引擎、2D 和 3D 图形库、基于 WEB 应用的的安全协议 SSL、用于点阵 和矢量字体渲染的 FreeType 以及 SQLite 引擎等。 Java 程序运行环境 Android 的 Java 程序运行环境包含一组 Java 核心函数库及 Dalvik 虚拟机,它 们有效

22、地优化了 Java 程序的运行过程。所有的 Android 应用都运行在它自己的进程 里,该进程是一个 Dalvik 虚拟机的实例,Dalvik 被设计成能在一台设备上高效的 运行多个虚拟机实例。Dalvik 虚拟机的可执行文件被封装成 Dalvik 可执行格式 (.dex)。这是被优化过的最小内存依赖的格式。Java 编译器(dx 工具)将注册了的和 运行时用到的类编译成.dex 格式。Dalvik 虚拟机依赖于底层 Linux 内核提供的功能, 如线程机制,和内存管理机制等。 Linux 内核 Android 系统平台是基于优化了的 Linux 内核,是其系统平台的核心。它提供 诸如内存管

23、理、进程管理、设备驱动等服务,同时也是手机软硬件的连接层,提供 了一个屏蔽层用于屏蔽硬件和上层软件。 4.2 系统功能设计系统功能设计 应用平台层是位于 Android 操作系统与应用层之间的,HomeScreen 是用来用用 程序显示的,它是用来管理和开启应用程序的平台。最上层的是应用程序,该层包 含手机上安装的各种应用程序,只要包括:日历,地图,联系人,短信,电话,闹 第 13 页 钟等。本文设计的手机电子说阅读器就是属于应用层。 图 2-系统功能设计 4.34.3 本章小结本章小结 本章介绍了系统设计的概要。 第 14 页 第五章第五章 系统实现系统实现 5.15.1 界面设计界面设计

24、界面设计见图 3、图 4、图 5、图 6、图 7。本阅读器的界面简单明了,使用户 在最短时间内打开自己想要查看的 PDF,省略花哨的界面只保留最有用的功能。 图 3-阅读器初始界面 第 15 页 图 4 阅读器打开 PDF 界面 第 16 页 、 图 5-阅读器未找到 PDF 界面 第 17 页 图 6-阅读器查找 PDF 界面 第 18 页 图 7-阅读器在应用程序列表中的图标 5.25.2 阅读阅读 PDFPDF 功能功能 本功能可以在 android 手机上将 PDF 文件以图片的形式打开,解决以往 PDF 文 件在手机上无法查看的问题。部分代码如下: package com.sun.p

25、dfview; import java.util.Iterator; 第 19 页 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.font.PDFFont; import com.sun.pdfview.font.PDFGlyph; public

26、 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 = 0; /* text mode */ private int tm = PDFShapeCmd.FIL

27、L; /* 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 between BT and ET? */ private boolean inuse = false; / priv

28、ate Object array= new Object1; 第 20 页 /* 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; /* location of the end of the previous hunk of text */

29、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.FILL; th = 1; /* * reset the PDFTextFormat for

30、 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; 第 21 页 /* get the char spacing */ public float getCharSpacing() return tc; /* set the character spacing */ public void setCharSpacing(float spc) t

31、his.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 getHorizontalScale() return th * 100; /* * set the

32、 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; 第 22 页 /* set the leading */ public void setLeading(float spc) this.tl = spc; /* get the font */ p

33、ublic 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 tm; /* * set the mode of the tex

34、t. 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 第 23 页 * 111 Clip * * Therefore: Fill corresponds to the low bit being 0;

35、 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 if (m if (m this.tm = mode; /* * Set the mode from another text format mode * * param mode the text render mode using the * codes from PDFShapeC

36、md and not the wacky PDF codes */ public void setTextFormatMode(int mode) this.tm = mode; /* * Get the rise */ public float getRise() return tr; /* 第 24 页 * set the rise */ public void setRise(float spc) this.tr = spc; /* * perform a carriage return */ public void carriageReturn() carriageReturn(0,

37、-tl); /* * perform a carriage return by translating by x and y. The next * carriage return will be relative to the new location. */ public void carriageReturn(float x, float y) Matrix trans = new Matrix(); trans.setTranslate(x, y); line.preConcat(trans); cur.set(line); /* * Get the current transform

38、 */ public Matrix getTransform() return cur; /* * set the transform matrix directly */ public void setMatrix(float matrix) line = new Matrix(); Utils.setMatValues(line, matrix); cur.set(line); 第 25 页 /* * add some text to the page. * param cmds the PDFPage to add the commands to * param text the tex

39、t to add */ public void doText(PDFPage cmds, String text) PointF zero = new PointF(); Matrix scale = new Matrix(); Utils.setMatValues(scale, fsize, 0, 0, fsize * th, 0, tr); Matrix at = new Matrix(); List l = font.getGlyphs(text); for (Iterator i = l.iterator(); i.hasNext();) PDFGlyph glyph = (PDFGl

40、yph) i.next(); at.set(cur); at.preConcat(scale); PointF advance = glyph.addCommands(cmds, at, tm); float advanceX = (advance.x * fsize) + tc; if (glyph.getChar() = ) advanceX += tw; advanceX *= th; cur.preTranslate(advanceX, advance.y); float src = zero.x, zero.y; float dst = new floatsrc.length; cu

41、r.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 Strings and Doubles, where the Strings * represent text to be added, and the Doubles represent kerning 第 26 页 * amounts. */ public void doText(PDFPa

42、ge cmds, Object ary) throws PDFParseException for (int i = 0; i stack; / stack of Object private Stack parserStates; / stack of RenderState / the current render state private ParserState state; private Path path; private int clip; private int loc; private boolean resend = false; private Tok tok; pri

43、vate boolean catchexceptions; / Indicates state of BX.EX /* a weak reference to the page we render into. For the page * to remain available, some other code must retain a strong reference to it. */ private WeakReference pageRef; /* the actual command, for use within a singe iteration. Note that * th

44、is must be released at the end of each iteration to assure the 第 36 页 * page can be collected if not in use */ private PDFPage cmds; / - result variables byte stream; HashMap resources; / public static int debuglevel = 4000; / TODO FHe: changed for debugging public static int debuglevel = -1; public

45、 static void debug(String msg, int level) if (level debuglevel) System.out.println(escape(msg); public static String escape(String msg) StringBuffer sb = new StringBuffer(); for (int i = 0; i = 127) c = ?; sb.append(c); return sb.toString(); public static void setDebugLevel(int level) debuglevel = l

46、evel; 第 37 页 /* * Dont call this constructor directly. Instead, use * PDFFile.getPage(int pagenum) to get a PDFPage. There should * never be any reason for a user to create, access, or hold * on to a PDFParser. */ public PDFParser(PDFPage cmds, byte stream, HashMap resources) super(); this.pageRef =

47、 new WeakReference(cmds); this.resources = resources; if (resources = null) this.resources = new HashMap(); this.stream = stream; this.cmdCnt = 0; 第 38 页 毕业设计(论文)原创性声明和使用授权说明毕业设计(论文)原创性声明和使用授权说明 原创性声明原创性声明 本人郑重承诺:所呈交的毕业设计(论文),是我个人在指导教师 的指导下进行的研究工作及取得的成果。尽我所知,除文中特别加以标 注和致谢的地方外,不包含其他人或组织已经发表或公布过的研究成果,

48、 也不包含我为获得 及其它教育机构的学位或学历而使用过的 材料。对本研究提供过帮助和做出过贡献的个人或集体,均已在文中作 了明确的说明并表示了谢意。 作 者 签 名: 日 期: 指导教师签名: 日 期: 使用授权说明使用授权说明 本人完全了解 大学关于收集、保存、使用毕业设计(论文) 的规定,即:按照学校要求提交毕业设计(论文)的印刷本和电子版本; 学校有权保存毕业设计(论文)的印刷本和电子版,并提供目录检索与 阅览服务;学校可以采用影印、缩印、数字化或其它复制手段保存论文; 在不以赢利为目的前提下,学校可以公布论文的部分或全部内容。 作者签名: 日 期: 第 39 页 学位论文原创性声明学位论文原创性声明 本人郑重声明:所呈交的论文是本人在导师的指导下独立进行研究 所取得的研究成果。除了文中特别加以标注引用的内容外,本论文不包 含任何其他个人或集体已经发表或撰写的成果作品。对本文的研究做出 重要贡献的个人和集体,均已在文中以明确方式标明。本人完全意识到 本声明的法律后果由本人承担。 作者签名: 日期: 年 月 日 学位论文版权使用授权书学位论文版权使用授权书 本学位论文作者完全了解学校有关保留、使用学位论文的规定,同 意学校保留并向国家有关部门或机构送交论文的复印件和电子版,允许 论文被查阅和借阅。本人授权 大学可以将本学位论文的 全

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

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1