FileDocCategorySizeDatePackage
GaugeLFImpl.javaAPI DocphoneME MR2 API (J2ME)6140Wed May 02 18:00:22 BST 2007javax.microedition.lcdui

GaugeLFImpl

public class GaugeLFImpl extends ItemLFImpl implements GaugeLF
Look & feel implementation for Gauge using platform widget.

Fields Summary
private Gauge
gauge
Gauge instance associated with this view.
Constructors Summary
GaugeLFImpl(Gauge gauge)
Creates GaugeLF for the passed in Gauge.

param
gauge the Gauge object associated with this look&feel.

        
        super(gauge);

        this.gauge = gauge;
    
Methods Summary
voidcreateNativeResource(int ownerId)
Create native resource for current Gauge. Override function in ItemLFImpl.

param
ownerId Owner screen's native resource id

	nativeId = createNativeResource0(ownerId,
					 gauge.label, gauge.layout,
					 gauge.interactive, 
					 gauge.maxValue, gauge.value);
    
private native intcreateNativeResource0(int ownerId, java.lang.String label, int layout, boolean interactive, int maxValue, int initialValue)
KNI function that creates native resource for current Gauge.

param
ownerId Owner screen's native resource id (MidpDisplayable *)
param
label label string of this Item
param
layout layout directive associated with this Item
param
interactive indicates whether gauge is interactive or not
param
maxValue the maximum value for this gauge
param
initialValue the current value of the gauge
return
native resource id (MidpItem *) of this Gauge

booleanequateNLA()
Determine if this Item should have a newline after it.

return
true if it should have a newline after

        if (super.equateNLA()) {
            return true;
        }

        return ((gauge.layout & Item.LAYOUT_2) != Item.LAYOUT_2);
    
booleanequateNLB()
Determine if this Item should have a newline before it.

return
true if it should have a newline before

        if (super.equateNLB()) {
            return true;
        }

        return ((gauge.layout & Item.LAYOUT_2) != Item.LAYOUT_2);
    
public intlGetValue()
Gets the current value.

return
the current value

	return gauge.value;
    
public voidlSetMaxValue(int oldMaxValue, int newMaxValue)
Notifies L&F of a maximum value change in the corresponding Gauge.

param
oldMaxValue the old maximum value set in the Gauge
param
newMaxValue the new maximum value set in the Gauge

	if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
	    // Only update native resource if it exists.
	    setValue0(nativeId, gauge.value, newMaxValue);
	    lRequestInvalidate(true, true);
	}
    
public voidlSetValue(int oldValue, int newValue)
Notifies L&F of a value change in the corresponding Gauge.

param
oldValue the old value set in the Gauge
param
newValue the new value set in the Gauge

	// little optimization to avoid calling into native
	// in cases where unnecessary
	if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
	    // Only update native resource if it exists.
	    setValue0(nativeId, newValue, gauge.maxValue);
	    
	    lRequestInvalidate(true, true);
	}
    
private native voidsetValue0(int nativeId, int newValue, int newMaxValue)
KNI function that sets the current and maximum values on the native resource corresponding to the current Gauge.

param
nativeId native resource id for this Item
param
newValue new value of the current Gauge
param
newMaxValue new maximum value of the current Gauge

booleanuCallPeerStateChanged(int hint)
Notification of a change in its peer state. Update Java peer with user input.

param
hint the new value of an interactive gauge
return
always true so to notify ItemStateListener

	synchronized (Display.LCDUILock) {
	    // Update Java peer with the new value
	    gauge.value = hint;
	}
	// Indicate to Form to notify ItemStateListener
	return true;