9 * by Oracle in the LICENSE file that accompanied this code. 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 * 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. 24 */ 25 26 package sun.tools.jconsole; 27 28 import java.awt.*; 29 import java.awt.event.*; 30 31 import javax.swing.*; 32 import javax.swing.border.*; 33 34 import static javax.swing.SwingConstants.*; 35 import static sun.tools.jconsole.JConsole.*; 36 import static sun.tools.jconsole.Resources.*; 37 import static sun.tools.jconsole.Utilities.*; 38 39 40 @SuppressWarnings("serial") 41 abstract class OverviewPanel extends PlotterPanel { 42 private static final Dimension PREFERRED_PLOTTER_SIZE = new Dimension(300, 200); 43 private static final Dimension MINIMUM_PLOTTER_SIZE = new Dimension(200, 150); 44 45 // This is the default view range for all the overview plotters 46 static final int VIEW_RANGE = -1; // Show all data 47 48 static Color PLOTTER_COLOR = IS_GTK ? new Color(231, 111, 80) : null; 49 50 private JLabel infoLabel; 51 52 public OverviewPanel(String title) { 53 this(title, null, null, null); 54 } 55 56 public OverviewPanel(String title, String plotterKey, 57 String plotterName, Plotter.Unit plotterUnit) { 58 super(title); 59 setLayout(new BorderLayout(0, 0)); 60 61 if (plotterKey != null && plotterName != null) { 62 Plotter plotter = new Plotter(); 63 plotter.setPreferredSize(PREFERRED_PLOTTER_SIZE); 64 plotter.setMinimumSize(MINIMUM_PLOTTER_SIZE); 65 plotter.setViewRange(VIEW_RANGE); 66 if (plotterUnit != null) { 67 plotter.setUnit(plotterUnit); 68 } 69 plotter.createSequence(plotterKey, plotterName, PLOTTER_COLOR, true); 70 setAccessibleName(plotter, 71 getText("OverviewPanel.plotter.accessibleName", 72 title)); 73 setPlotter(plotter); 74 } 75 } 76 77 78 public JLabel getInfoLabel() { 79 if (infoLabel == null) { 80 infoLabel = new JLabel("", CENTER) { 81 @Override 82 public void setText(String text) { 83 if (text.startsWith("<html>")) { 84 // Replace spaces with nbsp, except the 85 // last one of two or more (to allow wrapping) 86 StringBuilder buf = new StringBuilder(); 87 char[] chars = text.toCharArray(); 88 int n = chars.length; 89 for (int i = 0; i < n; i++) { 90 if (chars[i] == ' ' 91 && ((i < n-1 && chars[i+1] == ' ') | 9 * by Oracle in the LICENSE file that accompanied this code. 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 * 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. 24 */ 25 26 package sun.tools.jconsole; 27 28 import java.awt.*; 29 30 import javax.swing.*; 31 32 import sun.tools.jconsole.resources.Messages; 33 34 import static javax.swing.SwingConstants.*; 35 import static sun.tools.jconsole.JConsole.*; 36 import static sun.tools.jconsole.Utilities.*; 37 38 39 @SuppressWarnings("serial") 40 abstract class OverviewPanel extends PlotterPanel { 41 private static final Dimension PREFERRED_PLOTTER_SIZE = new Dimension(300, 200); 42 private static final Dimension MINIMUM_PLOTTER_SIZE = new Dimension(200, 150); 43 44 // This is the default view range for all the overview plotters 45 static final int VIEW_RANGE = -1; // Show all data 46 47 static Color PLOTTER_COLOR = IS_GTK ? new Color(231, 111, 80) : null; 48 49 private JLabel infoLabel; 50 51 public OverviewPanel(String title) { 52 this(title, null, null, null); 53 } 54 55 public OverviewPanel(String title, String plotterKey, 56 String plotterName, Plotter.Unit plotterUnit) { 57 super(title); 58 setLayout(new BorderLayout(0, 0)); 59 60 if (plotterKey != null && plotterName != null) { 61 Plotter plotter = new Plotter(); 62 plotter.setPreferredSize(PREFERRED_PLOTTER_SIZE); 63 plotter.setMinimumSize(MINIMUM_PLOTTER_SIZE); 64 plotter.setViewRange(VIEW_RANGE); 65 if (plotterUnit != null) { 66 plotter.setUnit(plotterUnit); 67 } 68 plotter.createSequence(plotterKey, plotterName, PLOTTER_COLOR, true); 69 setAccessibleName(plotter, 70 Resources.format(Messages.OVERVIEW_PANEL_PLOTTER_ACCESSIBLE_NAME, 71 title)); 72 setPlotter(plotter); 73 } 74 } 75 76 77 public JLabel getInfoLabel() { 78 if (infoLabel == null) { 79 infoLabel = new JLabel("", CENTER) { 80 @Override 81 public void setText(String text) { 82 if (text.startsWith("<html>")) { 83 // Replace spaces with nbsp, except the 84 // last one of two or more (to allow wrapping) 85 StringBuilder buf = new StringBuilder(); 86 char[] chars = text.toCharArray(); 87 int n = chars.length; 88 for (int i = 0; i < n; i++) { 89 if (chars[i] == ' ' 90 && ((i < n-1 && chars[i+1] == ' ') |