Sonntag, 30. November 2008

Blender Anination

Blender Animation


www.blender.org



EE3206/EE5805 Java-thread-5

EE3206/ EE5805 Java Programming and Applications


14.3.2 static synchronized mtehods,
notes from Gosling etc. "The Java progamming Language"

1. A static synchronized method acquires the lock of the Class object for its class. If static data is shared between threads then access to it must be protected by static synchronized methods.

2. Acquiring the Class object lock in a static synchronized method has no effect on any objects ofthat class.

3. You can still invoke synchronized methods on an object while another thread holds the Class object lock in a static synchronized method, only other static synchronized methods are blocked.



Samstag, 29. November 2008

The Java mind-set

The java mind-set

You must read Gosling etc 's "the Java programming Language".

It javalizes you on how to act in a java way.

The java mind-set, whether it is good or bad likes a pair of goggles put on your eyes.



EE3206/EE5805 Java thread-4

EE3206/EE5805 Java Programming and application

notes on 14.3.1 Synchronized methods
excerpted from the "The Java Programming Language, 4th ed."

1. Synchronization forces execution of the two threads to be mutually exclusive in time. On the contrary, unsynchronized access does not wait for any locks but proceeds regardless of locks that may be held on the object.

2. Locks are owned per thread, so invoking a synchronized method from within another method synchronized on the same object will proceed without blocking, releasing the lock only when the outermost synchronized method returns.

3. This per-thread behavior prevents a thread from blocking on lock it already has, and permits recursive method invocations and invocations of inherited methods which themselves may be synchronized.

4. The constructor does not need to be synchronized because it is executed only when creating an object, and that can happen in only one thread for any given new object.

5. Access to the field must be synchronized. With the synchronized declaration, two or more running thread are guaranteed not to interfere with each other.

6. There is no guarantee as to the order of operations. If the balance is queried about the same time that a deposit occurs, one of them will complete first but you cannot tell which.

7. You can ask whether the current thread holds the lock on a given object by passing that object to the Thread class's static holdsLock() method, which returnstrue if the current thread does hold the lock on that object.

Eg. assert Thread.holdsLock(this);

8. When an extended class overrides a synchronized method, the new method can be synchronized or not. The superclass's method will still be synchronized when it is invoked.

9. If the unsynchronized method uses super to invoke the superclss's synchronized method, the object 's lock will be acquired at that time and will be released when the superclass's method returns.




EE3206/EE5805 Java thread-3

EE3206/EE5805 Java Programming and Applications

notes on 14.3 Synchronization, from "The Java Programming Language":

1. We need to avoid interleaved operation that can corrupt the data. Such potentially interleaving actions are termed critical sections or critical regions, and you prevent interference by sychronizing access to those critical regions.

2. It is solved by acquiring a lock on an objet. Threads cooperate by agreeing to the protocol that before certain actions can occur on an object, the lock of the object must be acquired.

3. Acquiring the lock on an object prevents any other thread from acquiring that lock until the holder of the lock receives it.

4. Every object has a lock associated with it, and that lock can be acquired and released through the use of synchronized methods and statements. The terms syschronized code describes any code that is inside a synchronized method and statement.



EE3206/EE5805 Java thread-2

EE3206/EE5805 Java programming and Applications

notes on 14.2 using Runnable
from Gosling etc.. 's "The Java Programming Language , 4ed"

1.The work done by a thread is oackaged up in its run() method.

2. You can execute a Runnable object in its own thread by passing it to a thread constructor. If a thread object is constructed with a runnable object, the implementation of Thread.run will invoke the runnable object's run() method.

3. Real classes define complete state and behaviour, where having something execute in a separate thread is only a part of theit functionality.

4. Eg. new thread(this).start();
--While we didn't keep a reference to the thread, when the thread itself was created, it stored a reference to itself in its ThreadGroup.

5. We can place the run() method in part of an anonymous inner class (interface based) that implements Runnable. Eg.

...
public PrintServer2()
{
// constructor
Runnable service =
new Runnable() {
public void run() {
for(;;)
realPrint(request.remove() );
}
}; // queer
new Thread(sevice).start();
}
...


6. Using Runnable objects, you can create very flexible multithreaded designs. Each Runnable becomes a unit of work and each can be passed from one part of the system to another.

7. We can store Runnable objects in a queue and have a pool of worker threads servicing the work requests in the queue-- a very common design used in multithreaded server applications.



EE3206/EE5805 Java Threads-1

EE3206/ EE5805 Java Programming and Applications

notes on Threads from "The Java Programming Language, 3rd" p 229-231:

Creating Threads

1. To create a thread of control, you start by crating a Thread object:

Thread student = new Thread();

2. When the thread is ready to run, you invoke its start() method. The start() method spawns a new thread of control based on the data in the Thread object, then returns.

3. The JVM invokes the new thread's run() method, making the thread active. You can invoke start() only ONCE for each thread--invoking it again results in an
IllegalThreadStateException.

4. When a thread's run() method returns, the thread has exited. You can cease running a thread by invoking its interrupt() method.

5. To get a thread that does something, you must either extend Thread to provide a new method or create a Runnable object and pass it to the thread's constructor.

6. You can get the Thread object for the currently running thread by invoking the static method Thread.currentThread.



Mittwoch, 26. November 2008

java-src-3.1-Calculator.java

EE3206/EE5805 :

// java-src-3.1-Calculator.java


public class Calculator {
/** Main method */
public static void main(String[] args) {

// Check command-line arguments
if (args.length != 3) {
System.out.println(
"Usage: java Calculator operand1 operator operand2");
System.exit(0);
}

// The result of the operation
int result = 0;

// Determine the operator
switch (args[1].charAt(0)) {
case '+': result = Integer.parseInt(args[0]) +
Integer.parseInt(args[2]);
break;
case '-': result = Integer.parseInt(args[0]) -
Integer.parseInt(args[2]);
break;
case 'x': result = Integer.parseInt(args[0]) *
Integer.parseInt(args[2]);
break;
case '/': result = Integer.parseInt(args[0]) /
Integer.parseInt(args[2]);
}

// Display result
System.out.println(args[0] + ' ' + args[1] + ' ' + args[2]
+ " = " + result);
}
}





Java Coding Style

EE3206/ EE5805 Java Programming


Java Coding Style

http://geosoft.no/development/javastyle.html

http://java.sun.com/docs/codeconv/



Dienstag, 25. November 2008

Ogg Vorbis 格式

Ogg是一個完全開放性的多媒體系統計劃的名稱,也是Ogg Vorbis文件的擴展名。

Ogg Vorbis是一種類似于Mp3的有損音頻壓縮格式,但是它自由(免費、無專利限制)且開放源代碼。Vorbis是這種音頻壓縮格式的名稱。目前Ogg計劃只實現了Vorbis的部分。

Ogg Vorbis格式非常先進,雖然Vorbis也是有損壓縮,但是由于其使用了更加先進的聲學模型,同様位元率 (Bit Rate)下的Ogg文件比Mp3文件聽起來更好一些。事實上,一些評測結果顯示,在80k-256k的位元率下ogg格式呈現出該位元率範圍下的相對于其他音頻格式(mp3pro,wma,aac)更高的保真度。



http://en.wikipedia.org/wiki/Ogg

http://blog.roodo.com/rocksaying/archives/277025.html

http://www.fsf.org/resources/formats/playogg



Montag, 24. November 2008

Cora Diamond--Philosophy and the Mind-1

Cora Diamond--Philosophy and the Mind-1

Notes: (p.3)

1. ...Because logic 'fills' the world and because the possibilities of the world are the possibilities for thought, for the self considered non-psychologically, philosophical talk will be 'about the self' in its analysis of ordinary proposition about any and every ordinary subject matter.

2....remark about philosophy's being able to talk about the self in a non-psychological way is one of the remarks that has to be überwindet: we must win over it, throw away the ladder of which it is a rung.

3... The final step is the philosophical journey that takes us to the seeing of philosophical analysis as philosophy's non-philosophical presentation of the self leaves us without that description or any supposedly unspeakable understanding corresponding to it.



Samstag, 22. November 2008

The Logic of Experience

How is the logic of experience possible?

An empirical question cannot be logically deduced although it is logical.

So ./ cannot be .txt.

Donnerstag, 20. November 2008

EE3206 Java Mouse Color Panel

EE3206/EE5805 Java Programming (tut09)

There are 3 file in this exercise;

1.TestDrawableColorPanel.java (main)
2.RadioColorPanel.java
3.DrawColorPanel.java

/////////////////////////////////////////////////
//TestDrawableColorPanel.java (main)

public class TestDrawableColorPanel
{


public static void main(String[] args)
{
RadioColorPanel rcp = new RadioColorPanel();
rcp.setVisible(true);

}
}

//////////////////////////////////////////////////
//RadioColorPanel.java


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;



public class RadioColorPanel extends JFrame
{
public static final int WIDTH = 600;
public static final int HEIGHT =300;

private JPanel radioButtonPanel;
private DrawColorPanel colorPanel;

private JRadioButton blackButton;
private JRadioButton blueButton;
private JRadioButton greenButton;
private JRadioButton redButton;
private JRadioButton whiteButton;

// to group radio button and add() them
private ButtonGroup btg;


RadioColorPanel()
{
super("Test Drawable Color Panel");
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLayout(new BorderLayout(5,5) );

radioButtonPanel = new JPanel();

radioButtonPanel.setLayout(new FlowLayout() );

btg= new ButtonGroup();


blackButton = new JRadioButton("Black");
blackButton.addItemListener(new radioColorButtonListener() );
radioButtonPanel.add(blackButton);
btg.add(blackButton);

blueButton = new JRadioButton("Blue");
blueButton.addItemListener(new radioColorButtonListener() );
radioButtonPanel.add(blueButton);
btg.add(blueButton);


greenButton = new JRadioButton("Green");
greenButton.addItemListener(new radioColorButtonListener() );
radioButtonPanel.add(greenButton);
btg.add(greenButton);


redButton = new JRadioButton("Red");
redButton.addItemListener(new radioColorButtonListener() );
radioButtonPanel.add(redButton);
btg.add(redButton);

whiteButton= new JRadioButton("White");
whiteButton.addItemListener(new radioColorButtonListener());
radioButtonPanel.add(whiteButton);
btg.add(whiteButton);


//ButtonGroup is not a subclass of Component. So a Buttongroup
// object cannot be added to a container



add(radioButtonPanel, BorderLayout.NORTH);

colorPanel = new DrawColorPanel();
colorPanel.setBorder(new TitledBorder("Color Area by ( Martin Leung )") );
add(colorPanel, BorderLayout.CENTER);

}

private class radioColorButtonListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
//make sure the source is a JRadioButton
if (e.getSource() instanceof JRadioButton)
{
if(blackButton.isSelected())
colorPanel.drawInBlack();
else if (blueButton.isSelected() )
colorPanel.drawInBlue();
else if (greenButton.isSelected() )
colorPanel.drawInGreen();
else if (redButton.isSelected() )
colorPanel.drawInRed();
else if (whiteButton.isSelected() )
colorPanel.drawInWhite();

}
colorPanel.setBackground(Color.LIGHT_GRAY);
}
}

}

///////////////////////////////////////////////
DrawColorPanel.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class DrawColorPanel extends JPanel
implements MouseListener, MouseMotionListener
{

private Point lineStart = new Point(0,0);
private Point mousePoint = new Point();

private boolean blackColor =false;
private boolean blueColor = false;
private boolean greenColor = false;
private boolean redColor = false;
private boolean whiteColor = false;

public DrawColorPanel()
{
super();
addMouseMotionListener(this);
addMouseListener(this);

}

public void drawInBlack()
{
blackColor =true;
blueColor = false;
greenColor = false;
redColor = false;
whiteColor = false;
}

public void drawInBlue()
{

blackColor =false;
blueColor = true;
greenColor = false;
redColor = false;
whiteColor = false;
}

public void drawInGreen()
{

blackColor =false;
blueColor = false;
greenColor = true;
redColor = false;
whiteColor = false;

}

public void drawInRed()
{

blackColor =false;
blueColor = false;
greenColor = false;
redColor = true;
whiteColor = false;

}

public void drawInWhite()
{
blackColor =false;
blueColor = false;
greenColor = false;
redColor = false;
whiteColor = true;
}

// mouse handling interface

public void mouseClicked(MouseEvent e)
{
// get its (x,y) coord
// mousePoint = e.getPoint();
// repaint();
}

public void mouseEntered(MouseEvent e)
{
//
}

public void mouseExited(MouseEvent e)
{

}

public void mouseReleased(MouseEvent e)
{
//

}
public void mousePressed (MouseEvent e)
{
//
lineStart.move(e.getX(), e.getY());
// repaint();
}

public void mouseDragged(MouseEvent e)
{

Graphics g= getGraphics();


if (blackColor == true)
g.setColor(Color.BLACK);
else if (blueColor ==true)
g.setColor(Color.BLUE);
else if (greenColor == true)
g.setColor(Color.GREEN);
else if (redColor == true)
g.setColor(Color.RED);
else if (whiteColor == true)
g.setColor(Color.WHITE);

mousePoint = e.getPoint();

// the order of the 3 lines is very important...
g.drawLine(lineStart.x, lineStart.y, e.getX(), e.getY());
g.dispose();
lineStart.move(e.getX(), e.getY()) ;
// repaint();

}

public void mouseMoved(MouseEvent e)
{
//
}

public void paintComponent(Graphics g)
{
super.paintComponent(g);


//g.drawLine(lineStart.x, lineStart.y, mousePoint.x, mousePoint.y);
//g.dispose();

}


}




專家不過是訓練有素的狗

常言「專家只不過是一隻訓練有素的狗」語出何處及其英文原文?

From Student to Professional...

"讓學生 獲得對 各種價值的 理解和 感受是很重要的,
他必須能真切地 感受到 美麗 與道德的 良善,
否則他的專業知識只是使他更像一隻受過良好訓練的狗,
而不是 一個和諧發展的人."


http://reffaq.ncl.edu.tw/hypage.cgi?HYPAGE=faq_detail.htm&idx=1797

http://www.phy.ntnu.edu.tw/demolab/phpBB/viewtopic.php?topic=12179



EE3206 Java Drawing Mouse

EE3206 Java : How to Draw with a Mouse

tut09:

1. why only draw straight lines?

2.to use ArrayList to hold the points from the mouse event

http://www.leepoint.net/notes-java/examples/mouse/10mousetest.html




Mittwoch, 19. November 2008

Throwing Away the Ladder

Cora Diamond--Throwing Away the Ladder: How to Read the Tractatus

notes : (p.181-2)

1. to throw the ladder away is, among other things, to throw away in the end the attempt to take seriously the language of 'features of reality'.

2. To speak of features of reality in connection with what shows itself in language is to use a very add kind of figurative language. That goes also for "what shows itself."



Dienstag, 18. November 2008

EE3206 Java Event Handling

EE3206 Java Programming

Event Handling-- from Savitch 's Absolute Java (p.931)

1. Clicking a button with your mouse creates an object known as an event and sends the event object to another object known as the listeners. This is called firing the event.

2. The listener then performs some action. When we say that the event is "sent" to the listener object, what we really mean is that some method in the listeners object is invoked with event object as the argument.

3. For each button, it needs to specify what objects are listeners that will respond to events fired by that button; this is called registering the listener.

4. Different kinds of components require different kinds of listeners classes to handle the events they fire. A button fires events known as action events, which are handled by listeners known as action listeners.



聖鬥士--沙加的阿賴耶識

聖鬥士--沙加的阿賴耶識

http://hk.youtube.com/watch?v=ckyhzitRKQU&feature=related

http://hk.youtube.com/watch?v=3edWeKaDfLg&feature=related

http://hk.youtube.com/watch?v=uM_cf1T_QE0&feature=related



Montag, 17. November 2008

Cora Diamond--Realism and the Realistic Spirit

Cora Diamond--Realism and the Realistic Spirit

There is a quotation from Remarks on the Foundations of Mathematics (p.325)

"Not empiricism and yet realism in philosophy, that is the hardest thing."



Cora Diamond--How to Read the Tractatus

Cora Diamond-- Throwing Away the Ladder: How to read the Tractatus

Notes: (p.179)

"...the distinction between what can be said and what can only be shown."



Cora Diamond- Throwing Away the Ladder

Cora Diamond- "Throwing Away the Ladder: How to Read the Tractatus"

6.53 To say nothing except what can be said....

6.54. He must so to speak throw away the ladder, after he has climbed up on it.

7. Whereof one cannot speak, thereof one must be slient.

There is an useful link:

http://www.hum.utah.edu/philosophy/Faculty/millgram/witt/wittrdngs.html



Sonntag, 16. November 2008

Cora Diamond--linguistic surfaces

Cora Diamond--The Realistic Spirit (p.55)

'linguistic surfaces':

'sentences used independently of the ties to evidence and consequences which characterize the ordinary application of the expressions which they contain.'

-'The representation was not meant to be taken as an accurate portrayal of how things were...'

-'Conventions of representation of the sort we have been concerned with, in painting or in writing, do not settle truth...'

-(p.62) 'We make sentences called causal laws--when we have learned to reason inductively. To have learned to do so is indeed to have learned to behave in a certain way, and causal generalizations are what we come up with when we behave that way.'



Cora Diamond--conventions of description

Cora Diamond --The Realistic Spirit (p.54)

'conventions of description'

'the existence of rules or conventions concerning what my appropriately be said and indeed thought about a certain matter,... leaves open the question what is true about those matter.



HOW to convert yourself to LINUX

HOW to convert yourself to LINUX

1. You need a FRIEND who uses LINUX

2. Your LIFE needs LINUX


You need a complier to build from source.

Now think of Life as your compiler.
All of us have Life, but we need to recompile Life first using the -lessgeek and
-moreoutgoing flags in order to create Life suitable for you.

make LIFE -lessgeek -moreoutgoing


http://lxer.com/module/newswire/view/112116/index.html




Donnerstag, 13. November 2008

EE3206 Java-whichCard()

EE3206/EE5805 Java Hearts Programming Project

before executing westPlayer.playACard(CArd dealCard);, CPU needs to determine which card to deal, hence the algorithm :

public Card whichCardToDeal(int currentSuit);


public Card whichCardToDeal(int currentSuit)
{
if (player can follow suit)
{
retrun card same with the current suit
}
else if (player leads the suit && heartBreak == false)
{
if (player can deal card other than HEART)
{
retrun a card which is NOT a HEART
}
else
{
this player can only deal HEARTS
deal a HEART
heartBreak = ture
}
else if (player leads the trick && heartBreak == true)
{
can deal any card
}
else
{
this player only follow suit
return any card
}

}





Dienstag, 11. November 2008

Java Hearts remarks

EE3206/ EE5805 Java programming and Applications

Hearts game Project

public Card whcihCardToDeal(int leadSuit);

before CPU player playsACard(String cardname) , it needs to determine which card to deal.

The conditions are:

1. what is the value of leadSuit?
2. can it follow suit?
3. if not, which suit can be dealt?
4. if no other suits other than hearts-- deal a hearts,
then brokenHeart = ture
5 update playerCardList



Cora Diamond: The Realistic Spirit

Cora Diamond: The Realistic Spirit

Philosophy as liberating (p.32-33)

1."The way philosophy liberates is...connected with the significance of 'use' and of willingness or unwillingness to look to the use for what it enables us to see."

2."...philosophy as liberating is thus tied to an ability to look at the use without imposing on it what one thinks must already be there in it."

3."...an expression is not presented timelessly--its use is not given -- by the general form of the propositions it characterizes; use can be seen only as belonging to the spatial, temporal phenomenon of language."




Montag, 10. November 2008

EE3206 Hearts Games

EE3206/ EE5805 Java Programming and Applications

PlayACard()

1.It needs to be decomposed. Thre is a currentTrickList to record which player deals
whick and. display the displayCurrentTrickList().

2. When a CPU player deals a card , remove a card element in his playerCArdList. Add a card in currentTrickList in gamelogic.

randASuit();
whoTakeTrick() by using the currentTrickList
resetTrickList() for the next trick

Also, need to remember whoPlayNext. and the score



Frege's Ontological Argument

Notes on Joan Weiner's Frege Explained (p.159-161):

1. The ontological argument for the existence of God:

2." God is omniscient", "God exists"...

3. existence is not a property. The predicate 'exists' is actually a natural language expression for a quantifier.

4. To say that a cat exists is not to predicate existence of a particular cat but rather, to say that there exists an X such that X is a cat.

5. To say that God exists is not to predicate a property of God.

6. It is, rather to say something about the concept most perfect being that can be conceived; existence statements are about concepts.

7. There is no property of existence that can be predicated of an object. Thus the argument does not go through.

I first encountered this argument when I read Anscombe. But Weiner 's explanation is more clear and concise.



Sonntag, 2. November 2008

Frege Explained

Joan Weiner 's book "Frege Explained: From Arithmetic to Analytic Philosophy" is a very clear and good introduction to Frege.

I like Chaper 1: Frege's life and Character. I am rather sympathetic to Frege.

There is a sharp contrast between the fate of Frege and Russell in intellectual life.



Frege: Grundlagen

The Foundations of Arithmetic 算術基礎

From the Frege Reader (1997) edited by Michael Beaney, p.90 :

"In this investigation I have adhered to the following fundamental principles:

There must be a sharp separation of the psychological from the logical, the subjective from the objective;

The meaning of a word must be asked for in the context of a proposition, not in isolation;

The distinction between concept and object must be kept in mind.

Beaney comments on J.L. Austin's tranlation (page X) as making Frege "too muck like an Oxford linguistic philosopher." I hope there is another translation in the wiki.



Samstag, 1. November 2008

Frege: Begriffsschrift

Frege's Begriffsschrift

Summary: http://www.rbjones.com/rbjpub/philos/bibliog/frege01.htm

wiki: http://en.wikipedia.org/wiki/Begriffsschrift


In The Foundations of Arithmetic (算術基礎 ), Frege devised 3

"fundamental principles:

1. always to separate sharply the psychological from the logical, the subjective from the objective;

2. never to ask for the meaning of a word in isolation, but only in the context of a proposition;

3. never to loose sight of the distinction between concept and object."


(tranlated by J. L. Austin)(1980)