Skip to main content



      Home
Home » Eclipse Projects » GEF » draw2d TextExample.java
draw2d TextExample.java [message #64302] Tue, 11 February 2003 16:21 Go to next message
Eclipse UserFriend
In the TextExample, it has an example to render source code.
I am wonder what is the best way to implement color syntaxing when use that
to render source code.

I am thinking I can scan the content to look for key words and create a
number of TextFlow objects for text before the keyword, the keyword itself
and text after the keyword. And then set the font of each TextFlow
accordingly.

Is there a better approach than this? My concern is performance, since I
need to create a lot of small TextFlow objects.

Thank for any feedback.
Re: draw2d TextExample.java [message #64325 is a reply to message #64302] Tue, 11 February 2003 16:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There is probably a lighterweight approach. If you know that you are going
to use the same font, and only change the color, you could use a single
TextFlow. The subclass could store highlight regions, and override
paintFigure() to break up the text into its regions. This is similar to how
the JDT does it.

"Hal" <otaconss2@hotmail.com> wrote in message
news:b2bo33$j1l$1@rogue.oti.com...
> In the TextExample, it has an example to render source code.
> I am wonder what is the best way to implement color syntaxing when use
that
> to render source code.
>
> I am thinking I can scan the content to look for key words and create a
> number of TextFlow objects for text before the keyword, the keyword itself
> and text after the keyword. And then set the font of each TextFlow
> accordingly.
>
> Is there a better approach than this? My concern is performance, since I
> need to create a lot of small TextFlow objects.
>
> Thank for any feedback.
>
>
Re: draw2d TextExample.java [message #64347 is a reply to message #64325] Tue, 11 February 2003 17:01 Go to previous messageGo to next message
Eclipse UserFriend
what if I need to Bold and use a different color for keywords (same as JDT),
will your approach works too?

Thanks.

"Randy Hudson" <none@us.ibm.com> wrote in message
news:b2bq79$kta$1@rogue.oti.com...
> There is probably a lighterweight approach. If you know that you are
going
> to use the same font, and only change the color, you could use a single
> TextFlow. The subclass could store highlight regions, and override
> paintFigure() to break up the text into its regions. This is similar to
how
> the JDT does it.
>
> "Hal" <otaconss2@hotmail.com> wrote in message
> news:b2bo33$j1l$1@rogue.oti.com...
> > In the TextExample, it has an example to render source code.
> > I am wonder what is the best way to implement color syntaxing when use
> that
> > to render source code.
> >
> > I am thinking I can scan the content to look for key words and create a
> > number of TextFlow objects for text before the keyword, the keyword
itself
> > and text after the keyword. And then set the font of each TextFlow
> > accordingly.
> >
> > Is there a better approach than this? My concern is performance, since I
> > need to create a lot of small TextFlow objects.
> >
> > Thank for any feedback.
> >
> >
>
>
Re: draw2d TextExample.java [message #64369 is a reply to message #64347] Tue, 11 February 2003 17:07 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

only for monospace fonts :-)

"Hal" <otaconss2@hotmail.com> wrote in message
news:b2bqch$l16$1@rogue.oti.com...
> what if I need to Bold and use a different color for keywords (same as
JDT),
> will your approach works too?
>
> Thanks.
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:b2bq79$kta$1@rogue.oti.com...
> > There is probably a lighterweight approach. If you know that you are
> going
> > to use the same font, and only change the color, you could use a single
> > TextFlow. The subclass could store highlight regions, and override
> > paintFigure() to break up the text into its regions. This is similar to
> how
> > the JDT does it.
> >
> > "Hal" <otaconss2@hotmail.com> wrote in message
> > news:b2bo33$j1l$1@rogue.oti.com...
> > > In the TextExample, it has an example to render source code.
> > > I am wonder what is the best way to implement color syntaxing when use
> > that
> > > to render source code.
> > >
> > > I am thinking I can scan the content to look for key words and create
a
> > > number of TextFlow objects for text before the keyword, the keyword
> itself
> > > and text after the keyword. And then set the font of each TextFlow
> > > accordingly.
> > >
> > > Is there a better approach than this? My concern is performance, since
I
> > > need to create a lot of small TextFlow objects.
> > >
> > > Thank for any feedback.
> > >
> > >
> >
> >
>
>
Previous Topic:Caching Edit Parts
Next Topic:Connection Anchor
Goto Forum:
  


Current Time: Thu May 01 07:52:44 EDT 2025

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

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

Back to the top