Home » Eclipse Projects » Standard Widget Toolkit (SWT) » KTABLE Too Slow - Any Alternative?
|
Re: KTABLE Too Slow - Any Alternative? [message #465395 is a reply to message #465394] |
Mon, 12 December 2005 16:55 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi Steve,
just curious why you thing KTable is slow: on what OS and hardware are
you running? How do you render you cells?
Usually it is a slow model or renderer implementation that causes a slow
KTable. I might not be the most objective judge, but for me KTable is a
very smooth and "quick" widget...
Regards,
Friederich
steve lane wrote:
>
> Hi, we needed to add the ability to freeze the first column in our SWT
> app. Sadly SWT doesnt appear to support this so i used KTable. I like
> KTable - its more like SWING model. But, its slow and clunky,
> especially if you use rendering to colour the columns. Is there any
> alternative to KTable or any way of making SWT achieve this - i find
> SWT's table's very poor in comparison to Swing.
>
> thanks,
>
> steve.
>
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel +49 241 9979356
Fax +49 221 726670
www.kupzog.de/fkmk
|
|
| |
Re: KTABLE Too Slow - Any Alternative? [message #465413 is a reply to message #465396] |
Mon, 12 December 2005 22:11 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi Steve,
you should put the m_textRenderer.setBackground() call into
doGetCellRenderer(int, int). But I cannot imagine that
this causes the problem. Anyway try it...
What is this AppConstants.getInstance().gray1 stuff? Maybe try to set up
your colors in a couple of local Color variables. Is the table quicker
without color changes?
If not, from where do you get the actual content?
Regards,
Friederich
steve lane wrote:
>
> Thanks Friederich,
>
> Perhaps i am using it wrong ! I have a table that is quite wide and to
> make the table more readable, rows are grouped in 3's by changing the
> background colour of the columns from a lighter gray to a darker gray.
> When the table is scrolled with the scrollbar, it is visibly very slow
> at re-drawing (i am only displaying 10 rows at a time). Im running on
> XP with jdk1.4.2.
>
> What i am doing code wise is this:
>
> class KTableTextModel extends KTableDefaultModel {
> private final TextCellRenderer m_textRenderer = new
> TextCellRenderer(TextCellRenderer.INDICATION_FOCUS_ROW);
> .
> .
> public Object doGetContentAt(int col, int row) {
> if (col > 2) {
> if ((((col-3) / 3) % 2) == 0) {
> m_textRenderer.setBackground(AppConstants.getInstance().gray 1);
> }
> else {
> m_textRenderer.setBackground(AppConstants.getInstance().gray 2);
> }
> }
> .....
> .....
> }
> .
> .
>
> thanks,
>
> steve.
>
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel +49 241 9979356
Fax +49 221 726670
www.kupzog.de/fkmk
|
|
| | |
Re: KTABLE Too Slow - Any Alternative? [message #465432 is a reply to message #465430] |
Tue, 13 December 2005 10:44 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
steve lane wrote:
> On a slightly seperate ktable issue though, i understand it looks
> different to SWT as its not native widgets, but is it possible to make
> the header row look a little nicer ? The header row just comes up as a
> flat grey look - is there some way you can make it look slightly
> bevelled as with the SWT ones??
Hi Steve,
the following code draws WinXP-like table headers. You can implement
your own KTableCellRenderer and use this code. The code is taken from a
propriety renderer from a 1.x KTable implementation, therefore I am
unfortunately not able to send you the complete renderer class.
public static void drawHeader(GC gc, Rectangle rect, String text)
{
gc.setBackground(ResourceManager.getColor(SWT.COLOR_WIDGET_B ACKGROUND));
gc.fillRectangle(rect);
gc.setForeground(ResourceManager.getColor(SWT.COLOR_WIDGET_H IGHLIGHT_SHADOW));
// obere Linie
gc.drawLine(rect.x, rect.y, rect.x+rect.width-1, rect.y);
// Hellerer Trenner
gc.drawLine(rect.x+rect.width-2, rect.y+2, rect.x+rect.width-2,
rect.y+rect.height-4);
gc.setForeground(ResourceManager.getColor(192,192,192));
// leichtere Schattenlinien oben
gc.drawLine(rect.x, rect.y+rect.height-2, rect.x+rect.width-1,
rect.y+rect.height-2);
// dunklerer Trenner
gc.drawLine(rect.x+rect.width-3, rect.y+2, rect.x+rect.width-3,
rect.y+rect.height-4);
gc.setForeground(ResourceManager.getColor(SWT.COLOR_WIDGET_N ORMAL_SHADOW));
// Leichte Schattenlinie unten
gc.drawLine(rect.x, rect.y+rect.height-1, rect.x+rect.width-1,
rect.y+rect.height-1);
if (text == null) text = "";
Point textSize = getCachedStringExtent(gc, text);
boolean addPoint = false;
while ((text.length() > 0) && (textSize.x >= rect.width-4)) {
text = text.substring(0, text.length() - 1);
textSize = getCachedStringExtent(gc, text + "...");
addPoint = true;
}
if (addPoint) text = text + "...";
textSize = getCachedStringExtent(gc, text);
if (textSize.x >= rect.width-4) {
text = "";
textSize = getCachedStringExtent(gc, text);
}
gc.setForeground(ResourceManager.getColor(SWT.COLOR_WIDGET_F OREGROUND));
gc.drawText(text, rect.x+3, rect.y+3);
}
public static void drawInvertedHeader(GC gc, Rectangle rect, String text)
{
gc.setBackground(ResourceManager.getColor(220,220,212));
gc.fillRectangle(rect);
gc.setForeground(ResourceManager.getColor(250,250,240));
gc.drawLine(rect.x+1, rect.y+rect.height-2, rect.x+rect.width-1,
rect.y+rect.height-2);
gc.drawLine(rect.x+rect.width-2, rect.y+1, rect.x+rect.width-2,
rect.y+rect.height-3);
gc.setForeground(ResourceManager.getColor(SWT.COLOR_WIDGET_N ORMAL_SHADOW));
gc.drawRectangle(rect.x, rect.y, rect.width-1, rect.height-1);
if (text == null) text = "";
Point textSize = getCachedStringExtent(gc, text);
boolean addPoint = false;
while ((text.length() > 0) && (textSize.x >= rect.width-4)) {
text = text.substring(0, text.length() - 1);
textSize = getCachedStringExtent(gc, text + "...");
addPoint = true;
}
if (addPoint) text = text + "...";
textSize = getCachedStringExtent(gc, text);
if (textSize.x >= rect.width-4) {
text = "";
textSize = getCachedStringExtent(gc, text);
}
gc.setForeground(ResourceManager.getColor(SWT.COLOR_WIDGET_F OREGROUND));
gc.drawText(text, rect.x+4, rect.y+4);
}
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel +49 241 9979356
Fax +49 221 726670
www.kupzog.de/fkmk
|
|
| |
Goto Forum:
Current Time: Sun Dec 08 03:49:39 GMT 2024
Powered by FUDForum. Page generated in 0.04557 seconds
|