Senin, 09 Desember 2013



hy,.,......☻☻
nama saya Apsyalom Magang, Kali ini saya akan Coba memosting tugas dari Dosen saya mudah_mudahan bermanfaaat buat Sobb Smua yaNg nemu'in Blog ini ...........mohOn maaf jika ada Kesalahan ataupun tidak sesuai dengan keinginan sobb smua,.,.,.maklummmm daLam taHappp beLajaRrrrrrrr,,,,,,,x,ixixixixixixixixixixi


ROTASI

package Rotasi;

import java.awt.*;
import java.awt.event.*;
public class Rotasi extends Frame implements ActionListener{
int x = 200;
int y = 200;
public static void main(String[] args) {
Frame frame = new Rotasi();
frame.setSize(200,200);
frame.setVisible(true);
}
public Rotasi() {
setTitle("AWT Demo");
// create menu
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu menu = new Menu("File");
mb.add(menu);
MenuItem mi = new MenuItem("Exit");
mi.addActionListener(this);
menu.add(mi);
// end program when window is closed
WindowListener l = new WindowAdapter()  {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
};
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
x = ev.getX();
y = ev.getY();
repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {
int xasalA = 150; int yasalA = 100;
int xasalB = 100; int yasalB = 250;
int xasalC = 200; int yasalC = 250;


int sudut = 45;

g.setColor(Color.green);
g.drawLine(xasalA,yasalA, xasalB,yasalB);
g.drawLine(xasalB,yasalB,xasalC,yasalC);

long xA = Math.round(x+(xasalA-x)*Math.cos(sudut)-(yasalA-y)*Math.sin(sudut));
long yA = Math.round(x+(xasalA-x)*Math.sin(sudut)-(yasalA-y)*Math.cos(sudut));
long xB = Math.round(x+(xasalB-x)*Math.cos(sudut)-(yasalB-y)*Math.sin(sudut));
long yB = Math.round(x+(xasalB-x)*Math.sin(sudut)-(yasalB-y)*Math.cos(sudut));
long xC = Math.round(x+(xasalC-x)*Math.cos(sudut)-(yasalC-y)*Math.sin(sudut));
long yC = Math.round(x+(xasalC-x)*Math.sin(sudut)-(yasalC-y)*Math.cos(sudut));

int xA1 = (int)xA; int yA1 = (int)yA;
int xB1 = (int)xB; int yB1 = (int)yB;
int xC1 = (int)xC; int yC1 = (int)yC;

g.drawLine(xA1,yA1, xB1,yB1);
g.drawLine(xB1,yB1, xC1,yC1);



}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}




hy,.,......☻☻
nama saya Apsyalom Magang, Kali ini saya akan Coba memosting tugas dari Dosen saya mudah_mudahan bermanfaaat buat Sobb Smua yaNg nemu'in Blog ini ...........mohOn maaf jika ada Kesalahan ataupun tidak sesuai dengan keinginan sobb smua,.,.,.maklummmm daLam taHappp beLajaRrrrrrrr,,,,,,,x,ixixixixixixixixixixi
 

 PerulanGan

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

/**
 *
 * @author AB1
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int jumlah=5;
        while (jumlah>= 1){
            int k=jumlah;
            while (k >=1){
                System.out.print("*");
                k--;
                System.out.println();
                jumlah--;
            }
        }
        System.out.print("*");
               
    }
}
 Apsyalom Magang

PEMBUATAN MOBIL


 package apsya_mobil;

import java.awt.*;
import java.awt.event.*;
public class apsya_mobil extends Frame implements ActionListener{
    int x = 100;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new apsya_mobil();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public apsya_mobil() {
setTitle("apsya_mobil");
// create menu
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu = new Menu("File");
    mb.add(menu);
    MenuItem mi = new MenuItem("Exit");
    mi.addActionListener(this);
    menu.add(mi);
// end program when window is closed
    WindowListener l = new WindowAdapter()  {
    public void windowClosing(WindowEvent ev) {
    System.exit(0);
    }
    };
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
    x = ev.getX();
    y = ev.getY();
    repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {
g.setColor(Color.black);
g.fillRect(550, 250, 550, 270); //g.drawRect(x, y, WIDTH, WIDTH)

g.setColor(Color.blue);
g.drawRect(299, 320, 250, 200);
g.setColor(Color.gold);
g.fillOval(349, 520, 100, 100);
g.setColor(Color.red);
g.fillOval(470, 520, 100, 100);
g.setColor(Color.black);
g.drawOval(349, 560, 200, WIDTH);

g.setColor(Color.black);
g.fillOval(930, 520, 100, 100);

g.setColor(Color.black);
g.fillOval(800, 520, 100, 100);

g.drawOval(800, 560, 200, WIDTH);

g.setColor(Color.white);
g.fillOval(520, 240, 30, 30);

g.setColor(Color.black);
g.fillRect(550, 244, 550, 120);

g.setColor(Color.pink);
g.fillRect(380, 370, 100, 100);

}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
 hy....kali ini saya Apsyalom magang saya akan memosting tugas dari dosen saya tentang pembuatan orang 


package apsyalom;

import java.awt.*;

import java.awt.event.*;

public class Nuraini extends Frame implements ActionListener{

    int x = 100;

    int y = 100;

public static void main(String[] args) {

    Frame frame = new apsyalom();

    frame.setSize(640, 480);

    frame.setVisible(true);

}

public apsyalom() {

setTitle("apsyalom");

// create menu

    MenuBar mb = new MenuBar();

    setMenuBar(mb);

    Menu menu = new Menu("File");

    mb.add(menu);

    MenuItem mi = new MenuItem("Exit");

    mi.addActionListener(this);

    menu.add(mi);

// end program when window is closed

    WindowListener l = new WindowAdapter()  {

    public void windowClosing(WindowEvent ev) {

    System.exit(0);

    }

    };

this.addWindowListener(l);

// mouse event handler

MouseListener mouseListener = new MouseAdapter() {

public void mouseClicked(MouseEvent ev) {

    x = ev.getX();

    y = ev.getY();

    repaint();

}

};

addMouseListener(mouseListener);

}



public void paint(Graphics g) {

setBackground (Color.gold);



        //kepala

g.setColor(Color.RED);

g.drawOval(320,240,  200, 200);

// mata

g.setColor(Color.black);

g.fillOval(360, 310, 50, 20);

g.fillOval(440, 310, 50, 20);



// mulut

g.setColor(Color.black);

g.drawArc(380, 360, 90, 50, 180, 180);

g.drawArc(380, 366, 90, 50, 180, 180);

//alis mata

g.setColor(Color.green);

g.drawArc(360, 290, 50, 20, -180, -180);

g.drawArc(440, 290, 50, 20, -180, -180);



// bola mata

g.setColor(Color.white);

g.fillOval(379, 321, 10, 10);

g.fillOval(457, 321, 10, 10);

//hidung

g.setColor(Color.GREEN);

g.fillOval(410, 350, 30, 30);

//telinga

g.setColor(Color.YELLOW);

g.fillOval(300, 310, 20, 60);

g.fillOval(520, 310, 20, 60);



}

public void actionPerformed(ActionEvent ev) {

 

String command = ev.getActionCommand();

if ("Exit".equals(command)) {

System.exit(0);

}

}

}
☺☺☺ hy,.,.......
Nama Saya Apsyalom Magang kali ini saya akan posting tugas dari Dosen Saya mudah-mudahan bermanfaat yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


Algoritma pembentukan garis DDA :
SOAL

1. Tentukan dua titik yang akan dihubungkan dalam pembentukan garis.
2. Tentukan salah satu titik sebagai awal(x0,y0) dan titik akhir(x1,y1).
3. Hitung dx=x1¬x0, dan dy= y1¬y0.
4. Tentukan langkah, yaitu dengan cara jarak maksimum jumlah penambahan nilai x maupun nilai y, dengan caara :
Bila nilai absolut dari dx lebih besar dari absolut dy, maka langkah= absolut dari dx.
Bila tidak maka langkah= absolut dari dy
5. Hitung penambahan koordinat pixel yaitu x_increment=dx/langkah, dan y_increment=dy/langkah.
6. Koordinat selanjutnya (x+x_increment, y+y_increment).
7. Posisi pixel pada layar ditentukan dengan pembulatan nilai koordinat tersebut.
8. Ulangi nomor 6 dan 7 untuk menentukan posisi pixel selanjutnya,sampai x= x1 dan y= y1

CONTOH SOURCE CODENYA :


package Garis;

import java.awt.Graphics;


public class Garis {
 
    public void Garisku (Graphics g, int x0, int y0, int x1, int y1){
        int dx,dy,steps;
        int x_tambah,y_tambah,x,y;
                           
  dx= x1-x0;
  dy= y1-y0;    
              
  if (Math.abs(dx) > Math.abs(dy)){
   steps = Math.abs(dx);
  }
  else{
   steps = Math.abs(dy);
  }
  x_tambah = dx / steps;
  y_tambah = dy / steps;
                x=x0;
                y=y0;
                      
                g.fillRect(x, y, 1, 1);
  for (int k=10; k< steps ;k++){
   x += x_tambah;
   y += y_tambah;
 
                        g.fillRect(x, y, 1, 1);
  }            
      
    }
  
}

Contoh Source Code untuk memanggil Class Garis yang bagian pertama yang sudah kita buat
Source Code nya :

package garis;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class tampilgaris extends JPanel{
    @Override
    public void paintComponent(Graphics g){
        apsya baru = new apsya();
        g.setColor(Color.green);
        baru.Garisku(g, 200, 300, 400, 300);
        baru.Garisku(g, 200, 160, 400, 160);
            }
  
    public static void main(String[] args) {
        apsya baru = new apsya();
        JFrame frame = new JFrame("apsya Gambar ");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new tampilgaris());
        frame.setSize(600, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
             
    }
}
      
hy prkenalkan....
Nama   : Apsyalom Magang
Nim      : 11110053
kelas    :  B
saya akan posting tugas dari Dosen saya mudah-mudahan bermanfaat ya,.,...... 

package penggunaanawt;

import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
    int x = 100;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new AWTDemo();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public AWTDemo() {
setTitle("AWT Demo");
// create menu
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu = new Menu("File");
    mb.add(menu);
    MenuItem mi = new MenuItem("Exit");
    mi.addActionListener(this);
    menu.add(mi);
// end program when window is closed
    WindowListener l = new WindowAdapter()  {
    public void windowClosing(WindowEvent ev) {
    System.exit(0);
    }
    };
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
    x = ev.getX();
    y = ev.getY();
    repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {

g.drawLine(x, y, 100, 50);
g.setColor(Color.green);
g.drawOval(100, 100,100, 200);
g.drawRect(150, 150, 200, 200); //g.drawRect(x, y, WIDTH, WIDTH)
g.fillOval(100, 200, 80, 150); //g.fillOval(x, y, WIDTH, WIDTH);
g.setColor(Color.red);
g.fillOval(10, 20, 80, 150);
   
g.setColor(Color.BLUE);
g.drawOval(320,240,  200, 200);
g.setColor(Color.yellow);
g.drawArc(360, 290, 50, 20, -180, -180);
g.drawArc(440, 290, 50, 20, -180, -180);
g.setColor(Color.black);
g.drawArc(380, 360, 90, 50, 180, 180);
g.fillOval(360, 310, 50, 20);
g.fillOval(440, 310, 50, 20);


}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}

hy,.,......☻☻
nama saya Apsyalom Magang, Kali ini saya akan Coba memosting tugas dari Dosen saya mudah_mudahan bermanfaaat buat Sobb Smua yaNg nemu'in Blog ini ...........mohOn maaf jika ada Kesalahan ataupun tidak sesuai dengan keinginan sobb smua,.,.,.maklummmm daLam taHappp beLajaRrrrrrrr,,,,,,,x,ixixixixixixixixixixi

package penggunaanawt;

import java.awt.*;
import java.awt.event.*;
public class AWTDemo extends Frame implements ActionListener{
    int x = 50;
    int y = 100;
public static void main(String[] args) {
    Frame frame = new AWTDemo();
    frame.setSize(640, 480);
    frame.setVisible(true);
}
public AWTDemo() {
setTitle("AWT Demo");
// create menu
    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    Menu menu = new Menu("File");
    mb.add(menu);
    MenuItem mi = new MenuItem("Exit");
    mi.addActionListener(this);
    menu.add(mi);
// end program when window is closed
    WindowListener l = new WindowAdapter()  {
    public void windowClosing(WindowEvent ev) {
    System.exit(0);
    }
    };
this.addWindowListener(l);
// mouse event handler
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
    x = ev.getX();
    y = ev.getY();
    repaint();
}
};
addMouseListener(mouseListener);
}

public void paint(Graphics g) {
int xasalA=150; int yasalA=100;
int xasalB=100; int yasalB=250;
int xasalC=200; int yasalC=250;

int sudut=45;

g.setColor(Color.green);
g.drawLine(x, y, 400,100);
g.drawLine(400, 100, 400,300);

}
public void actionPerformed(ActionEvent ev) {
String command = ev.getActionCommand();
if ("Exit".equals(command)) {
System.exit(0);
}
}
}