KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > birt > chart > examples > api > script > java > DataPointsScript


1 /*******************************************************************************
2  * Copyright (c) 2004 Actuate Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Actuate Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.birt.chart.examples.api.script.java;
13
14 import org.eclipse.birt.chart.computation.DataPointHints;
15 import org.eclipse.birt.chart.model.component.Label;
16 import org.eclipse.birt.chart.script.ChartEventHandlerAdapter;
17 import org.eclipse.birt.chart.script.IChartScriptContext;
18
19 public class DataPointsScript extends ChartEventHandlerAdapter
20 {
21
22     /*
23      * (non-Javadoc)
24      *
25      * @see org.eclipse.birt.chart.script.IChartItemScriptHandler#beforeDrawDataPointLabel(org.eclipse.birt.chart.computation.DataPointHints,
26      * org.eclipse.birt.chart.model.component.Label,
27      * org.eclipse.birt.chart.script.IChartScriptContext)
28      */

29     public void beforeDrawDataPointLabel( DataPointHints dph, Label label,
30             IChartScriptContext icsc )
31     {
32         double value = ( (Double JavaDoc) dph.getOrthogonalValue( ) ).doubleValue( );
33         if ( value < -10.0 )
34         {
35             label.getCaption( ).getColor( ).set( 32, 168, 255 );
36         }
37         else if ( ( value >= -10.0 ) & ( value <= 10.0 ) )
38         {
39             label.getCaption( ).getColor( ).set( 168, 0, 208 );
40         }
41         else if ( value > 10.0 )
42         {
43             label.getCaption( ).getColor( ).set( 0, 208, 32 );
44         }
45     }
46
47 }
48
Popular Tags