GRAPHICS DEBUGGING.
GRAPHICS DEBUGGING.
Debugging graphics involves the ability to observe every painting operation as it occur during the rendering of a component and all of its children. Intended for problem finding with rendering, layout and container hierarchies. i.e everything display related.
When graphics debugging is enabled, the graphics object used in painting is an instance of DebugGraphics class which extends the Graphics class. JComponent and every swing component support graphics debugging which can be turned on or off with Jcomponent's setDebugGraphicsOption( ) method. This methods takes an int parameter that details the debug options. This parameter determines how the component should display the information:
if :
1.DebugGraphics.LOG_OPTION – a text message is printed.
2.DebugGraphics.FLASH_OPTION - The display flashes several times.
3.DebugGraphics.BUFFERED_OPTION - It creates an external window that displays the operations performed on this view's offscreen buffer.
4.DebugGraphics.NON_OPTION - Debug disabled.
5.If 0 no change is issued to the debugging option.
Note that these values can be bitwise OR'd into the current value.
Let's explore the options one after the other:
1.DebugGraphices.FLASH_OPTION.
Each paint operation flashes a specified number of times, in a specified flash color, with a specified flash interval.
You set this values with the following methods from the DebugGraphcics static methods :
setFlashTime(int flashTime)
setFlashCount (int flashCount)
setFlashColor (Color flashColor)
to see the flashing as it occurs you must disable buffering like this:
RepaintManager.currentManager(null).setDoubleBuffereingEnabled(false).
After this every component's doubleBuffered properyty will henceforth be ignored.
I loved the flashing at first instance and have been flashing my computer since.
So let me drop a code for that. See how the buttons changed color.
package tests;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Property extends JPanel{
//declaring an instance
static Color dColor = new Color(0, 255, 100, 125);
//the dimension
static Dimension dim = new Dimension(400, 400);
static JButton jButton1 = new JButton(" ");
static JTextArea jText;
/** Creates a new instance of Property */
public Property() {
jButton1 = new JButton("click me");
add(jButton1);
//we'll use the instance as foreground.
jButton1.setBackground(dColor);
}
private static void dButton(){
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Property");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Property nProp = new Property();
//buffering and opaque value for painting and updating
nProp.setOpaque(true);
nProp.setDoubleBuffered(true);
//graphics debugging
nProp.setDebugGraphicsOptions(DebugGraphics.FLASH_OPTION);
DebugGraphics.setFlashColor(Color.red);
DebugGraphics.setFlashCount(5);
DebugGraphics.setFlashTime(10);
RepaintManager.currentManager(null).setDoubleBufferingEnabled(false);
//set max, min and preferred sizes
nProp.setMaximumSize(dim);
nProp.setMinimumSize(dim);
nProp.setPreferredSize(dim);
frame.setContentPane(nProp);
//let the above size stay 4ever
frame.setResizable(false);
frame.pack();
frame.setVisible(true);
}
public static void simplyText(String txt){
jText.append(txt+"\n");
}
public void paintComponent(Graphics g){
super.paintComponent(g);
//counter
int c = 0;
//for use below
int w=0;
int h=0;
int d=0;
//get damaged region
Rectangle r = g.getClipBounds();
int clipx = r.x;
int clipy = r.y;
int clipw = r.width;
int cliph = r.height;
//fill only damaged region
g.setColor(Color.white);
g.fillRect(clipx, clipy, clipw, cliph);
//filled yellow circle only if bounding region is damaged
if (clipx <= 240 && clipy <= 240){
g.setColor(Color.yellow);
g.fillOval(0, 0, 240, 240);
c++;
}
//filled magenta cirlce if bounding region has been damaged
if (clipx + clipw>=160 && clipx<=400 && clipy+cliph>=160 && clipy<=400){
g.setColor(Color.magenta);
g.fillOval(160, 160, 240, 240);
c++;
}
}
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable(){
public void run(){
dButton();
}
});
}
}
2.DebugGraphics.LOG_OPTION: each paint operation is messaged as they occur and by default are directed to standard output i.e System.out. Note that these output can be redirected with DebugGraphic's static setLogStream() method which method takes a PrintStream instance as a parameter.
we can also instance any string into the log using the debuggraphics static logStream () method.
3.DebugGraphics.BUFFERED_OPTION . This pops up a frame that gives offscreen rendering. Double-buffering must be enabbled.
4.DebugGraphics.NONE_OPTION. Basically shuts down graphics debugging by nullifying the settings.
Caveats in graphics debugging.
You'll notice that the button color changed from the default to brown due to its being blended with the flash color, red. Yeah, that's a caveat in graphics debugging.
1. Where the UI delegate of the component is null. If a component's UI delegate is null, graphics debugging will not work. The best way to go around this is if you declared a class without a UI delegate so as to define a trivial (empty) UI delegate.
2. DebugGraphics does not properly clean up after itself. A flash results in painting over of the color of the components and it does not get erased. This presents a problem because transparent rendering now becomes alpha blended with the flash color. You can hide the flash color though by giving its color an alpha value of invisible, i.e 0 or 0.0. we can sidestep this blending by making the flash time and flashcount to wait long enough between operations.
To implement the above we can rewrite the above code adding the below:
package tests;
import javax.swing.plaf.ComponentUI;
import javax.swing.*;
public class EmptyUI extends ComponentUI {
private static final EmptyUI sharedInstance = new EmptyUI();
public static ComponentUI createUI(JComponent c){
return sharedInstance;
}
}
then to the Property class we add this code as the first line in its constructor:
super.setUI(EmptyUI.createUI(this));
8 comments:
[u][b]Xrumer[/b][/u]
[b]Xrumer SEO Professionals
As Xrumer experts, we secure been using [url=http://www.xrumer-seo.com]Xrumer[/url] quest of a wish leisure conditions and grasp how to harness the massive power of Xrumer and turn it into a Spondulix machine.
We also provender the cheapest prices on the market. Diverse competitors see fit cost 2x or consistent 3x and a a pile of the continuously 5x what we charge you. But we maintain in providing great accommodation at a debilitated affordable rate. The entire something of purchasing Xrumer blasts is because it is a cheaper variant to buying Xrumer. So we focusing to abide by that thought in mind and yield you with the cheapest censure possible.
Not simply do we be suffering with the unexcelled prices but our turnaround time after your Xrumer posting is super fast. We compel have your posting done before you certain it.
We also cater you with a ample log of affluent posts on contrary forums. So that you can see for yourself the power of Xrumer and how we hold harnessed it to gain your site.[/b]
[b]Search Engine Optimization
Using Xrumer you can trust to see thousands upon thousands of backlinks over the extent of your site. Many of the forums that your Location you intent be posted on get acute PageRank. Having your association on these sites can deep down expropriate found up some top quality back links and as a matter of fact riding-boot your Alexa Rating and Google PageRank rating utterly the roof.
This is making your instal more and more popular. And with this inflate in reputation as well as PageRank you can expect to witness your site in effect superiority high-pitched in those Search Mechanism Results.
Transport
The amount of conveyance that can be obtained aside harnessing the power of Xrumer is enormous. You are publishing your locality to tens of thousands of forums. With our higher packages you may even be publishing your locale to HUNDREDS of THOUSANDS of forums. Imagine 1 post on a popular forum disposition almost always get 1000 or so views, with communicate 100 of those people visiting your site. At once assume tens of thousands of posts on celebrated forums all getting 1000 views each. Your freight ordain associate because of the roof.
These are all targeted visitors that are interested or bizarre in the matter of your site. Assume how innumerable sales or leads you can achieve with this colossal loads of targeted visitors. You are in fact stumbling upon a goldmine primed to be picked and profited from.
Keep in mind, Traffic is Money.
[/b]
TRAVERSE B RECOVER YOUR CHEAP BURST TODAY:
http://www.xrumer-seo.com
[B]NZBsRus.com[/B]
No More Laggin Downloads Using NZB Files You Can Hastily Search Movies, Games, MP3s, Applications and Download Them at Flying Speeds
[URL=http://www.nzbsrus.com][B]Usenet[/B][/URL]
Disquietude casinos? confirm this unreserved [url=http://www.realcazinoz.com]casino[/url] documented and giving online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our up to trendy [url=http://freecasinogames2010.webs.com]casino[/url] pass on top of something at http://freecasinogames2010.webs.com and bring home the bacon in sight on more than genuine overwrought currency !
another unsurpassed [url=http://www.ttittancasino.com]casino spiele[/url] artifice is www.ttittancasino.com , in lieu of of german gamblers, flyover well-wishing online casino bonus.
crt in re-establish all to be aware of this without purchase or execrate [url=http://www.casinoapart.com]casino[/url] surplus at the win [url=http://www.casinoapart.com]online casino[/url] superintend with 10's of … la standing [url=http://www.casinoapart.com]online casinos[/url]. element [url=http://www.casinoapart.com/articles/play-roulette.html]roulette[/url], [url=http://www.casinoapart.com/articles/play-slots.html]slots[/url] and [url=http://www.casinoapart.com/articles/play-baccarat.html]baccarat[/url] at this [url=http://www.casinoapart.com/articles/no-deposit-casinos.html]no affix down displeasing casino[/url] , www.casinoapart.com
the finest [url=http://de.casinoapart.com]casino[/url] to UK, german and all unusual the world. so after the nonesuch [url=http://es.casinoapart.com]casino en linea[/url] weigh up on us now.
You could easily be making money online in the hush-hush world of [URL=http://www.www.blackhatmoneymaker.com]seo blackhat[/URL], It's not a big surprise if you haven’t heard of it before. Blackhat marketing uses alternative or little-understood methods to produce an income online.
In this cash support, there is have driver's licenses. Online loans are aimed at to have loans, payday loans uk, cash loans that best site's you need assail http://www. [url=http://paydayloansdepr.co.uk]payday[/url] This adequacy be in the form of a paycheck or you may get can even reach you on the same day that you make your absorbed attention. The applicant must accede a cut above can be private, fast and stress free. Basically it is a short-term if the application is done online. The new payday loan John Hancock Platonic idea algorithm that not only can we turn Charybdis Bermuda shorts term loan add up ascribable to your bank account by the end of that day only when you applied for it. This is what life deficient funds for any account.
[url=http://www.23planet.com]online casino[/url], also known as agreed casinos or Internet casinos, are online versions of pile up ("crony and mortar") casinos. Online casinos grant gamblers to assess as ingredient in and wager on casino games with the succour the Internet.
Online casinos typically boat odds and payback percentages that are comparable to land-based casinos. Some online casinos contend higher payback percentages with a censure link train railway coach games, and some bruit round payout asset audits on their websites. Assuming that the online casino is using an correctly programmed unspecific go generator, log games like blackjack aspire an established billet edge. The payout slice after these games are established at immediate the rules of the game.
Assorted online casinos motion on rank or acquire their software from companies like Microgaming, Realtime Gaming, Playtech, Intercontinental Evasion Technology and CryptoLogic Inc.
top [url=http://www.001casino.com/]casino[/url] brake the latest [url=http://www.casinolasvegass.com/]casino online[/url] unshackled no deposit hand-out at the chief [url=http://www.baywatchcasino.com/]www.baywatchcasino.com
[/url].
Post a Comment