Пример #1
0
int SVG_RenderToSurface(SDL_svg_context *Source, int X, int Y,
		SDL_Surface *Target)
{
	Source->surface = Target;
	Source->TargetOffsetX = X;
	Source->TargetOffsetY = Y;

	return svg_render (Source->SVG, &SDL_SVG_RenderEngine, Source);
}
Пример #2
0
svg_status_t svgAndroidRender
(JNIEnv *env, svg_android_t *svg_android, jobject android_canvas)
{
	__prepare_android_interface(svg_android, env, android_canvas); 

	_svg_android_push_state (svg_android, NULL);
	svg_android->state->viewport_width = ANDROID_GET_WIDTH(svg_android);
	svg_android->state->viewport_height = ANDROID_GET_HEIGHT(svg_android);

	svg_android->fit_to_area = 0;
	return svg_render (svg_android->svg, &SVG_ANDROID_RENDER_ENGINE, svg_android);
}
Пример #3
0
svg_status_t svgAndroidRenderToArea(JNIEnv *env, svg_android_t *svg_android, jobject android_canvas, int x, int y, int w, int h) {
	__prepare_android_interface(svg_android, env, android_canvas); 

	_svg_android_push_state (svg_android, NULL);

	svg_android->state->viewport_width = w;
	svg_android->state->viewport_height = h;
	
	svg_android->fit_to_area = -1;
	svg_android->fit_to_x = x;
	svg_android->fit_to_y = y;
	svg_android->fit_to_w = w;
	svg_android->fit_to_h = h;	
	svg_android->fit_to_MATRIX = NULL;
	
	return svg_render (svg_android->svg, &SVG_ANDROID_RENDER_ENGINE, svg_android);
}
Пример #4
0
char *hf_generate_graph( int *rc, int cases, float *xdata, float *ydata, char *style, char *title,
  char *xax_title, char *yax_title, struct chart_options *chopt)

{
    int grids, digits, num_grids;
    float dmin, dmax, span;
    char *dataformat, *svg_doc = 0;
    struct svg_model *svg;
    struct milestone *walk, *mstone = 0;
    struct svg_chart_milestone *ckpt;
    struct series_data *series = 0;

    ENTER( "hf_generate_graph" )

    if( *rc == RC_NORMAL)
    {
        svg = svg_make_chart();
        if( !svg) *rc = ERR_MALLOC_FAILED;
    }

    INSUB( "hf_generate_graph", "before-add-data" )
    if( *rc == RC_NORMAL) series = svg_add_float_data( rc, svg, cases, xdata, ydata);

    if( chopt )
    {
        mstone = chopt->mstone;

        for( walk = mstone; *rc == RC_NORMAL && walk; walk = walk->next)
        {
            ckpt = svg_add_xax_checkpoint( svg, walk->offset, walk->label);
            if( !ckpt) *rc = ERR_MALLOC_FAILED;
            else if( walk == mstone && strcmp( style, SVG_STYLE_DARK))
            {
                *rc = svg_set_checkpoint_line_color( ckpt, GR_MST_LINE_COLOR );
                if( *rc == RC_NORMAL) *rc = svg_set_checkpoint_text_color( ckpt, GR_MST_TEXT_COLOR );
            }
	}

        if( chopt->xmin_hard != CH_OPT_NO_VALUE ) (void) svg_set_xmin( svg, chopt->xmin_hard );
        else if( chopt->xmin_soft != CH_OPT_NO_VALUE && chopt->xmin_soft < svg->xmin ) (void) svg_set_xmin( svg, chopt->xmin_soft );

        if( chopt->xmax_hard != CH_OPT_NO_VALUE ) (void) svg_set_xmax( svg, chopt->xmax_hard );
        else if( chopt->xmax_soft != CH_OPT_NO_VALUE && chopt->xmax_soft > svg->xmax ) (void) svg_set_xmax( svg, chopt->xmax_soft );

        if( chopt->ymin_hard != CH_OPT_NO_VALUE ) (void) svg_set_ymin( svg, chopt->ymin_hard );
        else if( chopt->ymin_soft != CH_OPT_NO_VALUE && chopt->ymin_soft < svg->ymin ) (void) svg_set_ymin( svg, chopt->ymin_soft );

        if( chopt->ymax_hard != CH_OPT_NO_VALUE ) (void) svg_set_ymax( svg, chopt->ymax_hard );
        else if( chopt->ymax_soft != CH_OPT_NO_VALUE && chopt->ymax_soft > svg->ymax ) (void) svg_set_ymax( svg, chopt->ymax_soft );
    }

    INSUB( "hf_generate_graph", "before-titles" )

    if( *rc == RC_NORMAL) *rc = svg_set_chart_title( svg, title);
    if( *rc == RC_NORMAL) *rc = svg_set_xax_title( svg, xax_title);
    if( *rc == RC_NORMAL) *rc = svg_set_yax_title( svg, yax_title);
    if( *rc == RC_NORMAL)
    {
        if( cases < GR_ALL_XAX_GRIDS) num_grids = cases;
        else num_grids = GR_ALL_XAX_GRIDS;
        *rc = svg_set_xax_num_grids( svg, num_grids);
    }
    if( *rc == RC_NORMAL)
    {
        if( cases < GR_ALL_YAX_GRIDS) num_grids = cases;
        else num_grids = GR_ALL_YAX_GRIDS;
        *rc = svg_set_yax_num_grids( svg, num_grids);
    }

    INSUB( "hf_generate_graph", "before-finalize" )
    if( *rc == RC_NORMAL) *rc = svg_finalize_model( svg);

    if( *rc == RC_NORMAL)
    {
        dmin = svg_get_xmin( svg);
        dmax = svg_get_xmax( svg);
        grids = svg_get_xax_num_grids( svg);
        span = (dmax - dmin) / grids;
        if( span >= 1.0) digits = 0;
        else if( span == 0.0) digits = 0;
        else digits = (int) (1 - log10( span));
/* printf( "<!-- HFGG: min:%f max:%f span:%f digits:%d patt(%s) -->\n", dmin, dmax, span, digits, GR_DATA_META_FORMAT); */
        dataformat = string_from_int( rc, digits, GR_DATA_META_FORMAT);
/* printf( "<!-- HFGG: rc:%d format(%s)-->\n", *rc, dataformat); */
        if( *rc == RC_NORMAL) *rc = svg_set_xax_disp( svg, dataformat);
        if( dataformat) free( dataformat);
    }

    if( *rc == RC_NORMAL)
    {
        dmin = svg_get_ymin( svg);
        dmax = svg_get_ymax( svg);
        grids = svg_get_yax_num_grids( svg);
        span = (dmax - dmin) / grids;
        if( span >= 1.0) digits = 0;
        else if( span == 0.0) digits = 0;
        else digits = (int) (1 - log10( span));
        dataformat = string_from_int( rc, digits, GR_DATA_META_FORMAT);
        if( *rc == RC_NORMAL) *rc = svg_set_yax_disp( svg, dataformat);
        if( dataformat) free( dataformat);
    }

    INSUB( "hf_generate_graph", "before-styles" )

    if( strcmp( style, SVG_STYLE_DARK))
    {
        if( *rc == RC_NORMAL) *rc = svg_set_circ_line_size( series, GR_ALL_CIRC_LINE_SIZE);
        if( *rc == RC_NORMAL) *rc = svg_set_circ_radius( series, GR_ALL_CIRC_RADIUS);

        if( *rc == RC_NORMAL) *rc = svg_set_text_color( svg, GR_ALL_TEXT_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_axis_color( svg, GR_ALL_AXIS_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_chart_color( svg, GR_ALL_CHART_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_graph_color( svg, GR_ALL_GRAPH_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_circ_fill_color( series, GR_ALL_CIRC_FILL_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_circ_line_color( series, GR_ALL_CIRC_LINE_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_data_fill_color( series, GR_ALL_DATA_FILL_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_data_line_color( series, GR_ALL_DATA_LINE_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_x_gridline_color( svg, GR_ALL_XGRID_COLOR);
        if( *rc == RC_NORMAL) *rc = svg_set_y_gridline_color( svg, GR_ALL_YGRID_COLOR);

        if( *rc == RC_NORMAL) *rc = svg_set_graph_alpha( svg, GR_ALL_GRAPH_ALPHA);
        if( *rc == RC_NORMAL) *rc = svg_set_circ_fill_alpha( series, GR_ALL_CIRC_FILL_ALPHA);
        if( *rc == RC_NORMAL) *rc = svg_set_circ_line_alpha( series, GR_ALL_CIRC_LINE_ALPHA);
        if( *rc == RC_NORMAL) *rc = svg_set_data_fill_alpha( series, GR_ALL_DATA_FILL_ALPHA);
        if( *rc == RC_NORMAL) *rc = svg_set_data_line_alpha( series, GR_ALL_DATA_LINE_ALPHA);

        if( chopt )
        {
            if( chopt->data_line_alpha != CH_OPT_NO_VALUE ) (void) svg_set_data_line_alpha( series, chopt->data_line_alpha );
            if( chopt->data_line_color ) (void) svg_set_data_line_color( series, chopt->data_line_color );
	}
    }

    INSUB( "hf_generate_graph", "before-render" )
    if( *rc == RC_NORMAL) svg_doc = svg_render( rc, svg);

    INSUB( "hf_generate_graph", "before-free" )
    if( svg) svg_free_model( svg);

    return( svg_doc);
}