Can I learn the ip-address of the person whose comment is in my blog?
Rendering hints - use cases & requirements
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > Java Programming > Rendering hints - use cases & requirements 24 May 2003 14:53:32

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

Rendering hints - use cases & requirements

Tim Boudreau 18 May 2003 01:52:35
 In the thread "text properties of treetable cells",
we've been discussing use cases for a limited
rendering hints API. Here are the use cases I
know of so far:

General use cases:
- Nodes in explorer views
- Properties in the property sheet
- Tabs in tabbed windows in the IDE

Use cases where multiple styles in a single line
of text would be desirable:
- VCS status

Open questions:
- How should a renderable object
indicate the hints have changed, and that
it may need to be re-rendered?
- Should a renderable object provide one set
of hints for all views, or are per-view
sets desirable?
- Should rendering hints include actual
alternate display text (for example,
no VCS status text for tabs but provide
it for explorer nodes)
- Note that for Nodes & Properties, this
is easily implementable using, e.g.,
RenderingHints rh = (RenderingHints) someNode.getValue
("hints.tab");

Things a rendering hints interface should support:
- Font weight
- Font style
- Background color
- Foreground color

Comments? Additions? Removals?

-Tim



Add comment
Tim Boudreau 18 May 2003 01:58:09 permanent link ]
 Tim Boudreau wrote:> In the thread "text properties of treetable cells",> we've been discussing use cases for a limited> rendering hints API. Here are the use cases I> know of so far:>
General use cases:> - Nodes in explorer views> - Properties in the property sheet> - Tabs in tabbed windows in the IDE

I forgot one use case, coming from the earlier
discussion:
- Menu presenters for actions (e.g. make the
default action appear in boldface)



Add comment
Petr Kuzel 19 May 2003 00:14:20 permanent link ]
 Hi Tim,

do we need a hinting API to cover mentioned use cases?
We could use some attributes of object being rendered
and let view implementation choose best visualization:

- Node has isPreferred(), isExpert() attributes
- the same applies to described property
- Mode tab is tricky but it could try
TopComponent.getAct­ivatedNodes()
- menu presenter could take selected nodes and
invoke Node.getPreferredAc­tion()

Cc.

PS: I have not followed the thread "text properties of
treetable cells" so I may miss some other reasons.
Tim Boudreau wrote:>> In the thread "text properties of treetable cells",>> we've been discussing use cases for a limited>> rendering hints API. Here are the use cases I>> know of so far:>>
General use cases:>> - Nodes in explorer views>> - Properties in the property sheet>> - Tabs in tabbed windows in the IDE>
I forgot one use case, coming from the earlier> discussion:> - Menu presenters for actions (e.g. make the> default action appear in boldface)



Add comment
Tim Boudreau 19 May 2003 03:37:52 permanent link ]
 Petr Kuzel wrote:
Hi Tim,>
do we need a hinting API to cover mentioned use cases?> We could use some attributes of object being rendered> and let view implementation choose best visualization:>
- Node has isPreferred(), isExpert() attributes> - the same applies to described property> - Mode tab is tricky but it could try> TopComponent.getAct­ivatedNodes()> - menu presenter could take selected nodes and> invoke Node.getPreferredAc­tion()

This is really about specific properties/nodes that
want to provide some extra clues to a view about how
to render them (for example, a default action should
be bold, an editor tab might show a different color
text to indicate a file is modified, one of Tor's
task nodes may want to indicate some specific
status info, etc).

The thing being, we have generic objects (Nodes,
Properties), and generic views (Explorer, Property
sheet, tabbed pane, menu) - yet often the usability
of these views could be enhanced if the object
being rendered could contribute some information
about the optimal way to render itself. And it
simplifies things for a module developer, who might
otherwise have to write a view subclass to do
something as simple as show one node name in bold
text.

-Tim
Cc.>
PS: I have not followed the thread "text properties of> treetable cells" so I may miss some other reasons.>
Tim Boudreau wrote:>>
In the thread "text properties of treetable cells",>>>we've been discussing use cases for a limited>>>rendering­ hints API. Here are the use cases I>>>know of so far:>>>
General use cases:>>> - Nodes in explorer views>>> - Properties in the property sheet>>> - Tabs in tabbed windows in the IDE>>
I forgot one use case, coming from the earlier>>discussion­:>> - Menu presenters for actions (e.g. make the>> default action appear in boldface)>



Add comment
Jesse Glick 19 May 2003 04:27:24 permanent link ]
 Petr Kuzel wrote:>> - menu presenter could take selected nodes and>> invoke Node.getPreferredAc­tion()

Tim Boudreau wrote:> This is really about specific properties/nodes that> want to provide some extra clues to a view about how> to render them (for example, a default action should> be bold, [snip]

For the case of the default action, Petr is right I think - the menu
item does *not* know whether it is the default action or not. Only the
view does (because it has access to the entire menu and the node it
refers to). Cf. my post in "Usability issues vs. NB architecture": our
decision to have a Presenter.Popup actually prevents the view from
reliably boldfacing the default action, because the view does not
control the creation of the menu item. (*) For menu items, there is no
need for rendering hints because the presenter can already display
whatever it feels like. In contrast, for node display names, the view is
responsible for the display, with the node supplying only a display name
string, so some additional hints can be useful.

-Jesse

(*) We could introduce a Presenter.PopupMenu­WhichUnderstandDefau­lt or
whatever:

public interface WhateverItIsCalled {
JMenuItem getPopupPresenter(b­oolean defaultAction);
}

--
Jesse Glick <mailto:jesse.glick­@sun.com> x22801
NetBeans, Open APIs <http://www.netbean­s.org/>



Add comment
Petr Kuzel 19 May 2003 12:24:42 permanent link ]
 Tim Boudreau wrote:> This is really about specific properties/nodes that> want to provide some extra clues to a view about how> to render them (for example, a default action should

Would not be then a right solution to give possibility
to provide a renderer? Renderers could be located using
the classification framework. It's more powerfull and
does not clutter model layer with rendering hints.

Cc.



Add comment
Tim Boudreau 19 May 2003 13:03:11 permanent link ]
 Petr Kuzel wrote:> Tim Boudreau wrote:>
This is really about specific properties/nodes that>>want to provide some extra clues to a view about how>>to render them (for example, a default action should>
Would not be then a right solution to give possibility> to provide a renderer? Renderers could be located using> the classification framework. It's more powerfull and> does not clutter model layer with rendering hints.

In the sense of separating model from view, I suppose it
makes a kind of sense, BUT: Trees, tables, etc. are
(or at least can be) highly optimized by, for instance,
using a single component to render many items. Providing
a renderer means that, at best, something will instantiate
an additional component to do the rendering, and at worst
(with a naive implementation), it will instantiate a
renderer for every paint call.

In short, "more powerful" is exactly what we *don't*
want here.

-Tim



Add comment
Jaroslav Tulach 19 May 2003 15:43:49 permanent link ]
 

Tim Boudreau wrote:> Petr Kuzel wrote:>
Tim Boudreau wrote:>>
This is really about specific properties/nodes that>>> want to provide some extra clues to a view about how>>> to render them (for example, a default action should>>
Would not be then a right solution to give possibility>> to provide a renderer? Renderers could be located using>> the classification framework. It's more powerfull and>> does not clutter model layer with rendering hints.

What an interesting idea!
In the sense of separating model from view, I suppose it> makes a kind of sense, BUT: Trees, tables, etc. are> (or at least can be) highly optimized by, for instance,> using a single component to render many items.

This need not be problem as there can be one instance of renderer shared
among all objects of the same type.
Providing> a renderer means that, at best, something will instantiate> an additional component to do the rendering, and at worst> (with a naive implementation), it will instantiate a> renderer for every paint call.

The NodeRenderer might be modified to find the right renderer inside of
the Node.getLookup (). This would return the shared instance that would
render any additional attributes.


If not slow (and I do not think it is as slow), this could be an
excelent enhancement as it creates a pluggable architecture for
rendering extensions. From the Explorer View UI, it just uses provided
renderer, from the Node point of view, it just needs to provided it. And
there can be many additional libraries offering factory methods based on
simplified html, Tim's rendering interface, etc.

I like this separation.
yarda


Add comment
Petr Kuzel 19 May 2003 15:55:31 permanent link ]
 Tim Boudreau wrote:
Petr Kuzel wrote:>> Tim Boudreau wrote:>>
This is really about specific properties/nodes that>>>want to provide some extra clues to a view about how>>>to render them (for example, a default action should>>
Would not be then a right solution to give possibility>> to provide a renderer? Renderers could be located using>> the classification framework. It's more powerfull and>> does not clutter model layer with rendering hints.>
In the sense of separating model from view, I suppose it> makes a kind of sense, BUT: Trees, tables, etc. are> (or at least can be) highly optimized by, for instance,> using a single component to render many items. Providing> a renderer means that, at best, something will instantiate> an additional component to do the rendering, and at worst> (with a naive implementation), it will instantiate a> renderer for every paint call.

Well, you can provide precooked renderer that takes
the rendering hints...

Cc.


Add comment
Tim Boudreau 19 May 2003 17:17:43 permanent link ]
 Jaroslav Tulach wrote:>
Tim Boudreau wrote:>
Petr Kuzel wrote:>>
Tim Boudreau wrote:>>>
This is really about specific properties/nodes that>>>> want to provide some extra clues to a view about how>>>> to render them (for example, a default action should>>>
Would not be then a right solution to give possibility>>> to provide a renderer? Renderers could be located using>>> the classification framework. It's more powerfull and>>> does not clutter model layer with rendering hints.>>
What an interesting idea!>>
In the sense of separating model from view, I suppose it>> makes a kind of sense, BUT: Trees, tables, etc. are>> (or at least can be) highly optimized by, for instance,>> using a single component to render many items.>
This need not be problem as there can be one instance of renderer shared > among all objects of the same type.

Which will be written by whom? I think it's much more likely
that someone will not trust in this, and go out and instantiate
their own renderer whether they need to or not.
Providing>> a renderer means that, at best, something will instantiate>> an additional component to do the rendering, and at worst>> (with a naive implementation), it will instantiate a>> renderer for every paint call.>
The NodeRenderer might be modified to find the right renderer inside of > the Node.getLookup (). This would return the shared instance that would > render any additional attributes.

NONONONONONONONONON­ONONONONO....

No matter how fast it may, might, could, should be, the last
thing on earth I want to be doing is fishing around in maps,
hashtables or anything else in the middle of a paint loop.

And the fact is, not everybody is comfortable with writing
painting code. My goal is to make the common case easy, without
requiring anyone to play with java.awt.Graphics.
If not slow (and I do not think it is as slow), this could be an > excelent enhancement as it creates a pluggable architecture for > rendering extensions. From the Explorer View UI, it just uses provided

The whole point here is that if someone wants to do something so
exotic that it needs its own renderer, then probably they need to
be writing their own view. How many *useful* things could you do
with your own renderer beyond text color/style, etc.
renderer, from the Node point of view, it just needs to provided it. And > there can be many additional libraries offering factory methods based on > simplified html, Tim's rendering interface, etc.>
I like this separation.

I sincerely hope you're kidding.

-Tim



Add comment
Tor Norbye 19 May 2003 18:06:43 permanent link ]
 On Mon, 2003-05-19 at 07:17, Tim Boudreau wrote:> > This need not be problem as there can be one instance of renderer shared > > among all objects of the same type.>
Which will be written by whom? I think it's much more likely> that someone will not trust in this, and go out and instantiate> their own renderer whether they need to or not.

I hope this will not be the extent of the rendering hints API;
as a potential client of it, I just want to say "make this string
bold", "make that string red", or "add a strikethrough style on
that string".

I'd prefer not to have to write a bunch of Java2D code to get the
alignment just right, etc.

-- Tor



Add comment
Jaroslav Tulach 19 May 2003 18:11:55 permanent link ]
 Tim,
it is hard to reply with open mind, when receiving mail like this.

Tim Boudreau wrote:> Jaroslav Tulach wrote:>
Tim Boudreau wrote:>>
Petr Kuzel wrote:>>>
Tim Boudreau wrote:>>>>
This is really about specific properties/nodes that>>>>> want to provide some extra clues to a view about how>>>>> to render them (for example, a default action should>>>>
Would not be then a right solution to give possibility>>>> to provide a renderer? Renderers could be located using>>>> the classification framework. It's more powerfull and>>>> does not clutter model layer with rendering hints.>>>
What an interesting idea!>>
In the sense of separating model from view, I suppose it>>> makes a kind of sense, BUT: Trees, tables, etc. are>>> (or at least can be) highly optimized by, for instance,>>> using a single component to render many items.>>
This need not be problem as there can be one instance of renderer >> shared among all objects of the same type.>
Which will be written by whom? I think it's much more likely> that someone will not trust in this, and go out and instantiate> their own renderer whether they need to or not.

Looks you do not trust anybody. I think that sometimes you have to.
Providing>>> a renderer means that, at best, something will instantiate>>> an additional component to do the rendering, and at worst>>> (with a naive implementation), it will instantiate a>>> renderer for every paint call.>>
The NodeRenderer might be modified to find the right renderer inside >> of the Node.getLookup (). This would return the shared instance that >> would render any additional attributes.>
NONONONONONONONONON­ONONONONO....>
No matter how fast it may, might, could, should be, the last> thing on earth I want to be doing is fishing around in maps,> hashtables or anything else in the middle of a paint loop.

As far as I remember you are fishing in node.getValue == fishing in maps.
And the fact is, not everybody is comfortable with writing> painting code. My goal is to make the common case easy, without> requiring anyone to play with java.awt.Graphics.

Read the rest of my suggestion, please.
If not slow (and I do not think it is as slow), this could be an >> excelent enhancement as it creates a pluggable architecture for >> rendering extensions. From the Explorer View UI, it just uses provided >
The whole point here is that if someone wants to do something so> exotic that it needs its own renderer, then probably they need to> be writing their own view. How many *useful* things could you do> with your own renderer beyond text color/style, etc.

If somebody is writing own view, it does not need to pay attention to
this discussion at all. I thought that this is about providing a
rendering hints to the default views.
renderer, from the Node point of view, it just needs to provided it. >> And there can be many additional libraries offering factory methods >> based on simplified html, Tim's rendering interface, etc.>>
I like this separation.>
I sincerely hope you're kidding.

Alas, I am not. What is wrong on writing my Node like this:

class MyNode extends AbstractNode
implements org.nb.api.tim.Rend­eringHints {
public Font getFont () { ... }
public Color getBackground () { ... }
public Color getForeground () { ... }


public MyNode () {
super (Children.LEAF, Lookups.singleton (new Object[] {
org.nb.api.tim.Rend­eringHints.RENDERER,­
/* this is the instance of the rendered that renders this node, please
not that there is just one instance */
this
/* adds org.nb.api.tim.Rend­eringHints interface into the Lookup, so the
render can use it */
}));
}
}

this is neither slow or allocates too many objects. So why you think I
am kidding?

Sincerely yours,
yarda



Add comment
Jesse Glick 19 May 2003 18:54:07 permanent link ]
 Tim Boudreau wrote:> No matter how fast it may, might, could, should be, the last> thing on earth I want to be doing is fishing around in maps,> hashtables or anything else in the middle of a paint loop.

A simple hashtable lookup is so fast as to be negligible if you're only
doing a few of them. Paint loops already normally do lots of them. How
do you think UI defaults etc. work?

Calling into Lookup, on the other hand, I have no idea. Might be slow at
the moment. Lookup is currently oversynchronized and heavyweight IMHO.

-Jesse

--
Jesse Glick <mailto:jesse.glick­@sun.com> x22801
NetBeans, Open APIs <http://www.netbean­s.org/>



Add comment
Tim Boudreau 21 May 2003 20:11:22 permanent link ]
 Hi, all,

In order to explore all the possibilities, today I wrote a
lightweight HTML renderer that renders basically the same
subset of HTML that rendering hints would cover.

Timing it in comparison with Swing's HTML rendering is a
bit difficult - in a JLabel, a bunch of HTML rendering
data is actually computed when you call setText().

Anyway, for the first render, my rendering code is about
twice as fast (not including the additional time Swing rendering
spends in setText() - it's a very deep call stack). If
I felt really ambitious, I could probably also cache
some rendering data...

For subsequent renders, Swing's HTML support is faster,
since the data is already cached - but
in the case of tree and table elements, where a renderer
gets setText() called on it once for each cell, probably
my rendering code would be quicker.

At the same time, a simple rendering hints object would
be faster than either. Whaddayathink?

-Tim



Add comment
Jaroslav Tulach 22 May 2003 10:44:29 permanent link ]
 

Tim Boudreau wrote:> Hi, all,>
In order to explore all the possibilities, today I wrote a> lightweight HTML renderer that renders basically the same> subset of HTML that rendering hints would cover.>
Timing it in comparison with Swing's HTML rendering is a> bit difficult - in a JLabel, a bunch of HTML rendering> data is actually computed when you call setText().>
Anyway, for the first render, my rendering code is about> twice as fast

Good. How many times it is slower than plain drawText? In case the
string contains html and in case it does not?
(not including the additional time Swing rendering> spends in setText() - it's a very deep call stack). If> I felt really ambitious, I could probably also cache> some rendering data...

That would speed up the subsequent renders, I guess. I do not know if
that is necessary. When you scroll a tree, does it move the buffer or
draws it again completely? If the later, then some kind of cache would
be useful, otherwise I do not see use for it.

yarda



Add comment
Tim Boudreau 22 May 2003 13:07:34 permanent link ]
 Jaroslav Tulach wrote:>
Tim Boudreau wrote:>
Hi, all,>>
In order to explore all the possibilities, today I wrote a>> lightweight HTML renderer that renders basically the same>> subset of HTML that rendering hints would cover.>>
Timing it in comparison with Swing's HTML rendering is a>> bit difficult - in a JLabel, a bunch of HTML rendering>> data is actually computed when you call setText().>>
Anyway, for the first render, my rendering code is about>> twice as fast>
Good. How many times it is slower than plain drawText? In case the > string contains html and in case it does not?

I'll check this - I need to change my benchmarking to
compare a JLabel and a JComponent w/ rendering code, and
include the setText() call to both in the benchmark to
get a true picture of the overhead.

I'll try that today. One problem is that both rendering
methods are so fast that it's hard to get meaningful
data from something like OptimizeIt - there are too
many other things in the JVM that are slower that
crowd it out.
(not including the additional time Swing rendering>> spends in setText() - it's a very deep call stack). If>> I felt really ambitious, I could probably also cache>> some rendering data...>
That would speed up the subsequent renders, I guess. I do not know if > that is necessary. When you scroll a tree, does it move the buffer or > draws it again completely?

Probably depends on double buffering. The painting logic
for a tree or a table takes a single component and repeatedly
calls setText() and then paint() for each element. So
the overhead in setText() on a JLabel is relevant.

It could save one iteration of the string and a few
char comparisons to cache the locations and attributes
of strings that will actually be rendered.

There are two ways to implement such an optimization -
1. The render method keeps the data in a WeakSet,
or such and simply reuses it when it gets a string with a
matching hashcode.

2. The render method returns the data and will accept
it as an argument - slightly more efficient, but more
work for a client that wants to reuse it.

-Tim



Add comment
Tim Lebedkov 23 May 2003 18:16:41 permanent link ]
 I completely agree with Petr.
We need a renderer-based framework.
It will be much more powerful and faster too.
We could also provide a simple renderer implementation for
color/font changing.

Tim

Petr Kuzel wrote:
Tim Boudreau wrote:>
This is really about specific properties/nodes that>>want to provide some extra clues to a view about how>>to render them (for example, a default action should>>
Would not be then a right solution to give possibility>to provide a renderer? Renderers could be located using>the classification framework. It's more powerfull and>does not clutter model layer with rendering hints.>
Cc.>



Add comment
Tim Boudreau 23 May 2003 18:27:20 permanent link ]
 Tim Lebedkov wrote:> I completely agree with Petr.> We need a renderer-based framework.

Why? The only thing I've heard so far is that
it's "more powerful" - but nobody has offered
a use case where they would need to do something
that couldn't be done with colors and font styles.

Do you have such a use case?
It will be much more powerful and faster too.

Adding code to fetch a unique renderer for some
elements in a tree, table or tabbed pane, possibly
instantiating the renderer for the first time,
possibly loading classes to do it, and then
configuring it and painting...this process
can be many things, but faster is not
one of them.
We could also provide a simple renderer implementation for> color/font changing.

Sure, if we choose to go that way.


Note that, as I mentioned before, creating a
renderer infrastructure is in no way a blocker
for going ahead with either lightweight HTML rendering
or rendering hints right now.

-Tim



Add comment
Tim Lebedkov 23 May 2003 18:56:11 permanent link ]
 One more requirement for the rendering hints is
drawing an icon (and I will need different icons
for different property values).

How this could be achived using HTML?

Tim


Add comment
Tim Boudreau 24 May 2003 14:53:32 permanent link ]
 Tim Lebedkov wrote:> One more requirement for the rendering hints is> drawing an icon (and I will need different icons> for different property values).>
How this could be achived using HTML?

The renderer used by the tree/table will handle
that in its paint method, along with calling
html rendering.

-Tim



Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > Java Programming > Rendering hints - use cases & requirements 24 May 2003 14:53:32

see also:
OT. Happy Holidays to you all
Run external application script from…
Picture Importing
pass tests:
ДЛЯ РУССКИХ ЧУВАКОВ
see also:
A nice share:Put dvd and video on…
How to put any DVD and video on walkman
...

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .