|
Classes |
| class | AbsoluteTimeDateFormat |
| | Formats a date in the format HH:mm:ss,SSS for example, "15:49:37,459". More...
|
| class | AppenderAttachableImpl |
| class | APRInitializer |
| class | BufferedOutputStream |
| | Abstract class for writing to character streams. More...
|
| class | BufferedWriter |
| | Writes text to a character-output stream buffering requests to increase efficiency. More...
|
| class | ByteArrayInputStream |
| | InputStream implemented on top of a byte array. More...
|
| class | ByteArrayOutputStream |
| | OutputStream implemented on top of std::vector. More...
|
| class | ByteBuffer |
| | A byte buffer. More...
|
| class | CharsetDecoder |
| | An abstract engine to transform a sequences of bytes in a specific charset into a LogString. More...
|
| class | CharsetEncoder |
| | An engine to transform LogStrings into bytes for the specific character set. More...
|
| class | Class |
| class | ClassRegistration |
| class | Condition |
| | This class provides a means for one thread to suspend exception until notified by another thread to resume. More...
|
| class | CyclicBuffer |
| | CyclicBuffer is used by other appenders to hold instances of LoggingEvent for immediate or deferred display. More...
|
| class | DatagramPacket |
| | This class represents a datagram packet. More...
|
| class | DatagramSocket |
| | This class represents a socket for sending and receiving datagram packets. More...
|
| class | Date |
| | Simple transcoder for converting between external char and wchar_t strings and internal strings. More...
|
| class | DateFormat |
| | DateFormat is an abstract class for date/time formatting patterned after java.text.DateFormat. More...
|
| class | DateLayout |
| | This abstract layout takes care of all the date related options and formatting work. More...
|
| class | DateTimeDateFormat |
| | Formats a date in the format dd MMM yyyy HH:mm:ss,SSS for example, "06 Nov 1994 15:49:37,459". More...
|
| class | Exception |
| | The class Exception and its subclasses indicate conditions that a reasonable application might want to catch. More...
|
| class | RuntimeException |
| | RuntimeException is the parent class of those exceptions that can be thrown during the normal operation of the process. More...
|
| class | NullPointerException |
| | Thrown when an application attempts to use null in a case where an object is required. More...
|
| class | IllegalArgumentException |
| | Thrown to indicate that a method has been passed an illegal or inappropriate argument. More...
|
| class | IOException |
| | Signals that an I/O exception of some sort has occurred. More...
|
| class | MissingResourceException |
| class | PoolException |
| class | MutexException |
| class | InterruptedException |
| class | ThreadException |
| class | TranscoderException |
| class | IllegalMonitorStateException |
| class | InstantiationException |
| | Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated because it is an interface or is an abstract class. More...
|
| class | ClassNotFoundException |
| | Thrown when an application tries to load in a class through its string name but no definition for the class with the specified name could be found. More...
|
| class | NoSuchElementException |
| class | IllegalStateException |
| class | SocketException |
| | Thrown to indicate that there is an error in the underlying protocol, such as a TCP error. More...
|
| class | ConnectException |
| | Signals that an error occurred while attempting to connect a socket to a remote address and port. More...
|
| class | ClosedChannelException |
| class | BindException |
| | Signals that an error occurred while attempting to bind a socket to a local address and port. More...
|
| class | InterruptedIOException |
| | Signals that an I/O operation has been interrupted. More...
|
| class | SocketTimeoutException |
| | Signals that an I/O operation has been interrupted. More...
|
| class | FileInputStream |
| | InputStream implemented on top of APR file IO. More...
|
| class | FileOutputStream |
| | OutputStream implemented on top of APR file IO. More...
|
| class | FileWatchdog |
| | Check every now and then that a certain file has not changed. More...
|
| class | UnknownHostException |
| class | InetAddress |
| class | InputStream |
| | Abstract class for reading from character streams. More...
|
| class | InputStreamReader |
| | Class for reading from character streams. More...
|
| class | Integer |
| class | ISO8601DateFormat |
| | Formats a date in the format yyyy-MM-dd HH:mm:ss,SSS for example "1999-11-27 15:49:37,459". More...
|
| class | Loader |
| class | Locale |
| class | LogLog |
| | This class used to output log statements from within the log4cxx package. More...
|
| class | CharMessageBuffer |
| | This class is used by the LOG4CXX_INFO and similar macros to support insertion operators in the message parameter. More...
|
| class | UniCharMessageBuffer |
| | This class is designed to support insertion operations in the message argument to the LOG4CXX_INFO and similar macros and is not designed for general purpose use. More...
|
| class | WideMessageBuffer |
| | This class is designed to support insertion operations in the message argument to the LOG4CXX_INFO and similar macros and is not designed for general purpose use. More...
|
| class | MessageBuffer |
| | This class is used by the LOG4CXX_INFO and similar macros to support insertion operators in the message parameter. More...
|
| class | Mutex |
| class | Object |
| | base class for java-like objects. More...
|
| class | ObjectImpl |
| | Implementation class for Object. More...
|
| class | ObjectOutputStream |
| | Emulates java serialization. More...
|
| class | ObjectPtrBase |
| class | ObjectPtrT |
| | smart pointer to a Object descendant More...
|
| class | OnlyOnceErrorHandler |
| | The OnlyOnceErrorHandler implements log4cxx's default error handling policy which consists of emitting a message for the first error in an appender and ignoring all following errors. More...
|
| class | OptionConverter |
| | A convenience class to convert property values to specific types. More...
|
| class | OutputStream |
| | Abstract class for writing to character streams. More...
|
| class | OutputStreamWriter |
| | Abstract class for writing to character streams. More...
|
| class | Pool |
| class | Properties |
| class | PropertyResourceBundle |
| | PropertyResourceBundle is a concrete subclass of ResourceBundle that manages resources for a locale using a set of static strings from a property file. More...
|
| class | Reader |
| | Abstract class for reading from character streams. More...
|
| class | RelativeTimeDateFormat |
| | Formats a date by printing the number of seconds elapsed since the start of the application. More...
|
| class | ResourceBundle |
| | Resource bundles contain locale-specific objects. More...
|
| class | ServerSocket |
| class | SimpleDateFormat |
| | Concrete class for formatting and parsing dates in a locale-sensitive manner. More...
|
| class | Socket |
| class | SocketOutputStream |
| class | StrftimeDateFormat |
| | Concrete class for formatting and parsing dates in a locale-sensitive manner. More...
|
| class | StrictMath |
| | The class StrictMath contains methods for performing basic numeric operations. More...
|
| class | StringHelper |
| | String manipulation routines. More...
|
| class | StringTokenizer |
| class | synchronized |
| | utility class for objects multi-thread synchronization. More...
|
| class | SyslogWriter |
| | SyslogWriter is a wrapper around the DatagramSocket class it writes text to the specified host on the port 514 (UNIX syslog). More...
|
| class | System |
| | The System class contains several useful class fields and methods. More...
|
| class | SystemErrWriter |
| | Abstract class for writing to character streams. More...
|
| class | SystemOutWriter |
| | Abstract class for writing to character streams. More...
|
| class | Thread |
| | This class implements an approximation of java.util.Thread. More...
|
| class | ThreadLocal |
| | This class provides thread-local variables. More...
|
| class | ThreadSpecificData |
| | This class contains all the thread-specific data in use by log4cxx. More...
|
| class | TimeZone |
| class | Transcoder |
| | Simple transcoder for converting between external char and wchar_t strings and internal strings. More...
|
| class | Transform |
| | Utility class for transforming strings. More...
|
| class | Writer |
| | Abstract class for writing to character streams. More...
|
| class | DOMException |
| class | XMLDOMNode |
| | The XMLDOMNode interface is the primary datatype for the entire Document Object Model. More...
|
| class | XMLDOMElement |
| | The XMLDOMElement interface represents an element in an XML document. More...
|
| class | XMLDOMDocument |
| | The XMLDOMDocument interface represents an entire XML document. More...
|
| class | XMLDOMNodeList |
| | The XMLDOMNodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. More...
|
Namespaces |
| namespace | SimpleDateFormatImpl |
Typedefs |
| typedef ObjectPtrT< Object > | ObjectPtr |
| typedef ObjectPtrT< Object > | ObjectPtr |
| typedef std::ios_base &(* | ios_base_manip )(std::ios_base &) |
| typedef ObjectPtrT< Object > | ObjectPtr |
| typedef void *(* | Runnable )(apr_thread_t *thread, void *data) |
typedef helpers::ObjectPtrT<
XMLDOMNode > | XMLDOMNodePtr |
typedef helpers::ObjectPtrT<
XMLDOMDocument > | XMLDOMDocumentPtr |
typedef helpers::ObjectPtrT<
XMLDOMNodeList > | XMLDOMNodeListPtr |
| typedef ObjectPtrT< ObjectOutputStream > | ObjectOutputStreamPtr |
Functions |
| | LOG4CXX_PTR_DEF (AppenderAttachableImpl) |
| | LOG4CXX_PTR_DEF (BufferedOutputStream) |
| | LOG4CXX_PTR_DEF (ByteArrayInputStream) |
| | LOG4CXX_PTR_DEF (ByteArrayOutputStream) |
| | LOG4CXX_PTR_DEF (CharsetDecoder) |
| | LOG4CXX_PTR_DEF (CharsetEncoder) |
| | LOG4CXX_PTR_DEF (DatagramPacket) |
| | LOG4CXX_PTR_DEF (DatagramSocket) |
| | LOG4CXX_PTR_DEF (Date) |
| | LOG4CXX_PTR_DEF (DateFormat) |
| | LOG4CXX_PTR_DEF (FileInputStream) |
| | LOG4CXX_PTR_DEF (FileOutputStream) |
| | LOG4CXX_PTR_DEF (InetAddress) |
| | LOG4CXX_LIST_DEF (InetAddressList, InetAddressPtr) |
| | LOG4CXX_PTR_DEF (InputStream) |
| | LOG4CXX_PTR_DEF (InputStreamReader) |
| | LOG4CXX_PTR_DEF (Integer) |
| template<class V> |
| std::basic_ostream< char > & | operator<< (CharMessageBuffer &os, const V &val) |
| template<class V> |
| UniCharMessageBuffer::uostream & | operator<< (UniCharMessageBuffer &os, const V &val) |
| template<class V> |
| std::basic_ostream< wchar_t > & | operator<< (WideMessageBuffer &os, const V &val) |
| template<class V> |
| std::ostream & | operator<< (MessageBuffer &os, const V &val) |
| | LOG4CXX_PTR_DEF (Object) |
| | LOG4CXX_PTR_DEF (ObjectOutputStream) |
| | LOG4CXX_PTR_DEF (OutputStream) |
| | LOG4CXX_PTR_DEF (OutputStreamWriter) |
| | LOG4CXX_PTR_DEF (PropertyResourceBundle) |
| | LOG4CXX_PTR_DEF (Reader) |
| | LOG4CXX_PTR_DEF (ResourceBundle) |
| | LOG4CXX_PTR_DEF (Socket) |
| | LOG4CXX_PTR_DEF (SocketOutputStream) |
| | LOG4CXX_PTR_DEF (TimeZone) |
| | LOG4CXX_PTR_DEF (Writer) |
| | LOG4CXX_PTR_DEF (XMLDOMNode) |
| | LOG4CXX_PTR_DEF (XMLDOMElement) |
| | LOG4CXX_PTR_DEF (XMLDOMDocument) |
| | LOG4CXX_PTR_DEF (XMLDOMNodeList) |


clintk.utils.fold module¶
As data may come from different sources, it is best to retrieve all the bases into one single dataframe that would enables fetching the features very easily, as well as the dates at which the events/measures occured.
Doing so allows to retrieve the full timelines of the patients and therefore complete various tasks.
The objective of this module is to parse the databases available in order to have each one of them organized as
key1 | key2 | feature_name | value | date
-
class
clintk.utils.fold.
Folder
(key1, key2, features, date, n_jobs=1)[source]¶ Bases:
object
This object enables “unfolding” the features of a DataFrame, which means for a df that has 5 feature columns for instance, the unfolding would result in two feature columns: one is for the feature name and the other is the feature value.
All the attributes are column names to indicate how to unfold the dataframe
Parameters: - key1 (str) – indicator of the primary key indicator
- key2 (str, (optionnal?)) – secondary key
- features (list) – column names that contain the features
- date (str) – name of the date column,
- n_jobs (int) – number of CPUs to use for computation. If -1, all the available cores are used
-
fold
(df_base)[source]¶ Parameters: df_base (pandas DataFrame) Returns: columns are [key1, key2, feature, value, date] where feature contains the features names and values are the values. Return type: pandas.DataFrame Examples
>>> df = pd.DataFrame({'id1': [1, 2, 3], 'id2': ['id1', 'id2', 'id3'], ... 'feature_a': [0, 0.3, 1.4], ... 'date': ["12122012", "12122012","12122012"]}) >>> folder = fold.Folder('id1', 'id2', ['feature_a'], 'date') >>> folded = folder.fold(df) >>> print(folded) id1 id2 feature value date 0 1 id1 feature_a 0.0 12122012 1 2 id2 feature_a 0.3 12122012 2 3 id3 feature_a 1.4 12122012 For several features: >>> df['feature_b'] = [-1, 1, 0] >>> folder = fold.Folder('id1', 'id2', ['feature_a', 'feature_b'], ... 'date') >>> folded = folder.fold(df) >>> print(folded) id1 id2 feature value date 0 1 id1 feature_a 0.0 12122012 1 1 id1 feature_b -1.0 12122012 2 2 id2 feature_a 0.3 12122012 3 2 id2 feature_b 1.0 12122012 4 3 id3 feature_a 1.4 12122012 5 3 id3 feature_b 0.0 12122012


Malaysia population grew 0.6% in 3Q19 to 32.63 million
by Surin MurugiahKUALA LUMPUR (Nov 14): Malaysia's population for the third quarter of 2019 (3Q19) rose 0.6% to 32.63 million from 32.43 million a year earlier, according to the Department of Statistics Malaysia's Report of Demographic Statistics.
In the report released today, the department said the population comprised 16.85 million males and 15.78 million females.
It said there were 107 males per 100 females.
In terms of age groups, the highest group was 15-64 years old at 22.85 million, followed by those below 14 years of age at 7.57 million, while those above 65 years old made up 2.21 million persons.
In terms of citizenship, there were 29.46 million Malaysians (90.3%) against 3.18 million foreigners (9.7%).
Meanwhile, births decreased 3% year-on-year in the third quarter to 124,150, from 127,956.
Of this, 64,028 were male babies and 60,122 female babies.
The number of deaths also decreased in 3Q19, dipping 0.9% to 41,772 from 42,156 previously.
Chief Statistician Malaysia Datuk Seri Dr Mohd Uzir Mahidin said Selangor remained as the most populous state in 3Q19 with a population of 6.54 million.
Meanwhile, Wilayah Persekutuan Labuan recorded the lowest at 99,400 population.


The JLayer
class is a flexible and powerful decorator for Swing
components. It enables you to draw on components and respond to component
events without modifying the underlying component directly.
The JLayer
class in Java SE 7 is similar in spirit to the
JxLayer project project at
java.net. The JLayer
class was initially based on
the JXLayer
project, but its API evolved separately.
This document describes examples that show the power of the JLayer
class.
Full source code is available.
JLayer
Class
LayerUI
Class
For a brief introduction to the material on this page, watch the following video.
A JavaScript-enabled web browser and an Internet connection are required for the video. If you cannot see the video, try viewing it at YouTube.
JLayer
Class
The javax.swing.JLayer
class is half of a team. The other half
is the javax.swing.plaf.LayerUI
class.
Suppose you want to do some custom
drawing atop a JButton
object (decorate the
JButton
object). The component you want to decorate is the target.
LayerUI
subclass to do the drawing.JLayer
object that wraps the target and the
LayerUI
object.JLayer
object in your user interface just as you would use the
target component.
For example, to add an instance of a JPanel
subclass to a
JFrame
object, you would do something similar to this:
JFrame f = new JFrame(); JPanel panel = createPanel(); f.add (panel);
To decorate the JPanel
object, do something
similar to this instead:
JFrame f = new JFrame(); JPanel panel = createPanel(); LayerUI<JPanel> layerUI = new MyLayerUISubclass(); JLayer<JPanel> jlayer = new JLayer<JPanel>(panel, layerUI); f.add (jlayer);
Use generics to ensure that the JPanel
object and the LayerUI
object
are for compatible types. In the previous example, both the
JLayer
object and the LayerUI
object are used with
the JPanel
class.
The JLayer
class is usually generified with the exact type of its
view component, while the LayerUI
class is designed to be used with
JLayer
classes of its generic parameter or any of its ancestors.
For example, a LayerUI<JComponent>
object can be used with a
JLayer<AbstractButton>
object.
A LayerUI
object is responsible for custom decoration and event handling
for a JLayer
object. When you create an instance of a LayerUI
subclass,
your custom behavior can be applicable to every JLayer
object with an
appropriate generic type. That is why the JLayer
class is final
; all
custom behavior is encapsulated in your LayerUI
subclass, so there
is no need to make a JLayer
subclass.
LayerUI
Class
The LayerUI
class inherits most of its behavior from
the ComponentUI
class. Here are the most commonly overridden methods:
paint(Graphics g, JComponent c)
method is called when the target
component needs to be drawn. To render the
component in the same way that Swing renders it, call the
super.paint(g, c)
method.
installUI(JComponent c)
method is called when an instance of your
LayerUI
subclass is associated with a component. Perform any
necessary initializations here. The component that is passed in is the
corresponding JLayer
object. Retrieve the target component with
the JLayer
class' getView()
method.
uninstallUI(JComponent c)
method is called when an
instance of your
LayerUI
subclass is no longer associated with the given
component. Clean up here if necessary.
To use the JLayer
class, you need a good LayerUI
subclass. The simplest kinds of LayerUI
classes change how components are
drawn. Here is one, for example, that paints a transparent color gradient on a
component.
class WallpaperLayerUI extends LayerUI<JComponent> { @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); Graphics2D g2 = (Graphics2D) g.create(); int w = c.getWidth(); int h = c.getHeight(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, .5f)); g2.setPaint(new GradientPaint(0, 0, Color.yellow, 0, h, Color.red)); g2.fillRect(0, 0, w, h); g2.dispose(); } }
The paint()
method is where the custom drawing takes place.
The call to the
super.paint()
method draws the contents of the JPanel
object.
After setting up a 50% transparent composite, the color gradient is drawn.
After the LayerUI
subclass is defined, using it is simple.
Here is some source code that uses the WallpaperLayerUI
class:
import java.awt.*; import javax.swing.*; import javax.swing.plaf.LayerUI; public class Wallpaper { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createUI(); } }); } public static void createUI() { JFrame f = new JFrame("Wallpaper"); JPanel panel = createPanel(); LayerUI<JComponent> layerUI = new WallpaperLayerUI(); JLayer<JComponent> jlayer = new JLayer<JComponent>(panel, layerUI); f.add (jlayer); f.setSize(300, 200); f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo (null); f.setVisible (true); } private static JPanel createPanel() { JPanel p = new JPanel(); ButtonGroup entreeGroup = new ButtonGroup(); JRadioButton radioButton; p.add(radioButton = new JRadioButton("Beef", true)); entreeGroup.add(radioButton); p.add(radioButton = new JRadioButton("Chicken")); entreeGroup.add(radioButton); p.add(radioButton = new JRadioButton("Vegetable")); entreeGroup.add(radioButton); p.add(new JCheckBox("Ketchup")); p.add(new JCheckBox("Mustard")); p.add(new JCheckBox("Pickles")); p.add(new JLabel("Special requests:")); p.add(new JTextField(20)); JButton orderButton = new JButton("Place Order"); p.add(orderButton); return p; } }
Here is the result:
Source code:
Run with Java Web Start:
The LayerUI
class' paint()
method gives you complete control
over how a component is drawn. Here is another LayerUI
subclass that shows how the entire contents of a panel can be modified using Java 2D
image processing:
class BlurLayerUI extends LayerUI<JComponent> { private BufferedImage mOffscreenImage; private BufferedImageOp mOperation; public BlurLayerUI() { float ninth = 1.0f / 9.0f; float[] blurKernel = { ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth }; mOperation = new ConvolveOp( new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, null); } @Override public void paint (Graphics g, JComponent c) { int w = c.getWidth(); int h = c.getHeight(); if (w == 0 || h == 0) { return; } // Only create the offscreen image if the one we have // is the wrong size. if (mOffscreenImage == null || mOffscreenImage.getWidth() != w || mOffscreenImage.getHeight() != h) { mOffscreenImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); } Graphics2D ig2 = mOffscreenImage.createGraphics(); ig2.setClip(g.getClip()); super.paint(ig2, c); ig2.dispose(); Graphics2D g2 = (Graphics2D)g; g2.drawImage(mOffscreenImage, mOperation, 0, 0); } }
In the paint()
method, the panel is rendered into an offscreen
image. The offscreen image is processed with a convolution operator, then drawn
to the screen.
The entire user interface is still live, just blurry:
Source code:
Run with Java Web Start:
Your LayerUI
subclass can also receive all of the events of its
corresponding component. However, the JLayer
instance must register its
interest in specific types of events. This happens with the JLayer
class'
setLayerEventMask()
method. Typically, however, this call is made
from initialization performed in the LayerUI
class'
installUI()
method.
For example, the following excerpt shows a portion of a LayerUI
subclass that
registers to receive mouse and mouse motion events.
public void installUI(JComponent c) { super.installUI(c); JLayer jlayer = (JLayer)c; jlayer.setLayerEventMask( AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK ); }
All events going to your JLayer
subclass get routed to an
event handler method whose name matches the event type. For example, you can
respond to mouse and
mouse motion events by overriding corresponding methods:
protected void processMouseEvent(MouseEvent e, JLayer l) { // ... } protected void processMouseMotionEvent(MouseEvent e, JLayer l) { // ... }
The following is a LayerUI
subclass that draws a translucent circle
wherever the mouse moves inside a panel.
class SpotlightLayerUI extends LayerUI<JPanel> { private boolean mActive; private int mX, mY; @Override public void installUI(JComponent c) { super.installUI(c); JLayer jlayer = (JLayer)c; jlayer.setLayerEventMask( AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK ); } @Override public void uninstallUI(JComponent c) { JLayer jlayer = (JLayer)c; jlayer.setLayerEventMask(0); super.uninstallUI(c); } @Override public void paint (Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D)g.create(); // Paint the view. super.paint (g2, c); if (mActive) { // Create a radial gradient, transparent in the middle. java.awt.geom.Point2D center = new java.awt.geom.Point2D.Float(mX, mY); float radius = 72; float[] dist = {0.0f, 1.0f}; Color[] colors = {new Color(0.0f, 0.0f, 0.0f, 0.0f), Color.BLACK}; RadialGradientPaint p = new RadialGradientPaint(center, radius, dist, colors); g2.setPaint(p); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, .6f)); g2.fillRect(0, 0, c.getWidth(), c.getHeight()); } g2.dispose(); } @Override protected void processMouseEvent(MouseEvent e, JLayer l) { if (e.getID() == MouseEvent.MOUSE_ENTERED) mActive = true; if (e.getID() == MouseEvent.MOUSE_EXITED) mActive = false; l.repaint(); } @Override protected void processMouseMotionEvent(MouseEvent e, JLayer l) { Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), l); mX = p.x; mY = p.y; l.repaint(); } }
The mActive
variable indicates whether or not the mouse is inside the
coordinates of the panel. In the installUI()
method, the
setLayerEventMask()
method is called to indicate the
LayerUI
subclass' interest in receiving mouse and mouse motion
events.
In the processMouseEvent()
method, the mActive
flag is set
depending on the position of the mouse. In the
processMouseMotionEvent()
method, the coordinates of the mouse movement
are stored in the mX
and mY
member variables
so that they can be used later
in the paint()
method.
The paint()
method shows the default appearance of the panel, then
overlays a radial gradient for a spotlight effect:
Source code:
Run with Java Web Start:
This example is an animated busy indicator. It demonstrates animation in a
LayerUI
subclass and features a fade-in and fade-out. It
is more complicated that the previous examples, but it is based on the same
principle of defining a paint()
method for custom drawing.
Click the Place Order button to see the busy indicator for 4 seconds. Notice how the panel is grayed out and the indicator spins. The elements of the indicator have varying levels of transparency.
The LayerUI
subclass, the WaitLayerUI
class, shows how to
fire property change events to update the component. The WaitLayerUI
class uses a
Timer
object to update its state 24 times a second. This happens in the
timer's target method, the actionPerformed()
method.
The actionPerformed()
method uses the firePropertyChange()
method to
indicate that the internal state was updated. This triggers a call to
the applyPropertyChange()
method, which repaints the JLayer
object:
Source code:
Run with Java Web Start:
The final example in this document shows how the JLayer
class
can be used to
decorate text fields to show if they contain valid data. While the other
examples use the JLayer
class to wrap panels or general
components, this example shows how to wrap a JFormattedTextField
component
specifically. It also demonstrates that a single LayerUI
subclass
implementation can be used for multiple JLayer
instances.
The JLayer
class is used to provide a visual indication for fields that have
invalid data. When the ValidationLayerUI
class paints the text field, it
draws a red X if the field contents cannot be parsed. Here is an example:
Source code:
Run with Java Web Start:


Department of Information Systems Design, Doshisha University
Intelligent Mechanism Laboratory
sample[at]sample.com