0N/A/*
2362N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.tools.jconsole;
0N/A
0N/Aimport java.awt.*;
0N/A
0N/Aimport javax.swing.*;
5335N/A
0N/A
0N/Aimport static javax.swing.SwingConstants.*;
0N/Aimport static sun.tools.jconsole.JConsole.*;
0N/Aimport static sun.tools.jconsole.Utilities.*;
0N/A
0N/A
0N/A@SuppressWarnings("serial")
0N/Aabstract class OverviewPanel extends PlotterPanel {
0N/A private static final Dimension PREFERRED_PLOTTER_SIZE = new Dimension(300, 200);
0N/A private static final Dimension MINIMUM_PLOTTER_SIZE = new Dimension(200, 150);
0N/A
0N/A // This is the default view range for all the overview plotters
0N/A static final int VIEW_RANGE = -1; // Show all data
0N/A
0N/A static Color PLOTTER_COLOR = IS_GTK ? new Color(231, 111, 80) : null;
0N/A
0N/A private JLabel infoLabel;
0N/A
0N/A public OverviewPanel(String title) {
0N/A this(title, null, null, null);
0N/A }
0N/A
0N/A public OverviewPanel(String title, String plotterKey,
0N/A String plotterName, Plotter.Unit plotterUnit) {
0N/A super(title);
0N/A setLayout(new BorderLayout(0, 0));
0N/A
0N/A if (plotterKey != null && plotterName != null) {
0N/A Plotter plotter = new Plotter();
0N/A plotter.setPreferredSize(PREFERRED_PLOTTER_SIZE);
0N/A plotter.setMinimumSize(MINIMUM_PLOTTER_SIZE);
0N/A plotter.setViewRange(VIEW_RANGE);
0N/A if (plotterUnit != null) {
0N/A plotter.setUnit(plotterUnit);
0N/A }
0N/A plotter.createSequence(plotterKey, plotterName, PLOTTER_COLOR, true);
0N/A setAccessibleName(plotter,
5335N/A Resources.format(Messages.OVERVIEW_PANEL_PLOTTER_ACCESSIBLE_NAME,
0N/A title));
0N/A setPlotter(plotter);
0N/A }
0N/A }
0N/A
0N/A
0N/A public JLabel getInfoLabel() {
0N/A if (infoLabel == null) {
0N/A infoLabel = new JLabel("", CENTER) {
0N/A @Override
0N/A public void setText(String text) {
0N/A if (text.startsWith("<html>")) {
0N/A // Replace spaces with nbsp, except the
0N/A // last one of two or more (to allow wrapping)
0N/A StringBuilder buf = new StringBuilder();
0N/A char[] chars = text.toCharArray();
0N/A int n = chars.length;
0N/A for (int i = 0; i < n; i++) {
0N/A if (chars[i] == ' '
0N/A && ((i < n-1 && chars[i+1] == ' ')
0N/A || ((i == 0 || chars[i-1] != ' ')
0N/A && (i == n-1 || chars[i+1] != ' ')))) {
0N/A buf.append("&nbsp;");
0N/A } else {
0N/A buf.append(chars[i]);
0N/A }
0N/A }
0N/A text = buf.toString();
0N/A }
0N/A super.setText(text);
0N/A }
0N/A };
0N/A
0N/A if (IS_GTK) {
0N/A JPanel southPanel = new JPanel(new BorderLayout());
0N/A JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
0N/A southPanel.add(separator, BorderLayout.NORTH);
0N/A southPanel.add(infoLabel, BorderLayout.SOUTH);
0N/A add(southPanel, BorderLayout.SOUTH);
0N/A } else {
0N/A add(infoLabel, BorderLayout.SOUTH);
0N/A }
0N/A }
0N/A return infoLabel;
0N/A }
0N/A}