Skip to main content



      Home
Home » Eclipse Projects » GEF » Funny tab characters in Draw2d
Funny tab characters in Draw2d [message #68389] Wed, 05 March 2003 08:20 Go to next message
Eclipse UserFriend
Originally posted by: lking.tsti.co.za

Hi All
I am having a problem with the text in Draw2d. I've created a function
that will read a block of text from a file line by line and place this
text within a TextFlow object. This function then places this in a
BlockFlow and returns this.

The function seems to work as it does show the text BUT the tab character
is shown as some weird symbol. If instead of placing this in the textflow
and just use printline it works fine.

Heres the code:

protected IFigure createCode() {
BlockFlow blockFlow = new BlockFlow();
TextFlow contents = new TextFlow();
//contents.setFont(ITALICS);
String fileHeader;
try {
ResultSet result =
stmt.executeQuery(
"SELECT * FROM [Lambdas] WHERE lambda_id = '" + id + "'");
result.next();
fileHeader = result.getString("code_block");

if(fileHeader != null){
StringTokenizer stok = new StringTokenizer(fileHeader);
String file = stok.nextToken();
String begin = stok.nextToken();
String end = stok.nextToken();

FileReader in = new FileReader(file);
BufferedReader breader = new BufferedReader(in);
// skip unnecessary beggining lines
for (int i = 0; i < Integer.parseInt(begin.trim()); i++) {
breader.readLine();
}

for (int i = 0; i <= Integer.parseInt(end.trim()) -
Integer.parseInt(begin.trim()); i++) {
//String temp = new String(breader.readLine());
//temp = temp+"\n";
//contents.setLayoutManager(new SimpleTextLayout(contents));
contents = new TextFlow(breader.readLine() + "\n");
//contents.setText(temp+"\n");
contents.setLayoutManager(new SimpleTextLayout(contents));
blockFlow.add(contents);
}
}
else{
contents.setText("No code available.");
blockFlow.add(contents);
}

} catch (Exception e) {
System.out.println("Error: CodeDialog.createCode");
}
return blockFlow;
}
Re: Funny tab characters in Draw2d [message #68396 is a reply to message #68389] Wed, 05 March 2003 08:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lking.tsti.co.za

zapod7 wrote:

Sorry heres a more formatted copy of the code:

protected IFigure createCode() {
BlockFlow blockFlow = new BlockFlow();
TextFlow contents = new TextFlow();
String file = "somefile";

FileReader in = new FileReader(file);
BufferedReader breader = new BufferedReader(in);

// read until reach end which is some int
for(int i = 0; i <= end; i++) {
contents = new TextFlow(breader.readLine() + "\n");
contents.setText(temp+"\n");
blockFlow.add(contents);
}
in.close();
breader.clos();

return blockFlow;
}
Re: Funny tab characters in Draw2d [message #68417 is a reply to message #68389] Wed, 05 March 2003 10:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Tabs are not currently supported in the text package.
We are simply using GC.drawString() and stringExtent() to wrap the text, so
tabs are treated as unknown characters in these methods. We would have to
add "tab stop" support to flow context in order to process tabs correctly.

"zapod7" <lking@tsti.co.za> wrote in message
news:b44tjp$n0k$1@rogue.oti.com...
> Hi All
> I am having a problem with the text in Draw2d. I've created a function
> that will read a block of text from a file line by line and place this
> text within a TextFlow object. This function then places this in a
> BlockFlow and returns this.
>
> The function seems to work as it does show the text BUT the tab character
> is shown as some weird symbol. If instead of placing this in the textflow
> and just use printline it works fine.
>
> Heres the code:
>
> protected IFigure createCode() {
> BlockFlow blockFlow = new BlockFlow();
> TextFlow contents = new TextFlow();
> //contents.setFont(ITALICS);
> String fileHeader;
> try {
> ResultSet result =
> stmt.executeQuery(
> "SELECT * FROM [Lambdas] WHERE lambda_id = '" + id + "'");
> result.next();
> fileHeader = result.getString("code_block");
>
> if(fileHeader != null){
> StringTokenizer stok = new StringTokenizer(fileHeader);
> String file = stok.nextToken();
> String begin = stok.nextToken();
> String end = stok.nextToken();
>
> FileReader in = new FileReader(file);
> BufferedReader breader = new BufferedReader(in);
> // skip unnecessary beggining lines
> for (int i = 0; i < Integer.parseInt(begin.trim()); i++) {
> breader.readLine();
> }
>
> for (int i = 0; i <= Integer.parseInt(end.trim()) -
> Integer.parseInt(begin.trim()); i++) {
> //String temp = new String(breader.readLine());
> //temp = temp+"\n";
> //contents.setLayoutManager(new SimpleTextLayout(contents));
> contents = new TextFlow(breader.readLine() + "\n");
> //contents.setText(temp+"\n");
> contents.setLayoutManager(new SimpleTextLayout(contents));
> blockFlow.add(contents);
> }
> }
> else{
> contents.setText("No code available.");
> blockFlow.add(contents);
> }
>
> } catch (Exception e) {
> System.out.println("Error: CodeDialog.createCode");
> }
> return blockFlow;
> }
>
>
Re: Funny tab characters in Draw2d [message #68461 is a reply to message #68417] Thu, 06 March 2003 01:23 Go to previous message
Eclipse UserFriend
Originally posted by: lking.tsti.co.za

Will you be adding this feature and if so do you know when this will
happen?
Thanks
Len

Randy Hudson wrote:

> Tabs are not currently supported in the text package.
> We are simply using GC.drawString() and stringExtent() to wrap the text, so
> tabs are treated as unknown characters in these methods. We would have to
> add \"tab stop\" support to flow context in order to process tabs correctly.

> \"zapod7\" <lking@tsti.co.za> wrote in message
> news:b44tjp$n0k$1@rogue.oti.com...
> > Hi All
> > I am having a problem with the text in Draw2d. I\'ve created a function
> > that will read a block of text from a file line by line and place this
> > text within a TextFlow object. This function then places this in a
> > BlockFlow and returns this.
> >
> > The function seems to work as it does show the text BUT the tab character
> > is shown as some weird symbol. If instead of placing this in the textflow
> > and just use printline it works fine.
> >
> > Heres the code:
> >
> > protected IFigure createCode() {
> > BlockFlow blockFlow = new BlockFlow();
> > TextFlow contents = new TextFlow();
> > //contents.setFont(ITALICS);
> > String fileHeader;
> > try {
> > ResultSet result =
> > stmt.executeQuery(
> > \"SELECT * FROM [Lambdas] WHERE lambda_id = \'\" + id + \"\'\");
> > result.next();
> > fileHeader = result.getString(\"code_block\");
> >
> > if(fileHeader != null){
> > StringTokenizer stok = new StringTokenizer(fileHeader);
> > String file = stok.nextToken();
> > String begin = stok.nextToken();
> > String end = stok.nextToken();
> >
> > FileReader in = new FileReader(file);
> > BufferedReader breader = new BufferedReader(in);
> > // skip unnecessary beggining lines
> > for (int i = 0; i < Integer.parseInt(begin.trim()); i++) {
> > breader.readLine();
> > }
> >
> > for (int i = 0; i <= Integer.parseInt(end.trim()) -
> > Integer.parseInt(begin.trim()); i++) {
> > //String temp = new String(breader.readLine());
> > //temp = temp+\"\\n\";
> > //contents.setLayoutManager(new SimpleTextLayout(contents));
> > contents = new TextFlow(breader.readLine() + \"\\n\");
> > //contents.setText(temp+\"\\n\");
> > contents.setLayoutManager(new SimpleTextLayout(contents));
> > blockFlow.add(contents);
> > }
> > }
> > else{
> > contents.setText(\"No code available.\");
> > blockFlow.add(contents);
> > }
> >
> > } catch (Exception e) {
> > System.out.println(\"Error: CodeDialog.createCode\");
> > }
> > return blockFlow;
> > }
> >
> >
Previous Topic:connection routers, etc.
Next Topic:Problem with italic Text in Draw2D
Goto Forum:
  


Current Time: Sat Jul 12 21:38:10 EDT 2025

Powered by FUDForum. Page generated in 0.25251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top