About site: Programming/Languages/Java/Personal Pages - Java Java Proxy
Return to Computers also Computers
  About site: http://jroller.com/page/javaproxy

Title: Programming/Languages/Java/Personal Pages - Java Java Proxy Weblog with growing collection of real-life Java code tips in various programming realms.
Charles_Lindsey\'s_Home_Page Algol 68S compilers for Sun3, Sun Sparc, Atari ST and Acorn Archimedes.

PathScale Fortran 95, C, and C++ compilers for Linux on AMD Opteron and Intel 64-bit and 32-bit x86 CPUs.

Lustre_a_network_clustering_FS_ An offshoot of AFS, CODA, and Ext2.

Nass_Webdesign Offers design and programming services for small and middle size companies. Located in Freiburg, Germany. [English/German]

Microdivision Based in New York, United Stated. Provides web design, e-commerce solutions, and maintenance.

Sydney_Mac_Users_Group Offering a range of public as well as member-only features including forums, games area, news, blogs, articles, and reviews.


  Alexa statistic for http://jroller.com/page/javaproxy





Get your Google PageRank






Please visit: http://jroller.com/page/javaproxy


  Related sites for http://jroller.com/page/javaproxy
    Ctrlview_Viewer Compact viewer and converter for different 2D or 3D raster and vector file formats with format recognition system. Program will view the file in ASCII file form or in binary file form. Ideal for conve
    Google_SketchUp A 3D software tool that combines a tool-set with an intelligent drawing system. Enables to place models using real-world coordinates and share them with the world using the Google 3D Warehouse.
    Perverse_Perspective A personal blog site with emphasis on PHP programming, both examples and experiments.
    Wikipedia Article outlining the components of the protocol and competing formats.
    RFC_2588 IP Multicast and Firewalls. R. Finlayson. May 1999.
    Stormfx Reseller and distributor of specialised 3D graphics, animation, digital video, multimedia software solutions in Australia.
    GNU_Smalltalk Smalltalk-80 implementation, runs on most Unix types and most places with a POSIX compliant library, well suited to scripting tasks and headless processing. Part of GNU Project of Free Software Founda
    WebFx A showcase for DOM and DHTML JavaScript programming.
    Windex Index your documents from CD-Rom, a website or an intranet server and search for them using the Windex search engine. It is developed in Java and can run on many types of platforms.
    PC_Wallpapers Arranged in various categories like celebrities and landscapes.
    Gandi Introduction, FAQ, how to register, administration, rules, and contact information.
    The_Domain_Rental Offers domains for rent based on a monthly fee.
    XML_com__Buyer\'s_Guide The web magazine XML.COM offers this up-to-date list of XML software products with detailed reviews.
    RFC_0306 Network Host Status. E. Westheimer. February 1972.
    RFC_1942 HTML Tables. D. Raggett. May 1996.
    RFC_2832 NSI Registry Registrar Protocol (RRP) Version 1.1.0. S. Hollenbeck, M. Srivastava. May 2000.
    Ideal_Bulletin_Board A bulletin board system based on Windows 2000 and SQL Server 7.0/2000. By Ideal Science, Inc. [Source Available, Commercial]
    EFLIB_(Extended_Function_Library) Class library that brings object-oriented concepts to Pascal. Implements data structures, GUI, math, and I/O streaming. Source code included.
    Erigami Offering IT consulting, web development and design, programming, database development, and desktop application development. Located in Moscow, Russia.
    EasyMail_Objects Enable application to send, retrieve, merge, compose, view, edit, store and print Internet e-mail messages. By Quiksoft Corporation. [Component, Commercial]
This is websites2007.org cache of m/ as retrieved on 2008.10.10 websites2007.org's cache is the snapshot that we took of the page as we crawled the web. The page may have changed since that time.
.rWeblogCategoryChooser{ visibility: hidden; } .entries{ width: 100%; float: none; } .rightbar{ visibility: hidden; } Java Java Proxy : Weblog

Weblog

All | General | Java Main | Next page » 20050224 Thursday February 24, 2005 Stylish glass pane with animation effects After the previous post, I have received a request of providing visual confirmation on the background progress. As the background work involves compiling files, the progress bar is not good - it's hard to assess how much time will be needed. In this case I have decided to create a whitish stripe of gradient lines moving down the screen. When it reaches the end of the screen, it starts back from the top. The glass pane now uses double-buffering technique for efficient animation. The animation effect scrolls a patch of whitish lines down the screen in loop. When the glass pane is shown (setVisible(boolean) was overriden), a snapshot of the underlying window is taken and an animation thread is created and run: public void setVisible(boolean isVisible) { if (isVisible) { // reset owner snapshot this.ownerSnapshot = null; this.currHighLightRow = -HIGHLIGHT_ROW_SPAN; this.animator = new GlassPaneThread(this, 20); this.animator.start(); } else { if (this.animator != null) { this.animator.markStopped(); this.animator = null; } } super.setVisible(isVisible); } The animator thread calls back the iteration() function of the glass pane, prompting the refresh process: public void run() { this.toStop = false; while (!this.isMarkedStopped()) { this.glassPane.iteration(); try { Thread.sleep(this.sleepTime); } catch (InterruptedException e) { } } } The isMarkedStopped() checks a boolean flag that is set in markStopped() function when glass pane is called on setVisible(false). Both these functions are synchronized. The iteration() function of the glass pane updates the highlight band position and then performs the actual drawing: // get the offscreen buffer Graphics2D graphics = (Graphics2D) this.offscreenImage.getGraphics(); // draw the owner snapshot on it graphics.drawImage(this.ownerSnapshot, 0, 0, null); // paint the glass pane image on it if (this.isVisible()) this.paintComponent(graphics); // draw back on the owner graphics this.owner.getGraphics().drawImage(this.offscreenImage, 0, 0, null); The ownerSnapshot contains the snapshot of the frozen window when it activated the glass pane. First it is drawn on offscreenImage, then we paint the glass pane itself and then we paint back the offscreenImage on the frozen window. This achieves much better performance than simply calling the owner to redraw itself. The snapshot is performed once after the setVisible(true) call: if (!this.owner.getTopLevelAncestor().isVisible()) return; if (this.ownerSnapshot == null) { int width = this.owner.getWidth(); int height = this.owner.getHeight(); this.ownerSnapshot = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); this.offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); this.owner.paintAll(this.ownerSnapshot.getGraphics()); } In addition, the glass pane now allows showing a dynamic message (is updated at every iteration). To set the message, setMessage(String) is called, which is synchronized (as well as paintComponent). This message will be shown at the bottom of the screen on darkened background which is not affected by the highlight patch: Java Web Start version of the glass pane is available. Click Finish button for the animation effect. Enjoy Kirill ( Feb 24 2005, 09:52:57 AM IST ) Permalink Comments [0] 20050221 Monday February 21, 2005 A simple class for converting any Java object to XML string In need to save XML representation of your Java object? Here is a simple 200-line class that will do this using reflection. But don't worry, there is some very powerful caching going on, so that the performance will be very good. Thanks to comments for pointing out the isAssignableFrom() function in Class. Also, now the resulting XML is valid with all the special characters (&, <, >, ' and "). package own; import java.lang.reflect.*; import java.util.*; public class OptimizedReflectionMarshaller { // cache for getters private static HashMap gettersMap = new HashMap(); // cache for storing info on whether certain class implements Collection private static HashMap collectionsMap = new HashMap(); private static final String JAVA = "java."; private static final String JAVAX = "javax."; private static final Class[] EMPTYPARAMS = new Class[0]; /** * Info on a single field and the corresponding getter method */ private static class FieldMethodPair { private String fieldName; private Method getterMethod; public FieldMethodPair(String fieldName, Method getterMethod) { this.fieldName = fieldName; this.getterMethod = getterMethod; } public String getFieldName() { return fieldName; } public Method getGetterMethod() { return getterMethod; } } /** * Returns the marshalled XML representation of the parameter object */ public static String marshal(Object obj) { StringBuffer sb = new StringBuffer(); Class clazz = obj.getClass(); // get class name in lower letters (w/o package name) String className = clazz.getName(); int lastDotIndex = className.lastIndexOf("."); if (lastDotIndex >= 0) className = className.substring(lastDotIndex + 1); className = className.toLowerCase(); sb.append("<" + className + ">"); marshal(obj, sb); sb.append("</" + className + ">"); return sb.toString(); } /** * Returns getter function for the specified field */ private static Method getGetter(Class clazz, String fieldName) { try { // for example, for 'name' we will look for 'getName' String getMethodName = fieldName.substring(0, 1); getMethodName = getMethodName.toUpperCase(); getMethodName = "get" + getMethodName + fieldName.substring(1, fieldName.length()); Method getMethod = clazz.getMethod(getMethodName, EMPTYPARAMS); return getMethod; } catch (NoSuchMethodException nsme) { return null; } } /** * Returns a list of all fields that have getters */ private static List getAllGetters(Class clazz) { try { // check if have in cache if (gettersMap.containsKey(clazz.getName())) return (List) gettersMap.get(clazz.getName()); List fieldList = new LinkedList(); Class currClazz = clazz; while (true) { Field[] fields = currClazz.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field currField = fields[i]; int modifiers = currField.getModifiers(); // check if not static and has getter if (!Modifier.isStatic(modifiers)) { Method getterMethod = getGetter(clazz, currField .getName()); if (getterMethod != null) { FieldMethodPair fmp = new FieldMethodPair(currField .getName(), getterMethod); fieldList.add(fmp); } } } currClazz = currClazz.getSuperclass(); if (currClazz == null) break; } // store in cache gettersMap.put(clazz.getName(), fieldList); return fieldList; } catch (Exception exc) { exc.printStackTrace(); return null; } } /** * Checks whether the specified class implements Collection interface */ private static boolean isImplementsCollection(Class clazz) { String className = clazz.getName(); // check in cache if (collectionsMap.containsKey(className)) { return ((Boolean) collectionsMap.get(className)).booleanValue(); } boolean result = Collection.class.isAssignableFrom(clazz); // store in cache collectionsMap.put(className, new Boolean(result)); return result; } private static void appendFormatted(Object obj, StringBuffer sb) { String strRepresentation = obj.toString(); int len = strRepresentation.length(); for (int i = 0; i < len; i++) { char c = strRepresentation.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '\'': sb.append("&apos;"); break; case '\"': sb.append("&quot;"); break; default: sb.append(c); } } } private static void marshal(Object obj, StringBuffer sb) { try { Class clazz = obj.getClass(); String className = clazz.getName(); // check if implements Collection if (isImplementsCollection(clazz)) { Collection cobj = (Collection) obj; Iterator it = cobj.iterator(); while (it.hasNext()) { Object eobj = it.next(); sb.append("<" + eobj.getClass().getName() + ">"); marshal(eobj, sb); sb.append("</" + eobj.getClass().getName() + ">"); } return; } // check for primitive types if (className.startsWith(JAVA) || className.startsWith(JAVAX)) { appendFormatted(obj, sb); return; } // otherwise put all fields with getters List allGetters = getAllGetters(clazz); Iterator itGetters = allGetters.iterator(); while (itGetters.hasNext()) { FieldMethodPair currGetter = (FieldMethodPair) itGetters.next(); String currFieldName = currGetter.fieldName; Method currentGetter = currGetter.getterMethod; // call method Object val = currentGetter.invoke(obj, EMPTYPARAMS); if (val != null) { sb.append("<" + currFieldName + ">"); // call recursively marshal(val, sb); sb.append("</" + currFieldName + ">"); } } } catch (Exception e) { e.printStackTrace(); } } } Feel free to use and modify. Enjoy Kirill ( Feb 21 2005, 06:08:22 PM IST ) Permalink Comments [7] Create stylish glass pane on long GUI-blocking operations When your application performs some lengthy operation and the UI waits, you have at least two choices - perform this operation in the same thread as UI or create a separate thread to do the task. The first choice is the obvious one - just do the job and then go back to UI. The main problem is that the UI freezes - if you switch to some application and then switch back, you'll see a completely gray window. This is due to the fact that all UI updates are made in the same Swing thread, which currently performs that same lengthy operation. The second choice is much better one - the Swing thread is available for the GUI events. The main problem - this gives the user ability to communicate with GUI. In some cases this is undesirable. For example, if you have a wizard window, you want to complete that same lengthy operation before the next button can be enabled. This is a simple case - just disable it before creating a new thread, and once it is done, enable the button back. However, if you have more than few controls on your screen, this can be tiresome : everything must be restored to the way it was (not everything will be enabled when the lengthy operation ends). The solution in Swing - use glass pane. This pane can be thought of as the last sheet that is draw (on top of all other controls you have). It is automatically laid out to fill the entire window, and, once visible, can be easily used to disable all controls in your GUI while leaving the window fully drawn and movable around the screen. Usually, the glass pane is configured to intercept all mouse and keyboard events, so, when shown, the GUI does not get these events at all. Here is how you can spice things up and provide a stylish glass pane that conforms to lately-popular gradient horizontal lines style: public class GlassPane extends JPanel { public GlassPane() { // intercept mouse and keyboard events and do nothing this.addMouseListener(new MouseAdapter() { }); this.addMouseMotionListener(new MouseMotionAdapter() { }); this.addKeyListener(new KeyAdapter() { }); this.setOpaque(false); } public static final Color mainUltraLightColor = new Color(128, 192, 255); public static final Color mainLightColor = new Color(0, 128, 255); public static final Color mainMidColor = new Color(0, 64, 196); public static final Color mainDarkColor = new Color(0, 0, 128); protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g; BufferedImage oddLine = createGradientLine( this.getWidth(), mainLightColor, mainDarkColor, 0.6); BufferedImage evenLine = createGradientLine(this .getWidth(), mainUltraLightColor, mainMidColor, 0.6); int width = this.getWidth(); int height = this.getHeight(); for (int row = 0; row < height; row++) { if ((row % 2) == 0) graphics.drawImage(evenLine, 0, row, null); else graphics.drawImage(oddLine, 0, row, null); } } public static BufferedImage createGradientLine(int width, Color leftColor, Color rightColor, double opacity) { BufferedImage image = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB); int iOpacity = (int)(255*opacity); for (int col = 0; col < width; col++) { double coef = (double) col / (double) width; int r = (int) (leftColor.getRed() + coef * (rightColor.getRed() - leftColor.getRed())); int g = (int) (leftColor.getGreen() + coef * (rightColor.getGreen() - leftColor.getGreen())); int b = (int) (leftColor.getBlue() + coef * (rightColor.getBlue() - leftColor.getBlue())); int color = (iOpacity
 

Weblog

with

growing

collection

of

real-life

Java

code

tips

in

various

programming

realms.

http://jroller.com/page/javaproxy

Java Java Proxy 2008 October

dvd rental

dvd


Weblog with growing collection of real-life Java code tips in various programming realms.

Rules




© 2008 Internet Explorer 5+ or Netscape 6+

Recommended Sites: 1. Arts - Business - Computers - Games - Health - Home - Kids and Teens - News - Recreation - Reference - Regional - Science - Shopping - Society - Sports - World Miss Gallery - Top Anime Hentai - DVD rental by mail - Cheap Car Insurance - Credit Cards - Vanquis credit card - Secured Loans - Cadillac CTS
2008-10-10 23:58:26

Copyright 2005, 2006 by Webmaster
Websites is cool :) 292Hotel Dusseldorf - Reklama, Pozycjonowanie - Hotel Bergamo - Wybielanie - Drogeria Internetowa