How to rotate an ellipse
How would I change this code (shamelessly taken from one of DrLaszloJamf's posts) to rotate the ellipse around its center, I need an image with several ellipses at several different angles.
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import javax.imageio.ImageIO;
public class BW
public static void main(String[] args) throws IOException
byte[] two = {0, (byte)0xff};
ColorModel cm = new IndexColorModel(1, 2, two, two, two);
WritableRaster raster = cm.createCompatibleWritableRaster(650, 100);
BufferedImage image = new BufferedImage(cm, raster, false, null);
Graphics2D g = image.createGraphics();
g.setColor(Color.WHITE);
g.fillArc(200, 10, 60, 30, 45, 360);
g.dispose();
ImageIO.write(image,"png",(new File("output.png")));
You need to use java.awt.geom.AffineTransform, either directly or through the transform that the Graphics2D
object has.
Here is a simple example that animates using rotation.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class RotatingShape extends JPanel {
private Shape shape;
private double angle;
private Timer timer = new Timer(500, new ActionListener(){
public void actionPerformed(ActionEvent evt) {
angle += Math.PI/50;
repaint();
//rotates shape around its origin, which is placed in center of component
public RotatingShape(Shape shape) {
this.shape = shape;
timer.start();
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Insets insets = getInsets();
int w = getWidth() - insets.left - insets.right;
int h = getHeight() -insets.top - insets.bottom;
Graphics2D g2 = (Graphics2D) g.create(insets.left, insets.top, w, h);
g2.setColor(getForeground());
g2.translate(w/2.0, h/2.0);
g2.rotate(angle);
g2.setStroke(new BasicStroke(3));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.draw(shape);
public static void main(String[] args) {
Shape shape = new Ellipse2D.Float(-100, -200, 200, 400);
JComponent comp = new RotatingShape(shape);
comp.setBackground(Color.BLACK);
comp.setForeground(Color.GREEN);
comp.setPreferredSize(new Dimension(450, 450));
JFrame f = new JFrame("RotatingShape");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(comp);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
Similar Messages
-
How to rotate a text in the adobe reader for mobile ios ?
how to rotate a text in the adobe reader for mobile ios ?
There's no rotate command to rotate the document. Instead, rotate the iPad. If it doesn't rotate, turn off the Rotation Lock switch on the side of your iPad.
-
Does anyone know if/how to rotate a video clip in iphoto? I shot it so that it plays sideways on my computer and I cannot figure out how to rotate it. Thanks.
You can't do that in iPhoto. You'll need a video editor like iMovie for the job.
Regards
TD -
How to rotate a art board in a illustrator using adobe extended javascript
How to rotate a art board in a illustrator using adobe extended javascript
how to create mirror image of each textframe content of artboard1. there's no "Rotate" function, you have to rotate all your objects and then "resize" your artboard to simulate rotation.
2. there's no "Reflect" function either, to make "mirror" images, use the ScaleMatrix function, see this post
Reflect whole objects -
How to rotate photos in albums?
how to rotate photos in albums??
yes, i can downloaded the photo(s) and use preview or iphoto ot some other program to rotate each one, but it seems so awkward, inelegant and SLOW, just to take a quick peek at the five separate photos that someone sends.
is there really not an app or some similar thing to help? i recall downloaded an app for explorer on windows, to take care of the same problem... -
How to rotate photos in photostream so they don't show sideways on apple tv
how to rotate photos in photostream so they don't show sideways on apple tv? i am viewing my photos on my tv and many of them are sideways. how do i fix this?
ihint
Welcome to the Apple Discussions.
You'll need an application that edits the pics to do this: Acorn, Seashore, Photoshop Elements, Graphic Coverter are some, but there are many others - search on MacUpdate
Of course, iPhoto will do this too.
Regards
TD -
HT201401 how to rotate a video after recording on my iphone
how to rotate a video after recording on my iphone?
Import the video with your computer as with any other digital camera and you can use a video viewing/editing app on your computer to rotate the video.
For what purpose? -
How to rotate a Video in WindowsPhone 8.1 Silverlight
Hi,
Let me explain my problem.
I want to record video without shutter sound, so i choice CaptureSource instead of
MediaCapture.
With MediaCapture i can set SetPreviewRotation(VideoRotation) to
change to rotate of video, the problem is with CaptureSource,
i can't do that.
So i looking for some way to rotate a video.
With library, maybe ffmpeg is the right way, but i can't use it with WP.
Anyone can tell me how to rotate a video, please ?Since you didn't share any code, I hope this works for you. They key here is to rotate the VideoBrush.
//check if webcam is detected
if (captureSource.VideoCaptureDevice != null)
captureSource.Start();
//RotateTransform
RotateTransform aRotateTransform = new RotateTransform();
aRotateTransform.CenterX = 0.5;
aRotateTransform.CenterY = 0.5;
aRotateTransform.Angle = 90; //set this value to what you need
//create a videobrush
VideoBrush vBrush = new VideoBrush();
//set the rotate transform to VideoBrush relativetransform
vBrush.RelativeTransform = aRotateTransform;
//set it to us the capture source
vBrush.SetSource(captureSource);
//fill the rectangle with the video brush contents
vRect.Fill = vBrush;
Hope it works.
Abdulwahab Suleiman -
How to rotate pencil mark in Acrobat X?
How to rotate pencil mark in Acrobat X?
When I am coping pencil mark between pdfs it auto-rotates into horizontal position.
Thanks in advance.
GregHey,
Can you please share the snapshots of both PDF pages with pencil marks before and after rotation.
Regards,
Anubha -
Hi,
In a page layout document, I have a table that was created to be read 90°.
Now, I need to bring the table in a normal orientation.
I know how to rotate de text inside the cell but I need to rotate the whole table.
So the header that is actualy the left column become the top row.
I can't figure out out to rotate the table.
I copied and pasted the table outside the page to rotate it. But, when pasted back in the page layout, it still turn 90°.
Does anyone can help me?
ThanksThe only way to rotate an entire table is to rotate the text frame that
the table is in.
So just select the text frame that the table is in, and rotate 90 deg.
You will need to readjust the textframe so that it fits the page margins
again.
Ariel -
How to rotate jserv log files?
Hi all,
We are using 9iAS 1.0.2.1, which has Apache 1.3.12/Jserv 1.1
How to rotate jserv log files? We have 'rotatelog' to rotate httpds_access_log etc.., but no such program for jserv log.
(Tomcat has extended rotatelog to jserv, but what about Jserv?)
Thanks in advance,
Rajidhar Etta798852 wrote:
Hi i am trying to see the archive files location...here is how i did
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +LAWCRS_ARC1/lawcrsdb/
Oldest online log sequence 37264
Next log sequence to archive 37267
Current log sequence 37267
My question is how can I go to the location "+LAWCRS_ARC1/lawcrsdb/".....I am not able to find this location..can any one help...Perhaps you're looking for this...
http://download.oracle.com/docs/cd/E11882_01/server.112/e16102/asm_util001.htm#OSTMG01610
I'm not clear on what you're looking for so it's just a best guess. -
I can't figure out how to rotate an object in Adobe Muse. I want an object to be half a bubble off plumb.
Hi ,
You can rotate an object in Muse by using the Transform toolbar and selecting the rotation angle. Please refer to this screenshot :- http://prntscr.com/52vtux
However, if you want to create a circular looking object , then all you need to do is, set the corners as Rounded, Make the Height and Width Equal and then increase the corner radius. This would give you the desired result.
Please refer to this screenshot :- http://prntscr.com/52vu9n
Hope this helps
Regards,
Rohit Nair -
How to rotate images tacken by iPad?
Apple iPad MD513TA/T
Over a thousand pictures have been taken by this iPad, but all upside down.
Some of the pictures have been coppied/pasted to PC and have been tested for rotating by Windows Office Picture Manager.
The Office Picture Manager could display the pictures but its rotating function was nonfunctional for these pictures.
How to rotate the pictures taken by iPad? On iPad? On PC?
Thanks.If this happens on Windows systems it is because the Windows Photo Viewer and Live Photo Gallery may ignore the EXIF orientation of the photos. This data tells the viewer which way is up.
See here for discussion and details from Microsoft on how this may be fixed on Windows:
http://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/windows-phot o-viewer-or-live-photo-gallery-does/a161c8da-c1ce-4347-a92e-724f9e535c15
You can also avoid this problem by taking photos in landscape mode with the iPhone/iPad held with the Home button to the right. In portrait mode keep the Home button down. -
Anyone know how to rotate imported file 90 degrees in iMovie?
anyone know how to rotate imported file 90 degrees in iMovie?
i am watching myself laying down giving a talk, and need it to be vertical!
thanks...Use the Rotate, Crop, Ken Burns Tool on the Middle Toolbar.
-
How to rotate images in small increments in preview
how to rotate images in small increments in preview?
it is not going to happen in Preview. They took away that functionality quite a few OS ago.
Maybe you are looking for
-
Scheduling SecureErase of Free Space
I would like to schedule an automatic (daily) run of Disk Utility's Secure Erase Free Space. How do I do this? I did find this command: sudo diskutil secureErase freespace 1 <diskname> Thanks.
-
Hi, The condition type(ZALT) having there are three combinations like(destination country- depature contry , s.org-d.chanel , s.org-div ) and i have slected exlusive indicators for all combinations in Acess seq. So normally it will pick the First re
-
Why does safari always open a new windows on start up?
On startup safari opens one more window in addition to the previous session window, if i change settings safari boulbes previous session window. What I have to do to make safari open only one window on startup?
-
App doesn't show up in System Preferences after Installation
Hi - I've been trying to install a Wireless-G USB Adapter on a G3 and is is supposed to show up in the System Preferences, but after the installation is complete, it's not there. Can anyone help??? Thanks...
-
Dear All, There is a sales process chain that runs daily that is scheduled to pull data from Oracle directly to BW. Due to wrong Billing document the pull fails at times. How is it possible to generate a mail or a failure report of data pul