Commit 5964a7aa authored by Claes Sjofors's avatar Claes Sjofors

Java piechart and barchart implemented

parent 39bfb511
This diff is collapsed.
This diff is collapsed.
......@@ -34,6 +34,8 @@ local_java_sources := \
JopTrend.java \
JopAxis.java \
JopAxisarc.java \
JopPie.java \
JopBarChart.java \
GeTable.java \
GeDynElem.java \
GeDynDigLowColor.java \
......
......@@ -1082,6 +1082,22 @@ class Graph {
*/
int export_TrendTraceAttr( ofstream& fp, grow_tObject object, int cnt);
//! Export java code for dynamics of a pie object.
/*!
\param fp Output file.
\param object Object.
\param cnt Index for javabean name.
*/
int export_PieTraceAttr( ofstream& fp, grow_tObject object, int cnt);
//! Export java code for dynamics of a barchart object.
/*!
\param fp Output file.
\param object Object.
\param cnt Index for javabean name.
*/
int export_BarChartTraceAttr( ofstream& fp, grow_tObject object, int cnt);
//! Export java code for dynamics of a table object.
/*!
\param fp Output file.
......
......@@ -1483,6 +1483,10 @@ int Graph::export_gejava_nodeclass( ofstream& fp, grow_tNodeClass nodeclass)
export_BarTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTrend)
export_TrendTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowPie)
export_PieTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowBarChart)
export_BarChartTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTable)
export_TableTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowSlider)
......@@ -1627,6 +1631,10 @@ int Graph::export_javaframe( char *filename, char *bean_name, int applet,
export_BarTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTrend)
export_TrendTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowPie)
export_PieTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowBarChart)
export_BarChartTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTable)
export_TableTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowSlider)
......@@ -1882,6 +1890,10 @@ int Graph::export_gejava( char *filename, char *bean_name, int applet, int html)
export_BarTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTrend)
export_TrendTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowPie)
export_PieTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowBarChart)
export_BarChartTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowTable)
export_TableTraceAttr( fp, *object_p, i);
else if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowSlider)
......@@ -2284,19 +2296,6 @@ int Graph::export_BarTraceAttr( ofstream& fp, grow_tObject object, int cnt)
dyn->export_java( object, fp, var_name);
}
#if 0
grow_GetTraceAttr( object, &trace_data);
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", cnt);
if ( strcmp( trace_data->data[0], "") != 0)
{
fp <<
" " << var_name << ".setPwrAttribute(\"" << trace_data->data[0] << "\");" << endl;
}
#endif
return 1;
}
......@@ -2344,24 +2343,87 @@ int Graph::export_TrendTraceAttr( ofstream& fp, grow_tObject object, int cnt)
dyn->export_java( object, fp, var_name);
}
return 1;
}
#if 0
grow_GetTraceAttr( object, &trace_data);
int Graph::export_PieTraceAttr( ofstream& fp, grow_tObject object, int cnt)
{
GeDyn *dyn;
char class_name[] = "JopPie";
char var_name[40];
grow_GetUserData( object, (void **)&dyn);
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", cnt);
if ( strcmp( trace_data->data[0], "") != 0)
{
if ( strcmp( trace_data->data[0], "") != 0)
for ( GeDynElem *elem = dyn->elements; elem; elem = elem->next) {
if ( elem->dyn_type == ge_mDynType_Pie) {
fp <<
" " << var_name << ".setPwrAttribute1(\"" << trace_data->data[0] << "\");" << endl;
if ( strcmp( trace_data->data[1], "") != 0)
" " << var_name << ".setPwrAttribute(new String[]{";
for ( int i = 0; i < PIE_MAX_SECTORS; i++) {
if ( strcmp( ((GePie *)elem)->attribute[i], "") != 0)
fp << "\"" << ((GePie *)elem)->attribute[i] << "\"";
else
fp << "null";
if ( i != PIE_MAX_SECTORS - 1)
fp << ",";
}
fp << "});" << endl <<
" " << var_name << ".setFixRange(" << ((GePie *)elem)->fix_range << ");" << endl;
}
break;
}
if ( dyn->total_action_type & ~ge_mActionType_Inherit) {
fp <<
" " << var_name << ".dd.setActionType(" << (int)dyn->total_action_type << ");" << endl <<
" " << var_name << ".dd.setAccess(" << (int)dyn->access << ");" << endl;
dyn->export_java( object, fp, var_name);
}
return 1;
}
int Graph::export_BarChartTraceAttr( ofstream& fp, grow_tObject object, int cnt)
{
GeDyn *dyn;
char class_name[] = "JopBarChart";
char var_name[40];
grow_GetUserData( object, (void **)&dyn);
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", cnt);
for ( GeDynElem *elem = dyn->elements; elem; elem = elem->next) {
if ( elem->dyn_type == ge_mDynType_BarChart) {
fp <<
" " << var_name << ".setPwrAttribute2(\"" << trace_data->data[1] << "\");" << endl;
" " << var_name << ".setPwrAttribute(new String[]{";
for ( int i = 0; i < BARCHART_MAX_BARSEGMENTS; i++) {
if ( strcmp( ((GeBarChart *)elem)->attribute[i], "") != 0)
fp << "\"" << ((GeBarChart *)elem)->attribute[i] << "\"";
else
fp << "null";
if ( i != BARCHART_MAX_BARSEGMENTS - 1)
fp << ",";
}
fp << "});" << endl;
}
break;
}
#endif
if ( dyn->total_action_type & ~ge_mActionType_Inherit) {
fp <<
" " << var_name << ".dd.setActionType(" << (int)dyn->total_action_type << ");" << endl <<
" " << var_name << ".dd.setAccess(" << (int)dyn->access << ");" << endl;
dyn->export_java( object, fp, var_name);
}
return 1;
}
......@@ -2399,6 +2461,8 @@ int Graph::export_ObjectTraceAttr( ofstream& fp, grow_tObject object, int cnt) {
int Graph::export_GejavaObjectTraceAttr( ofstream& fp, grow_tObject object, int cnt) { return 1;}
int Graph::export_BarTraceAttr( ofstream& fp, grow_tObject object, int cnt){ return 1;}
int Graph::export_TrendTraceAttr( ofstream& fp, grow_tObject object, int cnt) { return 1;}
int Graph::export_PieTraceAttr( ofstream& fp, grow_tObject object, int cnt){ return 1;}
int Graph::export_BarChartTraceAttr( ofstream& fp, grow_tObject object, int cnt){ return 1;}
int Graph::export_TableTraceAttr( ofstream& fp, grow_tObject object, int cnt) { return 1;}
int Graph::export_SliderTraceAttr( ofstream& fp, grow_tObject object, int cnt) { return 1;}
......
......@@ -45,6 +45,8 @@
#include "glow_growctx.h"
#include "glow_grownode.h"
#include "glow_exportjbean.h"
#include "glow_growpie.h"
#include "glow_growbarchart.h"
#define glow_cJBean_Offset 2
#define glow_cJBean_SizeCorr 2
......@@ -3892,6 +3894,201 @@ void GlowExportJBean::axisarc( double x1, double y1, double x2, double y2,
}
}
void GlowExportJBean::pie( double x1, double y1, double x2, double y2, int angle1, int angle2,
glow_eDrawType border_drawtype,
glow_eDrawType fill_drawtype,
int fill,
int border,
int sectors,
glow_eDrawType *sector_colors,
double min_value,
double max_value,
int line_width,
double rotate,
double shadow_width, int shadow,
glow_eGradient gradient,
int gc1, int gc2,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp)
{
double dim_x0, dim_x1, dim_y0, dim_y1;
char var_name[40];
char class_name[] = "JopPie";
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", node_cnt);
switch ( pass)
{
case glow_eExportPass_Shape:
break;
case glow_eExportPass_Declare:
{
fp <<
" " << class_name << " " << var_name << ";" << endl;
break;
}
case glow_eExportPass_Attributes:
{
((GrowCtx *)ctx)->measure_javabean( &dim_x1, &dim_x0, &dim_y1, &dim_y0);
fp <<
" " << var_name << " = new " << class_name << "(session);" << endl <<
" " << var_name << ".setBounds(new Rectangle(" <<
(int)(x1 - dim_x0 + glow_cJBean_Offset) << "," <<
(int)(y1 - dim_y0 + glow_cJBean_Offset) << "," <<
(int)(x2 - x1) << "," <<
(int)(y2 - y1) << "));" <<
" " << var_name << ".setAngle1(" << angle1 << "F);" << endl <<
" " << var_name << ".setAngle2(" << angle2 << "F);" << endl;
if ( fill_drawtype != glow_eDrawType_No)
fp <<
" " << var_name << ".setFillColor(" << (int)fill_drawtype << ");" << endl;
if ( border_drawtype != glow_eDrawType_No)
fp <<
" " << var_name << ".setBorderColor(" << (int)border_drawtype << ");" << endl;
else
fp <<
" " << var_name << ".setBorderColor( 0);" << endl;
if ( fill)
fp <<
" " << var_name << ".setDrawFill(1);" << endl;
if ( border)
fp <<
" " << var_name << ".setDrawBorder(1);" << endl;
fp <<
" " << var_name << ".setSectors(" << sectors << ");" << endl <<
" " << var_name << ".setSectorColors(new int[] {";
for ( int i = 0; i < PIE_MAX_SECTORS; i++) {
fp << sector_colors[i];
if ( i != PIE_MAX_SECTORS - 1)
fp << ",";
}
fp << "});" << endl;
fp <<
" " << var_name << ".setLineWidth(" << line_width << ");" << endl <<
" " << var_name << ".setMinValue(" << min_value << "F);" << endl <<
" " << var_name << ".setMaxValue(" << max_value << "F);" << endl <<
" " << var_name << ".setRotate(" << rotate << ");" << endl <<
" " << var_name << ".setShadow(" << shadow << ");" << endl <<
" " << var_name << ".setShadowWidth(" << shadow_width << ");" << endl <<
" " << var_name << ".setGradient(" << (int)gradient << ");" << endl <<
" " << var_name << ".setGc1(" << gc1 << ");" << endl <<
" " << var_name << ".setGc2(" << gc2 << ");" << endl;
if ( is_nodeclass)
fp <<
" add(" << var_name << ");" << endl;
else
fp <<
" localPanel.add(" << var_name << ", new Proportion(" << var_name << ".getBounds(), dsize));" << endl;
break;
}
case glow_eExportPass_Draw:
break;
default:
;
}
}
void GlowExportJBean::barchart( double x1, double y1, double x2, double y2,
glow_eDrawType border_drawtype,
glow_eDrawType fill_drawtype,
int fill,
int border,
int bars,
int barsegments,
glow_eDrawType *bar_colors,
double min_value,
double max_value,
int line_width,
double rotate,
double shadow_width, int shadow,
glow_eGradient gradient,
int gc1, int gc2,
int vertical_lines, int horizontal_lines, glow_eDrawType line_color,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp)
{
double dim_x0, dim_x1, dim_y0, dim_y1;
char var_name[40];
char class_name[] = "JopBarChart";
strcpy( var_name, class_name);
var_name[0] = _tolower(var_name[0]);
sprintf( &var_name[strlen(var_name)], "%d", node_cnt);
switch ( pass)
{
case glow_eExportPass_Shape:
break;
case glow_eExportPass_Declare:
{
fp <<
" " << class_name << " " << var_name << ";" << endl;
break;
}
case glow_eExportPass_Attributes:
{
((GrowCtx *)ctx)->measure_javabean( &dim_x1, &dim_x0, &dim_y1, &dim_y0);
fp <<
" " << var_name << " = new " << class_name << "(session);" << endl <<
" " << var_name << ".setBounds(new Rectangle(" <<
(int)(x1 - dim_x0 + glow_cJBean_Offset) << "," <<
(int)(y1 - dim_y0 + glow_cJBean_Offset) << "," <<
(int)(x2 - x1) << "," <<
(int)(y2 - y1) << "));" << endl;
if ( fill_drawtype != glow_eDrawType_No)
fp <<
" " << var_name << ".setFillColor(" << (int)fill_drawtype << ");" << endl;
if ( border_drawtype != glow_eDrawType_No)
fp <<
" " << var_name << ".setBorderColor(" << (int)border_drawtype << ");" << endl;
else
fp <<
" " << var_name << ".setBorderColor( 0);" << endl;
if ( fill)
fp <<
" " << var_name << ".setDrawFill(1);" << endl;
if ( border)
fp <<
" " << var_name << ".setDrawBorder(1);" << endl;
fp <<
" " << var_name << ".setBars(" << bars << ");" << endl <<
" " << var_name << ".setBarSegments(" << barsegments << ");" << endl <<
" " << var_name << ".setBarColors(new int[] {";
for ( int i = 0; i < BARCHART_MAX_BARSEGMENTS; i++) {
fp << bar_colors[i];
if ( i != BARCHART_MAX_BARSEGMENTS - 1)
fp << ",";
}
fp << "});" << endl;
fp <<
" " << var_name << ".setLineWidth(" << line_width << ");" << endl <<
" " << var_name << ".setMinValue(" << min_value << "F);" << endl <<
" " << var_name << ".setMaxValue(" << max_value << "F);" << endl <<
" " << var_name << ".setRotate(" << rotate << ");" << endl <<
" " << var_name << ".setShadow(" << shadow << ");" << endl <<
" " << var_name << ".setShadowWidth(" << shadow_width << ");" << endl <<
" " << var_name << ".setGradient(" << (int)gradient << ");" << endl <<
" " << var_name << ".setGc1(" << gc1 << ");" << endl <<
" " << var_name << ".setGc2(" << gc2 << ");" << endl <<
" " << var_name << ".setVerticalLines(" << vertical_lines << ");" << endl <<
" " << var_name << ".setHorizontalLines(" << horizontal_lines << ");" << endl <<
" " << var_name << ".setLineColor(" << (int)line_color << ");" << endl;
if ( is_nodeclass)
fp <<
" add(" << var_name << ");" << endl;
else
fp <<
" localPanel.add(" << var_name << ", new Proportion(" << var_name << ".getBounds(), dsize));" << endl;
break;
}
case glow_eExportPass_Draw:
break;
default:
;
}
}
void GlowExportJBean::window( double x1, double y1, double x2, double y2,
char *filename,
int vertical_scrollbar, int horizontal_scrollbar, char *owner,
......
......@@ -194,6 +194,38 @@ class GlowExportJBean {
int text_idx,
char *format,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void pie( double x1, double y1, double x2, double y2, int angle1, int angle2,
glow_eDrawType border_drawtype,
glow_eDrawType fill_drawtype,
int fill,
int border,
int sectors,
glow_eDrawType *sector_color,
double min_value,
double max_value,
int line_width,
double rotate,
double shadow_width, int shadow,
glow_eGradient gradient,
int gc1, int gc2,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void barchart( double x1, double y1, double x2, double y2,
glow_eDrawType border_drawtype,
glow_eDrawType fill_drawtype,
int fill,
int border,
int bars,
int barsegments,
glow_eDrawType *bar_color,
double min_value,
double max_value,
int line_width,
double rotate,
double shadow_width, int shadow,
glow_eGradient gradient,
int gc1, int gc2,
int vertical_lines, int horizontal_lines, glow_eDrawType line_color,
glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void window( double x1, double y1, double x2, double y2,
char *filename,
int vertical_scrollbar,
......
......@@ -551,6 +551,8 @@ void GrowBarChart::export_javabean( GlowTransform *t, void *node,
{
double x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
double rotation;
double ish;
int gc1, gc2;
if (!t)
{
......@@ -577,12 +579,23 @@ void GrowBarChart::export_javabean( GlowTransform *t, void *node,
else
rotation = (trf.rot() / 360 - floor( trf.rot() / 360)) * 360;
#if 0
((GrowCtx *)ctx)->export_jbean->barchart( ll_x, ll_y, ur_x, ur_y, angle1, angle2,
draw_type, text_color_drawtype, min_value, max_value, lines, longquotient, valuequotient,
linelength, line_width, rotation, bold, idx, format,
pass, shape_cnt, node_cnt, fp);
#endif
ish = shadow_width / 100 * min(ur_x - ll_x, ur_y - ll_y);
if ( gradient_contrast >= 0) {
gc1 = gradient_contrast/2;
gc2 = -int(float(gradient_contrast)/2+0.6);
}
else {
gc1 = int(float(gradient_contrast)/2-0.6);
gc2 = -gradient_contrast/2;
}
ctx->export_jbean->barchart( ll_x, ll_y, ur_x, ur_y,
draw_type, fill_drawtype, fill,
border, bars, barsegments, bar_color, min_value, max_value,
line_width, rotation, ish, shadow, gradient, gc1, gc2,
vertical_lines, horizontal_lines, line_color,
pass, shape_cnt, node_cnt, fp);
}
void GrowBarChart::set_conf( int bar_num, int barsegment_num, double min_val, double max_val,
......
......@@ -523,6 +523,8 @@ void GrowPie::export_javabean( GlowTransform *t, void *node,
{
double x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
double rotation;
double ish;
int gc1, gc2;
if (!t)
{
......@@ -549,12 +551,22 @@ void GrowPie::export_javabean( GlowTransform *t, void *node,
else
rotation = (trf.rot() / 360 - floor( trf.rot() / 360)) * 360;
#if 0
((GrowCtx *)ctx)->export_jbean->pie( ll_x, ll_y, ur_x, ur_y, angle1, angle2,
draw_type, text_color_drawtype, min_value, max_value, lines, longquotient, valuequotient,
linelength, line_width, rotation, bold, idx, format,
pass, shape_cnt, node_cnt, fp);
#endif
ish = shadow_width / 100 * min(ur_x - ll_x, ur_y - ll_y);
if ( gradient_contrast >= 0) {
gc1 = gradient_contrast/2;
gc2 = -int(float(gradient_contrast)/2+0.6);
}
else {
gc1 = int(float(gradient_contrast)/2-0.6);
gc2 = -gradient_contrast/2;
}
ctx->export_jbean->pie( ll_x, ll_y, ur_x, ur_y, angle1, angle2,
draw_type, fill_drawtype, fill,
border, sectors, sector_color, min_value, max_value,
line_width, rotation, ish, shadow, gradient, gc1, gc2,
pass, shape_cnt, node_cnt, fp);
}
void GrowPie::set_conf( int sector_num, double min_val, double max_val, glow_eDrawType *color)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment