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ı

19 Şubat 2016 Cuma

Bir text dosyasındaki verileri okumak için gerekli java kod satırları aşağıda verilmiştir.Eğer text Dosyasındaki verilerinin kaç satırdan oluştuğunu bilmiyorsak ArrayList yapısını kullanılmasını öneririm.Kendim  yazdığım programlarda ArrayList sınıfı kullanarak okuma işlemini  yaptım.ArrayList'in bize kazancı ise bilinmeyen satır sayılarında bize kolaylık sağlayan bir list yapısıdır.Benim yaptığım işlem text dosyası verileri parametre olarak verilen Token değişkeni ile alınan her satırı parçalayarak double dizisine konulmuştur.Daha sonra her satırdaki data parçalanarak bir dizi yapısı oluşturularak  Arraylist Sınıfına aktarılmıştır.Geri dönüş değeri 2 boyutlu matrix satır sutun şeklinde hücrelere aktarılmıştır.Anlamadığınız noktalarda yorum yaparak sorabilirsiniz.

   public static double[][] doubleAllReadToFile(String file_name, String token) {
        double[][] d = new double[1][1];
        ArrayList<double[]> lst = new ArrayList<>();
        File file = new File(file_name);
        if (!file.exists()) {
            showMessage(file_name + " isminde bir dosya yok");
            return d;
        }
        try (BufferedReader br = new BufferedReader(new FileReader(file_name))) {
         String s;
         while ((s = br.readLine()) != null) {
         String[] sd = s.split(token);
         double[] row =new double[sd.length];
         for (int i = 0; i < sd.length; i++) {
          row[i] = Double.parseDouble(sd[i]);
          }
                lst.add(row);
            }
        br.close();
        } catch (IOException e) {
        e.printStackTrace();
          }
          return d;
        }

12 Şubat 2016 Cuma