Drill Down JavaBean Demo and Tutorial

Overview
Features

Applets constructed with DrillDown JavaBean
DrillDown Chart 1
DrillDown Chart 2
DrillDown Chart 3

Charts defined by JavaScript
Bean interacting with JavaScript

Data Model of DrillDown Bean

API of DrillDown Bean

Ask for DrillDown Beta

Copyright © 1998-1999
Vasanth Desai
The DrillDown JavaBean- API

Guidelines for using API

  1. Create a DrillDown bean object
  2. Add it to a container
  3. Add atleast one viewer
    If there are no viewers, data intialization will fail and return value of data initialization methods will be false.
    The bean will show a logo but no chart.
  4. Intialize data using one of the data loading API
Once the bean becomes 'live' you can add addtioanal viewers,remove viewers, intialize data. These can be done repeatedly in any order.
The following is the list of methods 'exposed' by bean. There are no property sheet properties ! (Except background color and font)

Methods affecting Visual Properties

  • setShowValues(boolean b)
    The values on the Pie chart are shown as percentages (Default). After this method is invoked,the Pie chart will show actual values instead of percentages. You should invoke this method after Pie view has been added to the bean. If the Pie is not one of the existing views, the call is ignored.
  • setShowTotal(boolean b)
    In the table/list view after list of values, the total is displayed (Default). By invoking setShowTotal(false) you can suppress Total line. Automatically the percentages are also not shown.
  • setScalePercent(int n)
    In the Bar and Line view of chart, bean does scaling such that none of the values will exceed the height of the chart. However when you drill down the heights of lower layers of chart may appear too small. When the mouse is on an item, you can click right mouse button to view a popup menu. When you select Zoom In of the popup menu, items will appear 15% taller(Default). By invoking this method you can set the scaling percentage to any value. It is in percent. e.g. If you want heights to be doubled percentage will be 100
  • setItemNameWidth(int n)
    This value determines width of name in Table view.Width is in terms of letter 'm' of current font. You may have to try couple of values before you find something sattisfacory.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setItemLWidth(int n)
    This value determines the x distance in pixel between two points in Line graph.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setItemWidth(int n)
    This value determines the x distance in pixel between two bars in Bar graph.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setBarWidth(int n)
    This value determines the width in pixel of bars in Bar graph.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setPieHeight(int n)
    This value determines the height in pixel of Pie in Pie graph.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setBottomSpacer(int n)
    This value determines the height in pixel of bottom spacer of Line,Pie and Bar graphs. If you use a larger font, the bottom spacer may not adequete to show legends.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setTopSpacer(int n)
    This value determines the height in pixel of top spacer of Line,Pie,Bar and Table views. If you use a larger font, the top spacer may not adequete to show titles.
    The user may find it more convenient to change value by popup dialog,created when he/she clicks the right mouse button when it is not on an item.
  • setBackground(Color clr)
    Changes background color of all the added views.(i.e those shown on the toolbar)
  • setFont(Font fnt)
    Changes Font of all the added views.(i.e those shown on the toolbar)
  • setView(String s)
    Makes the view repesented by 's' as curent. Valid values are Pie, Bar, Line and Table. If it is not one of the 'added' views the method is ignored
  • refresh()
    Refreshes the current view
  • setDoubleBuffering(boolean b)
    The bean uses its own double buffering. In some environments mouse display is not properly handled. Visual manifestation of this is when you drill down and move mouse; the colors and text of top layer appear where the mouse was present. By setting the value to false (default is true), you will be disabling internal doublebuffering by DrillDown bean. This may cause screen to flicker with some monitors.


Methods for controlling bean

  • actionPerformed(ActionEvent e)
    The bean processes following action command string of ActionEvent e:
    • UP --- Chart Drills up (ignored if the chart is not mulitilayer)
    • refresh --- Refreshes current view
    • R --- Removes all viewers
    • loadfile fname --- Initializes with data from fname. Use this API when the bean is an Application. fname is relative current working directory.
    • loadurl fname --- Initializes with data from fname. Use this API when the bean is an Applet. fname is relative current working directory.
    • addviewers vname --- adds view represendted by vname
    • addviewers vname1 vname2
    • addviewers vname1 vname2 vname3
    • addviewers vname1 vname2 vname3 vname4
    • addUpB --- add Up button to toolbar. Useful when multilayer charts are displyed
  • up()
    Drills up

Methods for building

  • setApplet(Applet app)
    Applicable when the Bean is used in an Applet. If the DrillDown bean is not added to container before addViewer(s) are called then you must call this method and pass the reference to 'this' applet.
  • addViewer(String s)
  • addViewers(String s1,String s2)
  • addViewers(String s1,String s2,String s3)
  • addViewers(String s1,String s2,String s3,String s4)
    Adds viewers represented by string arguments. Valid values are "Pie", "Line", "Bar", "Table". Names are case insensitive.
  • removeViewer(String s)
    Removes viewer represented by 's'
  • removeViewers()
  • addUpButton()
    After you have drilled down, you can go up by pressing up arrow key on the keyboard. By invoking this method a button is addted to the toolbar. You can click this button to go 'up'.
  • removeUpButton()
Methods for initializing data

  • loadSimpleChart(String s)
    The string s conatains data for one layer in specified format. (single layer chart)
  • loadDDChart(String name,String s[])
    Multilayer chart. The array s has the layers. Name is the name of the chart.
  • loadDDChart1(String name,String data)
    Similar to above. The elements of the array are concatenated into a single string with separators '_X_'
  • loadDDChartFromFile(String fname)
    The data for the multilayer chart is read from file fname. This method is suitable for standalone ie Java applications. If used in Applets it will fail throwing security exception unless you allow local file access for the applets.
  • loadDDChartFromURL(String fname)
    The data for the multilayer chart is from file fname relative to the html page containing the applet.
  • loadDDChartFromURL(URL url,String fname)
    The data for the multilayer chart is from file fname relative to the url. You noramlly set url with getDocumentBase() and call this method.
  • loadDDChartFromAppletParams(Applet app)
    The data for the multilayer chart is from PARAMS tags. There must be one layer with name "DATASET". This method requires applet refrence (usually this).
  • loadChartFromAppletParams(Applet app,String cname)
    The data for the single-layer chart is from PARAMS tags. There must be one layer with name cname. This method requires applet refrence (usually this).

Misc Methods

  • setTitle(String s)
    Use string s for the title instead of value derived from data
  • setPathSeparator(char c)
    In the case of multilayer chart it will be convenient to construct unique names for the items the way OS (Unix, DOS,Windos) identify files and folders.
    This scheme will be useful when you write software to generate data for the bean. e.g DP and DPodbc utilities supplied with the bean generate unique item names by this method. This pathname will be used to locate items and while displaying the 'leaf' stub is used. By default the bean will use '/' to extract the tail stub. You change the delimiter by this method.
  • getLevel()
    When the bean is displaying a multilayer chart, this method will return current level. The value is not useful in other contexts.
  • getLayerName()
    When the bean is displaying a multilayer chart, this method will return current layer name. The value is not useful in other contexts.