blog posts

databases (1) django (1) drupal (2) java (4) processing (7) wamp (1) yahoo pipes (1)

Friday, 18 March 2011

socialweb

this is my social site

Monday, 14 February 2011

Processing How to use the zoom feature

There is a method that is provided by the GiCentre which uses a class called
zoomPan.

To use this feature you need to download from the GiCentre site using this link

now you need to choose a class
ZoomPan zoomer

now create an instance of the zoom class. This need to be placed within the void setup() method.
eg zoomer = new ZoomPan(this); //  keyword this points to the zoomPan object


now you need to place zoomer.transform();   in the draw method. Remember the draw method is called again and again.

Now lets look at another features. There is feature that runs whats inside a particular loop


// if you want a certain task to be accomplished for example writing to appears on circles
 if(zoomer.getZoomScale() > 3) // the greater then 3 refers to how much you have zoom in
/* if you want to find out what your current zoomed position is you can use the print command
to return the current position 
 */
println(zoomer.getZoomScale)
    {
    text(countryName, x+pixel, y); 
}



Exercises

1. develop a zoom function which draw a group of triangle whens you have zoomed in with positon level 3
2.  make a button which when clicked on will zoom in to a particular position
3. disable the mouse panning and only allow the mouse scrole to work 

Sunday, 13 February 2011

java stack

What is a stack. A stack is used my the operating system. So they are very useful to learn about.
A stack in java has certain main methods
push
pop

Before we go onto programming a stack we are going to look at the logic of a stack they are known as LIFO last in first out and this I will demonstrate for you now how a stack works
 This is an example of pushing an item onto the stack. 
In java you create an instance of the stack class and there is a method called push you then pass to the stack class what you want to add 
eg 
Stack countries = new Stack()
countries.push("BRAZIL")

Now if you want to add another item we could add the line
countries.push("ENGLAND");
So now if we remove an item from a stack which item do you think will be removed well since its Last in first Out. The last item we added is england so this is removed first. 

To remove an item from a stack you use the same instance of the stack class that we created earlier. Instead of adding an item to the stack we pop it from the stack
stack.pop();

Why do I need to know how a stack works
Stack are very important in computer science. A stack is made up stack frames These are machine dependent data structure containing relevent subroutine state information. Each of these frame are assigned to a call to a subroutine which has not yet been terminated. 
eg if we have a sub routine DrawPint and its running. And it has just been called be a subroutine called DrawLine having called by a DrawSquare subroutine.

The stack layout is shown in an image below 






part 1 yahoo pipes basic feed

In this tutorial I show you how to setup a basic yahoo pipe

This yahoo pipe will return certain images from the flickr and show where they are geographically represented.

step 1 create a pipe


step 2
You will be taking to graph paper with  menu items on the side
Step 3

 drag the flickr item from the menu likes this:



This image shows the dragging of flickr onto the main screen

now let it drop in somewhere on the grid and you will get a state likes this

Step 4

When you let go you will see the output appears and the flickr panel opens up
with certain options
Step 5 now enter the data into the flickr panel

i entered 20 the number of items
images of i looked for cats but you can choose anything
i didnt specify a location but you can to just return images of cats from flickr in a particular location

you also need to run your mouse over the pipeout icon and where the circle is drag this to the flickr panel it should draw a line like so



 Step 6 now at the top fo the screen look the for next run pipe and click it
  Step 6.1 The next step is to choose the map  option from the tabular layout and you should get something like this

java Interface tutorial

/*In this tutorial I explain a bit about the concept of an interface. An interface is a group of methods that have the message body . The purpose of the interface is a blue print. Any object or class that uses the interface is guarentted to be able to use the specifics of the interface.  */

//what i mean is

public interface house
{

public void car( int car, int house {}

}


i//f you then created a class you could use the interface to implement these methods

public class cardetails implements car
//This will allow you to use the interface for your class
{
 public int setcar(int car, int house)
{
fregcar = car;
largehourse = house;
}

}

Gravity tutorial

In this tutorial I explain how gravity can work

first you need to declare a variable called
x and y these are the x and y position

eg
float x = 100;
float y = 0;
float y2 = 600;
float y3 = 600;
// initial speed is set to zero
float speed = 0;
float speed2 = 0;
float speed3 = 0;
float gravity = 0.1;
float gravity2 = 0.02;
float gravity3 = 0.04;




void setup()
{

void setup()
{
// width and height of the sketch
size(400,800);
// the speed of the fram rate. 
frameRate(9.8);


 
 
}

// this code can be improved by using loops but i am showing basic principles

void draw()
{
background(255);
// Display the square
fill(0);
noStroke();
rectMode(CENTER);
// the x coordinate is static and has a global float set to 100
// the y coordinate starts at zero and is effected by the y varabile as well as the speed and gravity variable
rect(x,y,10,10);
// what this line of code does is takes the current y position and then adds the speed onto this position

y = y + speed;
// this will increment the gravity by 0.1 each time the draw method is run.

speed = speed + gravity ;
/*
rect(x,y2,10,10);

y2 = y2 + speed;
speed = speed + gravity2 ;
*/
fill(255,0,0);
ellipse(x,y2,10,10);
y2 = y2 + speed2;

speed2 = speed2 + gravity2;

fill(0,255,0);
ellipse(x,y3,10,10);

y3 = y3 + speed3;

speed3 = speed3 + gravity3;

 
}

Popular Posts