Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11541 > unrolled thread
| Started by | student <freenow12345@gmail.com> |
|---|---|
| First post | 2012-01-20 17:05 -0800 |
| Last post | 2012-01-21 14:43 +1100 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Whats the error in my program-creating overlapping GOval objects using GraphicsProgram student <freenow12345@gmail.com> - 2012-01-20 17:05 -0800
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram Jeff Higgins <jeff@invalid.invalid> - 2012-01-20 21:52 -0500
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram student <freenow12345@gmail.com> - 2012-01-20 22:19 -0800
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram Lew <noone@lewscanon.com> - 2012-01-20 22:48 -0800
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram Jeff Higgins <jeff@invalid.invalid> - 2012-01-21 05:51 -0500
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram student <freenow12345@gmail.com> - 2012-01-21 18:08 -0800
Re: Whats the error in my program-creating overlapping GOval objects using GraphicsProgram Rajiv Gupta <rajiv@invalid.com> - 2012-01-21 14:43 +1100
| From | student <freenow12345@gmail.com> |
|---|---|
| Date | 2012-01-20 17:05 -0800 |
| Subject | Whats the error in my program-creating overlapping GOval objects using GraphicsProgram |
| Message-ID | <532275d9-eb03-4db0-a2ef-9b051de444cc@m4g2000pbc.googlegroups.com> |
I am trying to create three concentric circles of different color
using GraphicsProgram. However the circles never appear to be
concentric..they appear to be pushed off on the sides of each other as
if trying to show another dimension. I am simply creating and adding
the GOval objects. May be I am missing something. Is there a way to
set transparency of the circles?
Adding code below:
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Target extends GraphicsProgram {
final static double radiusOuterCircle = 72.0;
final static double radiusMiddleCircle = 47.0;
final static double radiusInnerCircle = 22.0;
public void run() {
final double centerX = this.getWidth() / 2.0;
final double centerY = this.getHeight() / 2.0;
GOval g = makeCircle(centerX, centerY,radiusOuterCircle ,
Color.RED);
add(g);
g = makeCircle(centerX, centerY,radiusMiddleCircle ,
Color.WHITE);
add(g);
g = makeCircle(centerX, centerY,radiusInnerCircle ,
Color.RED);
add(g);
}
private GOval makeCircle(double centerX, double centerY, double
radius, Color color)
{
GOval g = new GOval(centerX, centerY, radius, radius);
g.setFillColor(color);
g.setFilled(true);
return g;
}
}
[toc] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-01-20 21:52 -0500 |
| Message-ID | <jfd8pu$u2d$1@dont-email.me> |
| In reply to | #11541 |
On 01/20/2012 08:05 PM, student wrote:
> I am trying to create three concentric circles of different color
> using GraphicsProgram. However the circles never appear to be
> concentric..they appear to be pushed off on the sides of each other as
> if trying to show another dimension.
Reread the GOval documentation.
<http://jtf.acm.org/javadoc/student/acm/graphics/GOval.html#GOval(double,%20double,%20double,%20double)>
I am simply creating and adding
> the GOval objects. May be I am missing something. Is there a way to
> set transparency of the circles?
>
> Adding code below:
>
> import acm.graphics.*;
> import acm.program.*;
> import java.awt.*;
>
> public class Target extends GraphicsProgram {
>
> final static double radiusOuterCircle = 72.0;
> final static double radiusMiddleCircle = 47.0;
> final static double radiusInnerCircle = 22.0;
>
>
> public void run() {
>
>
> final double centerX = this.getWidth() / 2.0;
> final double centerY = this.getHeight() / 2.0;
>
>
> GOval g = makeCircle(centerX, centerY,radiusOuterCircle ,
> Color.RED);
> add(g);
>
>
> g = makeCircle(centerX, centerY,radiusMiddleCircle ,
> Color.WHITE);
> add(g);
>
>
> g = makeCircle(centerX, centerY,radiusInnerCircle ,
> Color.RED);
> add(g);
>
>
> }
>
>
>
> private GOval makeCircle(double centerX, double centerY, double
> radius, Color color)
> {
>
> GOval g = new GOval(centerX, centerY, radius, radius);
> g.setFillColor(color);
> g.setFilled(true);
>
> return g;
>
> }
> }
[toc] | [prev] | [next] | [standalone]
| From | student <freenow12345@gmail.com> |
|---|---|
| Date | 2012-01-20 22:19 -0800 |
| Message-ID | <930fb8aa-7429-4338-9baa-d3dc94b6a721@iu7g2000pbc.googlegroups.com> |
| In reply to | #11545 |
I read the documentation. How do I create concentric circles? I am not able to understand. I want to create sign like the sign of national chain of stores "Target".
[toc] | [prev] | [next] | [standalone]
| From | Lew <noone@lewscanon.com> |
|---|---|
| Date | 2012-01-20 22:48 -0800 |
| Message-ID | <jfdn3e$367$1@news.albasani.net> |
| In reply to | #11555 |
On 01/20/2012 10:19 PM, student wrote: > I read the documentation. How do I create concentric circles? I am not By drawing them in such a fashion that they have the same center. > able to understand. I want to create sign like the sign of national > chain of stores "Target". Think about how you line them up given the documentation. What conditions would have to hold in the constructor arguments for the circles' centers to be the same? What algebraic transformation do you have to perform? To put it another way: What data does the constructor require to position a circle in a particular place? What data do you have available at the point of the constructor call? What formula transforms the latter to the former? -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-01-21 05:51 -0500 |
| Message-ID | <jfe4qp$lmr$1@dont-email.me> |
| In reply to | #11555 |
On 01/21/2012 01:19 AM, student wrote: > I read the documentation. How do I create concentric circles? I am not > able to understand. I want to create sign like the sign of national > chain of stores "Target". It might help you to visualize the problem. Attempt to place a GRect centered upon centerX, centerY.
[toc] | [prev] | [next] | [standalone]
| From | student <freenow12345@gmail.com> |
|---|---|
| Date | 2012-01-21 18:08 -0800 |
| Message-ID | <7da90816-55d6-4e53-b8b5-2a83d11acbdd@i10g2000pbl.googlegroups.com> |
| In reply to | #11559 |
On Jan 21, 2:51 am, Jeff Higgins <j...@invalid.invalid> wrote: > On 01/21/2012 01:19 AM, student wrote:> I read the documentation. How do I create concentric circles? I am not > > able to understand. I want to create sign like the sign of national > > chain of stores "Target". > > It might help you to visualize the problem. > Attempt to place a GRect centered upon centerX, centerY. You are right, there is a bug in my code. I am not sending the upper left hand corner coordinates of the bounding rectangle in makeCircle() in the call to GOval. These coordinates will vary for all three circle because they have different radii. Thanks!
[toc] | [prev] | [next] | [standalone]
| From | Rajiv Gupta <rajiv@invalid.com> |
|---|---|
| Date | 2012-01-21 14:43 +1100 |
| Message-ID | <jfdc8t$g4n$1@speranza.aioe.org> |
| In reply to | #11541 |
On 2012-01-21 12:05:14 +1100, student said: > I am trying to create three concentric circles of different color > using GraphicsProgram. However the circles never appear to be > concentric..they appear to be pushed off on the sides of each other as > if trying to show another dimension. I am simply creating and adding > the GOval objects. May be I am missing something. Is there a way to > set transparency of the circles? You probably have an uncaught overlapped circle exception.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web