java ME creating your own layer - java-me

Is it possible to create your own Layer?
like:
public class MyLayer extends javax.microedition.lcdui.game.Layer{
(...)
}
i get the error: "Layer() is not public in Layer; cannot be accessed from outside the package."
I wanted to draw some 2D graphics (import javax.microedition.lcdui.Graphics), and on top of that a Sprite coursor. Graphics are mostly still, so there's no need to draw them every time, so i thought layerManager will help me, but with that one i'd need it to be a Sprite or a TiledLayer. Creating my own Layer would solve the problem.

Layer is not designed for extension outside the javax.microedition.lcdui.game package. The error messages is clear about it.
But you may extend TiledLayer or Sprite.
Update
As paint method on both classes is final (pointed by #bartholomew-surma on comments) my above statement is invalid.
Another approach is to create a mutable Image, call getGraphics method, draw the 2D graphics in it and finally paint the sprite.

Related

How do I set the center of rotation of a Qt3D scene to the center of the active .obj file in the scene?

I have a Qt3D scene in which I have only one 3D object. I would like to set the center of rotation of the scene(camera) to the center of this 3D object. Currently, the 3D model goes out of view when the scene is rotated with the mouse.
There is also a OrbitCameraController, which has the purpose to look at a certain position. You could let the camera position track your object's position.
QML example code:
Camera {
id: myCamera
viewCenter: YOUROBJECTPOSITION
}
OrbitCameraController { camera: myCamera }
// FirstPersonCameraController { camera: myCamera }
I'm not using pyqt like you do. Hope this helps.
I am using a Mesh with a custom 3D model as "source" the qt docs don't
really indicate any property of the Mesh object that will return its
3Dvector position.
If you import your obj file in a scene the origin of your mesh is placed at the origin of the scene. If you didn't transform it that origin is where you want the camera to look at.
If you used a transform, then use that new position to look at.
Qt3D uses an ECS (Entitiy Component System) Basically, you make an enitity and add components to it like a mesh and transform in your case. That's why the mesh doesn't have a property that reflects it's position. The transform component holds that information.
I suggest you read the following in the Qt docs: Qt3D Architecture
The above solution is just in case you have smaller objects and your camera is far enough. But if you import a larger mesh fi. like a spaceship you might need to get the coordinates of the spot you want to look at. You can get those coordinates by using an object picker.

Is it possible to draw a feature on a MapContent object (layer) in Geotools at runtime?

I am working on Geotools and trying to edit an existing layer at run time.
Basically I have a layer which I have added on to a MapContent object, which I then project it on JFrame. Now what I want to know is that can we manually draw some features on this showing on JFrame to edit this layer by drawing some features( which could be either a point or a polygon).
Yes, that is perfectly possible. You will need a Swing tool to handle the drawing and then some way to add any needed attributes to the geometry to make a new feature (see SimpleFeatureBuilder) and then add that to the layer.

GameViews in OpenTK-1.0 calling Destroy/CreateFramebuffer obliterates context...Why?

GameViews in OpenTK-1.0 initialize the context in CreateFramebuffer() and destroy said context in DestroyFramebuffer(). What if I want to hold onto my VBOs and just create a bunch of new FBOs? For example, on rotation, I need to create newly sized FBOs, but I don't want to have to completely reload all my VBOs and I just don't understand how this would work without completely reimplementing all/most of GameView. I can't just override these two methods, because the base class does not expose a setter on Renderbuffer or Framebuffer. What am I missing here?
In sum: I want to rotate the device and get a new OpenTK-1.0 FBO, but not destroy the context. How do I go about this?
CreateFramebuffer() creates an OpenGL context, not a framebuffer object. To create a FBO, call GL.GenFramebuffer(). To destroy it, use GL.DeleteFramebuffer().
Refer to the OpenGL wiki for more information. This is written for desktop OpenGL, but this article also applies to OpenGL ES.

Resizable MKOverlay using MKOverlayRenderer

I want to have a custom MKOverlay that's a circle anchored to the user location annotation that the user can resize by pinching. I was able to successfully achieve this using MKOverlayPathRenderer and a custom MKOverlay object by overriding the createPath method and making an arc. The resizing and moving of the overlay was handled by using KVO on the radius and coordinate properties of my overlay. However the resizing was incredibly choppy and the boundingMapRect wasn't correctly calculated.
I've also tried using an image and instead of subclassing MKOverlayPathRenderer just MKOverlayRenderer, overriding - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context but when I resize my CPU percentage jumps to 160% usage (not great yeah?) and the boundingRect is again being drawn incorrectly.
I really think the way to do it is with MKOverlayPathRenderer and maybe having an atomic counter of some kind so that a redraw only gets called say every 5 or 10 times the pinch gesture is triggered.
Does anyone have any suggestions? I've also considered but haven't tried making a UIView and adding it as a subview to the map view and putting the pinch gesture on that but that seems hacky and dirty.
When you computed new boundingMapRect on the Overlay, you must invoke invalidatePath on your Renderer. After that, system will invoke createPath for you when appropriate.

Rotating MKMapKit

I am attempting to rotate an MKMapView using MapKit.
I can display a map and rotate it, however not very efficiently. I create an MKMapView larger than the view and rotate it using CGAffineTransformMakeRotation, so the the grey areas behind the view are not visible. Although I have clip subviews checked in Interface Builder, I still have the feeling this is not the correct implementation.
This method does allow me to rotate any annotations displayed as MKPinAnnotationView conforms to the CGAffineTransformMakeRotation function, but I come into problems when trying to add an overlay to the map.
I can place an overlay on using the boundingMapRect property in the class declaration but the image remains unrotated on the display. Is there a way to achieve this? Or alternatively should I be rotating the MKMapView and annotations in a different method?
Thanks in advance for any advice or information.
Are you rotating the map so that it is facing the same way the user is? (i.e. not just North = Up). If so you don't need to do any transformation stuff at all, just set the MKUserTrackingMode to MKUserTrackingModeFollowWithHeading

Resources