Java - Draw rectangle with two rounded corners [duplicate] - java

This question already has an answer here:
How to draw custom rounded rectangles in java?
(1 answer)
Closed 6 years ago.
I need to draw a rectangle with the top-left and bottom-left corners, and another rectangle with the top-right and bottom-right corners, rounded.
I know you can draw a rounded rectangle using Graphics2D#drawRoundRect, but that rounds all four corners.

I think this question haves an answer here https://stackoverflow.com/a/20321954/4443053
Basically, you need to define your own shape. I-m pretty sure you can modify that example to your needed corners.

Related

Get Intersection of two shapes in javaFX [duplicate]

This question already has answers here:
Checking Collision of Shapes with JavaFX
(1 answer)
JavaFX Two Shapes Intersecting - Collision Method Not Working
(2 answers)
Constantly checking if a bullet has touched a node
(3 answers)
Closed 24 days ago.
Please how I get the intersection of two Circle objects where in transition in my situation the red circle and the blue .enter image description here
i try to use Shape.intersection() but doesn't work !!!

How to rotate a JButton? [duplicate]

This question already has answers here:
Rotating a JTextField vertically
(2 answers)
Closed 7 years ago.
Is it possible to rotate a JButton? In other words, I want to change the JButton's angle, for example to 45°. Is there a particular method for this? Thank you in advance.
As i know you can get absolution position of button with layouts.You can set any position of your elemnt in frame.AS i know it's impossible to rotate a button. You can implements Component and try to create your , and try to draw as you want. But i think rotating button is absolutely unreal.

Create wind rose android [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to create a wind rose similar to this :
The goal is to be able to update the green area based on information from a database.
The green area should take in two degrees and then create the green area between them.
Where could i start looking for a soulution ?
I have done such a compass for ios.
Besides custom views, you should be familiar with polar coordinates:
A point then is defined by (r, phi) instead of (x,y).
You need that all the time, you loop around the rose iterating with phi from 0 to 360, in steps. When you have the drawing coordinates in polar, you have to transform to x,y and draw it.
Further you will need AffineTransformations to scale the rose from a given pixel width, and height to a neutral -1, 1 range. Then drawing is easier.
Look at how to create a custom view : http://developer.android.com/training/custom-views/index.html
And keep in mind that you will have to optimize your drawing code : no object creation and rely as much as possible on java graphics primitives.
Happy coding, that's a very fun android development ahead, but a bit complex for novices.
Oh, and by the way, here you might be interested in using PorterDuff mode for translucency.
As has been mentioned, you'll likely want to implement a custom view.
In particular though, you'll want to divide the rendering into two. The background static image and the foreground dynamic image.
The foreground image could be generated using the Canvas class. It's quite easy to use once you get your head around it. The idea is that you'll be generating a bitmap using the canvas on whcih you draw. See the docs for more details:
http://developer.android.com/guide/topics/graphics/2d-graphics.html
For the actual rendering, you can use the drawArc method in the Canvas class:
public void drawArc (RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
http://developer.android.com/reference/android/graphics/Canvas.html#drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint)
All the best!

Android calculate angle between 2 GPS coordinates [duplicate]

This question already has answers here:
How to calculate angle between two Geographical/GPS coordinates?
(2 answers)
Closed 9 years ago.
I'm developing an application where I show the user's movements on a map using GPS coordinates. Calculating the size of the movement between two location with loc1.distanceTo (loc2), where loc1 and 2 are of type Location. How can I calculate the angle (in degrees) of the movement?
Did you do a search before you asked? This has been answered several times before. You can get the bearing (which I guess is what you mean by angle) through Location.bearingTo(). In your case it would be:
loc1.bearingTo(loc2)

draw smooth thin circle in java 2d graphics [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to draw a decent looking Circle in Java.
hi I drew onw circle with stroke in java by using graphics2d ...but am getting always irregular circle...I am getting circle without smooth...can u plz help me?
According to How to draw a decent looking Circle in Java:
Turning on antialiasing helps make things look better:
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
See also: Antialiasing, images, and alpha compositing in Java 2D

Categories

Resources