Advertisement
W0lf112

Untitled

Dec 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. import aguiaj.iscte.*;
  2.  
  3. public class Prancha {
  4.  
  5. private ColorImage img;
  6. private int colunas=1;
  7. private int tiras;
  8. private ColorImage prancha;
  9. Vinheta [][] vinhetas;
  10. private int espaco = 1;
  11.  
  12. Prancha(int tira) {
  13. this.espaco=espaco;
  14. vinhetas = new Vinheta[tira][colunas];
  15. this.tiras=tiras;
  16. for (int i = 0; i < vinhetas.length; i++)
  17. for(int j=0; j < vinhetas[i].length; j++)
  18. vinhetas[i][j] = new Vinheta(new ColorImage(100,50), 1, 1, Color.BLACK);
  19.  
  20.  
  21.  
  22. }
  23. private void espaco(int espaco)
  24. {
  25. this.espaco = espaco;
  26. // mostrar prancha()
  27. }
  28.  
  29.  
  30.  
  31. int getAlt() {
  32. int somador = 0;
  33. int altura = 0;
  34. for (int i = 0; i < vinhetas.length; i++) {
  35. for(int j = 0; j < vinhetas[i].length; j++) {
  36. if (vinhetas[i][j].getHeight() > altura)
  37. altura = vinhetas[i][j].getHeight();
  38. }
  39. somador += altura;
  40. altura = 0;
  41. }
  42. return somador; //falta espacos e tiras idk
  43. }
  44.  
  45. int getLarg() {
  46. int somador = 0;
  47. int largura = 0;
  48. for (int i = 0; i < vinhetas.length; i++) {
  49. for (int j = 0; j < vinhetas[i].length; j++) {
  50. if (vinhetas[i][j].getWidth() > largura)
  51. largura = vinhetas[i][j].getWidth();
  52. }
  53. somador = largura;
  54. largura = 0;
  55. }
  56. return somador; //falta espacos e tiras idk
  57.  
  58. }
  59.  
  60. private int getAltIni(int x, int y) {
  61. int altura = 0;
  62. for(int i = 0; i < y; i++) {
  63. altura += vinhetas[x][i].getHeight();
  64. }
  65. return altura; //falta espacos e tiras idk
  66. }
  67.  
  68. private int getLargIni(int x, int y) {
  69. int largura = 0;
  70. for(int i = 0; i < x; i++) {
  71. largura = vinhetas[i][y].getWidth();
  72. }
  73. return largura; //falta espacos e tiras idk
  74. }
  75. ColorImage getPrancha() { //PRANCHA
  76. ColorImage prancha = new ColorImage (getLarg(), getAlt());
  77. for(int x=0;x!=vinhetas.length;x++){
  78. for(int y=0;y!=vinhetas[x].length;y++){
  79. ColorImage vinh_img = vinhetas[x][y].retomarvineta();
  80. pasteImage(prancha,vinh_img, getLargIni(x,y), getAltIni(x,y));
  81. }
  82. }
  83. return prancha;
  84. }
  85.  
  86. private static void pasteImage(ColorImage img, ColorImage p, int x, int y){ //FUNÇÃO COPIAR PARA OUTRA
  87. for(int x1=x, x2=0; x2 != p.getWidth() && x1 != img.getWidth(); x1++, x2++){
  88. for(int y1=y, y2=0; y2 != p.getHeight() && y1 != img.getHeight(); y1++, y2++){
  89. img.setColor(x1,y1, p.getColor(x2,y2));
  90. }
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement