Java Forum / GUI / May 2004
Scrolling Artifact
Roedy Green - 23 May 2004 21:36 GMT I modified my Applet that scrolled a canvas to one swing version that scrolled JPanel.
It works just as before, but sometimes when you scroll you see "droppings", that clear themselves after a half a second or so.
I wondered what is causing them and how to get clean scrolling.
You can the effect at http://mindprod.com/jgloss/applet.html
Just scroll the code sample up and down.
The relevant code is posted at http://mindprod.com/javapresenter.html You can also see the smearing effect in the second code sample at http://mindprod.com/javapresenter.html
It only shows up when you move the scroll fast.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Andrew Thompson - 23 May 2004 21:54 GMT > The relevant code is posted at > http://mindprod.com/javapresenter.html '404'..
Roedy Green - 23 May 2004 23:07 GMT >> The relevant code is posted at >> http://mindprod.com/javapresenter.html Arrgh. That should read.
http://mindprod.com/projjavapresenter.html
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Andrew Thompson - 23 May 2004 22:08 GMT > I wondered what is causing them and how to get clean scrolling. Since I couldn't find the code, I am guessing.. (OK ..I'm bored)
You changed your paint, to paintComponent? <http://www.physci.org/guifaq.jsp#2.4>
> You can the effect at http://mindprod.com/jgloss/applet.html BTW.. the heading "documentation on Applet : available:" near bottom of page.. the last two links point at your 'J:' disk.
 Signature Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology
Roedy Green - 23 May 2004 23:07 GMT >BTW.. the heading "documentation on Applet : >available:" near bottom of page.. the last two >links point at your 'J:' disk. that's so you can map J: to wherever it really is.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Andrew Thompson - 23 May 2004 23:28 GMT >>BTW.. the heading "documentation on Applet : >>available:" near bottom of page.. the last two >>links point at your 'J:' disk. > > that's so you can map J: to wherever it really is. I must be thick, I still do not get it.
Do you mean 'you can map' as in,
a) Visitor downloads the page for local reference, then edits the links to point to local JDocs?
b) Visitor copies the link from your page on the net, pastes it in the address bar of their browser, edits it for the local drive, presses 'enter'?
c) ...?
 Signature Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology
Roedy Green - 23 May 2004 23:48 GMT >Do you mean 'you can map' as in, > [quoted text clipped - 4 lines] >pastes it in the address bar of their browser, edits >it for the local drive, presses 'enter'? See http://mindprod.com/jgloss/jdk.html for how to map your J: drive to C: (this is windows talk). Then when you click those links it will get the HTML off your local drive rather than from Sun, much more quickly.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Roedy Green - 24 May 2004 00:12 GMT >See http://mindprod.com/jgloss/jdk.html for how to map your J: drive >to C: (this is windows talk). Then when you click those links it will >get the HTML off your local drive rather than from Sun, much more >quickly. I thought this was obvious but several people have expressed bafflement. Perhaps I should include explicit C: links too.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Andrew Thompson - 24 May 2004 00:48 GMT ...
>>See http://mindprod.com/jgloss/jdk.html for ..
>>..how to map your J: drive to C: ..
> I thought this was obvious but several people have expressed > bafflement. Perhaps I should include explicit C: links too. If you have to update them all, I think it would be better to link to this _anchor_ specifically*.. <http://mindprod.com/jgloss/jdk.html#JDRIVE> Once the user (even the average Windows user) sees that it becomes pretty clear.
* jdk.html, typical of your pages, is a large page in terms of volume of content and 'page downs'. I almost missed the reference to drive mapping before I looked a second time.
BTW - How *do* you generate your pages, Roedy?
They look like ..HTML, yet I cannot understand how you maintain them without using server-side scripting of some kind..
 Signature Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology
Roedy Green - 24 May 2004 01:15 GMT >If you have to update them all, I think it would >be better to link to this _anchor_ specifically*.. ><http://mindprod.com/jgloss/jdk.html#JDRIVE> >Once the user (even the average Windows user) >sees that it becomes pretty clear. All those references to Sun documentation are generated by a Java macro, so all I would have to do is add some lines to it. However, instead I decided to put a link to the J: drive entry at the bottom of page where there is a link to the local mirror of the page.
I have a sort of poor man's JSP where I statically regenerate the pages, and upload them, using compaction and untouch to avoid reuploading ones that have not really changed.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Roedy Green - 24 May 2004 01:50 GMT >BTW - How *do* you generate your pages, Roedy? The key to understanding is that I don't have a webserver. I have to do everything statically. At some point I will try to package this up for everyone to use. It a bit too tough for novices, and most experts will go with JSP. I wanted to polish off the burrs before inflicting it on others.
You can get some hints looking at the source. You will see embedded macros like this for example:
<!-- macro CurrCon c$AN USD 10.00 -->
That generates an applet invocation that will display 10.00 in many different currencise, by default the user's home currency.
<!-- macro Sun "more than you wanted to know about JButtons" api/javax/swing/JButton -->
Will generate links to the online Sun doc, the docs in the local J: production JDK and the beta JDK.
<!-- macro Book generates a boof referal complete with book cover and links to six bookstores.
<!-- macro JDK xxx --> generates a variety of ways of referrnig to the lastest JDK.
<!-- macro Quilt generates multicolumn sorted lists, such as the index at http://mindprod.com/jgloss/errormesages.html#INDEX. That one I wrote expressly for you.
Here is a list of macros I have written so far:
AmanuensisHead.java header for an Amanunesis Applet BestBrowsers.java list of recommeded browsers BglossHead.java Buyer glossary header Book.java book referral ColourMenu.java menu to select colour palette CurrCon.java currency conversion Foot.java Footer GglossHead.java Gay glossary header HansHead.java HANS header HansPractHead.java HANS Practioner header HtmlMacros.java HtmlMacros main Java program source ImageInfo.java Gets info about an image Include.java Include unmodified JDisplay.java display Java, BAT, HTML source prettified JDK.java current JDK in various formats JglossHead.java Java glossary header JRE.java current JRE in various formats LaserHead.java Header for laser talks LL.java Living love database entry Macro.java Interface all macros implement Moved.java document moved ParmParser.java HtmlMacros main Java program source Picture.java Generate reference to image calc size Quilt.java list sorted in columns PriceList.java Generates Products downloads pages RandomLink.java randomly chosen link Replacer.java engine to invoke macros Reunion.java reunion data base entry run.bat execute the HtmlMacros application Signed.java notes on Signed Applet Sun.java ref to Sun docs Tools.java Tools for macros to use
There there is a tool I call QF (quick find??) to find all the <dt> entries and build the letter and master indexes.
The compactor takes out the unnecessary whitespace. Untouch dates files back that have not really changed. the Replicator uploads just what has changed in zipped form and automadically downloads to a mirror just what has changed.
I have another tool I wrote called MissingSee that finds unlinked words inside <div class="see"> ...</div> and turns them into links, if it can find an approximate match. It also sorts the links at the bottom of each page into alphabetical order. It also detects some common errors I make like linking with text ending in .html.
Xenu finds broken links.
hTMLValidator finds HTML syntax errors.
Here is the code for your Quilt Macro:
---------------------------------------------
package com.mindprod.htmlmacros; import java.io.File; import java.util.Arrays;
import com.mindprod.comparators.HTMLComparator;
/** * Generate the for grid of values like a quilt, with the entries sorted by columns. * * @author Roedy Green */ public class Quilt implements Macro {
/** * sample macro invocation: * <!-- macro Quilt 5 sort {bird} {ca<b>t</b>} {<a href="abc.html">rabbit</a>} --> * 5 = number of columns. sort/asis. * Generate the html for a grid of values, possibly containing HTM? * @param parms * @param fileBeingProcessed File being processed. */ public String expand ( String[] parms, File fileBeingProcessed ) {
System.out.print("Q"); if ( parms.length < 3 ) { throw new IllegalArgumentException("Quilt needs size, sorted the {value} {value} ..." ); }
int cols = Integer.parseInt( parms[0] ); String type = parms[1]; boolean sort; if ( type.equalsIgnoreCase("sort" ) ) { sort = true; } else if ( type.equalsIgnoreCase( "asis" ) ) { sort = false; } else throw new IllegalArgumentException ( "Quilt needs either sort or asis."); String[] cells = new String[ parms.length - 2 ];
for ( int i=0; i<cells.length; i++ ) { cells[i] = parms[i+2]; } if ( sort ) { Arrays.sort( cells, new HTMLComparator() ); } return expand( cols, cells );
} /** * guts to Generate the table for a quilt * * @param cols how many columns to generate. * @param cells cells to render * * @return expanded explanation */ public String expand ( int cols, String[] cells ) { // calc covered quotient int rows = ( cells.length + cols - 1) / cols;
// account for space taken by html tags, a bit of anally retentive coding. int size = "\n<table class=\"gridmenu\">\n</table>\n".length() + ( "<tr></tr>\n".length() * rows ) + ( "<td></th>\n".length() * rows * cols ) + ( " ".length() * ( rows * cols - cells.length ) );
// account for contents for ( int k=0; k<cells.length; k++ ) { size += cells[k].length(); } StringBuffer sb = new StringBuffer( size ); sb.append ( "\n<table class=\"gridmenu\">\n" ); for ( int i=0; i<rows; i++ ) { sb.append("<tr>");
for ( int j=0; j<cols; j++ ) { sb.append("<td>"); int k = j * rows + i; if ( k < cells.length ) { sb.append( cells[k] ); } else { sb.append( " " ); } sb.append("</td>\n"); } sb.append("</tr>\n");
} sb.append("</table>\n"); return sb.toString(); } }
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Andrew Thompson - 24 May 2004 04:17 GMT > On Sun, 23 May 2004 23:48:07 GMT, Andrew Thompson ...
> <!-- macro Quilt generates multicolumn sorted lists, such as the index > at http://mindprod.com/jgloss/errormesages.html#INDEX. That one I > wrote expressly for you. A good one indeed.
Now recorded under 'Exact Error Message' in the PhySci.codes Java FAQ <http://www.physci.org/codes/javafaq.jsp#exact>
I give a 'teensy weensy' crash-course in exceptions.. (maybe I should write a 'My Friend the Exception' page.. get it out of my system!) then link to directly to both the index of 'error messages:', and the page generally, at the bottom of my FAQ entry on errors.
[ I had been meaning to flesh out the 'exact error' entry for a long time, still so *much* more to do.. :-) ]
 Signature Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology
Andrew Thompson - 24 May 2004 00:22 GMT >> ...'you can map' as in, ? ...
> See http://mindprod.com/jgloss/jdk.html for how to map your J: drive > to C: (this is windows talk). <http://mindprod.com/jgloss/jdk.html#JDRIVE>
THUD!! I _finally_ get it. Thanx, that is handy..
I have been considering writing a servlet that will generate a very select group of .bat files helpful for Windoze Java set-up and troubleshooting, that might be a candidate for inclusion..
 Signature Andrew Thompson http://www.PhySci.org/ Open-source software suite http://www.PhySci.org/codes/ Web & IT Help http://www.1point1C.org/ Science & Technology
Roedy Green - 23 May 2004 23:10 GMT >You changed your paint, to paintComponent? ><http://www.physci.org/guifaq.jsp#2.4> yes I did. I did not see anything in the FAQ about other changes. I just got an idea. Perhaps I need to call super.paintComponent.
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Roedy Green - 23 May 2004 23:42 GMT >You changed your paint, to paintComponent? ><http://www.physci.org/guifaq.jsp#2.4> mystery solved.
I did a setOpaque( true ) and did a super.paintComponent().
The artifacts went away.
I still don't understand why this code did not work, rather why it worked, but with disappearing artifacts. I think I fulfilled the contract in the paintComponent JavaDoc.
// no super.paintComponent(); Rectangle r = g.getClipBounds(); g.setColor( this.getBackground() ); g.fillRect ( r.x, r.y, r.width, r.height );
 Signature Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|