Back to index

wims  3.65+svn20090927
Public Member Functions | Package Functions | Package Attributes | Private Member Functions | Private Attributes
SharpTools.Histogram Class Reference

This is a fully functional histogram class (including UI). More...

Inheritance diagram for SharpTools.Histogram:
Inheritance graph
[legend]
Collaboration diagram for SharpTools.Histogram:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void show ()
 Show histograms.
void hide ()
 Hide histograms.
void add (String title, CellRange range)
 Add a histogram to the tab panel.
void toggle ()
 toggle the show/hide state
void addHistogram ()
 Add Histogram.
boolean hasChart ()
 Whether the histogram is currently having any defined charts.
void actionPerformed (ActionEvent e)
 This method is activated on the Keystrokes we are listening to in this implementation.

Package Functions

 Histogram (SharpTools sharp, String title, int width, int height)
 Constructor:

Package Attributes

final ImageIcon histogramIcon = new ImageIcon(getClass().getResource("/images/chart.gif"))

Private Member Functions

void bringToFront ()

Private Attributes

SharpTools sharp
JTable table
SharpTableModel model
JTabbedPane tab
int width
int height
String title
Point location
Dimension dim

Detailed Description

This is a fully functional histogram class (including UI).

A tabbed panel is used. Multiple histograms can be managed simultaneously.

Author:
Hua Zhong
Version:
Revision:
1.35

Definition at line 23 of file Histogram.java.


Constructor & Destructor Documentation

SharpTools.Histogram.Histogram ( SharpTools  sharp,
String  title,
int  width,
int  height 
) [inline, package]

Constructor:

Parameters:
modelthe table model to read data from
titlethe title for the histogram window
widththe initial widh
heightthe initial height

Definition at line 46 of file Histogram.java.

                                                                     {
       super(title);
       setSize(width, height);
       //     setIconImage(histogramIcon.getImage());

       this.sharp = sharp;
       this.table = sharp.getTable();
       this.model = sharp.getTableModel();
       this.title = title;
       this.width = width;
       this.height = height;

       tab = new JTabbedPane();

       // register toggle key
       table.registerKeyboardAction
           (this, SharpTools.translation.getProperty("Show"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F8,0, false),
            JComponent.WHEN_FOCUSED);

       // register add histogram key
       table.registerKeyboardAction
           (this, SharpTools.translation.getProperty("Add"),
            KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.CTRL_MASK, false),
            JComponent.WHEN_FOCUSED);
       
       
       Container container = getContentPane();
       container.setLayout(new BorderLayout());

       container.add(tab, BorderLayout.CENTER);
       /*
       if (selected >= 0) {
           selected = Math.min(selected, tab.getTabCount()-1);
           tab.setSelectedIndex(selected);
       }
       */
       setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

Member Function Documentation

void SharpTools.Histogram.actionPerformed ( ActionEvent  e) [inline]

This method is activated on the Keystrokes we are listening to in this implementation.

Here it listens for "Show" ActionCommands. Without this listener, when we press certain keys the individual cell will be activated into editing mode in addition to the effect of the key accelerators we defined with menu items. With this key listener, we avoid this side effect.

Definition at line 180 of file Histogram.java.

                                               {

       if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("Show"))==0) {
           toggle();
       }
       else if (e.getActionCommand().compareTo(SharpTools.translation.getProperty("Add"))==0) {
           addHistogram();
       }
    }

Here is the call graph for this function:

void SharpTools.Histogram.add ( String  title,
CellRange  range 
) [inline]

Add a histogram to the tab panel.

Parameters:
titlethe title for the histogram
rangethe selected cell range

Definition at line 116 of file Histogram.java.

                                                   {

       bringToFront();

       if (!isVisible())
           show();

       TabPanel newTab = new TabPanel(model, range, this, tab);
       
       tab.addTab(title, null, newTab, range.toString());
       
       tab.setSelectedIndex(tab.getTabCount()-1);
       newTab.getOptions(true); // first time
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Add Histogram.

Definition at line 147 of file Histogram.java.

                               {
       //checks if anything is selected   
       if (table.getSelectedRowCount() != 0) { 
           CellRange range = new CellRange
              (table.getSelectedRows(), table.getSelectedColumns());

           String title = SharpTools.translation.getProperty("Chart")+" "+(tab.getTabCount()+1);
           add(title, range);
           
           sharp.checkShowHistogramState();
           
       } else {
            sharp.noCellsSelected(SharpTools.translation.getProperty("Histogram"));
        }
    }        

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.Histogram.bringToFront ( ) [inline, private]

Definition at line 87 of file Histogram.java.

                                {
       if (getState() == Frame.ICONIFIED)
           setState(Frame.NORMAL);
       
       toFront();
    }

Here is the caller graph for this function:

Whether the histogram is currently having any defined charts.

Returns:
true or false

Definition at line 168 of file Histogram.java.

                              {
       return tab.getTabCount()>0;
    }

Here is the caller graph for this function:

void SharpTools.Histogram.hide ( ) [inline]

Hide histograms.

Definition at line 105 of file Histogram.java.

                       {
       super.hide();
       sharp.checkShowHistogramState();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.Histogram.show ( ) [inline]

Show histograms.

Definition at line 97 of file Histogram.java.

                       {
       super.show();
       sharp.checkShowHistogramState();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SharpTools.Histogram.toggle ( ) [inline]

toggle the show/hide state

Definition at line 134 of file Histogram.java.

                         {
       if (isVisible())
           hide();
       else if (hasChart()) {
           //     setSize(width, height);
           bringToFront();
           show();
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Dimension SharpTools.Histogram.dim [private]

Definition at line 32 of file Histogram.java.

Definition at line 29 of file Histogram.java.

final ImageIcon SharpTools.Histogram.histogramIcon = new ImageIcon(getClass().getResource("/images/chart.gif")) [package]

Definition at line 33 of file Histogram.java.

Definition at line 31 of file Histogram.java.

Definition at line 26 of file Histogram.java.

Definition at line 24 of file Histogram.java.

JTabbedPane SharpTools.Histogram.tab [private]

Definition at line 27 of file Histogram.java.

JTable SharpTools.Histogram.table [private]

Definition at line 25 of file Histogram.java.

String SharpTools.Histogram.title [private]

Definition at line 30 of file Histogram.java.

Definition at line 28 of file Histogram.java.


The documentation for this class was generated from the following file: