UML实例--HELL_WORLD(四)



This figure makes it clear thatHelloWorld is just a leaf in a larger hierarchy of classes.HelloWorld is a child ofApplet ;Appletis a child ofPanel ;Panelis a child ofContainer; Containeris a child ofComponent ; andComponent is a child ofObject, which is the parent class of every class in Java. This model thus matches the Java library -- each child extends some parent.

图3-3很清楚的显示HelloWorld只是一个更大的类层次结构的叶.HelloWorldApplet的子节点;Applet是Panel的子节点;Panel是Container的子节点;Container是Component的子节点;而Component是Object的子节点,Object在Java中是每个类的父节点.这个模型与Java库一致--每个子节点扩展自多个父节点.

 

The relationship betweenImageObserver andComponent is a bit different, and the class diagram reflects this difference. In the Java library,ImageObserver is an interface, which, among other things, means that it has no implementation and instead requires that other classes implement it. You can show that classComponent implements interfaceImageObserver by the solid line from the rectangle (Component) to a provided interface circle (ImageObserver).

ImageObserverComponent关系有点不同,并且在类图中已表示出这点不同.在Java库中,ImageObserver是一个接口,除了别的之外,接口意味着它没有实现,而是需要其它类实现它.通过从矩形框(Component)连接到表示提供接口的圆的实线显示Component类实现ImageObserver接口.

 

As these figures show,HelloWorld collaborates directly with only two classes (Applet andGraphics), and these two classes are but a small part of the larger library of predefined Java classes. To manage this large collection, Java organizes its interfaces and classes in a number of different packages. The root package in the Java environment is named, not surprisingly,java. Nested inside this package are several other packages, which contain other packages, interfaces, and classes.Object lives in the packagelang , so its full path name isjava.lang.Object. Similarly,Panel ,Container , andComponent live inawt ; the classApplet lives in the packageapplet . The interfaceImageObserver lives in the packageimage , which in turn lives in the packageawt , so its full path name is the rather lengthy stringjava.awt.image.ImageObserver.

这些图形表明,与HelloWorld直接交互的只有两个类(AppletGraphics),且这两个类是预定义的Java类的大类库中的一小部分.为了管理这个大集合,Java将它的接口和类组织在多个不同的包里.在Java环境的根包命名毫不奇怪的是java. 嵌在这个包里的是几个其它的包,这些包包含了其它包,接口和类.Object存在于lang包,所以它的完整路径为java.lang.Object.同样的,Panel ,ContainerComponent存在awt包;类Applet存在applet包;接口ImageObserver存在image包,image又存在于awt包,所以它的完整路径名是相当长的字符串java.awt.image.ImageObserver.

 

You can visualize this packaging in a class diagram, shown in Figure 3-4. As this figure shows, packages are represented in the UML as a tabbed folders. Packages may be nested, and the dashed directed lines represent dependencies among these packages. For example, HelloWorld depends on the packagejava.applet , andjava.applet depends on the packagejava.awt .

你可以在一个类图中图形化这个包,如图3-4所示.这个图显示,包在UML中被带有标签的文件夹表示.包可以嵌套,并且包之间的依赖关系由有向虚线表示.例如,HelloWorld依赖java.applet包,java.applet依赖java.awt包.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值