Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 8
Registered: ‎05-14-2012
My Device: 8520
My Carrier: 919427209078

setZoomScale in BrowserField it zoomIN from top of screen not from Center

This is my code :

 

package mypackage;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.browser.field2.BrowserFieldConfig;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen implements FieldChangeListener
{
/**
* Creates a new MyScreen object
*/
VerticalFieldManager vf = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL|VerticalFieldManager.VERTICAL_SCROLLBAR);
HorizontalFieldManager hf = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL|HorizontalFieldManager.HORIZONTAL_SCROLLBAR);
BrowserField bf = null;
BrowserFieldConfig bfc = null;
PopupScreen ps = null;
ButtonField bfIn = new ButtonField("+");
private static float zoomValue = 1.0f;
ButtonField bfOut = new ButtonField("-");
public MyScreen()
{
// Set the displayed title of the screen
super(NO_VERTICAL_SCROLL|NO_VERTICAL_SCROLLBAR);
setTitle("MyTitle");
bfc = new BrowserFieldConfig();
bfc.setProperty(BrowserFieldConfig.NAVIGATION_MODE, BrowserFieldConfig.NAVIGATION_MODE_POINTER);
bf = new BrowserField(bfc);
bf.requestContent("local:///PrivacyPolicy.html");
hf.add(bf);
vf.add(hf);
add(vf);

// add(new LabelField("This is testing app"));
createPopup();
}
private void createPopup()
{
HorizontalFieldManager hfM = new HorizontalFieldManager();
hfM.add(bfIn);
hfM.add(bfOut);
bfIn.setChangeListener(this);
bfOut.setChangeListener(this);
ps = new PopupScreen(hfM){;

protected boolean keyDown(int keycode, int time) {
UiApplication.getUiApplication().popScreen(ps);
return true;
};
};
}
protected void makeMenu(Menu menu, int instance) {
menu.add(new MenuItem("Zoom My",0,0) {

public void run() {
UiApplication.getUiApplication().pushScreen(ps);
}
});
}
public void fieldChanged(Field field, int context) {

if(field == bfIn)
{
System.out.println("Zoom Value +:"+zoomValue);
System.out.println(" Ini Zoom Value +:"+bf.getZoomScale());
zoomValue = (zoomValue+0.1f);
if(zoomValue > 4.0)
{
zoomValue = 4.0f;
}
bf.setZoomScale(zoomValue);
}else
if(field == bfOut)
{
System.out.println("Zoom Value -:"+zoomValue);
System.out.println(" Ini Zoom Value -:"+bf.getZoomScale());
zoomValue = (zoomValue-0.1f);
if((zoomValue) < 0)
{
zoomValue = 1.0f;
}
//bField.refresh();

bf.setZoomScale(zoomValue);
}
}
}

 

 

when i try to set Zoom Value using setZoomScale method at time browser screen will zoom from TOP side not from Center. What i need that , i want zoom from Pointer Position. not from top.