< prev index next >

src/share/classes/sun/tools/jconsole/OverviewPanel.java

Print this page
rev 1501 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: mchung, mfang


   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 
  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,
  69                               Resources.format(Messages.OVERVIEW_PANEL_PLOTTER_ACCESSIBLE_NAME,
  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] == ' ')


< prev index next >