1 /*
2 *
3 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Oracle nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
82 g2.setStroke(new BasicStroke(0.5f));
83 }
84 AffineTransform at = AffineTransform.getTranslateInstance(w / 2, h
85 / 2);
86 at.rotate(Math.toRadians(angdeg));
87 g2.draw(at.createTransformedShape(ellipse));
88 }
89 g2.setColor(BLUE);
90 ellipse.setFrame(w / 2 - 10, h / 2 - 10, 20, 20);
91 g2.fill(ellipse);
92 g2.setColor(GRAY);
93 g2.setStroke(new BasicStroke(6));
94 g2.draw(ellipse);
95 g2.setColor(YELLOW);
96 g2.setStroke(new BasicStroke(4));
97 g2.draw(ellipse);
98 g2.setColor(BLACK);
99 g2.drawString("Rotate", 5, 15);
100 }
101
102 public static void main(String s[]) {
103 createDemoFrame(new Rotate());
104 }
105
106
107 static class DemoControls extends CustomControls implements ActionListener {
108
109 Rotate demo;
110 JTextField tf1, tf2;
111
112 @SuppressWarnings("LeakingThisInConstructor")
113 public DemoControls(Rotate demo) {
114 super(demo.name);
115 this.demo = demo;
116 JLabel l = new JLabel("Increment:");
117 l.setForeground(BLACK);
118 add(l);
119 add(tf1 = new JTextField("5.0"));
120 tf1.setPreferredSize(new Dimension(30, 24));
121 tf1.addActionListener(this);
122 add(l = new JLabel(" Emphasis:"));
|
1 /*
2 *
3 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of Oracle nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
82 g2.setStroke(new BasicStroke(0.5f));
83 }
84 AffineTransform at = AffineTransform.getTranslateInstance(w / 2, h
85 / 2);
86 at.rotate(Math.toRadians(angdeg));
87 g2.draw(at.createTransformedShape(ellipse));
88 }
89 g2.setColor(BLUE);
90 ellipse.setFrame(w / 2 - 10, h / 2 - 10, 20, 20);
91 g2.fill(ellipse);
92 g2.setColor(GRAY);
93 g2.setStroke(new BasicStroke(6));
94 g2.draw(ellipse);
95 g2.setColor(YELLOW);
96 g2.setStroke(new BasicStroke(4));
97 g2.draw(ellipse);
98 g2.setColor(BLACK);
99 g2.drawString("Rotate", 5, 15);
100 }
101
102 public static void main(String[] s) {
103 createDemoFrame(new Rotate());
104 }
105
106
107 static class DemoControls extends CustomControls implements ActionListener {
108
109 Rotate demo;
110 JTextField tf1, tf2;
111
112 @SuppressWarnings("LeakingThisInConstructor")
113 public DemoControls(Rotate demo) {
114 super(demo.name);
115 this.demo = demo;
116 JLabel l = new JLabel("Increment:");
117 l.setForeground(BLACK);
118 add(l);
119 add(tf1 = new JTextField("5.0"));
120 tf1.setPreferredSize(new Dimension(30, 24));
121 tf1.addActionListener(this);
122 add(l = new JLabel(" Emphasis:"));
|