The Modifying Graphs sample demonstrates how a BI Beans application can generate
a Graph using query builder and Graph format panels. BIGraph
extends
BIFrame
, which provides a connection to Oracle OLAP.
BIGraph
provides a menu to invoke a QueryBuilder that runs in
a wizard mode. The following graph format panels are added to this wizard at
run time: GraphLayout, GraphType, Legend, Title, PlotArea, GroupAxis (O1Axis),
and ValueAxis (X1, Y1 and Y2Axis). This sample also provides menus to invoke
these panels individually.
The Graph bean provides various formatting panels to set attributes of various graph components. This sample show how to create these panels and add them to a wizard. This sample also uses the QueryBuilder to generate the query. The QueryBuilder bean can also be run in wizard mode, so instead of creating a wizard provided by JEWT or the JDK, this sample shows how to add panels to Query Builder in wizard mode. The following line shows how to set wizard mode on the QueryBuilder.
m_queryBuilder.setMode(QueryBuilder.WIZARD);
This is a sample of how a graph type panel is initialized and added to the wizard:
// adding graph type panel to query builder wizard
StandardWizardPanel
wizPanel = new StandardWizardPanel ("GraphType");
if(m_graphTypePanel
== null)
m_graphTypePanel = new GraphType(m_graph);
else
m_graphTypePanel.setGraph(m_graph);
wizPanel.add (m_graphTypePanel);
m_queryBuilder.addPanel((StandardPanel) wizPanel, QueryBuilder.LAYOUT_PANEL_ID);
The QueryBuilder wizard expects an instance of the StandardPanel
interface, so the StandardWizardPanel
class is written to implement
that interface. To listen to the wizard's event, a WizardListener
is added:
((QueryBuilderDialog)m_queryBuilder.getContainer()).getWizard().addWizardListener(this);
following methods are provided by this listener:
public void wizardSelectionChanged(WizardEvent e);
public void wizardValidatePage(WizardEvent
e);
public void wizardApplyState(WizardEvent e);
public
void wizardCanceled(WizardEvent e);
public void wizardFinished(WizardEvent
e);
To invoke an individual panel, an ActionListener
is added to each
menu.
m_graphTypeMenu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent
event) {
_showGraphTypeDialog();
}
});
Each panel is invoked in a dialog that contains Apply and Cancel buttons. An Error dialog is displayed if the graph is null.
private void _showGraphTypeDialog()
{
if(m_graph == null) {
JOptionPane.showMessageDialog(this, "Graph is null", "Error!", JOptionPane.ERROR_MESSAGE);
return;
}
if(m_graphTypePanel == null)
m_graphTypePanel = new GraphType(m_graph);
else
m_graphTypePanel.setGraph(m_graph);
PanelDialog d = new PanelDialog( WindowUtils.parentFrame(this),"Graph
Type", m_graphTypePanel);
d.show();
}
This sample also updates the status bar with the name of the selected graph
subcomponent. To do this, a ViewMouseListener
is added to the generated
graph:
m_graph.addViewMouseListener( new ViewMouseListenerAdapter() {
// Invoked when a mouse button has been pressed on a component.
public void mousePressed(ViewMouseEvent e) {
getStatusBar().setText(" Currently selected object is " + m_graph.getSelectedObject().getName());
}
}
);
Copyright © 2004 Oracle Corporation. All Rights Reserved. |