@Override public void paintComponent(Graphics g) { super.paintComponent(g); Dimension sz = getSize(); int top = Math.max(0, (sz.height - tableHeight) / 2); int left = Math.max(0, (sz.width - tableWidth) / 2); Model model = getModel(); if (model == null) return; Selection sel = model.getSelection(); int columns = sel.size(); if (columns == 0) { g.setFont(BODY_FONT); GraphicsUtil.drawCenteredText( g, Strings.get("tableEmptyMessage"), sz.width / 2, sz.height / 2); return; } g.setColor(Color.GRAY); int lineY = top + cellHeight + HEADER_SEP / 2; g.drawLine(left, lineY, left + tableWidth, lineY); g.setColor(Color.BLACK); g.setFont(HEAD_FONT); FontMetrics headerMetric = g.getFontMetrics(); int x = left; int y = top + headerMetric.getAscent() + 1; for (int i = 0; i < columns; i++) { x = paintHeader(sel.get(i).toShortString(), x, y, g, headerMetric); } g.setFont(BODY_FONT); FontMetrics bodyMetric = g.getFontMetrics(); Rectangle clip = g.getClipBounds(); int firstRow = Math.max(0, (clip.y - y) / cellHeight - 1); int lastRow = Math.min(rowCount, 2 + (clip.y + clip.height - y) / cellHeight); int y0 = top + cellHeight + HEADER_SEP; x = left; for (int col = 0; col < columns; col++) { SelectionItem item = sel.get(col); ValueLog log = model.getValueLog(item); int radix = item.getRadix(); int offs = rowCount - log.size(); y = y0 + Math.max(offs, firstRow) * cellHeight; for (int row = Math.max(offs, firstRow); row < lastRow; row++) { Value val = log.get(row - offs); String label = val.toDisplayString(radix); int width = bodyMetric.stringWidth(label); g.drawString(label, x + (cellWidth - width) / 2, y + bodyMetric.getAscent()); y += cellHeight; } x += cellWidth + COLUMN_SEP; } }
public UIEventHandler() { eventBus = new EventBus(); eventBus.register(SimCardReader.getInstance()); eventBus.register(SimCashDispenser.getInstance()); eventBus.register(SimDisplay.getInstance()); eventBus.register(SimEnvelopeAcceptor.getInstance()); eventBus.register(SimKeyboard.getInstance()); eventBus.register(SimOperatorPanel.getInstance()); eventBus.register(SimReceiptPrinter.getInstance()); eventBus.register(BillsPanel.getInstance()); eventBus.register(CardPanel.getInstance()); eventBus.register(LogPanel.getInstance()); eventBus.register(GUI.getInstance()); eventBus.register(ATMPanel.getInstance()); }