Commit 2c75bc0d authored by claes's avatar claes

Support for center and right aligned annotations

parent 1df5e4ba
/* /*
* Proview $Id: glow_exportjbean.cpp,v 1.15 2006-06-14 05:04:10 claes Exp $ * Proview $Id: glow_exportjbean.cpp,v 1.16 2007-05-23 08:04:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -634,7 +634,7 @@ void GlowExportJBean::line( double x1, double y1, double x2, double y2, ...@@ -634,7 +634,7 @@ void GlowExportJBean::line( double x1, double y1, double x2, double y2,
fp << fp <<
" g.draw( shapes_p" << page << "[" << *shape_cnt << "]);" << endl; " g.draw( shapes_p" << page << "[" << *shape_cnt << "]);" << endl;
if ( *shape_cnt / 1000 > func_cnt) { if ( *shape_cnt / 500 > func_cnt) {
// Max number of bytes in a java function is ~65000 // Max number of bytes in a java function is ~65000
fp << fp <<
" paintComponent" << func_cnt << "( g, save);" << endl << " paintComponent" << func_cnt << "( g, save);" << endl <<
...@@ -1283,8 +1283,9 @@ void GlowExportJBean::text( int x0, int y0, char *text, ...@@ -1283,8 +1283,9 @@ void GlowExportJBean::text( int x0, int y0, char *text,
} }
void GlowExportJBean::annot( int x0, int y0, int number, void GlowExportJBean::annot( int x0, int y0, int number,
glow_eDrawType drawtype, glow_eDrawType text_drawtype, int bold, glow_eDrawType drawtype, glow_eDrawType text_drawtype, int bold,
int idx, glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp) glow_eAdjustment adjustment, int idx, glow_eExportPass pass,
int *shape_cnt, int node_cnt, ofstream& fp)
{ {
double dim_x0, dim_x1, dim_y0, dim_y1; double dim_x0, dim_x1, dim_y0, dim_y1;
int antialiasing_on = 0; int antialiasing_on = 0;
...@@ -1363,6 +1364,21 @@ void GlowExportJBean::annot( int x0, int y0, int number, ...@@ -1363,6 +1364,21 @@ void GlowExportJBean::annot( int x0, int y0, int number,
} }
case glow_eExportPass_Draw: case glow_eExportPass_Draw:
{ {
char adjustmentstr[200];
switch ( adjustment) {
case glow_eAdjustment_Right:
fp <<
" FontRenderContext frc = g.getFontRenderContext();" << endl;
sprintf( adjustmentstr, "- (float)g.getFont().getStringBounds(annot%d, frc).getWidth()", number);
break;
case glow_eAdjustment_Center:
fp <<
" FontRenderContext frc = g.getFontRenderContext();" << endl;
sprintf( adjustmentstr, "- (float)g.getFont().getStringBounds(annot%d, frc).getWidth()/2", number);
break;
default:
strcpy( adjustmentstr, "");
}
if ( is_nodeclass) if ( is_nodeclass)
nc->measure_javabean( &dim_x1, &dim_x0, &dim_y1, &dim_y0); nc->measure_javabean( &dim_x1, &dim_x0, &dim_y1, &dim_y0);
else else
...@@ -1380,7 +1396,7 @@ void GlowExportJBean::annot( int x0, int y0, int number, ...@@ -1380,7 +1396,7 @@ void GlowExportJBean::annot( int x0, int y0, int number,
" if ( annot" << number << " != null)" << endl << " if ( annot" << number << " != null)" << endl <<
" g.drawString( annot" << number << ", " << " g.drawString( annot" << number << ", " <<
x0 - int(dim_x0) + glow_cJBean_Offset << x0 - int(dim_x0) + glow_cJBean_Offset <<
" * original_height / height * width / original_width, " << " * original_height / height * width / original_width" << adjustmentstr << ", " <<
y0 - int(dim_y0) + glow_cJBean_Offset << "F);" << endl; y0 - int(dim_y0) + glow_cJBean_Offset << "F);" << endl;
else else
fp << fp <<
...@@ -1390,7 +1406,7 @@ void GlowExportJBean::annot( int x0, int y0, int number, ...@@ -1390,7 +1406,7 @@ void GlowExportJBean::annot( int x0, int y0, int number,
" if ( annot" << number << " != null)" << endl << " if ( annot" << number << " != null)" << endl <<
" g.drawString( annot" << number << ", " << " g.drawString( annot" << number << ", " <<
x0 - int(dim_x0) + glow_cJBean_Offset << x0 - int(dim_x0) + glow_cJBean_Offset <<
" * original_height / height * width / original_width, " << " * original_height / height * width / original_width" << adjustmentstr << ", " <<
y0 - int(dim_y0) + glow_cJBean_Offset << "F);" << endl; y0 - int(dim_y0) + glow_cJBean_Offset << "F);" << endl;
fp << fp <<
" g.setTransform( save_tmp);" << endl; " g.setTransform( save_tmp);" << endl;
......
/* /*
* Proview $Id: glow_exportjbean.h,v 1.9 2007-01-04 07:57:38 claes Exp $ * Proview $Id: glow_exportjbean.h,v 1.10 2007-05-23 08:04:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -68,8 +68,9 @@ class GlowExportJBean { ...@@ -68,8 +68,9 @@ class GlowExportJBean {
glow_eDrawType drawtype, glow_eDrawType color_drawtype, int bold, glow_eDrawType drawtype, glow_eDrawType color_drawtype, int bold,
int idx, glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp); int idx, glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp);
void annot( int x0, int y0, int number, void annot( int x0, int y0, int number,
glow_eDrawType drawtype, glow_eDrawType text_drawtype, int bold, glow_eDrawType drawtype, glow_eDrawType text_drawtype, int bold,
int idx, glow_eExportPass pass, int *shape_cnt, int node_cnt, ofstream& fp); glow_eAdjustment adjustment, int idx, glow_eExportPass pass,
int *shape_cnt, int node_cnt, ofstream& fp);
void annot_font( int number, glow_eDrawType drawtype, void annot_font( int number, glow_eDrawType drawtype,
glow_eDrawType background, int bold, glow_eDrawType background, int bold,
int idx, glow_eExportPass pass, ofstream& fp); int idx, glow_eExportPass pass, ofstream& fp);
......
/* /*
* Proview $Id: glow_growannot.cpp,v 1.9 2007-05-07 14:35:03 claes Exp $ * Proview $Id: glow_growannot.cpp,v 1.10 2007-05-23 08:04:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -416,7 +416,7 @@ void GrowAnnot::export_javabean( GlowTransform *t, void *node, ...@@ -416,7 +416,7 @@ void GrowAnnot::export_javabean( GlowTransform *t, void *node,
bold = (draw_type == glow_eDrawType_TextHelveticaBold); bold = (draw_type == glow_eDrawType_TextHelveticaBold);
((GrowCtx *)ctx)->export_jbean->annot( x1, y1, number, ((GrowCtx *)ctx)->export_jbean->annot( x1, y1, number,
draw_type, color_drawtype, bold, idx, pass, shape_cnt, node_cnt, fp); draw_type, color_drawtype, bold, adjustment, idx, pass, shape_cnt, node_cnt, fp);
// (*shape_cnt)++; // (*shape_cnt)++;
} }
......
/* /*
* Proview $Id: glow_growsubannot.cpp,v 1.5 2007-01-04 07:57:39 claes Exp $ * Proview $Id: glow_growsubannot.cpp,v 1.6 2007-05-23 08:04:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -541,7 +541,7 @@ void GrowSubAnnot::export_javabean( GlowTransform *t, void *node, ...@@ -541,7 +541,7 @@ void GrowSubAnnot::export_javabean( GlowTransform *t, void *node,
bold = (draw_type == glow_eDrawType_TextHelveticaBold); bold = (draw_type == glow_eDrawType_TextHelveticaBold);
ctx->export_jbean->annot( x1, y1, number, ctx->export_jbean->annot( x1, y1, number,
draw_type, color_drawtype, bold, idx, pass, shape_cnt, node_cnt, fp); draw_type, color_drawtype, bold, adjustment, idx, pass, shape_cnt, node_cnt, fp);
(*shape_cnt)++; (*shape_cnt)++;
} }
......
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