From: <doc...@us...> - 2007-08-22 00:24:13
|
Revision: 161 http://openpcl.svn.sourceforge.net/openpcl/?rev=161&view=rev Author: documentsystems Date: 2007-08-21 17:24:16 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Howard Hoagland. In the PosStatusBar class, 1. added the method adjustCursorPixelLocationPanelSize() and called it from OpenPCLViewer to change the status bar height and the width of the right side subpanel in the status bar depending on the on the fly font height and width calculation when the user changes the LookAndFeel, 2. Made the status bar 1 text line tall instead of 2 lines tall, 3. Changed the lowered bevel look of the status bar to a non 3D looking line border so it won't remind people of the old school Windows 3.1 days. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/statusbar/PosStatusBar.java Modified: openpcl/src/com/openpcl/viewer/statusbar/PosStatusBar.java =================================================================== --- openpcl/src/com/openpcl/viewer/statusbar/PosStatusBar.java 2007-08-22 00:08:10 UTC (rev 160) +++ openpcl/src/com/openpcl/viewer/statusbar/PosStatusBar.java 2007-08-22 00:24:16 UTC (rev 161) @@ -1,6 +1,7 @@ package com.openpcl.viewer.statusbar; import java.awt.Color; +import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; @@ -10,6 +11,10 @@ import javax.swing.JLabel; import javax.swing.JPanel; +/** + * Status bar panel + * @author DocMagic, Document Systems Inc, HowardH. + */ public class PosStatusBar extends JPanel { private static final long serialVersionUID = 1L; @@ -20,10 +25,8 @@ private JPanel mOnScreenZoomSliderJPanel = new JPanel(); // Text labels - private JLabel mStatusTextLine1JLabel = null; - private JLabel mStatusTextLine2JLabel = null; + private JLabel mStatusTextLineJLabel = null; private JLabel mCursorLocationJLabel = null; - private JLabel mMouseMoveLocationJLabel = null; // TableLayout private double mTloPref = TableLayout.PREFERRED; @@ -44,46 +47,36 @@ } public PosStatusBar() { - this(null); + this((JPanel)null); } // One liner getters - public String getStatusBarText() { return mStatusTextLine1JLabel.getText(); } - public String getStatusBarTextLine2() { return mStatusTextLine2JLabel.getText(); } + public String getStatusBarText() { return mStatusTextLineJLabel.getText(); } public String getCursorPixelLocationText() { return mCursorLocationJLabel.getText(); } public JPanel getOnScreenZoomSliderJPanel() { return mOnScreenZoomSliderJPanel; } // One liner setters - public void setStatusBarText(String pText) { mStatusTextLine1JLabel.setText(pText); } - public void setStatusBarTextLine2(String pText) { mStatusTextLine2JLabel.setText(pText); } + public void setStatusBarText(String pText) { mStatusTextLineJLabel.setText(pText); } public void setCursorPixelLocationText(String pText) { mCursorLocationJLabel.setText(pText); } public void setDefaultStatusBarMsg() { - mStatusTextLine1JLabel.setText(""); - mStatusTextLine2JLabel.setText(""); + mStatusTextLineJLabel.setText(""); } public void setMouseMoveLocation(int pViewNum, int pXPixel, int pYPixel, double pXInches, double pYInches) { - String tPixelLocationString = "View #" + pViewNum + ". (" + pXPixel + "," + pYPixel + ")"; - String tInchesLocationString = String.format("%1$.2f", pXInches) + - " x " + String.format("%1$.2f", pYInches) + " inches"; + String tPixelLocationString = "View #" + pViewNum + ". " + + String.format("%1$.2f", pXInches) + " x " + + String.format("%1$.2f", pYInches) + " inches (" + + pXPixel + "," + pYPixel + ")"; mCursorLocationJLabel.setText(tPixelLocationString); - mMouseMoveLocationJLabel.setText(tInchesLocationString); + adjustCursorPixelLocationPanelSize(); } private void buildUI() { - mStatusTextLine1JLabel = new JLabel(""); - mStatusTextLine2JLabel = new JLabel(""); + mStatusTextLineJLabel = new JLabel(""); setDefaultStatusBarMsg(); - mStatusTextLine1JLabel.setForeground(Color.BLUE); - mStatusTextLine2JLabel.setForeground(Color.BLUE); mCursorLocationJLabel = new JLabel(""); - mCursorLocationJLabel.setForeground(Color.BLUE); - - mMouseMoveLocationJLabel = new JLabel(""); - mMouseMoveLocationJLabel.setForeground(Color.BLUE); - mStatusBarMsgsJPanel = makeStatusLineMsgsPanel(); if (mWantZoomSliderPanel) { @@ -113,11 +106,10 @@ private JPanel makeStatusLineMsgsPanel() { JPanel panel = new JPanel(); setStatusBarSectionAttributes(panel); - double tloGridSpec[][] = new double[][] {{mTloFill }, {mTloPref, mTloPref }}; + double tloGridSpec[][] = new double[][] {{mTloFill }, {mTloPref }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); - panel.add("0,0", mStatusTextLine1JLabel); - panel.add("0,1", mStatusTextLine2JLabel); + panel.add("0,0", mStatusTextLineJLabel); return panel; } @@ -134,15 +126,11 @@ private JPanel makeCursorPixelLocationPanel() { JPanel panel = new JPanel(); setStatusBarSectionAttributes(panel); - Font tJLabelFont = mMouseMoveLocationJLabel.getFont(); - FontMetrics tJLabelFontMetrics = mMouseMoveLocationJLabel.getFontMetrics(tJLabelFont); - mCalculatedMaxWidthOfMouseLocationString = tJLabelFontMetrics.stringWidth("View #99. (9999,9999"); - double tloGridSpec[][] = new double[][] {{mCalculatedMaxWidthOfMouseLocationString }, - {mTloPref, mTloPref }}; + adjustCursorPixelLocationPanelSize(); + double tloGridSpec[][] = new double[][] {{mTloPref}, {mTloPref }}; TableLayout tloLayout = new TableLayout(tloGridSpec); panel.setLayout(tloLayout); panel.add("0,0", mCursorLocationJLabel); - panel.add("0,1", mMouseMoveLocationJLabel); return panel; } @@ -150,9 +138,17 @@ sectionPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( // The below line makes the separator bars wider - BorderFactory.createEmptyBorder(2, 4, 2, 4),BorderFactory.createLoweredBevelBorder()), + BorderFactory.createEmptyBorder(2, 2, 0, 2),BorderFactory.createLineBorder(Color.GRAY)), // The below line makes empty space to the left and right of the text in the sectional box - BorderFactory.createEmptyBorder(2, 5, 2, 5))); + BorderFactory.createEmptyBorder(1, 2, 0, 2))); } + public void adjustCursorPixelLocationPanelSize() { + Font tJLabelFont = mCursorLocationJLabel.getFont(); + FontMetrics tJLabelFontMetrics = mCursorLocationJLabel.getFontMetrics(tJLabelFont); + mCalculatedMaxWidthOfMouseLocationString = tJLabelFontMetrics.stringWidth( + "View #9. 9.99 x 99.99 inches (9999,9999)"); + mCursorLocationJLabel.setPreferredSize( + new Dimension(mCalculatedMaxWidthOfMouseLocationString, tJLabelFontMetrics.getHeight())); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |