Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 69ba6de

Browse files
committed
Merge pull request #78 from tiwiz/native-look-and-feel
Native look and feel
2 parents 5952071 + 2ba4e21 commit 69ba6de

16 files changed

+63
-124
lines changed

ClassySharkWS/resources/ic_back.png

281 Bytes
Loading

ClassySharkWS/resources/ic_export.png

313 Bytes
Loading
803 Bytes
Loading

ClassySharkWS/resources/ic_menu.png

165 Bytes
Loading

ClassySharkWS/resources/ic_next.png

290 Bytes
Loading

ClassySharkWS/resources/ic_open.png

224 Bytes
Loading

ClassySharkWS/src/com/google/classyshark/gui/GuiMode.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ public void run() {
4040
});
4141
}
4242

43-
private static void setParamsForOtherPlatforms() throws Exception {
44-
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
45-
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
46-
}
47-
4843
private static void buildAndShowClassyShark(List<String> cmdLineArgs) {
4944
try {
50-
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
45+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
5146
} catch (UnsupportedLookAndFeelException | IllegalAccessException | ClassNotFoundException
52-
| InstantiationException ex) {
47+
| InstantiationException | SecurityException ex) {
5348
ex.printStackTrace();
5449
}
5550

ClassySharkWS/src/com/google/classyshark/gui/panel/ClassySharkPanel.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,6 @@ public ClassySharkPanel(JFrame frame, File archive) {
9191

9292
public ClassySharkPanel(JFrame frame) {
9393
super(false);
94-
UIManager.put("swing.boldMetal", Boolean.FALSE);
95-
UIManager.put("Button.select", Color.GRAY);
96-
UIManager.put("ToggleButton.select", Color.GRAY);
97-
98-
UIManager.put("TabbedPane.contentAreaColor ", ColorScheme.LIGHT_GRAY);
99-
UIManager.put("TabbedPane.selected", ColorScheme.BLACK);
100-
UIManager.put("TabbedPane.background", ColorScheme.LIGHT_GRAY);
101-
UIManager.put("TabbedPane.shadow", ColorScheme.FOREGROUND_CYAN);
102-
UIManager.put("TabbedPane.darkShadow", ColorScheme.LIGHT_GRAY);
103-
UIManager.put("TabbedPane.foreground", ColorScheme.FOREGROUND_CYAN);
104-
UIManager.put("TabbedPane.unselectedTabForeground", ColorScheme.FOREGROUND_CYAN);
105-
UIManager.put("TabbedPane.selectedForeground", ColorScheme.FOREGROUND_CYAN);
106-
UIManager.put("TabbedPane.tabInsets", new Insets(5, 10, 5, 10));
107-
UIManager.put("TabbedPane.font", new Font("SansSerif", Font.BOLD, 16));
108-
10994
buildUI();
11095
parentFrame = frame;
11196
toolbar.setText("");
@@ -283,8 +268,6 @@ private void buildUI() {
283268
BorderLayout borderLayout = new BorderLayout();
284269
setLayout(borderLayout);
285270

286-
setBackground(ColorScheme.BLACK);
287-
288271
ringChartPanel = new RingChartPanel(this);
289272

290273
toolbar = new Toolbar(this);
@@ -296,12 +279,11 @@ private void buildUI() {
296279

297280
filesTree = new FilesTree(this);
298281
JTabbedPane jTabbedPane = new JTabbedPane();
299-
jTabbedPane.setBackground(ColorScheme.BACKGROUND);
300282
JScrollPane leftScrollPane = new JScrollPane(filesTree.getJTree());
301283

302-
jTabbedPane.addTab("Archive", leftScrollPane);
284+
jTabbedPane.addTab("Classes", leftScrollPane);
303285
methodsCountPanel = new MethodsCountPanel(this);
304-
jTabbedPane.addTab("Packages", methodsCountPanel);
286+
jTabbedPane.addTab("Methods count", methodsCountPanel);
305287

306288
jTabbedPane.addChangeListener(new ChangeListener() {
307289
@Override
@@ -318,7 +300,6 @@ public void stateChanged(ChangeEvent e) {
318300
});
319301

320302
jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
321-
jSplitPane.setBackground(ColorScheme.BACKGROUND);
322303
jSplitPane.setDividerSize(3);
323304
jSplitPane.setPreferredSize(new Dimension(1000, 700));
324305

ClassySharkWS/src/com/google/classyshark/gui/panel/ColorScheme.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
public class ColorScheme {
2525
private ColorScheme(){}
2626

27-
public static final Color BACKGROUND = new Color(0x2b, 0x2b, 0x2b);
28-
public static final Color FOREGROUND_YELLOW = new Color(0xFF, 0xFF, 0x80);
29-
public static final Color FOREGROUND_ORANGE = new Color(0xFF, 0x99, 0x33);
30-
public static final Color FOREGROUND_CYAN = new Color(0xd8, 0xd8, 0xd8);
31-
public static final Color WHITE = Color.white;
32-
public static final Color BLACK = Color.black;
33-
public static final Color FOREGROUND_YELLOW_ANNOTATIONS = new Color(0xBB, 0xB5, 0x29);
27+
public static final Color DEFAULT = new Color(0x61, 0x62, 0x7C);
28+
public static final Color KEYWORDS = new Color(0xAA, 0x7D, 0x29);
29+
public static final Color IDENTIFIERS = new Color(0x78, 0x8A, 0x4);
30+
public static final Color ANNOTATIONS = new Color(0xD2, 0x16, 0x5B);
3431
public static final Color SELECTION_BG = new Color(0x21, 0x42, 0x83);
35-
public static final Color LIGHT_GRAY = new Color(0x58, 0x58, 0x58);
32+
public static final Color NAMES = new Color(0x61, 0x62, 0x7C);
3633
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.google.classyshark.gui.panel;
2+
3+
4+
public class IconSchemes {
5+
6+
private static final String ROOT_PATH = "resources/";
7+
private static final String EXTENSION = ".png";
8+
9+
public static final String TOGGLE_ICON_PATH = ROOT_PATH + "ic_menu" + EXTENSION;
10+
public static final String RECENT_ICON_PATH = ROOT_PATH + "ic_history" + EXTENSION;
11+
public static final String BACK_ICON_PATH = ROOT_PATH + "ic_back" + EXTENSION;
12+
public static final String NEXT_ICON_PATH = ROOT_PATH + "ic_next" + EXTENSION;
13+
public static final String OPEN_ICON_PATH = ROOT_PATH + "ic_open" + EXTENSION;
14+
public static final String EXPORT_ICON_PATH = ROOT_PATH + "ic_export" + EXTENSION;
15+
}

ClassySharkWS/src/com/google/classyshark/gui/panel/chart/RingChart.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ public void render(int width, int height, ClassNode rootNode, Graphics g) {
163163
imageG2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
164164
imageG2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
165165
imageG2d.setComposite(AlphaComposite.Src);
166-
imageG2d.setColor(ColorScheme.BACKGROUND);
167166
imageG2d.fillRect(0, 0, width, height);
168167

169168
int graphWidth = width - MARGIN * 2;

ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/DisplayArea.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public DisplayArea(final ViewerController viewerController) {
6363
jTextPane.setTransferHandler(new FileTransferHandler(viewerController));
6464

6565
jTextPane.setEditable(false);
66-
jTextPane.setBackground(ColorScheme.BACKGROUND);
6766

6867
jTextPane.addMouseListener(new MouseAdapter() {
6968
@Override
@@ -168,7 +167,7 @@ public void displayReducedClassNames(List<String> classNamesToShow,
168167
String afterMatch = "";
169168

170169
StyleConstants.setFontSize(style, 18);
171-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);
170+
StyleConstants.setForeground(style, ColorScheme.IDENTIFIERS);
172171

173172
Document doc = jTextPane.getDocument();
174173

@@ -191,7 +190,6 @@ public void displayReducedClassNames(List<String> classNamesToShow,
191190
doc.insertString(doc.getLength(), beforeMatch, style);
192191
StyleConstants.setBackground(style, ColorScheme.SELECTION_BG);
193192
doc.insertString(doc.getLength(), match, style);
194-
StyleConstants.setBackground(style, ColorScheme.BACKGROUND);
195193
doc.insertString(doc.getLength(), afterMatch + "\n", style);
196194
} catch (BadLocationException e) {
197195
e.printStackTrace();
@@ -206,7 +204,7 @@ public void displayAllClassesNames(List<String> classNames) {
206204

207205
displayDataState = DisplayDataState.CLASSES_LIST;
208206
StyleConstants.setFontSize(style, 18);
209-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);
207+
StyleConstants.setForeground(style, ColorScheme.IDENTIFIERS);
210208

211209
clearText();
212210

@@ -269,25 +267,25 @@ public void displayClass(List<Translator.ELEMENT> elements) {
269267
for (Translator.ELEMENT e : elements) {
270268
switch (e.tag) {
271269
case MODIFIER:
272-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_ORANGE);
270+
StyleConstants.setForeground(style, ColorScheme.KEYWORDS);
273271
break;
274272
case DOCUMENT:
275-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW);
273+
StyleConstants.setForeground(style, ColorScheme.DEFAULT);
276274
break;
277275
case IDENTIFIER:
278-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);
276+
StyleConstants.setForeground(style, ColorScheme.IDENTIFIERS);
279277
break;
280278
case ANNOTATION:
281-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW_ANNOTATIONS);
279+
StyleConstants.setForeground(style, ColorScheme.ANNOTATIONS);
282280
break;
283281
case XML_TAG:
284-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW);
282+
StyleConstants.setForeground(style, ColorScheme.DEFAULT);
285283
break;
286284
case XML_ATTR_NAME:
287-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);
285+
StyleConstants.setForeground(style, ColorScheme.IDENTIFIERS);
288286
break;
289287
case XML_ATTR_VALUE:
290-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW_ANNOTATIONS);
288+
StyleConstants.setForeground(style, ColorScheme.ANNOTATIONS);
291289
break;
292290
default:
293291
StyleConstants.setForeground(style, Color.LIGHT_GRAY);
@@ -299,7 +297,7 @@ public void displayClass(List<Translator.ELEMENT> elements) {
299297
e.printStackTrace();
300298
}
301299

302-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_CYAN);
300+
StyleConstants.setForeground(style, ColorScheme.IDENTIFIERS);
303301

304302
jTextPane.setDocument(doc);
305303
}
@@ -311,7 +309,7 @@ public void displaySharkey() {
311309
Document doc = jTextPane.getStyledDocument();
312310

313311
try {
314-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW);
312+
StyleConstants.setForeground(style, ColorScheme.DEFAULT);
315313
StyleConstants.setFontSize(style, 13);
316314
StyleConstants.setFontFamily(style, "Menlo");
317315

@@ -331,7 +329,7 @@ public void displayError() {
331329
Document doc = jTextPane.getStyledDocument();
332330

333331
try {
334-
StyleConstants.setForeground(style, ColorScheme.FOREGROUND_YELLOW);
332+
StyleConstants.setForeground(style, ColorScheme.DEFAULT);
335333
StyleConstants.setFontSize(style, 13);
336334
StyleConstants.setFontFamily(style, "Menlo");
337335

ClassySharkWS/src/com/google/classyshark/gui/panel/methodscount/MethodsCountPanel.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,10 @@ private void setup() {
6060
this.setLayout(new BorderLayout());
6161
treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
6262
jTree = new JTree(treeModel);
63-
jTree.setBackground(ColorScheme.BACKGROUND);
6463
jTree.setRootVisible(false);
6564

6665
DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
67-
cellRenderer.setBackground(ColorScheme.BACKGROUND);
68-
cellRenderer.setBackgroundNonSelectionColor(ColorScheme.BACKGROUND);
69-
cellRenderer.setTextNonSelectionColor(ColorScheme.FOREGROUND_CYAN);
66+
7067
cellRenderer.setFont(new Font("Menlo", Font.PLAIN, 18));
7168
jTree.setCellRenderer(cellRenderer);
7269
jTree.addTreeSelectionListener(new TreeSelectionListener() {

ClassySharkWS/src/com/google/classyshark/gui/panel/toolbar/RecentArchivesButton.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616

1717
package com.google.classyshark.gui.panel.toolbar;
1818

19-
import com.google.classyshark.gui.panel.ColorScheme;
19+
import com.google.classyshark.gui.panel.IconSchemes;
2020
import com.google.classyshark.gui.panel.io.RecentArchivesConfig;
21-
import java.awt.Font;
21+
22+
import javax.swing.*;
23+
import javax.swing.event.PopupMenuEvent;
24+
import javax.swing.event.PopupMenuListener;
2225
import java.awt.event.ActionEvent;
2326
import java.awt.event.ActionListener;
2427
import java.awt.event.MouseAdapter;
2528
import java.awt.event.MouseEvent;
2629
import java.io.File;
27-
import javax.swing.BoxLayout;
28-
import javax.swing.JButton;
29-
import javax.swing.JMenuItem;
30-
import javax.swing.JPopupMenu;
31-
import javax.swing.event.PopupMenuEvent;
32-
import javax.swing.event.PopupMenuListener;
3330

3431
/**
3532
* recent files button
@@ -40,17 +37,15 @@ public class RecentArchivesButton extends JButton {
4037
private ToolbarController panel;
4138

4239
public RecentArchivesButton() {
40+
super(new ImageIcon(IconSchemes.RECENT_ICON_PATH));
41+
setToolTipText("History");
4342
popup = new JPopupMenu();
4443
popup.setLayout(new BoxLayout(popup, BoxLayout.Y_AXIS));
4544
popup.addPopupMenuListener(new PopupPrintListener());
4645
buildPopup();
4746

4847
setBorderPainted(false);
4948
setFocusPainted(true);
50-
setForeground(ColorScheme.FOREGROUND_YELLOW);
51-
setBackground(ColorScheme.BLACK);
52-
setFont(new Font("Menlo", Font.BOLD, 18));
53-
setText("፨");
5449
addMouseListener(new MousePopupListener());
5550
}
5651

@@ -64,15 +59,13 @@ private void buildPopup() {
6459

6560
for (String archiveName : RecentArchivesConfig.INSTANCE.getRecentArchiveNames()) {
6661
item = new JMenuItem(archiveName);
67-
item.setFont(new Font("Menlo", Font.BOLD, 16));
6862
popup.add(item);
6963
item.setHorizontalTextPosition(JMenuItem.RIGHT);
7064
item.addActionListener(new RecentFilesListener(archiveName));
7165
}
7266

7367
popup.addSeparator();
7468
final JMenuItem clearRecentArchivesItem = new JMenuItem("Clear");
75-
clearRecentArchivesItem.setFont(new Font("Menlo", Font.BOLD, 16));
7669
popup.add(clearRecentArchivesItem);
7770
clearRecentArchivesItem.addActionListener(new ActionListener() {
7871
@Override

0 commit comments

Comments
 (0)