Ciao a tutti!
Vorrei sottoporvi questo quesito semplice semplice: ho creato al seguente classe
ed una classe che la estendecodice:package Utility; import javax.swing.JPanel; import processing.core.PApplet; /** * * @author Lorenzo De Francesco */ public class Plane3D extends PApplet { @Override public void setup(){ background(255); addMouseWheelListener(new java.awt.event.MouseWheelListener() { @Override public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { mouseWheel(evt.getWheelRotation()); }}); } @Override public void draw(){ background(255); scaleUp = wheel; transScale(mouseX, mouseY, scaleUp); }; private float scaleUp = 0.5f; private float wheel = 1.0f; private float wheelMult = 0.10f; private float x; private float y; private float xOffset; private float yOffset; private float xold; private float yold; private float xpiv; private float xpivOld; private float ypiv; private float ypivOld; private void mouseWheel(int step) { wheel=constrain((float)wheel+step*wheelMult*-1,(float)0.1,(float)50); } private void transScale(float x, float y, float scale) { if (mousePressed == true) { xOffset = x-xold; yOffset = y-yold; xpiv = (xpivOld-xOffset/scaleUp); ypiv = (ypivOld-yOffset/scaleUp); xpiv = xpiv + (xOffset/scaleUp); ypiv = ypiv + (yOffset/scaleUp); xpivOld = xpiv; ypivOld = ypiv; xold = x; yold = y; } else{ xOffset = x-xold; yOffset = y-yold; xpiv = (xpivOld-xOffset/scaleUp); xpivOld = xpiv; ypiv = (ypivOld-yOffset/scaleUp); ypivOld = ypiv; xold = x; yold = y; } // blue grid position translate(x, y); scale(scale); strokeWeight(2); stroke(70); strokeWeight(2); // negate mouse position translate(xpiv, ypiv); } public JPanel getJPanel(){ JPanel panel = new JPanel(); panel.add(this); this.init(); return panel; } }
ecco io ho fatto l'overrride dei metodi setup() e draw() ma vorrei che in questi metodi venisse prima eseguito il codice della classe madre e poi quello che scrivo io nella classe figlia...codice:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Decks; import Utility.Plane3D; /** * * @author Lorenzo De Francesco */ public class Plot3D extends Plane3D{ private double a [][]; public Plot3D(){ a = new double[3][4]; a[0][0] = 1; a[0][1] = 2; a[0][2] = 3; a[1][0] = 1; a[1][1] = 5; } @Override public void setup(){ size(400, 400); } @Override public void draw(){ fill(123,23,45); ellipseMode(CENTER); ellipse(32,65,40,40); }; }
Come si fa?

Rispondi quotando