private void initSizesAndSpacing(Block<?> block, VisualConfig visualConfig) { pageWidth = visualConfig.getPageWidth(); pageHeight = visualConfig.getPageHeight(); pagesInRow = visualConfig.getPagesInRow(); spacing = visualConfig.getBlockSpace(); if (visualConfig.isShowCounters()) { verSpacing = VER_SPACING_WITH_COUNTERS; } else { verSpacing = spacing; } blockWidth = pageWidth * pagesInRow; blockHeight = pageHeight * ((block.getPagesNum() + pagesInRow - 1) / pagesInRow); dimension = new Dimension(blockWidth + 2 * spacing, blockHeight + spacing + verSpacing); }
private void drawCounters(Graphics2D g2d) { if (visualConfig.isShowCounters()) { g2d.setFont(Consts.UI.SMALL_FONT); String index = "(" + planeIndex + "," + blockIndex + ")"; String blockCounters = "v=" + block.getValidCounter() + ",e=" + block.getEraseCounter(); String counters = index + " " + blockCounters + " " + block.getStatusName(); g2d.setColor(block.getStatusColor()); g2d.drawString(counters, spacing, spacing + blockHeight + 13); } }
private void setPalette() { mZoomPalettePanel.removeAll(); if (mVisualConfig.getBlocksColorRange() == null) { return; } List<Color> colorRange = null; if (mVisualConfig.getBlocksColorRange() == null) { colorRange = Consts.defaultColorRange; } else { colorRange = mVisualConfig.getBlocksColorRange(); } JLabel paletteLabel = new JLabel("Zoom Palette:"); paletteLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT); paletteLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); mZoomPalettePanel.add(paletteLabel); mPalettePanel = new JPanel(); mPalettePanel.setLayout(new BoxLayout(mPalettePanel, BoxLayout.X_AXIS)); mZoomPalettePanel.add(mPalettePanel); for (int i = 0; i < colorRange.size(); i++) { JPanel paletteSquarePanel = new JPanel(); paletteSquarePanel.setLayout(new BoxLayout(paletteSquarePanel, BoxLayout.Y_AXIS)); Color color = colorRange.get(i); JPanel colorPanel = new JPanel(); colorPanel.setBackground(color); colorPanel.setMinimumSize(new Dimension(20, 20)); colorPanel.setPreferredSize(new Dimension(20, 20)); colorPanel.setMaximumSize(new Dimension(20, 20)); paletteSquarePanel.add(colorPanel); String value = " "; if (i == 0 && mVisualConfig.getRangeLowValue() != null) { value = Integer.toString(mVisualConfig.getRangeLowValue()); } else if (i == colorRange.size() - 1 && mVisualConfig.getRangeHighValue() != null) { value = Integer.toString(mVisualConfig.getRangeHighValue()); } JLabel valueLabel = new JLabel(value); valueLabel.setAlignmentX(Component.CENTER_ALIGNMENT); paletteSquarePanel.add(valueLabel); mPalettePanel.add(paletteSquarePanel); } }
private void doDrawing(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setFont(Consts.UI.FONT); drawBG(g2d); drawCounters(g2d); drawFrame(g2d, block); int x = spacing; int y = spacing; if (visualConfig.isShowCounters()) { g2d.setFont(Consts.UI.TINY_FONT); } else { g2d.setFont(Consts.UI.INVISIBLE_FONT); } int pageIndex = 0; for (Page page : block.getPages()) { drawPage(g2d, x, y, pageIndex++, page); } }