Creating and Formatting Graphs sample demonstrates how a BI Beans application can generate a Graph using query builder and Graph format panels. BIGraph extends BIFrame that provides connection to Oracle9i OLAP.
BIGraph provides a menu to invoke a Query builder 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.
If you have not already done so, you must perform several installation
and configuration tasks, then open the workspace javaclient\javaclient.jws
under the samples
directory within JDeveloper. All the necessary
files for this sample can be found in the modifying_graphs.jpr
project under the javaclient.jws
workspace.
The Graph bean provides various formatting panels to set attributes of various graph components. This sample show how to create these panel and add them to a wizard. This sample also uses Query Builder to generate the query. The QueryBuilder bean can also be run in wizard mode, so, instead of creating a wizard provided by JEWT or JDK, this sample shows how to add panels to Query Builder in wizard mode. The following line shows how to set wizard mode on Query Builder
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 Query builder wizard expects an instance of StandardPanel interface so the StandardWizardPanel
class is written to implement that interface. To listen to the wizard's event,
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, 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 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, 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());
}
}
);
To run the BIGraph example within JDeveloper, simply right-click the file BIGraph.java
and choose Run BIGraph.
From the File Menu in the application, choose Connect and enter
the username and password of the user that owns the BI Beans Catalog (e.g. BIBCAT).
![]() |
|
---|---|
Copyright © 2002, 2003 Oracle. All Rights Reserved. |
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. |