Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import aguiaj.iscte.*;
- public class Prancha {
- private ColorImage img;
- private int colunas=1;
- private int tiras;
- private ColorImage prancha;
- Vinheta [][] vinhetas;
- private int espaco = 1;
- Prancha(int tira) {
- this.espaco=espaco;
- vinhetas = new Vinheta[tira][colunas];
- this.tiras=tiras;
- for (int i = 0; i < vinhetas.length; i++)
- for(int j=0; j < vinhetas[i].length; j++)
- vinhetas[i][j] = new Vinheta(new ColorImage(100,50), 1, 1, Color.BLACK);
- }
- private void espaco(int espaco)
- {
- this.espaco = espaco;
- // mostrar prancha()
- }
- int getAlt() {
- int somador = 0;
- int altura = 0;
- for (int i = 0; i < vinhetas.length; i++) {
- for(int j = 0; j < vinhetas[i].length; j++) {
- if (vinhetas[i][j].getHeight() > altura)
- altura = vinhetas[i][j].getHeight();
- }
- somador += altura;
- altura = 0;
- }
- return somador; //falta espacos e tiras idk
- }
- int getLarg() {
- int somador = 0;
- int largura = 0;
- for (int i = 0; i < vinhetas.length; i++) {
- for (int j = 0; j < vinhetas[i].length; j++) {
- if (vinhetas[i][j].getWidth() > largura)
- largura = vinhetas[i][j].getWidth();
- }
- somador = largura;
- largura = 0;
- }
- return somador; //falta espacos e tiras idk
- }
- private int getAltIni(int x, int y) {
- int altura = 0;
- for(int i = 0; i < y; i++) {
- altura += vinhetas[x][i].getHeight();
- }
- return altura; //falta espacos e tiras idk
- }
- private int getLargIni(int x, int y) {
- int largura = 0;
- for(int i = 0; i < x; i++) {
- largura = vinhetas[i][y].getWidth();
- }
- return largura; //falta espacos e tiras idk
- }
- ColorImage getPrancha() { //PRANCHA
- ColorImage prancha = new ColorImage (getLarg(), getAlt());
- for(int x=0;x!=vinhetas.length;x++){
- for(int y=0;y!=vinhetas[x].length;y++){
- ColorImage vinh_img = vinhetas[x][y].retomarvineta();
- pasteImage(prancha,vinh_img, getLargIni(x,y), getAltIni(x,y));
- }
- }
- return prancha;
- }
- private static void pasteImage(ColorImage img, ColorImage p, int x, int y){ //FUNÇÃO COPIAR PARA OUTRA
- for(int x1=x, x2=0; x2 != p.getWidth() && x1 != img.getWidth(); x1++, x2++){
- for(int y1=y, y2=0; y2 != p.getHeight() && y1 != img.getHeight(); y1++, y2++){
- img.setColor(x1,y1, p.getColor(x2,y2));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement