📄 rankpanel.java
字号:
/*
* @(#)RankPanel.java 1.0 04/07/01 @(#)
*
* Copyright 2004 NTT DoCoMo, Inc. All rights reserved.
*/
import com.nttdocomo.ui.HTMLLayout;
import com.nttdocomo.ui.ImageLabel;
import com.nttdocomo.ui.Label;
import com.nttdocomo.ui.Panel;
import com.nttdocomo.ui.SoftKeyListener;
/**
* RankPanel<BR>
* The definition class of the score ranking screen.
* <p>
* @version 1.0
* </p>
*/
public class RankPanel extends Panel implements SoftKeyListener {
/** Title label */
private ImageLabel title;
/** Ranking label */
private Label[] rank = new Label[Score.COUNT_SCORE_RANKING + 1];
/** Score label */
private Label[] highScore = new Label[Score.COUNT_SCORE_RANKING+ 1];
/** Parent */
private CarRace parent = null;
/** Score */
private Score score = null;
/**
* Constructor.
* @param _parent Parent object
* @param _score Score object
*/
public RankPanel(CarRace _parent, Score _score) {
super();
this.parent = _parent;
this.score = _score;
title = new ImageLabel(MediaCollection.getImage(MediaCollection.IMG_RANKING));
title.setBackground(Color.BLACK);
for (int i = 0; i < highScore.length; i++) {
rank[i] = new Label();
rank[i].setSize(25, 13);
rank[i].setBackground(Color.BLACK);
highScore[i] = new Label();
highScore[i].setSize(60, 13);
highScore[i].setAlignment(Label.RIGHT);
highScore[i].setBackground(Color.BLACK);
if (0 == i) {
rank[i].setText("Rank");
rank[i].setForeground(Color.YELLOW);
highScore[i].setText("Score");
highScore[i].setForeground(Color.YELLOW);
} else {
rank[i].setForeground(Color.WHITE);
highScore[i].setForeground(Color.WHITE);
}
}
/* Layout Manager */
HTMLLayout lm = new HTMLLayout();
setLayoutManager(lm);
/* The background color of the panel */
setBackground(Color.BLACK);
/* Softkey label */
setSoftLabel(SOFT_KEY_2, "Return");
/* Hi-Score */
refresh();
/* Arrangement */
lm.begin(HTMLLayout.CENTER);
lm.br();
lm.br();
add(title);
for (int i = 0; i < highScore.length; i++) {
lm.br();
lm.br();
add(rank[i]);
add(highScore[i]);
}
lm.end();
/*
* Softkey listener
*/
setSoftKeyListener(this);
}
/**
* A Hi-Score is set up.
*/
public void refresh() {
title.setImage(MediaCollection.getImage(MediaCollection.IMG_RANKING));
int[] ranking = score.getScoreRanking();
for (int i = 1; i < highScore.length; i++) {
if ((score.isRankUp()) && (score.getRanking() == i)) {
rank[i].setForeground(Color.YELLOW);
highScore[i].setForeground(Color.YELLOW);
} else {
rank[i].setForeground(Color.WHITE);
highScore[i].setForeground(Color.WHITE);
}
rank[i].setText("No." + i);
highScore[i].setText(String.valueOf(ranking[i-1]));
}
}
/**
* Called when a soft key is pushed
* @param _key The pressed key
*/
public void softKeyPressed(int _key) {
}
/**
* Called when a soft key is detached
* <br>
* @param _key The detached key
*/
public void softKeyReleased(int _key) {
if (SOFT_KEY_2 == _key) {
parent.showTitlePanel();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -