|
Histogram in JAVA
|
|
Linas
|
Tue Apr 06 2010, 07:07AM
|
|
|
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
|
i have to make java program, which have to create Histogram, and it have to be opened with IE (internet explorer ) The method is final/Static or graph creation. It's just simple two arrows (X and Y ), and some rectangular (like 3-6 of them) Like this one:
So, can some body help me with code, because i have no idea how to make it ... ( in fact, just one person of 22 made this graph )
|
Back to top
|
|
Arkin
|
|
Registered Member #2140
Joined: Tue May 26 2009, 09:16PM
Location:
Posts: 53
|
Does the program need to run in IE? Or just have the image run in IE?
How is the graph data stored?
|
Back to top
|
|
Linas
|
|
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
|
Yes, it have to run in IE, NetBeams IDE can create HTML code and open it, now i need just make numbers near arrows...) package hi;
import javax.swing.*; import java.awt.*; public class hi extends JFrame{ @Override public void paint(Graphics g){ g.setColor(Color.yellow); g.fillRect(0, 0, 800, 600); g.setColor(Color.BLACK); g.drawString("Diagrama",50,40); g.drawLine(70,70,70,500);//y visa asis g.drawLine(70,500,500,500);//x visa asis g.drawString("x",710,510); g.drawString("y",75,60); g.drawLine(70,70,50,90);//rodiklytes g.drawLine(70,70,90,90); g.drawLine(500,500,480,480); g.drawLine(500,500,480,520); //x linijos mazosios g.drawLine(105,510,105,500); g.drawLine(155,510,155,500); g.drawLine(205,510,205,500); g.drawLine(255,510,255,500); g.drawLine(305,510,305,500); g.drawLine(355,510,355,500); g.drawLine(405,510,405,500); g.drawString("1", 100, 525); g.drawString("2", 150, 525); g.drawString("3", 200, 525); g.drawString("4", 250, 525); g.drawString("5", 300, 525); g.drawString("6", 350, 525); g.drawString("7", 400, 525); g.fillRect(90,500,30,-400); g.fillRect(140,500,30,-300);//tarpas yra 20 g.fillRect(190, 500, 30, -350);//x1= x1+50 g.fillRect(240, 500, 30, -370); g.fillRect(290, 500, 30, -270); g.fillRect(340, 500, 30, -200); g.fillRect(390, 500, 30, -170); g.drawLine(60,100,80,100); g.drawLine(60,150,80,150); g.drawLine(60,200,80,200); g.drawLine(60,250,80,250); g.drawLine(60,300,80,300); g.drawLine(60,350,80,350); g.drawLine(60,400,80,400); g.drawLine(60,450,80,450); g.drawString("80", 40, 105); g.drawString("70", 40, 155); g.drawString("60", 40, 205); g.drawString("50", 40, 255); g.drawString("40", 40, 305); g.drawString("30", 40, 355); g.drawString("20", 40, 405); g.drawString("10", 40, 455); g.drawString("0", 40, 505); } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here hi langas = new hi(); langas.setDefaultCloseOperation(JFrame.EXIT_ON_CLO
SE); langas.setSize(800, 600); langas.setTitle("Histograma"); langas.setVisible(true); } }
|
Back to top
|
|
Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob
|
|
Powered by e107 Forum System
|
|