example1

package rebecca.e9.standart.pipes;
import rebecca.e9.core.*;

public class EmptyPipe extends Pipe {

public EmptyPipe() {
super(“Do nothing.”);
}

public void Execute() {

}

public void Init() {
}

public void ShutDown() {
}
}

package Run;

import rebecca.e9.core.*;

public class EmptyPipeLine extends PipeLine {

public EmptyPipeLine() {
super(“Empty PipeLine – performs nothing”);

}

}

package rebecca.e9.standart.pipes;

import rebecca.e9.core.*;

public class Decolorizer extends Pipe {

private ObrazC1 tempO1=null;
private ObrazC3 tempO2=null;
private Slot in;
private Slot out;

public Decolorizer(Slot input,Slot output) {
super(“Converting ObrazC3 to gray-scale ObrazC1″);
if (input!=null&output!=null)
{
this.in=input;
this.out=output;
this.registerInSlot(input);
this.registerOutSlot(output);

}else{this.setDamage();}

}

public void Init() {
}

public void ShutDown() {
}

public void Execute() {

tempO2 = in.GetDATA(this);

int H=tempO2.getHeight();
int W=tempO2.getWidth();
tempO1 = new ObrazC1(H,W);

char r=0;
char g=0;
char b=0;
char w=0;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){

r=tempO2.getR(i, j);
g=tempO2.getG(i, j);
b=tempO2.getB(i, j);
w=(char)(0.30*r + 0.59*g + 0.11*b);
tempO1.setVal(i, j, w);

}}

this.out.PushDATA(tempO1, this);

}

}

package Run;

import java.awt.image.BufferedImage;
import rebecca.e9.core.*;
import rebecca.e9.standart.pipes.*;

public class ViolentPipeLine extends PipeLine {

public ViolentPipeLine(Slot path) {
super(“Example PipeLine”);

Slot bi = new Slot();
Slot ib = new Slot();
Slot c3 = new Slot();
Slot c1 = new Slot();

Pipe L=new ImageLoader(path,bi);
Pipe C1=new Image2ObrazC3(bi,c3);
Pipe D=new Decolorizer(c3,c1);
Pipe C2=new ObrazC1Image(c1,ib);
Pipe S=new Screen(“File Loaded”,ib);

this.registerInSlot(path);

this.registerInternalSlot(bi);
this.registerInternalSlot(ib);
this.registerInternalSlot(c3);
this.registerInternalSlot(c1);

this.registerPipe(L);
this.registerPipe(S);
this.registerPipe(C2);
this.registerPipe(C1);
this.registerPipe(D);

}
}

package Run;

import rebecca.e9.core.Factory;
import rebecca.e9.core.PipeLine;
import rebecca.e9.core.Slot;

public class DecolorizerFactory extends Factory{

public DecolorizerFactory() {
super(“Simple Decolourizer Factory”, “My Super Factory 1″);

Slot path = new Slot(“C://1.bmp”);
path.SetFresh(true);

PipeLine P = new ViolentPipeLine(path);
this.registerPipeLine(P);

}

}

package Run;

import rebecca.e9.core.Factory;
import rebecca.e9.core.Slot;

public class Run {

/**
* @param args
*/
public static void main(String[] args) {

Factory F = new DecolorizerFactory();
F.Start();

try {
Thread.sleep(200000);
} catch (InterruptedException e) {
e.printStackTrace();
}

F.Stop();;

}

}

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.