author | sla |
Tue, 19 Mar 2013 13:26:42 +0100 | |
changeset 18197 | ae73e4f50e08 |
parent 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
12851
diff
changeset
|
2 |
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.tools.jconsole; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
||
30 |
import javax.swing.*; |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
31 |
|
2 | 32 |
|
33 |
import static javax.swing.SwingConstants.*; |
|
34 |
import static sun.tools.jconsole.JConsole.*; |
|
35 |
import static sun.tools.jconsole.Utilities.*; |
|
36 |
||
37 |
||
38 |
@SuppressWarnings("serial") |
|
39 |
abstract class OverviewPanel extends PlotterPanel { |
|
40 |
private static final Dimension PREFERRED_PLOTTER_SIZE = new Dimension(300, 200); |
|
41 |
private static final Dimension MINIMUM_PLOTTER_SIZE = new Dimension(200, 150); |
|
42 |
||
43 |
// This is the default view range for all the overview plotters |
|
44 |
static final int VIEW_RANGE = -1; // Show all data |
|
45 |
||
46 |
static Color PLOTTER_COLOR = IS_GTK ? new Color(231, 111, 80) : null; |
|
47 |
||
48 |
private JLabel infoLabel; |
|
49 |
||
50 |
public OverviewPanel(String title) { |
|
51 |
this(title, null, null, null); |
|
52 |
} |
|
53 |
||
54 |
public OverviewPanel(String title, String plotterKey, |
|
55 |
String plotterName, Plotter.Unit plotterUnit) { |
|
56 |
super(title); |
|
57 |
setLayout(new BorderLayout(0, 0)); |
|
58 |
||
59 |
if (plotterKey != null && plotterName != null) { |
|
60 |
Plotter plotter = new Plotter(); |
|
61 |
plotter.setPreferredSize(PREFERRED_PLOTTER_SIZE); |
|
62 |
plotter.setMinimumSize(MINIMUM_PLOTTER_SIZE); |
|
63 |
plotter.setViewRange(VIEW_RANGE); |
|
64 |
if (plotterUnit != null) { |
|
65 |
plotter.setUnit(plotterUnit); |
|
66 |
} |
|
67 |
plotter.createSequence(plotterKey, plotterName, PLOTTER_COLOR, true); |
|
68 |
setAccessibleName(plotter, |
|
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
69 |
Resources.format(Messages.OVERVIEW_PANEL_PLOTTER_ACCESSIBLE_NAME, |
2 | 70 |
title)); |
71 |
setPlotter(plotter); |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
||
76 |
public JLabel getInfoLabel() { |
|
77 |
if (infoLabel == null) { |
|
78 |
infoLabel = new JLabel("", CENTER) { |
|
79 |
@Override |
|
80 |
public void setText(String text) { |
|
81 |
if (text.startsWith("<html>")) { |
|
82 |
// Replace spaces with nbsp, except the |
|
83 |
// last one of two or more (to allow wrapping) |
|
84 |
StringBuilder buf = new StringBuilder(); |
|
85 |
char[] chars = text.toCharArray(); |
|
86 |
int n = chars.length; |
|
87 |
for (int i = 0; i < n; i++) { |
|
88 |
if (chars[i] == ' ' |
|
89 |
&& ((i < n-1 && chars[i+1] == ' ') |
|
90 |
|| ((i == 0 || chars[i-1] != ' ') |
|
91 |
&& (i == n-1 || chars[i+1] != ' ')))) { |
|
92 |
buf.append(" "); |
|
93 |
} else { |
|
94 |
buf.append(chars[i]); |
|
95 |
} |
|
96 |
} |
|
97 |
text = buf.toString(); |
|
98 |
} |
|
99 |
super.setText(text); |
|
100 |
} |
|
101 |
}; |
|
102 |
||
103 |
if (IS_GTK) { |
|
104 |
JPanel southPanel = new JPanel(new BorderLayout()); |
|
105 |
JSeparator separator = new JSeparator(JSeparator.HORIZONTAL); |
|
106 |
southPanel.add(separator, BorderLayout.NORTH); |
|
107 |
southPanel.add(infoLabel, BorderLayout.SOUTH); |
|
108 |
add(southPanel, BorderLayout.SOUTH); |
|
109 |
} else { |
|
110 |
add(infoLabel, BorderLayout.SOUTH); |
|
111 |
} |
|
112 |
} |
|
113 |
return infoLabel; |
|
114 |
} |
|
115 |
} |