Results 1 to 2 of 2
- 06-06-2013, 04:08 PM #1
Adjusting Pixels and Color Tone Between Nested Ellipses
Hey all <3
I am currently trying to do little gui looks like a radar. Radar will contain 4096 nested ellipse and 4096 lines, total of around 16 million cells. However , encountered some problems while doing it. Before sharing my code, let me explain.
1) My purpose was drawing nested ellipses(ovals, whatever you call) like this:
nested ellipse - Google'da Ara
I achieved it and now I want to fill the gaps between two ellipses with yellow color. Color tone should be intense at the beginning of the each gap then slowly be lighter. That process should be repeatet for each gap between ellipses seperately.(Color tone will be between 0-255, so for each gap it will start from 0 to 255 until reaching the end of the gap) I am a Swing-noob so couldn't find the solution to do that job.
After that, I want to add 4096 lines to that ellipses and want to make 4096*4096 cells. Is it possible?
2) My resolution is 1024x768. However, in my radar code, I want to make 4096x4096 and as you can predict its impossible to make that with 1024x768 res. How to manage/adjust pixels to do that job?
Here is the code: Basically the code I wrote is able to draw 5 nested circles(for test purpose, I keep the number small)
Any assistance would be appreciated.
Java Code:import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; public class deneme2 extends JPanel { private static final int SIZE = 1000; public deneme2() { super(true); this.setPreferredSize(new Dimension(SIZE, SIZE)); //this.n = n; } protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D obj = (Graphics2D)g; obj.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int maxRadius = Math.min(getWidth(), getHeight()); int alpha = 255; int range = 255 - 32; obj.setStroke(new BasicStroke(0, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); for (int index = 0; index < 5; index++) { //Draws 5 circle float progress = (float) index / (float)5; alpha = 255 - Math.round(range * progress); Color color = new Color(0, 0, 0, alpha); obj.setColor(color); int radius = Math.round(maxRadius * progress); int x = (getWidth() - radius) / 2; int y = (getHeight() - radius) / 2; System.out.println(x + " " + y); obj.draw(new Ellipse2D.Float(x, y, radius, radius)); } obj.dispose(); } private static void make() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new deneme2()); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { make(); } }); } }
- 06-06-2013, 05:04 PM #2
Similar Threads
-
My ellipses on my JFrame disappear every time i try to maximize the window!!!!!!!!
By achiu17 in forum New To JavaReplies: 2Last Post: 11-08-2011, 06:12 AM -
Pixels and Color
By tenis_09 in forum Java 2DReplies: 3Last Post: 07-13-2010, 12:29 AM -
adjusting bar in java (GUI)
By it2512 in forum New To JavaReplies: 7Last Post: 06-30-2010, 11:55 AM -
Adjusting function
By rootpi in forum New To JavaReplies: 1Last Post: 02-02-2010, 01:40 PM -
how to make JScrollpane not to fetch data while scrollbar is adjusting?
By saba in forum AWT / SwingReplies: 4Last Post: 01-21-2010, 06:46 PM
Bookmarks