01: /*******************************************************************************
02: * Copyright (c) 2007-2008 Kirill Grouchnikov and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *******************************************************************************/package test;
08:
09: import java.awt.*;
10:
11: import javax.swing.*;
12:
13: import org.jvnet.substance.SubstanceLookAndFeel;
14: import org.jvnet.substance.border.BorderPainterChangeListener;
15: import org.jvnet.substance.painter.text.SubstanceTextPainter;
16: import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;
17:
18: public class VerticalTexts2 extends JFrame {
19: protected static class VerticalPanel extends JPanel {
20: private Font font;
21:
22: public VerticalPanel(Font font) {
23: this .font = font;
24: }
25:
26: @Override
27: protected void paintComponent(Graphics g) {
28: g.setColor(Color.white);
29: g.fillRect(0, 0, getWidth(), getHeight());
30:
31: SubstanceTextPainter textPainter = SubstanceLookAndFeel
32: .getCurrentTextPainter();
33: textPainter.init(this , null, true);
34: textPainter.setBackgroundFill(this , Color.lightGray, false,
35: 0, 0);
36: final Rectangle[] rectsB2T = new Rectangle[] {
37: new Rectangle(28, 163, 16, 12),
38: new Rectangle(28, 124, 16, 12),
39: new Rectangle(28, 84, 16, 12),
40: new Rectangle(28, 45, 16, 12),
41: new Rectangle(28, 2, 16, 12),
42: new Rectangle(28, 205, 16, 12) };
43:
44: textPainter
45: .attachCallback(new SubstanceTextPainter.BackgroundPaintingCallback() {
46: public void paintBackground(Graphics g) {
47: g.setColor(Color.red);
48: for (Rectangle rect : rectsB2T)
49: g.drawRect(rect.x, rect.y, rect.width,
50: rect.height);
51: }
52: });
53: int count = 0;
54: for (Rectangle rect : rectsB2T) {
55: textPainter.attachVerticalText(this , rect, ""
56: + (++count) + "0", -1, this .font, Color.blue,
57: null, true);
58: }
59: textPainter.renderSurface(g);
60: }
61: }
62:
63: public VerticalTexts2() {
64: super ("Vertical SWT texts");
65: this .setLayout(new BorderLayout());
66: this
67: .add(new VerticalPanel(new Font("Segoe UI", Font.PLAIN,
68: 12)), BorderLayout.CENTER);
69:
70: this .setSize(400, 400);
71: this .setLocationRelativeTo(null);
72: this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
73: }
74:
75: public static void main(String[] args) throws Exception {
76: UIManager
77: .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
78: SwingUtilities.invokeLater(new Runnable() {
79: public void run() {
80: new VerticalTexts2().setVisible(true);
81: }
82: });
83: }
84:
85: }
|