about displayWidth and displayHeight in OpenDDR - java

Does somebody know if the properties displayWidth and displayHeight (in OpenDDR) are in pixels or in millimeters? I tried to find the id but I am not successful.
I found it: displayWidth and displayHeight (in OpenDDR) are in pixels

I found it:displayWidth and displayHeight (in Open DDR) are in pixels.

Related

Getting screen width with newer phones

I'm using a Samsung Galaxy S20 phone and I'm trying to get the width of the display using:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height2 = metrics.heightPixels;
width2 = metrics.widthPixels;
This returns 810, but seeing the phone specifications on the internet the actual screen width is 1080. I started having problems in code because of this, is there a way to get the actual screen width in Java?

Set bar width on ColumnChart from google chart in Java

I am having trouble setting the bar width on my bars in my ColumnChart.
So far I have the following options set:
private Options createOptions() {
Options options = Options.create();
options.setWidth(600);
options.setHeight(400);
options.set3D(true);
options.setEnableTooltip(false);
return options;
}
But it seems like the option for setting the bar width is not there. If I set my width to 600 px, and only have 2 entries/bars, they will each be huge. If I have 10 it will look more normal.
I found the documentation for this here: https://developers.google.com/chart/interactive/docs/gallery/barchart
The variable you'll want to be modifying is bar.groupWidth - you can set it to a size, or a percent ratio. So possibly something like this:
bar: {
groupWidth: 20
}
See some other resources if you need more help:
Google Charts / visualisations column width
Here's another great set of posts:
http://developer.actuate.com/community/forum/index.php?/topic/28797-bar-charts-bar-width/

resize images in android

I want to resize my images (original size is 1080p) but they don't resize properly and I don't know why. The Images just don't have the right size sometimes. On my emulator and my old 800*480 smartphone it works fine but on my nexus 4 with 1280*768 things don't look right. There is no problem reading the right screen resolution. There is just a bug with my resize procedure. Please help me. Heres a Snippet:
private Bitmap bitmap,bitmap1;
private float factor;
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics displaymetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(displaymetrics);
width = displaymetrics.widthPixels;
height = displaymetrics.heightPixels;
factor = (float)height/1080;
Int bitmapheight,bitmapwidth;
bitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.picture),(int)(factor*BitmapFactory.decodeResource(getResources(), R.drawable.picture).getwidth() ,(int)(factor*BitmapFactory.decodeResource(getResources(), R.drawable.picture).getHeight(), true);
canvas.drawBitmap(bitmap,.....
In the end the height is not resized to 768/1080*bitmapheight on my nexus and i don't know why. Note everything else works. Mathmatics indicates that the height should be the same on every phone.
These are screenshots of my programm showing the images have not the same height
First image:
Second:
As you can see the Images are not equal in terms of height. On my emulator and my old smartphone they look right. The Images should not touch the bottom but on my nexus 4 they do touch the bottom.
For anyone who is interessted why it didnt work. Finally i found out.
Now
BitmapFactory.decodeResource(getResources(), R.drawable.picture)
not only loads the pictures but also scales it depending on your resolution ( not always just on some resolution) thats why it confused me. I thought it just loads the damn picture. Now how to solve this:
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
BitmapFactory.decodeResource(getResources(), R.drawable.picture,opts)

Alternative to DISPLAY.getWidth()

I know the Display method getWidth() has been deprecated since API 13. I have the following line of code:
Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int displayWidth = display.getWidth();
What is the alternative for API Level 13 and above?
In case you're not in an activity use
context.getResources().getDisplayMetrics().heightPixels;
context.getResources().getDisplayMetrics().widthPixels;
You are looking for getSize(Point outSize) (according to official android API documentation )
Hope this helps!

Problem creating a mosaic of images using JAI

I'm trying to use JAI to create a single mosaic consisting of 4 TIF images each of which is 5000 x 5000. The code I have written is as follows ..
RenderedOp mosaic=null;
ParameterBlock pbMosaic=new ParameterBlock();
pbMosaic.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
RenderedOp in=null;
// Get 4 tiles and add them to the Mosaic
in=returnRenderedOp(path,"northwest.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"northeast.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"southwest.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"southeast.tif");
pbMosaic.addSource(in);
// Setup the ImageLayout
ImageLayout imageLayout=new ImageLayout(0,0,10000,10000);
imageLayout.setTileWidth(5000);
imageLayout.setTileHeight(5000);
imageLayout.setColorModel(in.getColorModel());
imageLayout.setSampleModel(in.getSampleModel());
mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,imageLayout));
The problem is that all 4 images are being positioned in the same place in the top left hand corner of the mosaic so the other three quarters of it is empty. Can anyone tell me how I can choose the position of each picture that makes up the mosaic so each appears in the correct place ?
Thanks
Ian
http://download.oracle.com/docs/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/MosaicDescriptor.html
I think you misunderstood the doc you need to set the minX minY for EACH source image before the operation.
northwest.tif should have minX=0 and minY=0,
northeast.tif should have minX=5000 and minY=0,
southwest.tif should have minX=0, minY=5000 and
southeast.tif should have minx=5000 and minY = 5000
In the doc they suggest you deserialize the files directly "moved" by using rendering hint on the deserialization operation.
Somehow, mosaic is just a normal compositing operation.

Categories