Projenizin design ve documentation aşamalarında genellikle kullanılan UML diagrams, sequence diagrams,
state diagram, activity diagram ... oluşturmak için gliffy çok kullanışlı online olarak üyeliğe gerek olmadan kolay bir şekilde kulanabilirsiniz.
Eğer büyük bir proje yapıyorsanız veya source code dan hemen UML oluşturturmak istiyorsanız
Visual Paradigm kullanabilirsiniz.
30 Mart 2012 Cuma
26 Mart 2012 Pazartesi
24 Mart 2012 Cumartesi
Icon overlay on taskbar button
Sample code
overlay icon un yanı sıra jump list, progress bar, gibi değişikler yapabilirisiniz taskbar button a.
package com.strixcode.j7goodies.samples;
import com.strixcode.j7goodies.AppUserModelId;
import com.strixcode.j7goodies.TaskbarButton;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;
/**
* Demonstrates how to use the TaskbarButton class to display an overlay icon.
*/
public class OverlayIconSample extends JFrame implements ActionListener {
TaskbarButton taskbarButton;
public OverlayIconSample() {
super("J7Goodies Demo");
getContentPane().add("Center", new JLabel("Click a button to display an overlay icon"));
Box box = Box.createVerticalBox();
final String[] icons = {"n/a", "images/available.png", "images/away.png",
"images/busy.png", "images/offline.png"
};
final String[] captions = {"No icon", "Available", "Away", "Busy",
"Offline"
};
for (int i = 0; i < icons.length; ++i) {
JButton cb = new JButton(captions[i], loadIcon(icons[i]));
cb.addActionListener(this);
box.add(cb);
}
getContentPane().add("South", box);
}
protected final ImageIcon loadIcon(String path) {
java.net.URL imgURL = this.getClass().getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL);
else
return null;
}
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
ImageIcon icon = (ImageIcon) button.getIcon();
if (icon != null)
taskbarButton.setOverlayIcon(icon);
else
taskbarButton.clearOverlayIcon();
}
private void setTaskbarButton(TaskbarButton taskbarButton) {
this.taskbarButton = taskbarButton;
}
public static void main(String[] args) throws Exception {
// AppUserModelID must be set before any GUI is shown
AppUserModelId.setCurrentProcessId("StrixCode.J7Goodies.Trial");
// Access GUI objects on the GUI thread
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {}
final OverlayIconSample frame = new OverlayIconSample();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
// *After* the frame become visible, create a TaskbarButton
// instance for it.
frame.setTaskbarButton(new TaskbarButton(frame));
}
});
}
}
overlay icon un yanı sıra jump list, progress bar, gibi değişikler yapabilirisiniz taskbar button a.
package com.strixcode.j7goodies.samples;
import com.strixcode.j7goodies.AppUserModelId;
import com.strixcode.j7goodies.TaskbarButton;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;
/**
* Demonstrates how to use the TaskbarButton class to display an overlay icon.
*/
public class OverlayIconSample extends JFrame implements ActionListener {
TaskbarButton taskbarButton;
public OverlayIconSample() {
super("J7Goodies Demo");
getContentPane().add("Center", new JLabel("Click a button to display an overlay icon"));
Box box = Box.createVerticalBox();
final String[] icons = {"n/a", "images/available.png", "images/away.png",
"images/busy.png", "images/offline.png"
};
final String[] captions = {"No icon", "Available", "Away", "Busy",
"Offline"
};
for (int i = 0; i < icons.length; ++i) {
JButton cb = new JButton(captions[i], loadIcon(icons[i]));
cb.addActionListener(this);
box.add(cb);
}
getContentPane().add("South", box);
}
protected final ImageIcon loadIcon(String path) {
java.net.URL imgURL = this.getClass().getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL);
else
return null;
}
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
ImageIcon icon = (ImageIcon) button.getIcon();
if (icon != null)
taskbarButton.setOverlayIcon(icon);
else
taskbarButton.clearOverlayIcon();
}
private void setTaskbarButton(TaskbarButton taskbarButton) {
this.taskbarButton = taskbarButton;
}
public static void main(String[] args) throws Exception {
// AppUserModelID must be set before any GUI is shown
AppUserModelId.setCurrentProcessId("StrixCode.J7Goodies.Trial");
// Access GUI objects on the GUI thread
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {}
final OverlayIconSample frame = new OverlayIconSample();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
// *After* the frame become visible, create a TaskbarButton
// instance for it.
frame.setTaskbarButton(new TaskbarButton(frame));
}
});
}
}
19 Mart 2012 Pazartesi
Matlab - histeq implementation
Matlab da histogram equalization için kullanılan histeq fonksiyonunun implementasyonu:
***F bir gray scale input image****
function image_histeq(F)
I = imread(F);
%histeq
J = histeq(I);
%Output image of our algorithm and its histogram
width = size(I,1);
height = size(I,2);
MN = width * height;
Hist = uint8(zeros(width , height));
frequency = zeros(256 , 1);
probability = zeros(256,1);
for i = 1 : width
for j = 1 : height
value = I(i , j);
frequency(value + 1) = frequency(value + 1) + 1;
probability(value + 1) = frequency(value + 1) / MN;
end
end
sum = 0;
bits = 255;
probCount = zeros(256 , 1);
cum = zeros(256 , 1);
output = zeros(256 , 1);
for i = 1 : size(probability)
sum = sum + frequency(i);
cum(i) = sum;
probCount(i) = cum(i) / MN;
output(i) = round(probCount(i) * bits);
end
for i = 1 : width
for j = 1 : height
Hist(i,j) = output(I(i , j) + 1);
end
end
%display all
subplot(3,2,1);
imshow(I);
title('Input Image');
subplot(3,2,2);
imhist(I);
title('Input image histogram');
subplot(3,2,3);
imshow(J);
title('Output image of histeq function');
subplot(3,2,4);
imhist(J);
title('histeq function histogram');
subplot(3,2,5);
imshow(Hist);
title('Output image of our algorithm');
subplot(3,2,6);
imhist(Hist);
title('our algorithm histogram');
return
Download Code
***F bir gray scale input image****
function image_histeq(F)
I = imread(F);
%histeq
J = histeq(I);
%Output image of our algorithm and its histogram
width = size(I,1);
height = size(I,2);
MN = width * height;
Hist = uint8(zeros(width , height));
frequency = zeros(256 , 1);
probability = zeros(256,1);
for i = 1 : width
for j = 1 : height
value = I(i , j);
frequency(value + 1) = frequency(value + 1) + 1;
probability(value + 1) = frequency(value + 1) / MN;
end
end
sum = 0;
bits = 255;
probCount = zeros(256 , 1);
cum = zeros(256 , 1);
output = zeros(256 , 1);
for i = 1 : size(probability)
sum = sum + frequency(i);
cum(i) = sum;
probCount(i) = cum(i) / MN;
output(i) = round(probCount(i) * bits);
end
for i = 1 : width
for j = 1 : height
Hist(i,j) = output(I(i , j) + 1);
end
end
%display all
subplot(3,2,1);
imshow(I);
title('Input Image');
subplot(3,2,2);
imhist(I);
title('Input image histogram');
subplot(3,2,3);
imshow(J);
title('Output image of histeq function');
subplot(3,2,4);
imhist(J);
title('histeq function histogram');
subplot(3,2,5);
imshow(Hist);
title('Output image of our algorithm');
subplot(3,2,6);
imhist(Hist);
title('our algorithm histogram');
return
Download Code
Matlab - filter Implementation
filter2 fonkiyonuyla yapılan bluring işleminin implementasyonu:
***filter2 ve algoritmanın output imageları aynı pencerede subplot kullanarak gösteriliyor***
**** 3 X 3 bir filter kullanılıyor****
***filter size arttıkça bluring artar***
*** F input image: bir gray scale image***
% Main function
function image_filter(F)
%filter2
I = imread(F);
filt = ones(3 , 3) / 9;
res = filter2(filt, I, 'same');
J = uint8(res);
%our filtering algorithm
height = size(I, 1);
width = size(I, 2);
a = zeros(height + 2, width + 2, 'uint8');
for i = 2 : height + 1
for j = 2 : width + 1
a (i, j) = I(i - 1, j - 1);
end
end
b = zeros(height, width, 'uint8');
for i = 1 : height
for j=1 : width
avg = mean2(a(i : i + 2, j : j + 2));
b(i , j) = avg;
end
end
%display all
subplot(2,2,1);
imshow(I);
title('Input Image');
subplot(2,2,2);
imshow(J);
title('Output image of filter2 function');
subplot(2,2,3);
imshow(b);
title('Output image of our function');
return
Download Code
***filter2 ve algoritmanın output imageları aynı pencerede subplot kullanarak gösteriliyor***
**** 3 X 3 bir filter kullanılıyor****
***filter size arttıkça bluring artar***
*** F input image: bir gray scale image***
% Main function
function image_filter(F)
%filter2
I = imread(F);
filt = ones(3 , 3) / 9;
res = filter2(filt, I, 'same');
J = uint8(res);
%our filtering algorithm
height = size(I, 1);
width = size(I, 2);
a = zeros(height + 2, width + 2, 'uint8');
for i = 2 : height + 1
for j = 2 : width + 1
a (i, j) = I(i - 1, j - 1);
end
end
b = zeros(height, width, 'uint8');
for i = 1 : height
for j=1 : width
avg = mean2(a(i : i + 2, j : j + 2));
b(i , j) = avg;
end
end
%display all
subplot(2,2,1);
imshow(I);
title('Input Image');
subplot(2,2,2);
imshow(J);
title('Output image of filter2 function');
subplot(2,2,3);
imshow(b);
title('Output image of our function');
return
Download Code
15 Mart 2012 Perşembe
Windows Loopback Sniffer
Projenizi localde çalıştırıp denemek için 127.0.0.1 yani localhost kullanılır.
Socket programlama da debugging biraz sıkıntı olduğu için paketleri izlemek için en iyisi wireshark kullanmak.
Wireshark
Ubuntu da loopback çalışıyor ama windows da çalışmıyor maalesef :(
En basit çözümü bir tane snifferla, örneğin RawCap, 127.0.0.1 i dinlemek ve oluşan dosyayı, örneğin "a.pcap",
wireshark la açıp paketleri inceliyebilirsinz.
RawCap
>>cmd
> RawCap.exe 127.0.0.1 localhost a.pcap
Socket programlama da debugging biraz sıkıntı olduğu için paketleri izlemek için en iyisi wireshark kullanmak.
Wireshark
Ubuntu da loopback çalışıyor ama windows da çalışmıyor maalesef :(
En basit çözümü bir tane snifferla, örneğin RawCap, 127.0.0.1 i dinlemek ve oluşan dosyayı, örneğin "a.pcap",
wireshark la açıp paketleri inceliyebilirsinz.
RawCap
>>cmd
> RawCap.exe 127.0.0.1 localhost a.pcap
13 Mart 2012 Salı
Java - TCP - Streams
TCP de data stream olarak gönderildiği için data nızın fixed size olması gerekiyor.
mesela 5 byte okuyacağını karşı taraf bilmeli.
Eğer göndereceğiniz paketin size ı değişiyorsa, ilk önce okuyacağı size miktarını göndermeniz lazım ve daha sonra
data yı göndermelisiniz.
Veya bir size belirleyip o size kadar göndermelisiniz.
/***
**** 11 byte okuyorum. Eger -1 olana kadar okursam stream in kapanana kadar anlamına gelir.
/
public static byte[] getRequest(InputStream is) {
byte[] aByte = new byte[11];
int bytesRead = 0;
if (is != null) {
try {
bytesRead = is.read(aByte, 0, aByte.length);
}
catch (Exception ex) {
// Do exception handling
System.out.println("hatta " + ex.getMessage());
}
}
return aByte;
}
mesela 5 byte okuyacağını karşı taraf bilmeli.
Eğer göndereceğiniz paketin size ı değişiyorsa, ilk önce okuyacağı size miktarını göndermeniz lazım ve daha sonra
data yı göndermelisiniz.
Veya bir size belirleyip o size kadar göndermelisiniz.
/***
**** 11 byte okuyorum. Eger -1 olana kadar okursam stream in kapanana kadar anlamına gelir.
/
public static byte[] getRequest(InputStream is) {
byte[] aByte = new byte[11];
int bytesRead = 0;
if (is != null) {
try {
bytesRead = is.read(aByte, 0, aByte.length);
}
catch (Exception ex) {
// Do exception handling
System.out.println("hatta " + ex.getMessage());
}
}
return aByte;
}