 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Griffith Jones Guest
|
Posted: Wed Jun 14, 2006 8:08 pm Post subject: Re: MVC Framework for Swing? |
|
|
Thanks Thomas, that's a big help ...
Griff Jones
"Thomas Weidenfeller" <nobody (AT) ericsson (DOT) invalid> wrote in message
news:e6of12$g2s$1 (AT) news (DOT) al.sw.ericsson.se...
| Quote: | Griffith Jones wrote:
I'm looking for Swing app frameworks, if you know of any ...
I haven't followed java app framework development closely. So some of the
stuff in the list below no longer exist or is not suited. Anyhow, you
might want to have a look at JLense, Kanabos, Pustefix, Merlin, Jaffa,
Pulpitum, JGoodies, JUICe, or Atris Framework. Oh, and both Netbeans and
Eclipse (the IDEs) do have some RCP (rich client platform). The NetBeans
Rich Client Platform and the Eclipse Rich Client Platform respectively.
Sun is also going to standardize an app framework in JSR 296, related to
http://wiki.java.net/bin/view/Javadesktop/SwingLabs. But that will take
some time, and it will be a committee compromise.
There is also stuff like SwiXML or XUI for the XML-everywhere fanboys.
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/ |
|
|
| Back to top |
|
 |
IchBin Guest
|
Posted: Wed Jun 14, 2006 10:59 pm Post subject: Re: Layout problem driving me insane - panels, resizing, etc |
|
|
jackp (AT) spambob (DOT) com wrote:
| Quote: | Karsten Lentzsch wrote:
Right. I just like to add that there exist layout managers
that handle huge classes of screen design, for example
the ExplicitLayout, or even better the ExplicitLayout plus
Explicit Table Builder.
Ladies and gentlemen, I do believe we have a winner.
import com.zookitec.layout.*;
|
[snip code]
| Quote: |
This layout manager is exactly what I've been looking for - I don't
think I'll ever use gridbaglayout again. IchBin's JGoodies solution
looks great too, but since I already spent way too much time on this, I
wanted to go with a standalone, layout manager only solution - and
since IchBin's already solved the problem with JGoodies there wasn't
any more fun to be had that way.
I still need to install eclipse and look at SWT and netBeans, and
probably the other JGoodies, but it seems at least as far as layout
managers are concerned, I'm all set.
Again: Thanks, everybody.
|
Good, at least now you are all squared away. Funny, as it were, Karsten
Lentzsch, who recommended ExplicitLayout for a large amount of classes
in a screen design, is the developer and owner of JGoodies.
Sorry, I took the fun out of it for ya. I just wanted to give you a good
example of JGoodies and factories to work from now and in the future. I
still think that the actual code to do what you wanted was smaller than
the ExplicitLayout. For me, it actually only took 5 commands to lay it out.
Well, this is also for the benefit of anyone else looking at this thread
and the Forms from JGoodies...
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-) |
|
| Back to top |
|
 |
steve Guest
|
Posted: Thu Jun 15, 2006 2:52 am Post subject: Re: Layout problem driving me insane - panels, resizing, etc |
|
|
On Wed, 14 Jun 2006 22:57:10 +0800, jackp (AT) spambob (DOT) com wrote
(in article <1150297030.237486.86270 (AT) p79g2000cwp (DOT) googlegroups.com>):
| Quote: | Karsten Lentzsch wrote:
Right. I just like to add that there exist layout managers
that handle huge classes of screen design, for example
the ExplicitLayout, or even better the ExplicitLayout plus
Explicit Table Builder.
Ladies and gentlemen, I do believe we have a winner.
import com.zookitec.layout.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class LayoutProblem extends JFrame {
public static void main(String[] args) {
new LayoutProblem();
}
String columnNames[] = { "Column 1", "Column 2", "Column 3" };
String dataValues[][] = {
{ "0aa","bbb","ccc"}, { "0dd","eee","fff"}, { "0gg","hhh","iii"},
{ "1aa","bbb","ccc"}, { "1dd","eee","fff"}, { "1gg","hhh","iii"},
{ "2aa","bbb","ccc"}, { "2dd","eee","fff"}, { "2gg","hhh","iii"},
{ "3aa","bbb","ccc"}, { "3dd","eee","fff"}, { "3gg","hhh","iii"},
{ "4aa","bbb","ccc"}, { "4dd","eee","fff"}, { "4gg","hhh","iii"},
{ "5aa","bbb","ccc"}, { "5dd","eee","fff"}, { "5gg","hhh","iii"},
{ "6aa","bbb","ccc"}, { "6dd","eee","fff"}, { "6gg","hhh","iii"},
{ "7aa","bbb","ccc"}, { "7dd","eee","fff"}, { "7gg","hhh","iii"},
{ "8aa","bbb","ccc"}, { "8dd","eee","fff"}, { "8gg","hhh","iii"},
{ "9aa","bbb","ccc"}, { "9dd","eee","fff"}, { "9gg","hhh","iii"},
{ "aaa","bbb","ccc"}, { "ddd","eee","fff"}, { "ggg","hhh","iii"},
};
public LayoutProblem() {
JTable table;
JButton button1, button2, button3, button4;
JTextArea logArea;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// table
table = new JTable(dataValues, columnNames);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane tableScrollPane = new JScrollPane(table);
// button panel
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createRaisedBevelBorder() );
SpringLayout buttonPanelLayout = new SpringLayout();
buttonPanel.setLayout(buttonPanelLayout);
final int PADDING = 6;
button1 = new JButton("Button 1");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button1, PADDING,
SpringLayout.WEST, buttonPanel);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button1, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button1);
button2 = new JButton("Button 2");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button2, PADDING,
SpringLayout.EAST, button1);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button2, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button2);
button3 = new JButton("Button 3");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button3, PADDING,
SpringLayout.EAST, button2);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button3, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button3);
button4 = new JButton("Button 4");
buttonPanelLayout.putConstraint(SpringLayout.WEST, button4, PADDING,
SpringLayout.EAST, button3);
buttonPanelLayout.putConstraint(SpringLayout.NORTH, button4, PADDING,
SpringLayout.NORTH, buttonPanel);
buttonPanel.add(button4);
// text area
logArea = new JTextArea();
logArea.setText("---------------------------\n--------------------------- |
\n
| Quote: | ---------------------------\n");
JScrollPane logAreaScrollPane = new JScrollPane(logArea);
// and now, the magic begins
Container cont = getContentPane(); // for Java 1.4
cont.setLayout(new ExplicitLayout());
cont.add(buttonPanel, new ExplicitConstraints(
buttonPanel,
ContainerEF.centerX(cont),
ContainerEF.centerY(cont),
ContainerEF.width(cont),
MathEF.constant(40),
0.5, 0.5, true, true
));
cont.add(tableScrollPane, new ExplicitConstraints(
tableScrollPane,
ContainerEF.left(cont),
ContainerEF.top(cont),
ContainerEF.width(cont),
true,
MathEF.subtract(ComponentEF.top(buttonPanel), PADDING),
false
));
cont.add(logAreaScrollPane, new ExplicitConstraints(
logAreaScrollPane,
ContainerEF.left(cont),
MathEF.add(ComponentEF.bottom(buttonPanel), PADDING),
ContainerEF.width(cont),
true,
ContainerEF.bottom(cont),
false
));
pack();
setSize(450,600); // initial app size
setVisible(true);
}
}
This layout manager is exactly what I've been looking for - I don't
think I'll ever use gridbaglayout again. IchBin's JGoodies solution
looks great too, but since I already spent way too much time on this, I
wanted to go with a standalone, layout manager only solution - and
since IchBin's already solved the problem with JGoodies there wasn't
any more fun to be had that way.
I still need to install eclipse and look at SWT and netBeans, and
probably the other JGoodies, but it seems at least as far as layout
managers are concerned, I'm all set.
Again: Thanks, everybody.
|
glad we could all help.
personally , I love GBL
but if you want to see why GBL sorts the men from the boys checkout:
http://madbean.com/blog/2004/17/totallygridbag.html
Steve |
|
| Back to top |
|
 |
Karsten Lentzsch Guest
|
Posted: Thu Jun 15, 2006 12:27 pm Post subject: Re: Layout problem driving me insane - panels, resizing, etc |
|
|
steve wrote:
| Quote: | glad we could all help.
personally , I love GBL
but if you want to see why GBL sorts the men from the boys checkout:
|
If you want to see what sorts men from men that
can compete with native application layout, see
http://tinyurl.com/ar5n5 and you may want to love
layout systems that can do more than the weak GBL ;-)
-Karsten |
|
| Back to top |
|
 |
Thomas Fritsch Guest
|
Posted: Thu Jun 29, 2006 5:05 pm Post subject: Re: AbstractAction |
|
|
toton wrote:
| Quote: | From Java 1.5 or lower version, can an Action be used for JCheckBox &
JCheckBoxMenuItem pair or JToggleButton & JCheckBoxMenuItem pair?
JCheckBox, JCheckBoxMenuItem, JToggleButton and JCheckBoxMenuItem all |
have a constructor taking an Action. They also have a setAction(Action)
method inherited from AbstractButton.
| Quote: | Java 1.6 has Action.SELECTED_KEY but 1.5 doesnt have.
So what? |
| Quote: | Also how to execute an Action from program? like JButton has a
doClick method. I want to execute an action from program even when the
actual button or menuitem is removed from gui, thus i dont have an
reference for the actual gui component.
You can do |
Action a = ...;
ActionEvent e =
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "bla";
a.actionPerformed(e);
--
Thomas |
|
| Back to top |
|
 |
toton Guest
|
Posted: Fri Jun 30, 2006 7:10 am Post subject: Re: AbstractAction |
|
|
Thanks for the answer.
For programatically performing action, I used the command pattern
(design patterns by GoF) which extends AbstractAction & has an execute
method. A convinent way.
For the first question i am still unclear that how an action will know
the component's selected state & take decision as SELECTED_KEY is
missing. In that case I have to pass the actual component in the
action? (Then for the components constructor wont work, neew to use
setAction instead, also the very basic idea of using one action for
multiple component will be violeted, as two action is needed for those
two components).
Or I need to pass the selected state to action additionally.
abir
Thomas Fritsch wrote:
| Quote: | toton wrote:
From Java 1.5 or lower version, can an Action be used for JCheckBox &
JCheckBoxMenuItem pair or JToggleButton & JCheckBoxMenuItem pair?
JCheckBox, JCheckBoxMenuItem, JToggleButton and JCheckBoxMenuItem all
have a constructor taking an Action. They also have a setAction(Action)
method inherited from AbstractButton.
Java 1.6 has Action.SELECTED_KEY but 1.5 doesnt have.
So what?
Also how to execute an Action from program? like JButton has a
doClick method. I want to execute an action from program even when the
actual button or menuitem is removed from gui, thus i dont have an
reference for the actual gui component.
You can do
Action a = ...;
ActionEvent e =
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "bla";
a.actionPerformed(e);
--
Thomas |
|
|
| Back to top |
|
 |
Thomas Fritsch Guest
|
Posted: Fri Jun 30, 2006 2:52 pm Post subject: Re: AbstractAction |
|
|
toton wrote:
[reordered]
| Quote: | Thomas Fritsch wrote:
toton wrote:
From Java 1.5 or lower version, can an Action be used for JCheckBox &
JCheckBoxMenuItem pair or JToggleButton & JCheckBoxMenuItem pair?
JCheckBox, JCheckBoxMenuItem, JToggleButton and JCheckBoxMenuItem all
have a constructor taking an Action. They also have a setAction(Action)
method inherited from AbstractButton.
Java 1.6 has Action.SELECTED_KEY but 1.5 doesnt have.
So what?
Also how to execute an Action from program? like JButton has a
doClick method. I want to execute an action from program even when the
actual button or menuitem is removed from gui, thus i dont have an
reference for the actual gui component.
You can do
Action a = ...;
ActionEvent e =
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "bla";
a.actionPerformed(e);
Thanks for the answer.
For programatically performing action, I used the command pattern
(design patterns by GoF) which extends AbstractAction & has an execute
method. A convinent way.
For the first question i am still unclear that how an action will know
the component's selected state & take decision as SELECTED_KEY is
missing.
ActionEvent has (inherited from Action) a getSource() method. Calling it |
you usually get the component which raised the event. If the component
is a JCheckBox/JToggleButton/... you can cast it and call its
isSelected() method.
| Quote: | In that case I have to pass the actual component in the
action? (Then for the components constructor wont work, neew to use
setAction instead, also the very basic idea of using one action for
multiple component will be violeted, as two action is needed for those
two components).
Or I need to pass the selected state to action additionally.
|
--
Thomas |
|
| Back to top |
|
 |
toton Guest
|
Posted: Fri Jun 30, 2006 3:54 pm Post subject: Re: AbstractAction |
|
|
Thanks. Got it. They are both from AbstractButton which has isSelected.
Thus I can cust it.
abir
Thomas Fritsch wrote:
| Quote: | toton wrote:
[reordered]
Thomas Fritsch wrote:
toton wrote:
From Java 1.5 or lower version, can an Action be used for JCheckBox &
JCheckBoxMenuItem pair or JToggleButton & JCheckBoxMenuItem pair?
JCheckBox, JCheckBoxMenuItem, JToggleButton and JCheckBoxMenuItem all
have a constructor taking an Action. They also have a setAction(Action)
method inherited from AbstractButton.
Java 1.6 has Action.SELECTED_KEY but 1.5 doesnt have.
So what?
Also how to execute an Action from program? like JButton has a
doClick method. I want to execute an action from program even when the
actual button or menuitem is removed from gui, thus i dont have an
reference for the actual gui component.
You can do
Action a = ...;
ActionEvent e =
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "bla";
a.actionPerformed(e);
Thanks for the answer.
For programatically performing action, I used the command pattern
(design patterns by GoF) which extends AbstractAction & has an execute
method. A convinent way.
For the first question i am still unclear that how an action will know
the component's selected state & take decision as SELECTED_KEY is
missing.
ActionEvent has (inherited from Action) a getSource() method. Calling it
you usually get the component which raised the event. If the component
is a JCheckBox/JToggleButton/... you can cast it and call its
isSelected() method.
In that case I have to pass the actual component in the
action? (Then for the components constructor wont work, neew to use
setAction instead, also the very basic idea of using one action for
multiple component will be violeted, as two action is needed for those
two components).
Or I need to pass the selected state to action additionally.
--
Thomas |
|
|
| Back to top |
|
 |
Guest
|
Posted: Fri Jul 07, 2006 2:06 pm Post subject: Re: restituzione dei valori di un jtable |
|
|
daniele.nexo (AT) gmail (DOT) com wrote:
| Quote: | Salve
google translate |
Perhaps blank I have a problem with the jtable, is
one banal what but having never used them I do
not become account.
Practically I have a window where in the jtable I
visualize turns out you of one query. More just in
the window I have the following members:
- a push-button in order to send the query to the DB
- some cases of text (where I insert of the parameters
based on which pressing on the push-button I carry
out the query)
- the jtable where I visualize it turns out to you
What I would want to make I am this: once that I
have carried out query and the jtable riempe with
the values of the query carried out, I would want
that if passing over a line of jtable the values of
the fields of the jtable, come puttinges in the fields
of the text cases where I insert the values in order
to make the query.
Practically a method serves me that passing over
the lines of jtable me restitusca the contained
values inside of the cells of the line so as to to
be able to insert these values in the text cases.
I hope that someone can is me of aid
</google translate>
Hi Daniele, L'inglese è la lingua principalmente
usata nel Java gruppi di programmi (benchè ci
siano gruppi del Java per gli altoparlanti
francesi e tedeschi). Li suggerirei includo
"una versione inglese,, di ogni alberino -
anche se dovete usare "Google traducete,,
per ottenerli!
Andrew T. |
|
| Back to top |
|
 |
Delvy Guest
|
Posted: Fri Jul 07, 2006 3:39 pm Post subject: Re: restituzione dei valori di un jtable |
|
|
daniele.nexo (AT) gmail (DOT) com ha scritto:
| Quote: | Salve
ho un problema con le jtable, forse è una cosa banale ma non avendole
mai usate non mi rendo conto.
In pratica ho una finestra dove nella jtable visualizzo i risultati di
una query. Più precisamente nelle finestra ho i seguenti componenti:
- un pulsante per inviare la query al DB
- alcune caselle di testo (dove inserisco dei parametri in base al
quale premendo sul pulsante effettuo la query)
- la jtable dove visualizzo i risultati
Quello che vorrei fare io è questo: una volta che ho effettuato la
query e la jtable si riempe con i valori della query effettuata, vorrei
che se passando sopra una riga della jtable i valori dei campi della
jtable, vengano messi nei campi delle caselle di testo dove inserisco i
valori per fare le query.
In pratica mi serve un metodo che passando sopra le righe della jtable
mi restitusca i valori contenuti all'interno delle celle della riga in
modo da poter inserire questi valori nelle caselle di testo.
Spero che qualcuno possa essermi di aiuto
Daniele
|
Metodo veloce:
JTable ha il metoto Object getValueAt(int a, int b)... dove a e d sono
le coordinate della cella.
Procedura elegante e "più giusta" (IMHO):
JTable è il compenente "visuale" di una tabella, in pratica si occupa si
visualizzare i dati e consentire all'utente di cliccare sulle celle
selezionandole.
La gestione dei dati dobrebbe venire fatta da un TableModel.
Un table model è in pratica il modello dei dati contenuti nella tabella.
Le JTable prendono il TableModel nel costruttore e disegnano la tabella
di conseguenza.
Questo ti consente di astrarre i data dalla loro visualizzazione.
Tipicamente in un TableModel si ha una Collezione di oggetti che è molto
più gestibile di una array classico o una matrice.
Inoltre puoi facilmente aggiungere o togliere oggetti dal Model e, cosa
più importante, puoi avere dei dati anche diversi da quelli che visualizzi.
Studiati i TableModel e vedrai che non potrai più farne a meno.
Delvy |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jul 13, 2006 9:11 pm Post subject: Re: Auto Select text on textfield focus |
|
|
therodet (AT) gmail (DOT) com wrote:
| Quote: | I want to make JTextFields in my application automatically select all
text when they receive focus, whether by mouse or by keyboard. More
importantly, I don't want to have to manually install listeners on
every JTextField I create.
|
Here's one way, try this for a few laughs..
<sscce>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class AutoSelectTextField
extends JTextField
implements FocusListener {
AutoSelectTextField(String text) {
super(text);
addFocusListener(this);
}
public void focusLost(FocusEvent fe) {}
public void focusGained(FocusEvent fe) {
setCaretPosition(0);
if (getText()!=null) {
moveCaretPosition( getText().length() );
}
}
public static void main(String[] args) {
JFrame f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new GridLayout(0,1));
StringBuffer sb = new StringBuffer();
for (int ii=0; ii<10; ii++) {
c.add( new AutoSelectTextField(sb.toString()) );
sb.append("Ha ");
}
f.pack();
f.setVisible(true);
}
}
</sscce>
HTH
Andrew T. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jul 13, 2006 9:20 pm Post subject: Re: Auto Select text on textfield focus |
|
|
andrewthommo (AT) gmail (DOT) com wrote:
| Quote: | therodet (AT) gmail (DOT) com wrote:
I want to make JTextFields in my application automatically select all
text when they receive focus, whether by mouse or by keyboard. More
importantly, I don't want to have to manually install listeners on
every JTextField I create.
Here's one way, try this for a few laughs..
sscce
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class AutoSelectTextField
extends JTextField
implements FocusListener {
AutoSelectTextField(String text) {
super(text);
addFocusListener(this);
}
public void focusLost(FocusEvent fe) {}
public void focusGained(FocusEvent fe) {
setCaretPosition(0);
if (getText()!=null) {
moveCaretPosition( getText().length() );
}
}
public static void main(String[] args) {
JFrame f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new GridLayout(0,1));
StringBuffer sb = new StringBuffer();
for (int ii=0; ii<10; ii++) {
c.add( new AutoSelectTextField(sb.toString()) );
sb.append("Ha ");
}
f.pack();
f.setVisible(true);
}
}
/sscce
HTH
Andrew T.
|
I had considered that option, but that would require altering quite a
few classes that alreay have JTextFields and JFormattedTextFields,
which I would prefer to avoid. |
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Thu Jul 13, 2006 9:47 pm Post subject: Re: Drawing 25 000 Shape fast |
|
|
[post re-ordered]
"MTP" <mtp (AT) nowhere (DOT) invalid> wrote in message
news:e95r4e$lkr$2 (AT) s1 (DOT) news.oleane.net...
| Quote: | Andrey Kuznetsov a écrit :
i have to render 25 000 "points" with each one a specific fill color,
and a specific Shape (java.awt.Shape or customized) in a JPanel.
Drawing every Shape, one by one, is too slow (panning the view ins't
smooth). So i tried to create a BufferedImage for each point, and render
them instead. But it is even slower.
Direct : 3 sec
BI: 4.5 sec
And all the BI take about 60 Mbytes of memory, which is a lot.
use one BufferedImage.
You need to draw your shapes to BI only if something changes.
I already use this. But it's unusable if one of these events happen:
- pan (let's say that i'm at Zoom Factor 2000)
|
Zoom factor 2000? So if an object was previous 1x1 pixel, it is now
2000x2000 pixels?
What's the difference between zoom and resize, assuming vector (i.e. not
raster) images?
| Quote: | - the user want to map column 3 instead of column 4 for colors OR size of
the shape OR type of shape
I need to reach 0.1 sec by any mean. Right now i'm thinking to add some
kind of Z-buffer but with aliasing it's pretty hard i think. Trying
ideas take time so i'm asking if somebody can help me.
|
Have you considered using Java3D/OpenGL and taking advantage of the 3D
accelerator to perform zoom and pan?
- Oliver |
|
| Back to top |
|
 |
Larry Barowski Guest
|
Posted: Thu Jul 13, 2006 10:01 pm Post subject: Re: Drawing 25 000 Shape fast |
|
|
"MTP" <mtp (AT) nowhere (DOT) invalid> wrote in message
news:e95oal$lkr$1 (AT) s1 (DOT) news.oleane.net...
| Quote: | Hello,
i have to render 25 000 "points" with each one a specific fill color, and
a specific Shape (java.awt.Shape or customized) in a JPanel.
Drawing every Shape, one by one, is too slow (panning the view ins't
smooth). So i tried to create a BufferedImage for each point, and render
them instead. But it is even slower.
Direct : 3 sec
BI: 4.5 sec
I need to reach 0.1 sec by any mean. Right now i'm thinking to add some
kind of Z-buffer but with aliasing it's pretty hard i think.
|
I'm not sure why you bring up a Z-buffer for 2D shapes. Are
they sorted by depth? If so, how long does the sort take? |
|
| Back to top |
|
 |
Larry Barowski Guest
|
Posted: Thu Jul 13, 2006 10:17 pm Post subject: Re: Drawing 25 000 Shape fast |
|
|
"MTP" <mtp (AT) nowhere (DOT) invalid> wrote in message
news:e95r4e$lkr$2 (AT) s1 (DOT) news.oleane.net...
| Quote: | Andrey Kuznetsov a écrit :
use one BufferedImage.
You need to draw your shapes to BI only if something changes.
I already use this. But it's unusable if one of these events happen:
- pan (let's say that i'm at Zoom Factor 2000)
|
When panning, you just use copyArea() to move the part of the
image that will still be in view, and only redraw to the exposed
areas. So if the pan moves the image one pixel, you do one
copyArea(), then redraw to the one-pixel wide exposed area.
Assumning you have some sort of shape-level culling in place,
this should be quite fast.
While zooming, you may want to display a limited form of the
shapes. For example, you could show just the centerpoints, or an
outline - whatever is enough to give the user a sense of the zoom
level. Then when the zoom is finished, do a normal redraw.
You could also do this while panning. 3 seconds for a full redraw
may still be intolerable, but you can probably get away with a
half second or so, and the .1 second requirement can apply to
the centerpoint or outline drawing mode only.
For overall speed, if the shapes are simple enough, try rendering
yourself to an int array and using setRGB() to place the data in
the image. You could try it for rectangles and see what kind of
speed you get. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|