2011年3月30日

UML 基本图示[轉貼]

UML 基本图示
2009-07-11 17:58
UML 基本图速查---类图. 对象图. 用例图 .参与者. 依赖关系. 泛化/继承关系. 关联.....
UML 类图. 对象图. 接口图. 用例图 .包,参与者. 依赖关系. 泛化/继承关系. 关联关系 .聚合/聚集关系. 实现关系 组合关系。

结构元素

结构元素包括,类,对象,接口,用例,参与者。
类图

类图图示
     类图是UML中最基本的元素了吧?根据OO的思想“天下一切皆对象”,而类是对象的抽象。 
     左侧图示为一个类图。顶端“ClassName”表示类名 
     中间部分为该类的属性,其中分别表示为可访问性,属性名,以及属性的数据类型。 
     第三部分为该类的方法,包括方法的可访问性,方法名,方法的参数以及方法的返回值。 
     需要说明的是:
             “#”表示protected 
             “+”表示Public
             “-”表示private
                                         “i”表示internal

对象图图示
对象图
右侧图示为一对象图,该对象为类className类的一个实例对象
该图第一部分说明了该对象为className的一个实例,第二部分指定了该实例的属性值。该图指定的是一个特殊的实例的对象,如果要代表className的所有的对象可省略掉对象名,即为“:ClassName”。
接口

类图图示
左图为一个比较简单的接口事例图示。与类图差不多,该图示分为三部分,第一部分为接口名,为了更明确的标明其“接口”的身份通常以“I”开头。第二部分为属性,第三部分为方法。
用例与参与者
下图为一简单的用例视图。小人表示参与者,而椭圆表示的是用例。

用例与参与者图示

包图图示
右侧图示为一包图,该图示为一名称为Utility的工具包。
包用来组织类,被包含在包里的类一般通过如Utility::StrUtility的形式来反应该类的路径。

关系

     关系元素包括了聚集,组成,实现,继承,依赖,关联等。
关联

关联图示
     关联是类之间的联系,如篮球队员与球队之间的关联(下图所示)。其中,关联两边的"employee"和“employer”标示了两者之间的关系,而数字表示两者的关系的限制,是关联两者之间的多重性。通常有“*”(表示所有,不限),“1”(表示有且仅有一个),“0...”(表示0个或者多个),“0,1”(表示0个或者一个),“n...m”(表示n到m个都可以),“m...*”(表示至少m个)。
     在关联中有一种叫“限定关联”,还有一种谓之自身关联。另外,对象之间的关联就没那么复杂,只是将类的关联实例化而已。
依赖

依赖图示
依赖是表示一个类中使用了另外一个类,最常用的依赖是在类A的方法中使用了类B,那么A依赖B。如上图所示。
继承

继承图示
这里的继承是指子类对父类的关系。理解面向对象的各位对继承应该不陌生。啥也不说,看看图好了。
继承使用空心箭头表示继承的方向,用实线连接。
实现

实现图示
实现指的是类对接口的实现。接口实现的表示与继承的表示差不多,只是将实线变为了虚线。
聚集

聚集图示
一个类可能有几个部分类聚集在一起而成。如:电脑主机由CPU,主板,光驱....等组成。类与类之间是“整体-部分”的关系。
组合

组成图示
组成是强类型的聚集,每个部分体只能属于一个整体。如桌子由桌腿和桌面组成。
----------------------------------------------------------------------------------------------------------------------------------
以上为UML的基本元素的一些表示法,主要目的是供查阅。

2011年3月23日

HTC 手機重設方式(Reset)

在手機關機的情況下,按住調低音量鍵,然後快速按下電源鍵。
等待畫面上出現 3 個 Android 影像,然後放開調低音量鍵。
按下調低音量鍵,選取清理磁碟空間,然後按下電源鍵。
按下調低音量鍵,開始執行出廠重設。

2011年3月22日

UIActivityIndicatorView : WaitView implementation

Header file --------------------------------------------------

//
//  WaitView.h
//  UIActivityIndicatorView
//
//  Created by Lin, Justin on 2011/3/22.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import


@interface WaitView : NSObject {

UIActivityIndicatorView *activityIndicator;
}

-(void) endWait;

- (void) beginWait;

@end

Source file --------------------------------------------------
//
//  WaitView.m
//  UIActivityIndicatorView
//
//  Created by Lin, Justin on 2011/3/22.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "WaitView.h"

@interface WaitView(PrivateMethods)

- (UIView *) mainWindow;
- (void) startWaitAnimation;
- (void) stopWaitAnimation;

@end

@implementation WaitView

- (UIView *) mainWindow {

return [[[UIApplication sharedApplication] windows] objectAtIndex:0];
}

- (void) startWaitAnimation {
if (activityIndicator != nil) {
return;
}
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[activityIndicator setFrame:CGRectMake(135, 125, 24, 24)];
[activityIndicator setHidesWhenStopped:YES];
[[self mainWindow] addSubview:activityIndicator];
[activityIndicator startAnimating];
}

- (void) stopWaitAnimation {
if (activityIndicator == nil) {
return;
}
[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];
activityIndicator = nil;
}

-(void) endWait {
// stop thread
    [NSThread detachNewThreadSelector: @selector(stopWaitAnimation) toTarget:self withObject:nil];
}

- (void) beginWait {
// start thread
    [NSThread detachNewThreadSelector: @selector(startWaitAnimation) toTarget:self withObject:nil];
}

@end

2011年3月21日

[轉貼] JavaScript Touch and Gesture Events iPhone and Android

JavaScript Touch and Gesture Events iPhone and Android

There are quite a few sites that describe the touch and gesture events that can be used in the mobile version of WebKit running on iPhone and iPod Touch. There is, however, not so much info with regards to Android. I've placed a few links at the bottom of this article that contain information used to compile this brief explanation.
Touch events are a bit like mouse events, but there are some very important differences when it comes to touch vs. mouse:
  • A touch is very hard to keep steady whilst a mouse can stay at a fixed position - this means that we go from a touchStart event directly to a touchMove event. Unlike a mouse where a mouseDown event is likely to fire without being followed up by a mouseMove event.
  • There is no mouseOver equivalent since a touch can be discontinuous, i.e., we can get from point A to point B without the need of drawing a continuous line between these points.
  • A touch is an averaged point taken from the surface area in contact with the pointing device (your finger) translated to pixel coordinates - like finding the centre of a circle. A mouse is very precise and there is no averaging that needs to be done. What I'm trying to say is that a touch is not as accurate as a mouse.

Android and iPhone touch events

Android and iPhone versions of WebKit have some touch events in common:
  • touchstart - triggered when a touch is initiated. Mouse equivalent - mouseDown
  • touchmove - triggered when a touch moves. Mouse equivalent - mouseMove
  • touchend - triggered when a touch ends. Mouse equivalent - mouseUp. This one is a bit special on the iPhone - see below
  • touchcancel - bit of a mystery
Example:
document.addEventListener('touchstart', function(event) {
    alert(event.touches.length);
}, false);

The Event object

As you may have noticed above, the event object contains an array called touches (in Androids case, the event object also containes a touch object - at this stage, touches has always a length of 1 in Android so event.touches[0] === event.touch). The touches array is Apples way of handling multi-touch events - but more on that later.
A touch object contains pretty much the same data as a mouse event such as pageX, pageY etc...

Example:
document.addEventListener('touchmove', function(event) {
    event.preventDefault();
    var touch = event.touches[0];
    console.log("Touch x:" + touch.pageX + ", y:" + touch.pageY);
}, false);

What about a click?

mouseClick events are triggered after a touchStart, touchEnd event sequence. A reason for mouseClick events not triggering can be that the event propagates further and a touchMove being initiated - this will cancel the mouseClick event sequence.

iPhone Touch and Gesture Events


Apples WebKit implementation has a few things that are different from the Android implementation. The touchEnd event removes the current touch from the event.touches array. Instead, we have to look inside the event.changedTouches array.

Apples event object for touch events

The event object contains the following arrays:
  • touches - contains touch information upon touchStart and touchMove not touchEnd events
  • targetTouches - contains information for touches originating from the same target element
  • changedTouches - contains touch information upon all touch events

Gesture events

Apple supports gestures which are mult-touch events such as "pinching" and "rotating":
  • gesturestart - triggered when initiating a multi-touch event
  • gesturechange - triggered when multiple touches move
  • gestureend - triggered when a multi-touch event ends
The event object for gesture events looks very different. It contains scale and rotation values and no touch objects.

Example:
document.addEventListener('gesturechange', function(event) {
    event.preventDefault();
    console.log("Scale: " + event.scale + ", Rotation: " + event.rotation);
}, false);

Event table

touchstarttouchmovetouchendgesturestartgesturemovegestureend
Androidyyynnn
iPhoneyyyyyy
has event.touchesyyynnn
(iPhone) has event.scale and event.rotationnnnyyy
(iPhone) touch in event.touchesyyn---
(iPhone) touch in event.changedTouchesyyy---

Links

2011年3月3日

7-11 賬單條碼規則


代收服務之電腦條碼及安全機制※條碼品質及規則:
一、        第一段條碼固定為9碼,前6碼為代收期限,後3為代收代號
二、    條碼固定為Code39,品質為C級以上,由7-11行銷作業人員檢測通過
三、    各段條碼由上而下依序排列,條碼間距請至少保留0.6公分,左右間距的空白長度一般為「Xdimension10倍寬或1/4英吋,建議以約2公分為主。
四、    條碼長度不可超過6.2公分,英數字位數不超過20位,條碼高度建議在0.8公分至1.4公分左右,建議條碼寬窄比 2:5及印刷寬度愈大愈好。
五、    避免列印條碼為彩色或淺色系顏色,背景色(建議為白色空白)與條碼及空白間顏色的對比需明顯
六、    條碼前後需加起始字元*及結束字元*
七、    條碼區請加印「統一超商專用條碼區」以利辨視
八、    2-3段條碼欄位內容,英數字及長度依各代收項目規格設定
九、    條碼檢查碼計算方式依所指定公式計算。
 
Barcode:三段式條碼 (9+16+15)第一段(9)  繳費期限yymmdd (6) + 代收項目XXX(3)第二段(16) 業者自行訂定 (16)
第三段(15) 應繳日期mmdd (4) + 檢碼(2) + 應繳金額(9)
ps: 1.
檢碼為檢查碼公式一(二碼之校對碼公式
)”
   2.yymm
為民國年月

   3.
帳單之唯一性以第二段條碼為依據(繳費證明單上查詢依據)
   4.
第二段條碼不足位數者,由位數小者補0
   5.請說明第二段條碼編碼原則
校對碼計算:
附件校對碼公式一 (二碼校對碼的公式)
       (1).Barcode中金額欄位之前二字元為全部條碼之檢查碼.
       (2)Barcode中有文字型態資料,則將其轉換成數值後計算
        轉換Table
字母
代碼
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
 (3)校對碼之第一碼計算公式:
  
各段Barcode基數值之加總值 除以11 後之餘數
                (
若餘數為0則放A,若餘數為10則放B)  
  校對碼之第二碼算公式:
  
各段Barcode偶數值之加總值 除以11 後之餘數
                (
若餘數為則放X, 若餘數為10則放Y)

有三段條碼,Barcode3的後9金額“則**即為校對碼
       Barcode1: 991231Y01
       Barcode2: ABCDEFGHIKLMNPQR
       Barcode3: 1234**000007890(本例不佳,因前4MMDD12月沒34)
    校對碼之第一碼計算
        第一段積數位總和    (9+1+3+'Y':8+1)  = 22
        第二段積數位總和    ('A':1+'C':3+'E':5+'G':7+'I':9+'L':3+'N':5+'Q':8) = 41
        第三段積數位總和    (1+3+0+0+8)  = 12
        積數位總位  22+41+12= 75 / 11→餘數9
    校對碼之第二碼計算
        第一段偶數位總和     (9+2+1+0)  = 12
        第二段偶數位總和   ('B':2+'D':4+'F':6+'H':8+'K':2+'M':4+'P':7+'R':9)= 42
        第三段偶數位總和     (2+4+0+0+0+8+0) = 22
        偶數位總位  12+42+22= 76 / 11→餘數10
    →因此校對碼為  '9Y'

※超商手續費代碼(超商稱之為「代收項目」以台中商銀為例)
機構代碼
費用區間
手續費
625
10000以下
10
62E
10000-20000
15
6BE
20000以上
20
※超商條碼
條碼一
繳費期限(YYMMDD)+機構代碼
9
條碼二
學校代碼+繳費編號(8)+00
16
條碼三
繳費期限(MMDD)+校對碼(2)+繳款金額(9)
15