7 Haziran 2016 Salı

Java ile basit bir Icecek listesi Arayüzü




package test.io;

/**
 *
 * @author ozaytunctan13
 */
public class Icecekler {

    double satisTop = 0;

    public Icecekler() {
        satisTop = 0;
    }

    Icecekler(Icecek c, int adet) {
        for (Icecek icecek : Icecek.values()) {
            if (icecek == c) {
                this.satisTop += icecek.getFiyat() * adet;
                return;
            }

        }
        System.out.println("Tanımlı Icecek bulunamadı");
    }

    void IcecekSatis(Icecek c, int adet) {
        hesapla(c, adet);
    }

    double toplamSatisTutari() {
        return this.satisTop;
    }

    private void hesapla(Icecek c, int adet) {
        for (Icecek icecek : Icecek.values()) {
            if (icecek == c) {
                this.satisTop += icecek.getFiyat() * adet;
                return;
            }

        }
        System.out.println("Tanımlı Icecek bulunamadı");
    }

    public void IcecekFiyatGuncelle(Icecek c, double fiyat) {
        for (Icecek icecek : Icecek.values()) {
            if (icecek == c) {
                icecek.setFiyat(fiyat);
                return;
            }
        }
    }

    public double IcecekFiyati(Icecek c) {
        for (Icecek icecek : Icecek.values()) {
            if (icecek == c) {
                return icecek.getFiyat();
            }
        }
        return 0.0;
    }

    enum Icecek {

        Cola(3.75), Cay(0.75), Coffee(4.0), Sut(2.70);
        private double fiyat;

        private Icecek(double fiyat) {
            this.fiyat = fiyat;
        }

        private Icecek() {
            this.fiyat = 0.0;
        }

        double getFiyat() {
            return fiyat;
        }

        void setFiyat(double fiyat) {
            this.fiyat = fiyat;
        }
    }

    public static void main(String[] args) {
        Icecekler ic = new Icecekler();

        ic.IcecekSatis(Icecekler.Icecek.Cay, 2);
        ic.IcecekSatis(Icecekler.Icecek.Coffee, 1);
        ic.IcecekFiyatGuncelle(Icecek.Sut, 5);
        ic.IcecekSatis(Icecekler.Icecek.Sut, 3);
        System.out.println(ic.toplamSatisTutari());
    }
}

4 Mart 2016 Cuma

VHDL FULL ADDER

VHDL FULL ADDER PROGRAMİNG SOURCE CODE 
----------------------------------------------------------------------------------
-- Company: Siirt Üniversty
-- Engineer: Ozay tunctan bil.Müh
-- Create Date:    14:19:47 03/04/2016 
-- Design Name: Full adder
-- Module Name:    AND_KAPISI - Behavioral 
-- Project Name: full adder
-- Target Devices: 
-- Tool versions: 
-- Description: 
-- Dependencies: 
-- Revision: 1.5
-- Revision 0.01 - File Created
-- Additional Comments: 
----------------------------------------------------------------------------------
-----And kapısı Tasarımı
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity AND_KAPISI is
port(ve_g1:in std_logic;
     ve_g2:in std_logic;
     ve_cikis:out std_logic);
end AND_KAPISI;
architecture veriAkisi of AND_KAPISI is
begin
process(ve_g1,ve_g2)
begin
ve_cikis<=ve_g1 and ve_g2;
end process;
end veriAkisi;
----------------------------------------------------------------------------------------
----xor kapısı tasırımı
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity XOR_KAPISI is
port(xor_g1:in std_logic;
     xor_g2:in std_logic;
     xor_cikis:out std_logic);
end XOR_KAPISI;
architecture veriAkisi of XOR_KAPISI is
begin
process(xor_g1,xor_g2)
begin 
xor_cikis<=xor_g1 xor xor_g2;

end process;
end veriAkisi;


---------------------------------------------------------------------------------------
----Veya kapısı tasırımı
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity VEYA_KAPISI is
port(veya_g1:in std_logic;
     veya_g2:in std_logic;
     veya_cikis:out std_logic);
end VEYA_KAPISI;
architecture veriAkisi of VEYA_KAPISI is
begin
process(veya_g1,veya_g2)
begin 
veya_cikis<=veya_g1 or veya_g2;

end process;
end veriAkisi;
----------------------------------------------------------------------------------------
---half adder yarı toplayıcı devresi tasarımı
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity YARI_TOPLAYICI is
port(yt_g1:in std_logic;
     yt_g2:in std_logic;
     yt_elde:out std_logic;
 yt_toplam:out std_logic);
end YARI_TOPLAYICI;
architecture yapisal of YARI_TOPLAYICI is
component AND_KAPISI is
port(ve_g1:in std_logic;
     ve_g2:in std_logic;
     ve_cikis:out std_logic);
end component;
component XOR_KAPISI is
port(xor_g1:in std_logic;
     xor_g2:in std_logic;
     xor_cikis:out std_logic);
end component;
begin 
block1:AND_KAPISI port map(ve_g1=>yt_g1,ve_g2=>yt_g2,ve_cikis=>yt_elde);
block2:XOR_KAPISI port map(xor_g1=>yt_g1,xor_g2=>yt_g2,xor_cikis=>yt_toplam);
end yapisal;
-----------------------------------------------------------------------------------------------------
-----Tam toplayıcı devresinin tasarımı
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity TAM_TOPLAYICI is
port(tt_g1:in std_logic;
     tt_g2:in std_logic;
 tt_Cin:in std_logic;
 tt_elde:out std_logic;
 tt_toplam:out std_logic
    );
end TAM_TOPLAYICI;
architecture yapisal of TAM_TOPLAYICI is
component YARI_TOPLAYICI is
port(yt_g1:in std_logic;
     yt_g2:in std_logic;
     yt_elde:out std_logic;
 yt_toplam:out std_logic);
end component;
component VEYA_KAPISI is
port(veya_g1:in std_logic;
     veya_g2:in std_logic;
     veya_cikis:out std_logic);
end component;
signal ve_signal:std_logic;
signal xor_signal:std_logic;
signal yt_signal:std_logic;
begin
Block1:YARI_TOPLAYICI port map(yt_g1=>tt_g1,yt_g2=>tt_g2,yt_elde=>ve_signal,yt_toplam=>xor_signal);
Block2:YARI_TOPLAYICI port map(yt_g1=>xor_signal,yt_g2=>tt_Cin,yt_elde=>yt_signal,yt_toplam=>tt_toplam);
Block3:VEYA_KAPISI port map(veya_g1=>ve_signal,veya_g2=>yt_signal,veya_cikis=>tt_elde);
end yapisal;







26 Şubat 2016 Cuma

c# Dynamic Frame Design

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FreeCodeLibrary;
namespace OgrenciOtomasyon
{
    class FrameState:Form
    {

        TextBox mX, mY;
        private string v;
        public FrameState(string v)
        {
            this.v = v;
            this.Text = v.ToString();
            SetBounds(45,20,500,500);
            this.Show();
            this.BackColor = Color.Gainsboro;
            Panel pane = new Panel();
            Button oku = new Button();
            oku.FlatStyle = FlatStyle.Popup;
            oku.BackColor = Color.Yellow;
            oku.Text =" Biz  C# ";
            oku.MouseClick += oku_MouseClick;
            pane.MouseMove += pane_MouseMove;
            mX = new TextBox();
            mY = new TextBox();
            mX.SetBounds(30, 60, 100, 100);
            mY.SetBounds(30, 90, 100, 100);
            pane.Controls.Add(mX);
            pane.Controls.Add(mY);
            oku.SetBounds(30,30,80,20);
            pane.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D;
            pane.SetBounds(50,50,200,200);
            pane.Controls.Add(oku);
            pane.BackColor = Color.LightCyan;
            this.Controls.Add(pane);
        }
        private void oku_MouseClick(Object sender, MouseEventArgs e)
        {
             MessageBox.Show(Cmath.Sum(5,6,7,5,8).ToString());
         
        }
        private void pane_MouseMove(Object sender, MouseEventArgs e)
        {
            mX.Text = e.X.ToString();
            mY.Text = e.Y.ToString();
        }
    }
}

22 Şubat 2016 Pazartesi

Java ImageProcess

Cmatrix cm=Cmatrix.getInstance();
Static bir classtır.Image üzerinde Morfolojik işlemler yapılabilmektedir.Image'nin  Histogramı cıkarma ,Plot ,Döndürme acısı ,EdgeCanny( Kenar bulma),Thresold vb işlemler yapılabilmektedir.
Nokta rotasyonu ile
main{
 CMatrixcm=CMatrix.getInstance().imread().imshow().imhist().imshow().imrotate(180).imshow().edgeDetectionCanny().imshow();
}
Ekran Cıktısı(Logcat):

21 Şubat 2016 Pazar

Java RgbColor

Uğraşma sonucu Allahın lutfuyla Güzel bir Uygulama oldu.
Bu uygulama asıl amac renklerin butun tonlarını bir panele verebilmekti.Ve sonunda başarabildik.
public class ColorFrame extends JFrame implements ChangeListener {

    JPanel renkPane;
    JPanel rgbPane;
    JSlider s1;
    JSlider s2;
    JSlider s3;
    int r, g, b;

    public ColorFrame(String title) {
        super(title);
        renkPane = new JPanel();
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        s1 = new JSlider(0, 255);
        s1.setPaintTicks(true);
        s1.setForeground(Color.red);
        s1.setMinorTickSpacing(5);
        s1.setMajorTickSpacing(5);
        s2 = new JSlider(0, 255);
        s2.setForeground(Color.GREEN);
        s2.setPaintTicks(true);
        s2.setMinorTickSpacing(5);
        s2.setMajorTickSpacing(5);
        s3 = new JSlider(0, 255);
        s3.setPaintTicks(true);
        s3.setForeground(Color.BLUE);
        s3.setMinorTickSpacing(5);
        s3.setMajorTickSpacing(5);
        renkPane = new JPanel();
        rgbPane = new JPanel();
        s1.addChangeListener(this);
        s2.addChangeListener(this);
        s3.addChangeListener(this);
        renkPane.setSize(100, 100);
        renkPane.setLayout(new BoxLayout(renkPane, BoxLayout.Y_AXIS));
        renkPane.setBorder(new EtchedBorder(Color.lightGray, Color.RED));
        rgbPane.setBorder(new EtchedBorder(Color.lightGray, Color.RED));
        this.setSize(500, 500);
        renkPane.add(s1);
        renkPane.add(s2);
        renkPane.add(s3);
        renkPane.add(rgbPane);
        this.add(renkPane);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        ColorFrame fr = new ColorFrame("Color Frame");
    }

    @Override
    public void stateChanged(ChangeEvent e) {
        if (e.getSource() == s1) {
            r = (int) s1.getValue();
            g = (int) s2.getValue();
            b = (int) s3.getValue();
            rgbPane.setBackground(new Color(r, g, b));
            repaint();
        } else if (e.getSource() == s2) {
            r = (int) s1.getValue();
            g = (int) s2.getValue();
            b = (int) s3.getValue();
            rgbPane.setBackground(new Color(r, g, b));
            repaint();
        } else {
            r = (int) s1.getValue();
            g = (int) s2.getValue();
            b = (int) s3.getValue();
            rgbPane.setBackground(new Color(r, g, b));
            repaint();
        }
    }
}
Ekran cıktısı :

Java Container

Tarih:21.02.2016
Siradaki Container ise JTabbedPane nasıl kullanılır .

class JTabbedPanel extends JFrame {

    public JTabbedPanel(String title)  {
        super(title);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JLabel aciklama = new JLabel("Java JTabbedPane nedir ne işe Yarar?");
        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        JPanel p3 = new JPanel();
        JPanel p4 = new JPanel();
        p1.setBorder(new EtchedBorder(Color.BLACK, Color.RED));
        p2.setBorder(new EtchedBorder(Color.BLACK, Color.RED));
        p3.setBorder(new EtchedBorder(Color.BLACK, Color.RED));
        p4.setBorder(new EtchedBorder(Color.BLACK, Color.RED));
        String l1 = "OgrenciIslemleri";
        String l2 = "PersonelIslemleri";
        String l3 = "DersIslemleri";
        String l4 = "Ozay Tunctan YardımEt";
        JTabbedPane pane = new JTabbedPane(JTabbedPane.LEFT);
        p1.add(aciklama);
        pane.setBackground(Color.LIGHT_GRAY);
        JButton i1=new JButton("Ögrenci Ekle");
        JButton i2=new JButton("Ögrenci sil");
        p1.add(i1);
        p1.add(i2);
        pane.setFont(new Font("Arial", Font.BOLD, 15));
        pane.setForeground(Color.blue);
        pane.addTab(l1, p1);
        pane.addTab(l2, p2);
        pane.addTab(l3, p3);
        pane.addTab(l4, p4);
        this.add(pane);
        this.setSize(400, 400);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        JTabbedPanel pane = new JTabbedPanel("JtabbedPanel Frame");
    }
}
Ekran Cıktısı:

21.02.2015 tarihli Ders


Container(Kap diyorum ben)
Bütün  componentler ,bir container olmak zorundadır.Container swing componentleri yönetmek ve düzenlemek için özel tasarlanmış bir swing componentidir.Başlıca swing Componentleri JPanel,JSrollpane,JTabbedPane,JSplitPane dir.
Bu örneğimizde Jpanel olacak
Jpanelin cervesini düzenleme Component eklemeyi göstereceğim.
Kod satırları:
class Container {

    public static void main(String[] args) {
        JFrame fr = new JFrame();
        fr.setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel pane = new JPanel();
        JButton b1 = new JButton("1");
        JButton b2 = new JButton("2");
        b1.setBorder(new BevelBorder(BevelBorder.RAISED));
        b2.setBorder(new BevelBorder(BevelBorder.RAISED));
        pane.setBorder(new EtchedBorder(Color.BLACK, Color.RED));
        pane.add(b1);
        pane.add(b2);
        fr.add(pane);
        fr.setSize(100,100);
        fr.setVisible(true);
    }
}
Ekran Cıktısı