setting extent using setExtent in blackberry - blackberry

I want to make use of the setExtent() method in blackberry.
Every time i use setExtent(), it allocates the space from the zero, zero coordinate to any custom field that i paint by extending the Field class.
I want when I draw any custom field from (100,100), then it should allocate space from (100,100) and not from (0,0).
my code looks like:
protected void layout(int width,int height)
{
setExtent(100,100);
}
Please help me out with any solutions.

What you appear to be trying to do actually doesn't sound like a very good idea. 100 pixels is a useful measure on one device, but 100 pixels on a 9300 is over 1/3 of the height of the screen, but on a 9800 is no where near that. I would strongly recommend that you do not use fixed pixel sizes for any Blackberry development.
That said, if you want to Field to start at position 100,100, you should use setPositionChild for that Field in the Field's Manager.
Before you start leaping off attempting this, I would recommend that you review the following:
http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749
and
http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/ta-p/442990
But perhaps the best options might be to explain what you are trying to achieve and we might be able to suggest an alternative.

Related

Should we use integer strictly when we layout controls in iOS? Why?

I need to draw a line on the screen. The designer tell me to set the height of line to 2.5 pt. I'm wondering if it's acceptable to use decimal here.
I know it will be better if we use integer as the size or position of a UIView. But I can't tell why. I didn't find any convincing document about it.
So could anyone explain it or find something for me?
The only problem I know is UILabel with decimal size will be blurry. Is there any other problem like performance problem would happen?
As per your case it's just about half point which in my opinion should be ok. I often find that in storyboards my frames get moved 0.5 point up or down when I have lot of UI elements and sometimes constraints just get confused.
Additionally: the easiest scenario when your frame could be positioned at "some 0.5 point" is if you use a constraint to centre your view in it's superview. In this case the default x or y frame position could easily end up being "some 0.5 point". So it can happen often times and could be done by Xcode itself, so that's why I think your view will be just fine.
As stated previous in comments those points are CGFloat. What we have now is 1x, 2x and 3x resolutions. So there will always be the need for some calculations for at least one of the devices.
You may also look at this Screen resolutions guide to see all the time when up sampling and downsampling occurs.

As3 Creating a tiled background

First of all, I would like to say that I'm fairly new to AS3, so feel free to correct me when needed.
So I'm trying to create a moving background, made out of different types of isometric tiles, like a floor or a wall, disposen in a grid like fashion.
At first, I tried creating a symbol containing the floor and the wall on different frames, and alternate between the frames as needed. Then I would add multiple instances of this symbol to a container and move the container around. Quickly I realized that this probably wouldn't be an ifficient method, as confirmed by the unsmooth movement of the container. (I gave up on this method).
So I did a little digging around, and then I converted the tile symbol to a png file, created a bitmap container to where I would copyPixels from the png as many times as the map required it.
The problem now is that when I do this:
var pngBitmapData:BitmapData=new tilePng
the bitmapData height and width don't match the height and width of the actual tile. There seem to be some transparent pixels around the tile and I have no idea how to remove them. This causes the tiles to be misaligned on the background's grid, with some small empty spaces around them.
So I have a couple of questions:
Is this an effective way to build the background?
Is there a way to avoid that transparent pixels "problem" ?
Hmm, it's hard to tell without seeing your png.
Are you doing this?
var pngBitmapData:BitmapData = new tilePng();
var bmp:Bitmap = new Bitmap(pngBitmapData);
To initialize your bitmap?
Also, check the anti-aliasing on your bitmap, that could be it. I'd set it to none.

Trim and find position of result with rmagick

I'm working on a jigsaw puzzle webapp, and one of the requirements is automatically generating puzzle pieces from any image. I'm using RMagick for the image processing. I've got some sets of blank puzzle pieces to use as masks, and I can handle that part, but then I need to trim the whitespace (er, transparentspace) out of the resulting images.
Now, I know I can use trim for this - I might have to put a one-pixel border on it to make sure all four corners are the right color, but that's easy and I can just subtract one pixel from the final number. The only problem is that I also need to record the position of the piece. According to the documentation on trim, the function will "retain the offset information", which sounds like exactly what I need. But I can't find anything about how to retrieve the offset information! Does anyone know how to do that?
If worst comes to worst, I suppose I could always just look through pixel-by-pixel, find the boundaries myself, and use crop to trim the picture, but that wouldn't exactly be good for performance.
Aha, found it. image.page.x and image.page.y give the upper left corner, and then image.rows and image.columns have the height and width.

jquery Image slider without define width?

I have used the coin slider.But the coin slider is restricted by the width.I need to run my application in various screen size like 1280*768,800*600.is there any image slider in jquery without restrict width of image?Please help me.
Thanks in advance.
Most image sliders are designed for being placed within a container of a certain width, so that they fit within a specific slot in a layout. Given that the size of the screen/window(you don't specify) is irrelevant to that, it seems like what you're looking for is a gallery that adapts to the size of the entire window, rather than fit within a specific size.
You should probably widen your search to JS galleries in general, which might have that option or even function that way in the first place. As initial suggestions, have a look at the full-screen example for Galleria, or maybe the Supersized plugin

MapField Display problem

I want to display MapField on Storm on Full Screen and for this i am using MapField.setPreferredSize(Display.getWidth,Display.getHeight) . But instead of seeing MapField of dimensions 320X480 ,i get MapField of dimensions of roughly 320X280 and remaining space(480-280 = 200) filled with black colour..I have crosschecked values of Display.getWidth() and Display.getHeight(320 , 480)
The problem is that on a Storm, Display.getWidth() and getHeight() don't return the same thing all the time-- they attempt to account for the presence (or not) of the soft keyboard. The point at which the system decides the keyboard is there or not is pretty irrational. (The Storm absolutely sucks, as I guess you've figured out.)
One way that seems to work is subclass sublayout(width, height) in your Screen. This will get called multiple times on the Storm, as the system flops its way around figuring out what's going on. So it means more calculation, but it works. The last values you see through there will be right.
Here's a rough template. Remember this is in your class that extends the Screen. (e.g. MainScreen)
protected void sublayout(int width, int height) {
super.sublayout(width, height);
// the screen is acutally width X height
// do your screen-specific stuff here
}
It sounds like your application is running in compatibility mode. You can check this using Application#isInTouchCompatibilityMode(). Touch Compatibility Mode fixes the drawable region of the Storms to 320x240, like you're experiencing.

Resources