2. Tugas UTS Komputer Grafik 1 (IRWAN 171011401576)

Tugas UTS Komputer Grafik 1 (IRWAN 171011401576) – Postingan yang ke-2 ini merupakan tugas UTS Komputer Grafik 1 , yang mengambil tema tentang siklus data kasus Covid-19. Disini saya akan memberikan cara membuat program aplikasi input data kasus Covid-19 menggunakan Java Netbeans, berikut langkah-langkahnya:

Program input data kasus penyebaran penyakit Covid-19

New project “UTS_IRWAN171011401576”

Masukkan file JfreeChart

Membuat JframeForm dengan nama “DataInput”

Membuat design sebaik mungkin seperti berikut:

Masukkan action performed pada Button “SIMPAN”

int positif,pdp,odp,kematian;

positif = Integer.parseInt(jTextField1.getText());

pdp = Integer.parseInt(jTextField2.getText());

odp = Integer.parseInt(jTextField3.getText());

kematian = Integer.parseInt(jTextField4.getText());

jLabel5.setText(“”+positif+” Orang”);

jLabel6.setText(“”+pdp+” Orang”);

jLabel7.setText(“”+odp+” Orang”);

jLabel8.setText(“”+kematian+” Orang”);

seperti tampilan dibawah ini:

Masukkan action performed pada Button “GRAFIK”

PieChart IrwanObjek = new PieChart();

IrwanObjek.setNilai(jTextField1.getText(),jTextField2.getText(),jTextField3.getText(),jTextField4.getText());

IrwanObjek.setVisible(true); dispose();

seperti tampilan dibawah ini.

Membuat New Java Class dengan nama “PieChart”

Masukkan Source Code pada Java Class PieChart

package uts_irwan171011401576;

import javax.swing.JFrame;

import javax.swing.SwingUtilities;

import javax.swing.UIManager;

import org.jfree.chart.ChartFactory;

import org.jfree.chart.ChartPanel;

import org.jfree.chart.JFreeChart;

import org.jfree.chart.plot.PiePlot3D;

import org.jfree.data.general.DefaultPieDataset;

import org.jfree.data.general.PieDataset;

import org.jfree.util.Rotation;

import java.awt.Dimension;

import java.awt.GridLayout;

import javax.swing.JPanel;

import org.jfree.chart.plot.PiePlot;

import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities;

seperti tampilan dibawah ini.

Masukkan Source Code pada Java Class PieChart

public class PieChart extends JFrame {

double irwan1=0,irwan2=0,irwan3=0,irwan4=0;

public void setNilai(String nilai1, String nilai2, String nilai3, String nilai4){

try {

irwan1 = Double.parseDouble(nilai1);

} catch (NumberFormatException ex){}

try {

irwan2 = Double.parseDouble(nilai2);

} catch (NumberFormatException ex){}

try {

irwan3 = Double.parseDouble(nilai3); } catch (NumberFormatException ex){}

Masukkan Source Code pada Java Class PieChart

this.setSize(800,700);

JPanel irwanPanel = new JPanel(new GridLayout(2, 2));

DefaultPieDataset irwanDataset1 = new DefaultPieDataset();

irwanDataset1.setValue(“Positif = “+irwan1, irwan1);

irwanDataset1.setValue(“PDP = “+irwan 2, irwan2);

irwanDataset1.setValue(“ODP = “+irwan3,irwan3);

// int n5 = (int) irwan1; double jml = irwan1+ irwan2+ irwan3;

Masukkan Source Code pada Java Class PieChart

DefaultPieDataset irwanDataset2 = new DefaultPieDataset();

irwanDataset2.setValue(“Data Termasuk : Positif, PDP, ODP = “+jml,jml);

irwanDataset2.setValue(“Kematian = “+irwan4, irwan4);

JFreeChart irwanChart1 = ChartFactory.createPieChart3D(“Data Penduduk Yang Terkena COVID-19”, irwanDataset1, false, false, false);

PiePlot3D irwanPlot1 = (PiePlot3D) irwanChart1.getPlot();

irwanPlot1.setForegroundAlpha(0.6f);

irwanPlot1.setCircular(true);

JFreeChart irwanChart2 = ChartFactory.createPieChart3D(“Perbandingan Data Keselamatan”, irwanDataset2, false, false, false);

PiePlot3D irwanPlot2 = (PiePlot3D) irwanChart2.getPlot();

irwanPlot2.setForegroundAlpha(0.6f);

irwanPlot2.setCircular(true);

irwanPanel.add(new ChartPanel(irwanChart1));

irwanPanel.add(new ChartPanel(irwanChart2)); irwanPanel.setPreferredSize(new Dimension(800, 600));

Hasil Program Sebagai Berikut:

Info ruanglab lainnya:

Share

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *