• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テキストの各行をキーと値に分離し、複数テキストファイルを読み込み、キーを突き合わせ照合し、その結果を表示するGUIユーテリティです。


Commit MetaInfo

Revisioneac76798be9aa6d0656bfc5015b4d34f5b68a82f (tree)
Time2011-10-23 03:27:52
Authorseraphy <seraphy@192....>
Commiterseraphy

Log Message

・データがないセルの偶数・奇数行での背景色分け

Change Summary

Incremental Difference

--- a/src/textkeymatcher/entity/KeyMatchedRowView.java
+++ b/src/textkeymatcher/entity/KeyMatchedRowView.java
@@ -134,6 +134,19 @@ public class KeyMatchedRowView extends AbstractTableModel {
134134 RowNumMap rowNumMap = rowNumMaps.get(rowIndex);
135135 return rowNumMap.getRowGroupSerialNo();
136136 }
137+
138+ /**
139+ * 指定した行が、キーごとの先頭行以外を指しているか?
140+ * @param rowIndex 行
141+ * @return キーごとの行グループの先頭行以外の場合はtrue
142+ */
143+ public boolean isTrailRow(int rowIndex) {
144+ if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) {
145+ return false;
146+ }
147+ RowNumMap rowNumMap = rowNumMaps.get(rowIndex);
148+ return rowNumMap.getRowNumber() != 0;
149+ }
137150
138151 /**
139152 * 第一列をキー、それ以降をデータ列として1つのテーブルのカラムとしてアクセスする.<br>
--- a/src/textkeymatcher/ui/TextKeyMatcherView.java
+++ b/src/textkeymatcher/ui/TextKeyMatcherView.java
@@ -63,10 +63,15 @@ public class TextKeyMatcherView extends FrameView implements ExitListener {
6363 private Color evenColor = new Color(240, 240, 255);
6464
6565 /**
66- * データがnullである場合の背景色
66+ * データがnullで、奇数行の場合の背景色
6767 */
6868 private Color nullValueColor = new Color(220, 220, 220);
6969
70+ /**
71+ * データがnullで、偶数行の場合の背景色.<br>
72+ */
73+ private Color evenNullValueColor = new Color(210, 210, 240);
74+
7075
7176 public TextKeyMatcherView(SingleFrameApplication app) {
7277 super(app);
@@ -175,18 +180,29 @@ public class TextKeyMatcherView extends FrameView implements ExitListener {
175180 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
176181
177182 if (isSelected) {
183+ // フォーカスあり
178184 setForeground(table.getSelectionForeground());
179185 setBackground(table.getSelectionBackground());
180186
181187 } else {
182- setForeground(table.getForeground());
188+ int colIndex = dataViewTable.convertColumnIndexToModel(column);
189+ if (colIndex == 0 && dataViewTableModel.isTrailRow(row)) {
190+ // キーカラムの連続キー行の場合、二つ目以降を灰色文字で表示する.
191+ setForeground(Color.lightGray);
183192
193+ } else {
194+ // それ意外は通常文字色
195+ setForeground(table.getForeground());
196+ }
197+
198+ // 有効なデータがある場合はキーごとに背景色を分ける
199+ int serialNo = dataViewTableModel.getRowGroupSerialNo(row);
200+ boolean even = (serialNo % 2 == 0);
184201 if (value == null) {
185- setBackground(getNullValueColor());
202+ // データがnullである場合の背景色
203+ setBackground(even ? getEvenNullValueColor() : getNullValueColor());
186204
187205 } else {
188- int serialNo = dataViewTableModel.getRowGroupSerialNo(row);
189- boolean even = (serialNo % 2 == 0);
190206 setBackground(even ? getEvenColor() : table.getBackground());
191207 }
192208 }
@@ -219,6 +235,27 @@ public class TextKeyMatcherView extends FrameView implements ExitListener {
219235 public Color getEvenColor() {
220236 return this.evenColor;
221237 }
238+
239+ /**
240+ * データがnullで、偶数行の場合の背景色を設定する.
241+ * @param evenNullValueColor 背景色
242+ */
243+ public void setEvenNullValueColor(Color evenNullValueColor) {
244+ if (evenNullValueColor == null) {
245+ throw new IllegalArgumentException();
246+ }
247+ Color oldValue = this.evenNullValueColor;
248+ this.evenNullValueColor = evenNullValueColor;
249+ firePropertyChange("evenNullValueColor", oldValue, evenNullValueColor);
250+ }
251+
252+ /**
253+ * データがnullで、偶数行の場合の背景色を設定する.
254+ * @return 背景色
255+ */
256+ public Color getEvenNullValueColor() {
257+ return this.evenNullValueColor;
258+ }
222259
223260 /**
224261 * データがnullである場合の背景色を設定する.