The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » SwingLabs

Thread: [FYI] Highlighter overhaul starting ...

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 27 - Last Post: Jul 5, 2007 9:26 AM by: Kleopatra
Kleopatra
[FYI] Highlighter overhaul starting ...
Posted: May 10, 2007 7:33 AM
  Click to reply to this thread Reply


We started to debate about it quite a while ago (have a look at the wiki
highlighter basics page and the references thereon) - now it's going to
happen. This will break existing code, though I'll try to be as gentle
as possible. Will keep you informed about the details as I go.

The swingx code-base is tagged as per today with
jw_before_highlighter_20may2007 to allow easy backing out.

Cheers
Jeanette


---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 10, 2007 5:05 PM   in response to: Kleopatra
  Click to reply to this thread Reply

Jeanette,

What's the status of the Mustang sorting/filtering backport for the JXTable?

Karl

kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 10, 2007 6:45 PM   in response to: kschaefe
  Click to reply to this thread Reply

I found Richard's slides on the SwingLabs site. Looks like the DevPack distributions will handle the splitting of what version of sorting/filtering you get. So the 1.6 pack will have a JXTable with Mustang support.

Karl

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 11, 2007 2:01 AM   in response to: kschaefe
  Click to reply to this thread Reply

>
> What's the status of the Mustang sorting/filtering backport for the JXTable?
>

none available and none planned

> I found Richard's slides on the SwingLabs site. Looks like the
DevPack distributions will handle the splitting of what version of
sorting/filtering you get. So the 1.6 pack will have a JXTable with
Mustang support.
>

that's the idea, yes. But note that the xtable in 1.5 pack will be
different from the xtable in 1.6 pack. Changing the xtable from 1.5 to
1.6 has some issues ... ehem ...

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 11, 2007 5:15 AM   in response to: Kleopatra
  Click to reply to this thread Reply

Kleopatra schrieb:

>
> We started to debate about it quite a while ago (have a look at the wiki
> highlighter basics page and the references thereon) - now it's going to
> happen. This will break existing code, though I'll try to be as gentle
> as possible. Will keep you informed about the details as I go.
>

okay, the first big chunk is committed - basically changed the class
hierarchy as discussed earlier (to make use of the Composite pattern)

1. renamed Highlighter to LegacyHighlighter
2. extracted Highlighter interface and AbstractHighlighter
3. let HighlighterPipeline extend AbstractHighlighter
4. renamed HighlighterPipeline to CompoundHighlighter
5. renamed methods/fields refering to compoundHighlighter in JXTable,
JXList, JXTree accordingly

next will be to remove the get/setCompoundHighlighter methods from the
collection views' public api and add the getter for the highlighters
array. After that's done (maybe not before the weekend), I assume it
will be safe enough to update custom code to the api change.

Cheers
Jeanette


---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 11, 2007 7:50 AM   in response to: Kleopatra
  Click to reply to this thread Reply

Kleopatra schrieb:
> next will be to remove the get/setCompoundHighlighter methods from the
> collection views' public api and add the getter for the highlighters
> array. After that's done (maybe not before the weekend), I assume it
> will be safe enough to update custom code to the api change.
>

done and committed - but not quite stable yet, so better wait a bit
until updating custom code. Nevertheless, if you stumble across
something grossly wrong, please let me know.

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 11, 2007 8:03 AM   in response to: Kleopatra
  Click to reply to this thread Reply

Kleopatra schrieb:
> Kleopatra schrieb:
>> next will be to remove the get/setCompoundHighlighter methods from the
>> collection views' public api and add the getter for the highlighters
>> array. After that's done (maybe not before the weekend), I assume it
>> will be safe enough to update custom code to the api change.
>>
>
> done and committed - but not quite stable yet, so better wait a bit
> until updating custom code. Nevertheless, if you stumble across
> something grossly wrong, please let me know.
>

forgot: one thing that might (or not, can't judge) be seriously broken
is the HighlighterPropertyEditor in the beaninfos source tree. Would any
of the editor experts please keep an eye on it?

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 14, 2007 5:14 AM   in response to: Kleopatra
  Click to reply to this thread Reply

another sequel in the overhaul story:

The main thing I did over the weekend was to introduce the notion of a
conditional highlight near the top of the Highlighter hierarchy. Now
there's a dedicated class for a boolean on/off highlight (named
HighlightPredicate) and the AbstractHighlighter has a property for
setting it. The default highlight method at that level is implemented to
ask the predicate and calls the actual (abstract) highlighting code only
if the predicate consents.

That's along the lines which we (Patrick and others) discussed in the
latest thread about highlighters (the link is on the base highlighter
wiki): the separation between the decision and the decoration itself
allows for nice flexibility and high re-use. Code snippet, creating
rollover highlighting with normal background or painter (the latter is
still in the test source hierarchy only):

Highlighter background = new ColorHighlighter(Color.RED, null,
   HighlightPredicate.ROLLOVER_ROW);
Highlighter painter = new PainterHighlighter(new MattePainter(),
   HighlightPredicate.ROLLOVER_ROW);	


Right now I'm working on moving over all (most?, didn't yet hit a wall
:) functionality of the specialized SomethingHighlighter to
SomethingHighlightPredicate.

Another change is that the predefined Highlighters will be replaced by a
factory to create commonly useful highlighters - this allows to get rid
off the hack (immutable) around the memory leak introduced by static
highlighters. Currently there's a simpleStriping, alternateStriping and
both with options to group more than one row into a stripe. Code
snippets to create striped:

// highlights every second row with the given background
Highlighter simple = HighlighterFactory.
   createSimpleStriping(stripeColor);
// highlights rows alternating the given backgrounds
Highlighter alternate = HighlighterFactory.
   createAlternateStriping(firstRowColor, alternateRowColor);



Feedback welcome!

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 14, 2007 6:01 AM   in response to: Kleopatra
  Click to reply to this thread Reply

Jeanette,

My only feedback, thus far is: I like it.

Is all of that checked in? I want to start fooling with it.

Karl

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 14, 2007 7:19 AM   in response to: kschaefe
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
> Jeanette,
>
> My only feedback, thus far is: I like it.
>

good to hear :-)

> Is all of that checked in? I want to start fooling with it.
>
>

yeah, I commit while going - often-and-early.

Have fun
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kleopatra

Posts: 1,677
Re: [FYI] Highlighter overhaul starting ...
Posted: May 14, 2007 9:22 AM   in response to: kschaefe
  Click to reply to this thread Reply

[duplicate ... mailinglist crooky again?]

jdnc-interest@javadesktop.org schrieb:
> Jeanette,
>
> My only feedback, thus far is: I like it.
>

good to hear :-)

> Is all of that checked in? I want to start fooling with it.
>
>

yeah, I commit while going - often-and-early.

Have fun
Jeanette

kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 31, 2007 10:35 AM   in response to: kleopatra
  Click to reply to this thread Reply

Well, I converted over my application to use the new TreeTable stuff (OK, so I wrote that part and know it well) and the new Highlighting stuff (which I don't know that well). I simply replaced my current jar with a new build and started squashing errors. It took me less than 30 minutes and most of that time was reading Jeanette's documentation and testing the app.

So, it's easy. ;) Possibly not for some applications, but I do recommend upgrading.

Having fooled with it a little bit, I can say that I really prefer the new approach to highlighting. Good work, Jeanette.

Karl

kleopatra

Posts: 1,677
Re: [FYI] Highlighter overhaul starting ...
Posted: May 15, 2007 7:18 AM   in response to: Kleopatra
  Click to reply to this thread Reply

yet another step into bright Highlighter world ...

The main change is an added SearchPredicate and let TableSearchable use it with a ColorHighlighter instead of the old SearchHighlighter. This will break any code which extended TableSearchable and related (sorry Paul, but you had been warned ;-) On the bright side, the code is simpler and more easy to extend (okay, it will be so in the end) - I updated the Find/replace in my incubator (under foreign/paultaylor) to show how it can be done, but did nothing to get the logic correct there.

Cheers
Jeanette

kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 15, 2007 7:43 AM   in response to: kleopatra
  Click to reply to this thread Reply

Jeanette,

What's our ETA on this? (Please don't say Friday, since you won't have a chance to look at the tree table code until you return.) I'm to the point where I'm quashing bugs in the unit tests for the JXTreeTable changes. I keep having to update the visual check for the highlighter changes. So, I'm sort of waiting on the changes at this point to be finished (but I believe that I'm done!).

Karl

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 15, 2007 9:19 AM   in response to: kschaefe
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
> Jeanette,
>
> What's our ETA on this? (Please don't say Friday, since you won't have a chance to look at the tree table code until you return.)

what ever ETA is, I guess the answer is "Friday". The code you are
talking about is the part under your 218, right? If that doesn't diverge
too much from what we discussed earlier, there's not much left for me to
look over :-)

> I'm to the point where I'm quashing bugs in the unit tests for the JXTreeTable changes. I keep having to update the visual check for the highlighter changes. So, I'm sort of waiting on the changes at this point to be finished (but I believe that I'm done!).

weeell, I'm still in the process of updating the tests to the new
highlighters - but would not expect too much problems when you merge
into those your model-related changes. If you think you are ready, go!
Just tag the existing code base, and alert the community that and which
changes are about to happen and that they will blow their code, to the
better, of course <g>. On the bright side: there are two major chunks of
changes at the same time, but only one custom code revision needed.

Any objections?

Cheers
Jeanette



---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kleopatra

Posts: 1,677
Re: [FYI] Highlighter overhaul starting ...
Posted: May 15, 2007 9:36 AM   in response to: Kleopatra
  Click to reply to this thread Reply

> what ever ETA is, I guess the answer is "Friday".

it's a bit less time than it looks - the day after tomorrow is a holiday here in Germany, and I promised by all my pyramids to not work ;-)

> The
> code you are
> talking about is the part under your 218, right? If
> that doesn't diverge
> too much from what we discussed earlier, there's not
> much left for me to
> look over :-)

just realized that might be misunderstandable - what I meant is that your code was in excellent state last time a gave it cursory look! So I'm looking forward to seeing it in head asap

Cheers - have to run now
Jeanette

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 16, 2007 4:17 AM   in response to: kleopatra
  Click to reply to this thread Reply

again ...

> yet another step into bright Highlighter world ...
>

deprecated the LegacyHighlighter tree and moved all (most :-) internal
code, that is mostly the tests, to not use it.

One thing that doesn't yet feel quite ready is the PatternPredicate and
how to couple it to a JXSearchPanel (the HighlighterClientVisualCheck
has a first go on it). Have to brood a bit about.

Apart from that (and the exact location of the *Predicate) it looks
quite okay - being biased of course <g> Waiting for complaints to the
contrary ...

CU
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 16, 2007 7:24 AM   in response to: Kleopatra
  Click to reply to this thread Reply

I'm not too sure about having all those Predicates defined in the interface. Of course, I'm not sure that they belong as top-level classes either. The factory approach might be the way to go.

I know that OR can be defined using NAND operations ;), but could you give me a logical OR predicate please.

Any particular reason that ShadingColorHighlighter is not using Color.darker? Also, what are you doing about the alpha channel on the color? Color.brighter and Color.darker seem to ignore it, ensuring the new color is 100% opaque. Is this the model to use or should we do a better job.

Why does SearchPredicate not extend PatternPredicate? This seems like a good case of extension for specialization.

Karl

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 16, 2007 8:56 AM   in response to: kschaefe
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
>
> I know that OR can be defined using NAND operations ;), but could you give me a logical OR predicate please.
>

oversight - will do.

> Any particular reason that ShadingColorHighlighter is not using Color.darker? Also, what are you doing about the alpha channel on the color? Color.brighter and Color.darker seem to ignore it, ensuring the new color is 100% opaque. Is this the model to use or should we do a better job.
>

don't know - I just copied from the old HierarchicalColumnHighlighter
and assumed they knew better than me what they had been doing (everyone
does when it comes to painting whatever <g>)

> Why does SearchPredicate not extend PatternPredicate? This seems like a good case of extension for specialization.
>

maybe or not - there are subtle differences which went more-or-less
unnoticed until now, currently I'm not quite sure, not even which
direction inheritance should go (my gut and memory tells me that the old
inheritence Search extends Pattern was a bit accidental <g>), first
incomplete thoughts:

- marking a search match cell based: we always test the current cell
(that is there is no notion of testColumn); the highlightColumn and
highlightRow properties are used to define the "area" where a matching
cell should be highlighted (-1 == everywhere, positive values only in a
single row/col). Hidden columns are neither tested nor highlighted.

- for the pattern-based highlighting we have a notion of a test cell
(corrently only in column dimension, probably should be extended to the
row dimension as well, don't know yet) which is inherently independent
of the highlight cell. The test cell may be hidden.

- the row is nasty anyway: it's in view coordinates, while all column
coordinates are model ...

Without 'nough time to think to the bottom I left it with the first
working solution for now - we'll propably find out more when we use it.

Thanks for the feedback, exactly what I need to order my thoughts!
Jeanette






---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 17, 2007 3:25 AM   in response to: kschaefe
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
>
> I know that OR can be defined using NAND operations ;), but could you give me a logical OR predicate please.
>

Done (tests still missing, but then ... it's holiday and I'll be
dragged from here by my hairs any minute now <g>)

Added a fun (my interpretation, and _not_ recommended out in the wild)
demo to the demo src tree in swingx to go a bit to the limit of when/how
to use Highlighters: a couple of lines and default boolean rendering is
replaced by a custom icon.

HighlightPredicate truePredicate = new
     EqualsHighlightPredicate(Boolean.TRUE);
HighlightPredicate falsePredicate = new
     EqualsHighlightPredicate(Boolean.FALSE);
Highlighter yesHighlighter = new PainterHighlighter(
getPainter("resources/green-orb.png"),
     truePredicate);
Highlighter noHighlighter = new PainterHighlighter(
     getPainter("resources/exit.png"), falsePredicate); 
table.setHighlighters(yesHighlighter, noHighlighter); 
table.setDefaultRenderer(Boolean.class,
     new DefaultTableRenderer(StringValue.EMPTY));


Cheers
Jeanette

BTW - the custom boolean was a real-world requirement:
http://forums.java.net/jive/thread.jspa?threadID=25300

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


paultaylor

Posts: 103
Re: [FYI] Highlighter overhaul starting ...
Posted: May 30, 2007 9:25 AM   in response to: Kleopatra
  Click to reply to this thread Reply

kleopatra wrote:
>> This will break any code which extended TableSearchable and related (sorry Paul, but you had been warned ;-) On the bright side, the code is simpler and more easy to extend (okay, it will be so in the end) - I updated the Find/replace in my incubator (under foreign/paultaylor) to show how it can be done, but did nothing to get the logic correct there.

Hi, did you check this file in because I'm unable to find any folder called foreign. I have been trying to fix my code but I'm struggling I never fully understood how the SearchHighlighter class worked and I cant find the equivalent code to the searchhighlighters.setHighlightCell() method in the new ColourHiglighter with SearchPredicate code.

Paul

paultaylor

Posts: 103
Re: [FYI] Highlighter overhaul starting ...
Posted: May 30, 2007 9:50 AM   in response to: paultaylor
  Click to reply to this thread Reply

Actually after staring at this code for ages with my brain hurting I suddenly got it, Ive checked in replacement which I think works

paultaylor

Posts: 103
Re: [FYI] Highlighter overhaul starting ...
Posted: May 31, 2007 6:07 AM   in response to: paultaylor
  Click to reply to this thread Reply

Ive just updated my table highlighter code, and I have to say seperating the Testing from the actual Highlighting is definently better.

I use a highlighter to highlight fields in a table that have the same value (duplicates) in a particular column. Because the only way I can identify a value is a duplicate is by comparing against every other row I don't want to do this on a row by row basis, so I used to calculate the duplicate rows once before adding my own highlighter, initilized with a list of known rows and then these were referred to in the test method. Ive now rewritten this as a RowsKnownPredicate, it is very simple but I think useful nonetheless,maybe you would like to add it in to the highlighter code, Ive checked it into the incubator.

Also PatternPredicate,SearchPredicate and my own predicate share some common behaviour, what about having them subclass a ConditionalPredicate class (similar to the legacy ConditionalHighlighter)
Paul

kleopatra

Posts: 1,677
Re: [FYI] Highlighter overhaul starting ...
Posted: Jul 4, 2007 8:27 AM   in response to: Kleopatra
  Click to reply to this thread Reply

taking up the old thread ...

just fixed a long-standing task - implement ui-specific highlighters cleanly

https://swingx.dev.java.net/issues/show_bug.cgi?id=205

Until now, the UIColorHighlighter got the striping background from an internal hardcoded map, a quick&dirty implementation based on the work of our visual designer, Coleen (her color table is accessible from the highlighter wiki pages). The mapping is done (same as before) only for a handful of the most common LFs, not quite sure what's the best approach to allow third party LF colors be easily installed. Could any of the LF gurus please have a look at the code and my comments?

Now I changed that to load in a UIColorHighlighterAddon - the colors are the same, except for maybe c&p errors - so please let me know if you experience any new trouble.

Cheers
Jeanette

kirillcool

Posts: 796
Re: [FYI] Highlighter overhaul starting ...
Posted: Jul 5, 2007 8:33 AM   in response to: kleopatra
  Click to reply to this thread Reply

Would it be possible to have a small example of a test program using the JXTable the "right" way + the list of extension points in the UIManager for the LAFs to put their entries.

Thanks
Kirill

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: Jul 5, 2007 9:26 AM   in response to: kirillcool
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
> Would it be possible to have a small example of a test program using the JXTable the "right" way + the list of extension points in the UIManager for the LAFs to put their entries.
>

to add lf-dependend background striping to a table:

table.addHighlighter(HighlighterFactory
    .createSimpleStriping());


an example with LF-switching is in JXTreeTableVisualCheck (in the test
hierarchy) - simply toggles between cross-platform and system LF.

A really pluggable extension point for LFs still has to be defined <g>
Currently it's rather crude - UIColorHighlighterAddon adds a
ColorUIResource for stripingBackground key. Basically, they would
register a custom color, but not sure how to prevent to override such a
custom color in the addon. LFs need a possibility to hook into that
addon lookup mechanism - didn't follow the discussions regarding such a
pluggable thingy.

Cheers and have a nice day - I'm hungry now
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net


kschaefe

Posts: 1,662
Re: [FYI] Highlighter overhaul starting ...
Posted: May 11, 2007 9:47 AM   in response to: Kleopatra
  Click to reply to this thread Reply

I'll take a peek over the weekend. Not much time today.

BTW, I'm finishing up the unit tests for my tree table changes (JavaOne inspiration, I guess).

Speaking of unit tests ;) I didn't hear you mention any.

Karl

Kleopatra
Re: [FYI] Highlighter overhaul starting ...
Posted: May 14, 2007 4:43 AM   in response to: kschaefe
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
>
> Speaking of unit tests ;) I didn't hear you mention any.
>

no need to mention - they are still passing <g>

Obviously that's only part of the story, they have to be revisited and
adjusted to the newer api.

Cheers
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net





 XML java.net RSS