Results 1 to 2 of 2
  1. #1
    nihirus's Avatar
    nihirus is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default 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();
    			}
    		});
    	}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Adjusting Pixels and Color Tone Between Nested Ellipses

    Moved from AWT/Swing

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 11-08-2011, 06:12 AM
  2. Pixels and Color
    By tenis_09 in forum Java 2D
    Replies: 3
    Last Post: 07-13-2010, 12:29 AM
  3. adjusting bar in java (GUI)
    By it2512 in forum New To Java
    Replies: 7
    Last Post: 06-30-2010, 11:55 AM
  4. Adjusting function
    By rootpi in forum New To Java
    Replies: 1
    Last Post: 02-02-2010, 01:40 PM
  5. Replies: 4
    Last Post: 01-21-2010, 06:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •