From b7e7dd4b38b89242982d0b7304a1de3b194456ee Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 7 Sep 2020 03:49:04 +0200 Subject: JogAmp: Change Java3D + vecmath packages to jogamp.* ; Fix Color3f ctor passing AWT Color.getRGBColorComponents(null), lost AWT Color arg ctor variant --- logo/src/xlogo/Logo.java | 2 +- logo/src/xlogo/kernel/DrawPanel.java | 1166 ++++++++++---------- logo/src/xlogo/kernel/LaunchPrimitive.java | 2 +- logo/src/xlogo/kernel/perspective/Element3D.java | 4 +- logo/src/xlogo/kernel/perspective/ElementLine.java | 33 +- .../src/xlogo/kernel/perspective/ElementPoint.java | 27 +- .../xlogo/kernel/perspective/ElementPolygon.java | 21 +- logo/src/xlogo/kernel/perspective/LightDialog.java | 30 +- logo/src/xlogo/kernel/perspective/MyFog.java | 12 +- logo/src/xlogo/kernel/perspective/MyLight.java | 22 +- logo/src/xlogo/kernel/perspective/Viewer3D.java | 40 +- 11 files changed, 683 insertions(+), 676 deletions(-) diff --git a/logo/src/xlogo/Logo.java b/logo/src/xlogo/Logo.java index 41a399c..a82bc5c 100644 --- a/logo/src/xlogo/Logo.java +++ b/logo/src/xlogo/Logo.java @@ -34,7 +34,7 @@ */ package xlogo; -import javax.media.j3d.VirtualUniverse; +import org.jogamp.java3d.VirtualUniverse; import javax.swing.UIManager; import javax.swing.SwingUtilities; diff --git a/logo/src/xlogo/kernel/DrawPanel.java b/logo/src/xlogo/kernel/DrawPanel.java index 10e61ae..803baa8 100644 --- a/logo/src/xlogo/kernel/DrawPanel.java +++ b/logo/src/xlogo/kernel/DrawPanel.java @@ -1,29 +1,29 @@ /* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Loic Le Coq * Copyright (C) 2013 Marko Zivkovic - * + * * Contact Information: marko88zivkovic at gmail dot com - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. This program is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the - * GNU General Public License along with this program; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. This program is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the + * GNU General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic * during his Bachelor thesis at the computer science department of ETH Zurich, * in the year 2013 and/or during future work. - * + * * It is a reengineered version of XLogo written by Loic Le Coq, published * under the GPL License at http://xlogo.tuxfamily.org/ - * + * * Contents of this file were initially written by Loic Le Coq, - * modifications, extensions, refactorings might have been applied by Marko Zivkovic + * modifications, extensions, refactorings might have been applied by Marko Zivkovic */ package xlogo.kernel; @@ -48,7 +48,7 @@ import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Transparency; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; import java.awt.FontMetrics; import java.awt.Stroke; @@ -71,7 +71,7 @@ import java.awt.image.CropImageFilter; import java.awt.image.ReplicateScaleFilter; import java.awt.image.FilteredImageSource; -import com.sun.j3d.utils.geometry.Text2D; +import org.jogamp.java3d.utils.geometry.Text2D; import javax.swing.ImageIcon; import javax.swing.SwingUtilities; @@ -82,10 +82,10 @@ import java.math.BigDecimal; import javax.swing.JPanel; import javax.imageio.ImageIO; -import javax.media.j3d.*; -import javax.vecmath.Vector3d; -import javax.vecmath.Matrix3d; -import javax.vecmath.Point3d; +import org.jogamp.java3d.*; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Matrix3d; +import org.jogamp.vecmath.Point3d; import java.util.Stack; import java.util.Set; @@ -108,16 +108,16 @@ import xlogo.kernel.gui.*; import xlogo.kernel.perspective.*; /** * Title : XLogo - * Description : XLogo is an interpreter for the Logo + * Description : XLogo is an interpreter for the Logo * programming language * @author Loïc Le Coq */ public class DrawPanel extends JPanel implements MouseMotionListener,MouseListener { - public static final LogoTypeNull nullType=new LogoTypeNull(); + public static final LogoTypeNull nullType=new LogoTypeNull(); private static final long serialVersionUID = 1L; public Turtle tortue; - public Turtle[] tortues; - + public Turtle[] tortues; + /** * When a turtle is active on screen, its number is added to this stack * @uml.property name="tortues_visibles" @@ -146,7 +146,7 @@ import xlogo.kernel.perspective.*; protected static final int WINDOW_CLOSE=2; /** * Perspective MODE
- * The screen is a projection of the 3D universe + * The screen is a projection of the 3D universe */ protected static final int WINDOW_3D=3; @@ -156,15 +156,15 @@ import xlogo.kernel.perspective.*; public final static boolean MODE_ANIMATION=false; /** Classic mode */ public final static boolean MODE_CLASSIC=true; - + /** - * default predefined colors + * default predefined colors */ public static final Color[] defaultColors={Color.BLACK,Color.RED,Color.GREEN,Color.YELLOW,Color.BLUE, Color.MAGENTA,Color.CYAN,Color.WHITE,Color.GRAY,Color.LIGHT_GRAY,new Color(128,0,0),new Color(0,128,0), new Color(0,0,128),new Color(255,128,0),Color.PINK,new Color(128,0,255),new Color(153,102,0)}; - + /** * The id for the drawing font (with primitive label) * @uml.property name="police_etiquette" @@ -176,9 +176,9 @@ import xlogo.kernel.perspective.*; */ private Color couleurfond = Color.white; private Shape shape=null; - private Line2D line; + private Line2D line; private Rectangle2D rec; - private Application cadre; + private final Application cadre; /** This Image is used for Buffering the drawing*/ public static BufferedImage dessin; /** @@ -189,22 +189,22 @@ import xlogo.kernel.perspective.*; /** The scale for the zoom*/ public static double zoom=1; - + /** * All Gui Objects on the drawing area are stored in the GuiMap gm * @uml.property name="gm" * @uml.associationEnd multiplicity="(1 1)" */ - private GuiMap gm; + private final GuiMap gm; /** * The Stroke for the triangle turtle * @uml.property name="crayon_triangle" */ - private BasicStroke crayon_triangle = new BasicStroke(1); + private final BasicStroke crayon_triangle = new BasicStroke(1); /** * Tools for 3D Mode * @uml.property name="w3d" - * @uml.associationEnd + * @uml.associationEnd */ private World3D w3d=null; /** @@ -216,7 +216,7 @@ import xlogo.kernel.perspective.*; protected final static int record3D_LINE=2; protected final static int record3D_POINT=3; protected final static int record3D_TEXT=4; - + /** * Boolean that indicates if the interpreter is recording polygon in 2D Mode */ @@ -224,10 +224,10 @@ import xlogo.kernel.perspective.*; private final static int record2D_NONE=0; private final static int record2D_POLYGON=1; private Vector stackTriangle; - - + + protected static Element3D poly; - + private double[] coords; private double oldx; private double oldy; @@ -250,11 +250,11 @@ import xlogo.kernel.perspective.*; * @uml.property name="possouris" */ private String possouris="[ 0 0 ] "; // Coordonnées du point du dernier événement souris - + /** * Notify if a mouse event has occured * @uml.property name="lissouris" - */ + */ private boolean lissouris=false; //Indique si un événement souris est intervenu depuis le debut du programme /** * The rectangular selection zone @@ -271,7 +271,7 @@ import xlogo.kernel.perspective.*; * @uml.property name="origine" */ Point origine; - public DrawPanel(Application cadre){ + public DrawPanel(final Application cadre){ this.gm= cadre.getKernel().getWorkspace().getGuiMap(); setLayout(null); this.setPreferredSize(new Dimension( @@ -286,54 +286,54 @@ import xlogo.kernel.perspective.*; * This method is used to draw for primitive "forward" * @param arg LogoType which represents the number of steps to move */ - protected LogoType av(LogoType number){ + protected LogoType av(final LogoType number){ if (number.isException()) return number; - LogoNumber ln=(LogoNumber)number; + final LogoNumber ln=(LogoNumber)number; return av(ln.getValue()); - + } /** * This method is used to draw for primitive "backward" * @param arg LogoType which represents the number of steps to move */ - protected LogoType re(LogoType number){ + protected LogoType re(final LogoType number){ if (number.isException()) return number; - LogoNumber ln=(LogoNumber)number; + final LogoNumber ln=(LogoNumber)number; return av(-ln.getValue()); - + } /** * This method is used to draw for primitive "right" * @param arg LogoType which represents the number of steps to rotate */ - protected LogoType td(LogoType number){ + protected LogoType td(final LogoType number){ if (number.isException()) return number; - LogoNumber ln=(LogoNumber)number; + final LogoNumber ln=(LogoNumber)number; return td(ln.getValue()); - + } /** * This method is used to draw for primitive "left" * @param arg LogoType which represents the number of steps to rotate */ - protected LogoType tg(LogoType number){ + protected LogoType tg(final LogoType number){ if (number.isException()) return number; - LogoNumber ln=(LogoNumber)number; + final LogoNumber ln=(LogoNumber)number; return td(-ln.getValue()); - + } - + /** * This method is used to draw for primitive "forward" and "backward" * @param arg Number of steps */ - protected LogoType av(double arg) { + protected LogoType av(final double arg) { // Graphics2D g=(Graphics2D)dessin.getGraphics(); - + oldx = tortue.corX; oldy = tortue.corY; if (DrawPanel.WINDOW_MODE == DrawPanel.WINDOW_CLASSIC) { //mode fenetre montrecacheTortue(false); - + tortue.corX = tortue.corX + arg * Math.cos(tortue.angle); tortue.corY = tortue.corY - arg @@ -358,15 +358,15 @@ import xlogo.kernel.perspective.*; } else if (oldx==tortue.corX){ if (oldy coords[1]) angle = 0; else angle = 180; - } + } else { angle = Math.toDegrees(Math.atan(Math .abs(coords[0] - tortue.corX) @@ -702,22 +702,22 @@ import xlogo.kernel.perspective.*; else if (coords[0] < tortue.corX && coords[1] < tortue.corY) angle = 360 - angle; // 4eme quadrant } - return angle; + return angle; } /** * Draw with the primitive "setposition" in 2D mode or 3D * @param liste The list with the coordinates to move * @throws LogoError If the coordinates are invalid */ - protected void fpos(String liste) throws LogoError { + protected void fpos(final String liste) throws LogoError { initCoords(); oldx = tortue.corX; oldy = tortue.corY; - extractCoords(liste,Utils.primitiveName("drawing.fpos")); + extractCoords(liste,Utils.primitiveName("drawing.fpos")); montrecacheTortue(false); if (enabled3D()) { tortue.X = coords[0]; - tortue.Y = coords[1]; + tortue.Y = coords[1]; tortue.Z = coords[2]; } coords=toScreenCoord(coords,true); @@ -741,9 +741,9 @@ import xlogo.kernel.perspective.*; } else if (oldx==tortue.corX){ if (oldy(); + if (DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP) centers=new Vector(); arc2D(tortue.corX,tortue.corY,rayon,fangle,angle); /* if (null==gp) gp=new GeneralPath(); @@ -816,14 +816,14 @@ import xlogo.kernel.perspective.*; tortue.corY-rayon-tortue.getPenWidth(), 2*(rayon+tortue.getPenWidth()),2*(rayon+tortue.getPenWidth()));*/ clip(); - + } else{ arcCircle3D(rayon,fangle,angle); } - montrecacheTortue(true); + montrecacheTortue(true); } - private void arc2D(double x, double y, double radius,double fangle, double angle){ + private void arc2D(final double x, final double y, final double radius,final double fangle, final double angle){ arc.setArcByCenter(x,y,radius, fangle,angle, Arc2D.OPEN); if (tortue.isPenReverse()) { @@ -835,11 +835,11 @@ import xlogo.kernel.perspective.*; } g.draw(arc); clip(); - - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + if (DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP){ if (x+radius>w&& x<=w){ pt=new Point2D.Double(-w+x,y); @@ -871,13 +871,13 @@ import xlogo.kernel.perspective.*; } } } - - - private void arcCircle3D(double radius,double angleStart,double angleExtent) throws LogoError{ + + + private void arcCircle3D(final double radius,final double angleStart,final double angleExtent) throws LogoError{ if (null==arc) arc=new Arc2D.Double(); arc.setArcByCenter(0,0,radius, angleStart,angleExtent, Arc2D.OPEN); - Shape s=transformShape(arc); + final Shape s=transformShape(arc); if (tortue.isPenReverse()) { g.setColor(couleurfond); g.setXORMode(tortue.couleurcrayon); @@ -890,25 +890,25 @@ import xlogo.kernel.perspective.*; recordArcCircle3D(radius,angleStart,angleExtent); } } - - + + /** - * - * returns the color for the pixel "ob" + * + * returns the color for the pixel "ob" * @param liste: The list containing the coordinates of the pixel * @return Color of this pixel - * @throws LogoError If the list doesn't contain coordinates + * @throws LogoError If the list doesn't contain coordinates */ - protected Color guessColorPoint(String liste) throws LogoError { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); + protected Color guessColorPoint(final String liste) throws LogoError { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); initCoords(); extractCoords(liste,Utils.primitiveName("tc")); coords=toScreenCoord(coords,false); int couleur = -1; - int x=(int)coords[0]; - int y=(int)coords[1]; + final int x=(int)coords[0]; + final int y=(int)coords[1]; if (0 < x && x < w && 0 < y && y < h) { couleur = DrawPanel.dessin.getRGB(x, y); } @@ -917,26 +917,26 @@ import xlogo.kernel.perspective.*; /** * This method draw a circle from the turtle position on the drawing area * @param radius The radius of the circle - * @throws LogoError + * @throws LogoError */ - protected void circle(double radius) throws LogoError { + protected void circle(final double radius) throws LogoError { montrecacheTortue(false); if (null==arc) arc=new Arc2D.Double(); if (!enabled3D()){ - if (DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP) centers=new Vector(); + if (DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP) centers=new Vector(); circle2D(tortue.corX,tortue.corY,radius); /* if (null==clipArc) clipArc=new Arc2D.Double(); clipArc.setArcByCenter(tortue.corX,tortue.corY, rayon+2+tortue.getPenWidth(),0,360, Arc2D.OPEN);*/ } - else{ + else{ circle3D(radius); } montrecacheTortue(true); // on efface la tortue si elle st visible } /** * This method draws a circle in 2D mode in WRAP mode, makes recursion to draw all circle part on the screen - * @param x x circle center + * @param x x circle center * @param y y circle center * @param circle radius * @uml.property name="pt" @@ -946,14 +946,14 @@ import xlogo.kernel.perspective.*; * @uml.property name="centers" */ private Vector centers; - private void circle2D(double x,double y, double radius){ - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + private void circle2D(final double x,final double y, final double radius){ + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + arc.setArcByCenter(x,y,radius, 0,360, Arc2D.OPEN); - + if (tortue.isPenReverse()) { g.setColor(couleurfond); g.setXORMode(tortue.couleurcrayon); @@ -992,18 +992,18 @@ import xlogo.kernel.perspective.*; circle2D(x,-h+y,radius); } } - } + } } - + /** * used for drawing with primitive "dot" * @param liste The list with the dot coordinates * @throws LogoError If the list is invalid coordinates */ - protected void point(String liste) throws LogoError { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); + protected void point(final String liste) throws LogoError { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); initCoords(); extractCoords(liste,Utils.primitiveName("drawing.point")); coords=toScreenCoord(coords,true); @@ -1012,32 +1012,32 @@ import xlogo.kernel.perspective.*; if (tortue.isPenReverse()) { g.setColor(couleurfond); g.setXORMode(tortue.couleurcrayon); - + } else { g.setColor(tortue.couleurcrayon); g.setPaintMode(); - } + } if (rec==null) rec=new Rectangle2D.Double(); // High quality if (uc.getQuality()==DrawQuality.HIGH){ - double width=tortue.getPenWidth(); + final double width=tortue.getPenWidth(); rec.setRect(coords[0]-width+0.5,coords[1]-width+0.5, 2*width,2*width); } // Normal or Low Quality else{ // penWidth is 2k or 2k+1?? - int intWidth=(int)(2*tortue.getPenWidth()+0.5); + final int intWidth=(int)(2*tortue.getPenWidth()+0.5); if (intWidth%2==1){ - double width=tortue.getPenWidth()-0.5; + final double width=tortue.getPenWidth()-0.5; // System.out.println(coords[0]+" "+coords[1]); rec.setRect(coords[0]-width,coords[1]-width, 2*width+1,2*width+1); } else { - double width=tortue.getPenWidth(); + final double width=tortue.getPenWidth(); rec.setRect(coords[0]-width,coords[1]-width, - 2*width,2*width); + 2*width,2*width); } } if (uc.getPenShape()==PenShape.SQUARE){ // MAKE ENUM @@ -1051,22 +1051,22 @@ import xlogo.kernel.perspective.*; clip(); } } - - - + + + /** - * @throws LogoError - * + * @throws LogoError + * */ - private void circle3D(double radius) throws LogoError{ - + private void circle3D(final double radius) throws LogoError{ + // In camera world, // the circle is the intersection of // - a plane with the following equation: ax+by+cz+d=0 <-> f(x,y,z)=0 // - and a sphere with the following equation: (x-tx)^2+(y-ty)^2+(z-tz)^2=R^2 <-> g(x,y,z)=0 // I found the cone equation resolving f(x/lambda,y/lambda,z/lambda)=0=g(x/lambda,y/lambda,z/lambda) - - double[] v=new double[3]; + + final double[] v=new double[3]; for(int i=0;i<3;i++){ v[i]=tortue.getRotationMatrix()[i][2]; } @@ -1075,42 +1075,42 @@ import xlogo.kernel.perspective.*; v[2]+=w3d.zCamera; w3d.toCameraWorld(v); // Now v contains coordinates of a normal vector to the plane in camera world coordinates - double a=v[0]; - double b=v[1]; - double c=v[2]; - + final double a=v[0]; + final double b=v[1]; + final double c=v[2]; + // We convert the turtle coordinates v[0]=tortue.X; v[1]=tortue.Y; v[2]=tortue.Z; w3d.toCameraWorld(v); - - double x=v[0]; - double y=v[1]; - double z=v[2]; + + final double x=v[0]; + final double y=v[1]; + final double z=v[2]; // We calculate the number d for the plane equation - double d=-a*x-b*y-c*z; - + final double d=-a*x-b*y-c*z; + // We have to work with Bigdecimal because of precision problems - - BigDecimal[] big=new BigDecimal[6]; - BigDecimal bx=new BigDecimal(x); - BigDecimal by=new BigDecimal(y); - BigDecimal bz=new BigDecimal(z); - BigDecimal ba=new BigDecimal(a); - BigDecimal bb=new BigDecimal(b); - BigDecimal bc=new BigDecimal(c); - BigDecimal bd=new BigDecimal(d); - BigDecimal deux=new BigDecimal("2"); - BigDecimal screenDistance=new BigDecimal(w3d.screenDistance); - BigDecimal bradius=new BigDecimal(String.valueOf(radius)); - + + final BigDecimal[] big=new BigDecimal[6]; + final BigDecimal bx=new BigDecimal(x); + final BigDecimal by=new BigDecimal(y); + final BigDecimal bz=new BigDecimal(z); + final BigDecimal ba=new BigDecimal(a); + final BigDecimal bb=new BigDecimal(b); + final BigDecimal bc=new BigDecimal(c); + final BigDecimal bd=new BigDecimal(d); + final BigDecimal deux=new BigDecimal("2"); + final BigDecimal screenDistance=new BigDecimal(w3d.screenDistance); + final BigDecimal bradius=new BigDecimal(String.valueOf(radius)); + // Now we calculate the coefficient for the conic ax^2+bxy+cy^2+dx+ey+f=0 // Saved in an array - + // lambda=(x*x+y*y+z*z-radius*radius); - BigDecimal lambda=bx.pow(2).add(by.pow(2)).add(bz.pow(2)).subtract(bradius.pow(2)); - + final BigDecimal lambda=bx.pow(2).add(by.pow(2)).add(bz.pow(2)).subtract(bradius.pow(2)); + // x^2 coeff // d*d+2*d*x*a+a*a*lambda; big[0]=bd.pow(2).add(bd.multiply(bx).multiply(ba).multiply(deux)).add(ba.pow(2).multiply(lambda)); @@ -1135,25 +1135,25 @@ import xlogo.kernel.perspective.*; } } /** - * This method records this circle in the polygon's List + * This method records this circle in the polygon's List * @param radius The circle's radius * @param angleStart The starting Angle * @param angleExtent The angle for the sector - * @throws LogoError + * @throws LogoError */ - public void recordArcCircle3D(double radius,double angleStart,double angleExtent) throws LogoError{ - double[][] d=tortue.getRotationMatrix(); - Matrix3d m=new Matrix3d(d[0][0],d[0][1],d[0][2],d[1][0],d[1][1],d[1][2],d[2][0],d[2][1],d[2][2]); + public void recordArcCircle3D(final double radius,final double angleStart,final double angleExtent) throws LogoError{ + final double[][] d=tortue.getRotationMatrix(); + final Matrix3d m=new Matrix3d(d[0][0],d[0][1],d[0][2],d[1][0],d[1][1],d[1][2],d[2][0],d[2][1],d[2][2]); // Vector X - Point3d v1=new Point3d(radius/1000,0,0); - Transform3D t=new Transform3D(m,new Vector3d(),1); + final Point3d v1=new Point3d(radius/1000,0,0); + final Transform3D t=new Transform3D(m,new Vector3d(),1); t.transform(v1); // Vector Y - Point3d v2=new Point3d(0,radius/1000,0); + final Point3d v2=new Point3d(0,radius/1000,0); t.transform(v2); // Turtle position - Point3d pos=new Point3d(tortue.X/1000,tortue.Y/1000,tortue.Z/1000); + final Point3d pos=new Point3d(tortue.X/1000,tortue.Y/1000,tortue.Z/1000); int indexMax=(int)angleExtent; if (indexMax!=angleExtent) indexMax+=2; else indexMax+=1; @@ -1168,28 +1168,28 @@ import xlogo.kernel.perspective.*; } for(int i=0;i w|| ny < 0 || ny > h) return trouve_longueur(mini, milieu, oldx, oldy); else @@ -1238,16 +1238,16 @@ import xlogo.kernel.perspective.*; * @param oldx X position * @param oldy Y position */ - private void trace_enroule(double arg, double oldx, double oldy) { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + private void trace_enroule(double arg, final double oldx, final double oldy) { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + boolean re = false; if (arg < 0) { re = true; } - double diagonale=Math.sqrt(Math.pow(w,2)+Math.pow(h,2))+1; + final double diagonale=Math.sqrt(Math.pow(w,2)+Math.pow(h,2))+1; double longueur; if (re) longueur = trouve_longueur(0, -diagonale, oldx, oldy); @@ -1266,7 +1266,7 @@ import xlogo.kernel.perspective.*; if (uc.getTurtleSpeed() != 0) { try { Thread.sleep(uc.getTurtleSpeed() * 5); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { } } if (tortue.isVisible()) @@ -1315,14 +1315,14 @@ import xlogo.kernel.perspective.*; * @param arg The length to forward * @throws LogoError */ - private void trace_ferme(double oldx, double oldy, double arg) throws LogoError { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + private void trace_ferme(final double oldx, final double oldy, final double arg) throws LogoError { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + boolean re = false; double longueur; - double diagonale=Math.sqrt(Math.pow(w,2)+Math.pow(h,2))+1; + final double diagonale=Math.sqrt(Math.pow(w,2)+Math.pow(h,2))+1; if (arg < 0) re = true; if (re) @@ -1348,9 +1348,9 @@ import xlogo.kernel.perspective.*; * @param prim The calling primitive * @throws LogoError If List isn't a list coordinate */ - - private void extractCoords(String liste,String prim)throws LogoError{ - StringTokenizer st = new StringTokenizer(liste); + + private void extractCoords(final String liste,final String prim)throws LogoError{ + final StringTokenizer st = new StringTokenizer(liste); try { for(int i=0;i * size 2 for 2D coordinates
* size 3 for 3D coordinates */ - + private void initCoords(){ if (null==coords) coords=new double[2]; if (enabled3D()){ if (coords.length!=3) coords=new double[3]; - } + } else { if (coords.length!=2) coords=new double[2]; } @@ -1468,7 +1468,7 @@ import xlogo.kernel.perspective.*; g.setXORMode(couleurfond); g.setColor(tortue.couleurcrayon); tortue.drawTriangle(); - BasicStroke crayon_actuel = (BasicStroke) g.getStroke(); + final BasicStroke crayon_actuel = (BasicStroke) g.getStroke(); if (crayon_actuel.getLineWidth() == 1) g.draw(tortue.triangle); else { @@ -1478,10 +1478,10 @@ import xlogo.kernel.perspective.*; } } else { g.setXORMode(couleurfond); - double angle = Math.PI / 2 - tortue.angle; - float x = (float) (tortue.corX * Math.cos(angle) + tortue.corY + final double angle = Math.PI / 2 - tortue.angle; + final float x = (float) (tortue.corX * Math.cos(angle) + tortue.corY * Math.sin(angle)); - float y = (float) (-tortue.corX * Math.sin(angle) + tortue.corY + final float y = (float) (-tortue.corX * Math.sin(angle) + tortue.corY * Math.cos(angle)); g.rotate(angle); g.drawImage(tortue.tort, (int) x - tortue.largeur / 2, @@ -1495,25 +1495,25 @@ import xlogo.kernel.perspective.*; tortue.gabarit * 2); */ clip(); - + /* clip((int) (tortue.corX - tortue.gabarit), (int) (tortue.corY - tortue.gabarit), tortue.gabarit * 2, tortue.gabarit * 2);*/ } /** * When the turtle has to be redrawn, this method erase the turtle on the drawing screen - * + * */ - protected void montrecacheTortue(boolean b) { + protected void montrecacheTortue(final boolean b) { g.setColor(couleurfond); for (int i = 0; i < tortues_visibles.size(); i++) { - int id = Integer.parseInt(tortues_visibles.get(i)); + final int id = Integer.parseInt(tortues_visibles.get(i)); // Turtle triangle if (null == tortues[id].tort) { g.setXORMode(couleurfond); g.setColor(tortues[id].couleurmodedessin); tortues[id].drawTriangle(); - BasicStroke crayon_actuel = (BasicStroke) g.getStroke(); + final BasicStroke crayon_actuel = (BasicStroke) g.getStroke(); if (crayon_actuel.getLineWidth() == 1) g.draw(tortues[id].triangle); else { @@ -1524,10 +1524,10 @@ import xlogo.kernel.perspective.*; } else { // Image turtle g.setXORMode(couleurfond); - double angle = Math.PI / 2 - tortues[id].angle; - float x = (float) (tortues[id].corX * Math.cos(angle) + tortues[id].corY + final double angle = Math.PI / 2 - tortues[id].angle; + final float x = (float) (tortues[id].corX * Math.cos(angle) + tortues[id].corY * Math.sin(angle)); - float y = (float) (-tortues[id].corX * Math.sin(angle) + tortues[id].corY + final float y = (float) (-tortues[id].corX * Math.sin(angle) + tortues[id].corY * Math.cos(angle)); g.rotate(angle); g.drawImage(tortues[id].tort, (int) x @@ -1544,9 +1544,9 @@ import xlogo.kernel.perspective.*; if (b) clip(); } } - - - + + + /* private void montrecacheTortue() { // Graphics2D g=(Graphics2D)dessin.getGraphics(); g.setColor(couleurfond); @@ -1584,7 +1584,7 @@ import xlogo.kernel.perspective.*; tortues[id].corY - tortues[id].gabarit, tortues[id].gabarit * 2, tortues[id].gabarit * 2); - + clip(); // g.dispose(); } @@ -1595,10 +1595,10 @@ import xlogo.kernel.perspective.*; */ protected void videecran() { // Delete all Gui Component - Set set=gm.keySet(); - Iterator it=set.iterator(); + final Set set=gm.keySet(); + final Iterator it=set.iterator(); while(it.hasNext()){ - String element=it.next(); + final String element=it.next(); gui=gm.get(element).getGuiObject(); it.remove(); if (SwingUtilities.isEventDispatchThread()){ @@ -1610,15 +1610,15 @@ import xlogo.kernel.perspective.*; SwingUtilities.invokeAndWait(new Runnable(){ public void run(){ remove(gui); - validate(); + validate(); } }); } - catch(Exception e){} + catch(final Exception e){} } } - - + + // Delete List Polygon in 3D mode // DrawPanel.listPoly=new Vector(); // DrawPanel.listText=new Vector(); @@ -1627,18 +1627,18 @@ import xlogo.kernel.perspective.*; cadre.getViewer3D().clearScreen(); System.gc(); } - - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + g.setPaintMode(); couleurfond=uc.getScreencolor(); g.setColor(uc.getScreencolor()); g.fillRect(0, 0, w,h); stopRecord2DPolygon(); - - // Draw Grid + + // Draw Grid g.setStroke(new BasicStroke(1)); drawGrid(); drawXAxis(); @@ -1647,10 +1647,10 @@ import xlogo.kernel.perspective.*; if (null == tortues[0]) tortues[0] = new Turtle(cadre); // The active turtle will be the turtle 0 - tortue = tortues[0]; + tortue = tortues[0]; tortue.id = 0; // We delete all other turtles - for (int i = 1; i < tortues.length; i++) { + for (int i = 1; i < tortues.length; i++) { tortues[i] = null; } tortues_visibles.removeAllElements(); @@ -1663,16 +1663,16 @@ import xlogo.kernel.perspective.*; montrecacheTortue(true); // Update the selection frame updateColorSelection(); - + } /** * Primitive wash */ protected void nettoie() { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + stopRecord2DPolygon(); g.setPaintMode(); g.setColor(couleurfond); @@ -1707,10 +1707,10 @@ import xlogo.kernel.perspective.*; * @param couleur_frontiere * @return */ - - private int bornes_remplis_zone(int x, int y, int increment, int couleur_frontiere) { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); + + private int bornes_remplis_zone(int x, final int y, final int increment, final int couleur_frontiere) { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); // System.out.println(x+" "+y); while (!meme_couleur(DrawPanel.dessin.getRGB(x, y) ,couleur_frontiere)) { DrawPanel.dessin.setRGB(x, y, couleur_frontiere); @@ -1726,7 +1726,7 @@ import xlogo.kernel.perspective.*; * @param col2 The second color * @return true or false */ - private boolean meme_couleur(int col1,int col2){ + private boolean meme_couleur(final int col1,final int col2){ /* if (Config.quality==Logo.QUALITY_HIGH){ int rouge1 = (col1 >> 16) & 0xFF; int vert1 = (col1 >> 8) & 0xFF; @@ -1764,7 +1764,7 @@ import xlogo.kernel.perspective.*; else bleu=false; } - return rouge&&bleu&| + return rouge&&bleu&| // if (Math.abs(rouge1-rouge2) 0 & x < w & y > 0 & y < h) { - int couleur_origine = DrawPanel.dessin.getRGB(x, y); - int couleur_frontiere = tortue.couleurcrayon.getRGB(); + final int couleur_origine = DrawPanel.dessin.getRGB(x, y); + final int couleur_frontiere = tortue.couleurcrayon.getRGB(); // System.out.println(couleur_origine+" " +couleur_frontiere); - Stack pile_germes = new Stack(); - boolean couleurs_differentes = !meme_couleur(couleur_origine,couleur_frontiere); + final Stack pile_germes = new Stack(); + final boolean couleurs_differentes = !meme_couleur(couleur_origine,couleur_frontiere); if (couleurs_differentes) pile_germes.push(new Point(x, y)); while (!pile_germes.isEmpty()) { - Point p = pile_germes.pop(); - int xgerme = p.x; - int ygerme = p.y; - int xmax = bornes_remplis_zone(xgerme, ygerme, 1, + final Point p = pile_germes.pop(); + final int xgerme = p.x; + final int ygerme = p.y; + final int xmax = bornes_remplis_zone(xgerme, ygerme, 1, couleur_frontiere); int xmin=0; if (xgerme>0) xmin = bornes_remplis_zone(xgerme - 1, ygerme, -1, @@ -1840,10 +1840,10 @@ import xlogo.kernel.perspective.*; * @param couleur_origine * @return */ - private int bornes_remplis(int x, int y, int increment, int couleur_crayon, - int couleur_origine) { - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); + private int bornes_remplis(int x, final int y, final int increment, final int couleur_crayon, + final int couleur_origine) { + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); while (DrawPanel.dessin.getRGB(x, y) == couleur_origine) { DrawPanel.dessin.setRGB(x, y, couleur_crayon); x = x + increment; @@ -1857,26 +1857,26 @@ import xlogo.kernel.perspective.*; */ protected void remplis() { montrecacheTortue(false); - int x = (int) (tortue.corX + 0.5); - int y = (int) (tortue.corY + 0.5); - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + final int x = (int) (tortue.corX + 0.5); + final int y = (int) (tortue.corY + 0.5); + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + if (x > 0 & x < w & y > 0 & y < h) { - int couleur_origine = DrawPanel.dessin.getRGB(x, y); - int couleur_crayon = tortue.couleurcrayon.getRGB(); + final int couleur_origine = DrawPanel.dessin.getRGB(x, y); + final int couleur_crayon = tortue.couleurcrayon.getRGB(); if (x > 0 & x < w & y > 0 & y < h) { - Stack pile_germes = new Stack(); - boolean couleurs_differentes = !(couleur_origine == couleur_crayon); + final Stack pile_germes = new Stack(); + final boolean couleurs_differentes = !(couleur_origine == couleur_crayon); if (couleurs_differentes) pile_germes.push(new Point(x, y)); while (!pile_germes.isEmpty()) { - Point p = pile_germes.pop(); - int xgerme = p.x; - int ygerme = p.y; + final Point p = pile_germes.pop(); + final int xgerme = p.x; + final int ygerme = p.y; // System.out.println(xgerme+" "+ygerme); - int xmax = bornes_remplis(xgerme, ygerme, 1, couleur_crayon, + final int xmax = bornes_remplis(xgerme, ygerme, 1, couleur_crayon, couleur_origine); int xmin=0; if (xgerme>0) xmin = bornes_remplis(xgerme - 1, ygerme, -1, @@ -1917,11 +1917,11 @@ import xlogo.kernel.perspective.*; * Primitive "label" * @param mot The word to write on the drawing area */ - protected void etiquette(String mot) { + protected void etiquette(final String mot) { // Graphics2D g = (Graphics2D) Ardoise.dessin.getGraphics(); montrecacheTortue(false); if (!enabled3D()){ - double angle = Math.PI / 2 - tortue.angle; + final double angle = Math.PI / 2 - tortue.angle; if(DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP) centers=new Vector(); etiquette2D(tortue.corX,tortue.corY,angle,mot); /* g.rotate(angle); @@ -1937,56 +1937,56 @@ import xlogo.kernel.perspective.*; g.rotate(-angle);*/ } else{ - FontRenderContext frc=g.getFontRenderContext(); - GlyphVector gv=g.getFont().createGlyphVector(frc, mot); - Shape outline=gv.getOutline(0, 0); - Shape s=transformShape(outline); + final FontRenderContext frc=g.getFontRenderContext(); + final GlyphVector gv=g.getFont().createGlyphVector(frc, mot); + final Shape outline=gv.getOutline(0, 0); + final Shape s=transformShape(outline); g.setPaintMode(); g.setColor(tortue.couleurcrayon); g.fill(s); if (record3D==DrawPanel.record3D_TEXT){ - Text2D text=new Text2D( - mot,new Color3f(tortue.couleurcrayon), UserConfig.fontes[police_etiquette].getName(), + final Text2D text=new Text2D( + mot,new Color3f(tortue.couleurcrayon.getRGBColorComponents(null)), UserConfig.fontes[police_etiquette].getName(), tortue.police,Font.PLAIN); - + text.setRectangleScaleFactor(0.001f); - Appearance appear=text.getAppearance(); - PolygonAttributes pa=new PolygonAttributes(); + final Appearance appear=text.getAppearance(); + final PolygonAttributes pa=new PolygonAttributes(); pa.setCullFace(PolygonAttributes.CULL_NONE); pa.setBackFaceNormalFlip(true); appear.setPolygonAttributes(pa); text.setAppearance(appear); // if (null==DrawPanel.listText) DrawPanel.listText=new Vector(); - TransformGroup tg=new TransformGroup(); - double[][] d=tortue.getRotationMatrix(); - Matrix3d m=new Matrix3d(d[0][0],d[0][1],d[0][2],d[1][0],d[1][1],d[1][2],d[2][0],d[2][1],d[2][2]); - Transform3D t=new Transform3D(m,new Vector3d(tortue.X/1000,tortue.Y/1000,tortue.Z/1000),1); + final TransformGroup tg=new TransformGroup(); + final double[][] d=tortue.getRotationMatrix(); + final Matrix3d m=new Matrix3d(d[0][0],d[0][1],d[0][2],d[1][0],d[1][1],d[1][2],d[2][0],d[2][1],d[2][2]); + final Transform3D t=new Transform3D(m,new Vector3d(tortue.X/1000,tortue.Y/1000,tortue.Z/1000),1); tg.setTransform(t); tg.addChild(text); cadre.getViewer3D().add2DText(tg); // DrawPanel.listText.add(tg); } - - + + } montrecacheTortue(true); if (classicMode) repaint(); } - private void etiquette2D(double x,double y, double angle, String word){ + private void etiquette2D(final double x,final double y, final double angle, final String word){ if (word.length()==0) return; - + g.setPaintMode(); g.setColor(tortue.couleurcrayon); - Font f= UserConfig.fontes[police_etiquette] + final Font f= UserConfig.fontes[police_etiquette] .deriveFont((float) tortue.police); - g.setFont(f); + g.setFont(f); g.translate(x, y); g.rotate(angle); - FontRenderContext frc = g.getFontRenderContext(); - TextLayout layout = new TextLayout(word, f, frc); - Rectangle2D bounds = layout.getBounds(); - float height=(float)bounds.getHeight(); - float width=(float)bounds.getWidth(); + final FontRenderContext frc = g.getFontRenderContext(); + final TextLayout layout = new TextLayout(word, f, frc); + final Rectangle2D bounds = layout.getBounds(); + final float height=(float)bounds.getHeight(); + final float width=(float)bounds.getWidth(); float x1=0,y1=0; switch(tortue.getLabelHorizontalAlignment()){ case Turtle.LABEL_HORIZONTAL_ALIGNMENT_LEFT: @@ -2015,20 +2015,20 @@ import xlogo.kernel.perspective.*; g.rotate(-angle); g.translate(-x, -y); if (DrawPanel.WINDOW_MODE==DrawPanel.WINDOW_WRAP){ - Rectangle2D.Double rec=new Rectangle2D.Double(0,0,width,height); - AffineTransform at=new AffineTransform(); + final Rectangle2D.Double rec=new Rectangle2D.Double(0,0,width,height); + final AffineTransform at=new AffineTransform(); at.translate(x, y); at.rotate(angle); - Rectangle2D bound =at.createTransformedShape(rec).getBounds2D(); - double right= bound.getX()+bound.getWidth()-x; - double left= x-bound.getX(); - double up=y-bound.getY(); - double down=bound.getY()+bound.getHeight()-y; - - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + final Rectangle2D bound =at.createTransformedShape(rec).getBounds2D(); + final double right= bound.getX()+bound.getWidth()-x; + final double left= x-bound.getX(); + final double up=y-bound.getY(); + final double down=bound.getY()+bound.getHeight()-y; + + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + if (x+right>w&& x<=w){ pt=new Point2D.Double(-w+x,y); if (! centers.contains(pt)) { @@ -2059,20 +2059,20 @@ import xlogo.kernel.perspective.*; } } } - + /** - * This method transform a plane 2D shape in the shape corresponding to the turtle plane + * This method transform a plane 2D shape in the shape corresponding to the turtle plane * @param s the first shape * @return the new shape after transformation */ - private Shape transformShape(Shape s){ - PathIterator it=s.getPathIterator(null); - double[] d=new double[6]; + private Shape transformShape(final Shape s){ + final PathIterator it=s.getPathIterator(null); + final double[] d=new double[6]; double[][] coor=new double[3][1]; - GeneralPath gp=new GeneralPath(); - double[] end=new double[3]; - double[] ctl1=new double[3]; - double[] ctl2=new double[3]; + final GeneralPath gp=new GeneralPath(); + final double[] end=new double[3]; + final double[] ctl1=new double[3]; + final double[] ctl2=new double[3]; boolean b=false; while(!it.isDone()){ it.next(); @@ -2088,7 +2088,7 @@ import xlogo.kernel.perspective.*; end[1]=coor[1][0]+tortue.Y; end[2]=coor[2][0]+tortue.Z; w3d.toScreenCoord(end); - + if (id==PathIterator.SEG_MOVETO) gp.moveTo((float)end[0], (float)end[1]); else if (id==PathIterator.SEG_LINETO) @@ -2108,7 +2108,7 @@ import xlogo.kernel.perspective.*; Point2D p=null; if (s instanceof Arc2D.Double) p=((Arc2D.Double)s).getStartPoint(); - else if (s instanceof GeneralPath) + else if (s instanceof GeneralPath) p=((GeneralPath)s).getCurrentPoint(); coor[0][0]=p.getX(); coor[1][0]=-p.getY(); @@ -2129,8 +2129,8 @@ import xlogo.kernel.perspective.*; ctl1[2]=coor[2][0]+tortue.Z; w3d.toScreenCoord(ctl1); if(id==PathIterator.SEG_QUADTO){ - QuadCurve2D qc=new QuadCurve2D.Double(gp.getCurrentPoint().getX(),gp.getCurrentPoint().getY() - ,end[0], end[1],ctl1[0], ctl1[1]); + final QuadCurve2D qc=new QuadCurve2D.Double(gp.getCurrentPoint().getX(),gp.getCurrentPoint().getY() + ,end[0], end[1],ctl1[0], ctl1[1]); gp.append(qc, true);} else if (id==PathIterator.SEG_CUBICTO){ coor[0][0]=d[4]; @@ -2141,15 +2141,15 @@ import xlogo.kernel.perspective.*; ctl2[0]=coor[0][0]+tortue.X; ctl2[1]=coor[1][0]+tortue.Y; ctl2[2]=coor[2][0]+tortue.Z; - + w3d.toScreenCoord(ctl2); - CubicCurve2D qc=new CubicCurve2D.Double(gp.getCurrentPoint().getX(),gp.getCurrentPoint().getY() - ,end[0], end[1],ctl1[0], ctl1[1],ctl2[0], ctl2[1]); + final CubicCurve2D qc=new CubicCurve2D.Double(gp.getCurrentPoint().getX(),gp.getCurrentPoint().getY() + ,end[0], end[1],ctl1[0], ctl1[1],ctl2[0], ctl2[1]); gp.append(qc, true); } } } - return gp; + return gp; } public World3D getWorld3D(){ return w3d; @@ -2158,7 +2158,7 @@ import xlogo.kernel.perspective.*; * primitive setscreencolor * @param color The Color of the nackground screen */ - protected void fcfg(Color color) { + protected void fcfg(final Color color) { couleurfond=color; updateColorSelection(); if (enabled3D()){ @@ -2172,7 +2172,7 @@ import xlogo.kernel.perspective.*; * Primitive setpencolor * @param color The pen Color */ - protected void fcc(Color color) { + protected void fcc(final Color color) { if (tortue.isVisible()&&null==tortue.tort) montrecacheTortue(false); tortue.couleurcrayon = color; tortue.couleurmodedessin = color; @@ -2186,7 +2186,7 @@ import xlogo.kernel.perspective.*; * @param name The translated name for the primitive "guiposition" * @throws LogoError If coordinates list is invalid */ - protected void guiposition(String id, String liste,String name) throws LogoError{ + protected void guiposition(final String id, final String liste,final String name) throws LogoError{ if (guiExist(id)){ initCoords(); extractCoords(liste,name); @@ -2195,13 +2195,13 @@ import xlogo.kernel.perspective.*; } } /** - * Draw the Gui object refered with "id" + * Draw the Gui object refered with "id" * @param id The Gui Object Id * @throws LogoError If this object doesn't exist */ - protected void guiDraw(String id) throws LogoError{ + protected void guiDraw(final String id) throws LogoError{ if (guiExist(id)){ - GuiComponent gc=gm.get(id); + final GuiComponent gc=gm.get(id); add(gc.getGuiObject()); validate(); repaint(); @@ -2210,7 +2210,7 @@ import xlogo.kernel.perspective.*; } /** * @uml.property name="gui" - * @uml.associationEnd + * @uml.associationEnd */ private javax.swing.JComponent gui; /** @@ -2218,8 +2218,8 @@ import xlogo.kernel.perspective.*; * @param id The Gui Object id * @throws LogoError */ - - protected void guiRemove(String id) throws LogoError{ + + protected void guiRemove(final String id) throws LogoError{ if (guiExist(id)){ gui=gm.get(id).getGuiObject(); gm.remove(id); @@ -2232,21 +2232,21 @@ import xlogo.kernel.perspective.*; SwingUtilities.invokeAndWait(new Runnable(){ public void run(){ remove(gui); - validate(); + validate(); } }); } - catch(Exception e){} + catch(final Exception e){} } repaint(); } } - private StringBuffer extractList(String list) throws LogoError{ - StringBuffer sb=new StringBuffer(); + private StringBuffer extractList(final String list) throws LogoError{ + final StringBuffer sb=new StringBuffer(); int compteur=0; int i=0; while(list.length()!=0){ - char c=list.charAt(i); + final char c=list.charAt(i); if (c=='[') compteur++; else if (c==']') { if (compteur==0) return sb; @@ -2257,10 +2257,10 @@ import xlogo.kernel.perspective.*; } throw new LogoError("[ "+list+" "+Logo.messages.getString("pas_liste")); } - - protected void guiAction(String id, String liste) throws LogoError{ + + protected void guiAction(final String id, String liste) throws LogoError{ if (guiExist(id)){ - GuiComponent gc=gm.get(id); + final GuiComponent gc=gm.get(id); // If gc is a JButton if (gc.isButton()){ ((GuiButton)gc).setAction(Utils.decoupe(liste)); @@ -2276,14 +2276,14 @@ import xlogo.kernel.perspective.*; while(liste.length()!=0){ if (liste.charAt(0)=='['){ liste=liste.substring(1).trim(); - StringBuffer sb=extractList(liste); + final StringBuffer sb=extractList(liste); liste=liste.substring(sb.length()+1).trim(); ((GuiMenu)gc).setAction(sb, i); i++; } else throw new LogoError(liste.charAt(0)+" "+Logo.messages.getString("pas_liste")); } - GuiMenu gm=(GuiMenu)gc; + final GuiMenu gm=(GuiMenu)gc; if (!gm.hasAction){ gm.hasAction=true; ((javax.swing.JComboBox)gc.getGuiObject()).addActionListener(gm); @@ -2291,27 +2291,27 @@ import xlogo.kernel.perspective.*; } } } - private boolean guiExist(String id) throws LogoError{ + private boolean guiExist(final String id) throws LogoError{ if (gm.containsKey(id.toLowerCase())) return true; else throw new LogoError(Logo.messages.getString("no_gui")+" "+id); } // boolean access=false; private void clip(){ if (classicMode){ - + //access=true; // refresh(); - + repaint(); /* if (SwingUtilities.isEventDispatchThread()){ repaint(); } else { try { - + SwingUtilities.invokeLater(new Runnable(){ public void run(){ - repaint(); + repaint(); } }); } @@ -2326,13 +2326,13 @@ import xlogo.kernel.perspective.*; } }*/ } - public void setQuality(DrawQuality q){ + public void setQuality(final DrawQuality q){ /* * Marko Zivkovic * I improved all the qualities for one level. I introduced a super high quality that is assigned to "high" * and dropped the low quality, which is now the old normal/default quality */ - + if (q==DrawQuality.HIGH){ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); @@ -2350,7 +2350,7 @@ import xlogo.kernel.perspective.*; g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } } - public void change_image_tortue(Application cadre, String chemin) { + public void change_image_tortue(final Application cadre, String chemin) { if (tortue.isVisible()) montrecacheTortue(false); if (chemin.equals("tortue0.png")) { @@ -2367,12 +2367,12 @@ import xlogo.kernel.perspective.*; tracker.addImage(tortue.tort, 0); try { tracker.waitForID(0); - } catch (InterruptedException e1) { + } catch (final InterruptedException e1) { } - double largeur_ecran = Toolkit.getDefaultToolkit().getScreenSize() + final double largeur_ecran = Toolkit.getDefaultToolkit().getScreenSize() .getWidth(); // On fait attention à la résolution de l'utilisateur - double facteur = largeur_ecran / 1024.0; + final double facteur = largeur_ecran / 1024.0; if ((int) (facteur + 0.001) != 1) { tortue.largeur = tortue.tort.getWidth(cadre.getFrame()); @@ -2385,7 +2385,7 @@ import xlogo.kernel.perspective.*; tracker.addImage(tortue.tort, 0); try { tracker.waitForID(0); - } catch (InterruptedException e1) { + } catch (final InterruptedException e1) { } } tortue.largeur = tortue.tort.getWidth(cadre.getFrame()); @@ -2397,8 +2397,8 @@ import xlogo.kernel.perspective.*; montrecacheTortue(true); } - // animation - protected void setAnimation(boolean predic){ + // animation + protected void setAnimation(final boolean predic){ if (predic==classicMode){ if (predic) { cadre.getHistoryPanel().active_animation(); @@ -2409,48 +2409,48 @@ import xlogo.kernel.perspective.*; } } } - - protected void setGraphicsFont(Font f){ + + protected void setGraphicsFont(final Font f){ g.setFont(f); } protected Font getGraphicsFont(){ return g.getFont(); } - protected void setStroke(Stroke st){ + protected void setStroke(final Stroke st){ g.setStroke(st); } public Color getBackgroundColor(){ return couleurfond; } - protected void setBackgroundColor(Color c){ + protected void setBackgroundColor(final Color c){ couleurfond=c; } protected void updateColorSelection(){ - float r=(255-couleurfond.getRed())/255; - float v=(255-couleurfond.getGreen())/255; - float b=(255-couleurfond.getBlue())/255; + final float r=(255-couleurfond.getRed())/255; + final float v=(255-couleurfond.getGreen())/255; + final float b=(255-couleurfond.getBlue())/255; colorSelection=new Color(r,v,b,0.2f); } - public void setNumberOfTurtles(int max){ + public void setNumberOfTurtles(final int max){ WSManager.getUserConfig().setMaxTurtles(max); - Turtle[] tampon = tortues.clone(); + final Turtle[] tampon = tortues.clone(); tortues = new Turtle[max]; - int borne_sup=Math.min(tampon.length,tortues.length); + final int borne_sup=Math.min(tampon.length,tortues.length); for(int i=0;i-1;i--){ - int integer=Integer.parseInt(tortues_visibles.get(i)); + final int integer=Integer.parseInt(tortues_visibles.get(i)); if (integer>=max){ tortues_visibles.remove(i); } } } protected void initGraphics(){ - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + police_etiquette=UserConfig.police_id(WSManager.getWorkspaceConfig().getFont()); // init all turtles tortues = new Turtle[uc.getMaxTurtles()]; @@ -2459,7 +2459,7 @@ import xlogo.kernel.perspective.*; tortues[0] = tortue; tortue.id = 0; tortues_visibles.push("0"); - for (int i = 1; i < tortues.length; i++) { + for (int i = 1; i < tortues.length; i++) { // All other turtles are null tortues[i] = null; } @@ -2472,9 +2472,9 @@ import xlogo.kernel.perspective.*; if (!enabled3D()){ drawGrid(); drawXAxis(); - drawYAxis(); + drawYAxis(); } - MediaTracker tracker; + MediaTracker tracker; if (0==uc.getActiveTurtle()) { g.setXORMode(couleurfond); tortue.drawTriangle(); @@ -2486,52 +2486,52 @@ import xlogo.kernel.perspective.*; tracker=new MediaTracker(cadre.getFrame()); tracker.addImage(tortue.tort,0); try{tracker.waitForID(0);} - catch(InterruptedException e){} + catch(final InterruptedException e){} if (tracker.checkID(0)) g.drawImage(tortue.tort, w/2 - tortue.largeur / 2, h/2 - tortue.hauteur/2, this); } updateColorSelection(); } - - private void resizeAllGuiComponents(double d){ + + private void resizeAllGuiComponents(final double d){ // Resize all GuiComponent - Set set=gm.keySet(); - Iterator it=set.iterator(); + final Set set=gm.keySet(); + final Iterator it=set.iterator(); while (it.hasNext()){ - String element=it.next(); - GuiComponent gui=gm.get(element); + final String element=it.next(); + final GuiComponent gui=gm.get(element); gui.getGuiObject().setSize((int)(gui.getOriginalWidth()*d), (int)(gui.getOriginalHeight()*d) ); - Font f=gui.getGuiObject().getFont(); + final Font f=gui.getGuiObject().getFont(); gui.getGuiObject().setFont(f.deriveFont((float)(WSManager.getWorkspaceConfig().getFont().getSize()*d))); - double x=gui.getLocation().x/zoom; - double y=gui.getLocation().y/zoom; + final double x=gui.getLocation().x/zoom; + final double y=gui.getLocation().y/zoom; gui.setLocation((int)(x*d),(int)(y*d)); - + } - + } - - + + /** * Make a zoom on the drawing area * @param d The absolute factor */ - public void zoom(double d, boolean zoomIn){ + public void zoom(double d, final boolean zoomIn){ // Disable zoom buttons //cadre.setZoomEnabled(false); // TODO REMOVE ZOOM COMPLETELY? - - javax.swing.JViewport jv=cadre.scrollArea.getViewport(); + + final javax.swing.JViewport jv=cadre.scrollArea.getViewport(); Point p=jv.getViewPosition(); - Rectangle r=jv.getVisibleRect(); + final Rectangle r=jv.getVisibleRect(); + - // If a selection rectangle is displaying on the drawing area // And If zoomout has been pressed - // Zooming on the rectangular selection + // Zooming on the rectangular selection if (null!=selection&&cadre.commande_isEditable()&&zoomIn){ - int originalWidth=jv.getWidth(); - double width=selection.getWidth(); + final int originalWidth=jv.getWidth(); + final double width=selection.getWidth(); d=zoom*originalWidth/width; p=selection.getLocation(); r.width=selection.width; @@ -2542,11 +2542,11 @@ import xlogo.kernel.perspective.*; } // Resize all Gui Components on the drawing area resizeAllGuiComponents(d); - - double oldZoom=zoom; + + final double oldZoom=zoom; zoom=d; - /* + /* * ------------------------------------- * | | * | ------------------------- | @@ -2558,46 +2558,46 @@ import xlogo.kernel.perspective.*; * | ------------------------- | * ------------------------------------- * */ - - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - - double dx=Math.min(r.width,w*oldZoom)/2; - double dy=Math.min(r.height,h*oldZoom)/2; - Point centerView=new Point((int)(p.x+dx),(int)(p.y+dy)); + + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + + final double dx=Math.min(r.width,w*oldZoom)/2; + final double dy=Math.min(r.height,h*oldZoom)/2; + final Point centerView=new Point((int)(p.x+dx),(int)(p.y+dy)); // Dynamically modify the drawing Area size setPreferredSize(new java.awt.Dimension( (int)(w*zoom) ,(int)(h*zoom))); - SwingUtilities.invokeLater(new PositionJViewport(jv, + SwingUtilities.invokeLater(new PositionJViewport(jv, new Point((int)(centerView.x/oldZoom*zoom-dx), - (int)(centerView.y/oldZoom*zoom-dy)))); + (int)(centerView.y/oldZoom*zoom-dy)))); } - private Color getTransparencyColor(int color,int trans){ - Color c=new Color(color); + private Color getTransparencyColor(final int color,final int trans){ + final Color c=new Color(color); return new Color(c.getRed(),c.getGreen(),c.getBlue(),trans); } /** * Draw the horizontal axis - */ + */ private void drawXAxis(){ - UserConfig uc = WSManager.getUserConfig(); - int w = uc.getImageWidth(); - int h = uc.getImageHeight(); - + final UserConfig uc = WSManager.getUserConfig(); + final int w = uc.getImageWidth(); + final int h = uc.getImageHeight(); + if (uc.isDrawXAxis()){ g.setColor(getTransparencyColor(uc.getAxisColor(),128)); g.drawLine(0,h/2,w,h/2); for (int i=w/2%uc.getXAxis();i vertex; diff --git a/logo/src/xlogo/kernel/perspective/ElementLine.java b/logo/src/xlogo/kernel/perspective/ElementLine.java index 09a0108..3ae94d4 100644 --- a/logo/src/xlogo/kernel/perspective/ElementLine.java +++ b/logo/src/xlogo/kernel/perspective/ElementLine.java @@ -28,24 +28,25 @@ package xlogo.kernel.perspective; -import javax.media.j3d.Appearance; -import javax.media.j3d.LineStripArray; -import javax.media.j3d.Material; -import javax.media.j3d.PolygonAttributes; -import javax.media.j3d.Shape3D; -import javax.media.j3d.LineAttributes; -import javax.media.j3d.TransformGroup; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.LineStripArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.LineAttributes; +import org.jogamp.java3d.TransformGroup; -import com.sun.j3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.geometry.Sphere; -import javax.media.j3d.Transform3D; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.AxisAngle4d; +import org.jogamp.java3d.Transform3D; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.AxisAngle4d; -import com.sun.j3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.geometry.Cylinder; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3d; import xlogo.kernel.LogoError; @@ -94,7 +95,7 @@ public class ElementLine extends Element3D { line.setCoordinate(i, vertex.get(i)); // System.out.println("sommet "+(2*i-1)+" "+vertex.get(i).x+" "+vertex.get(i).y+" "+vertex.get(i).z+" "); - line.setColor(i, new Color3f(color.get(i))); + line.setColor(i, new Color3f(color.get(i).getRGBColorComponents(null))); } final Shape3D s = new Shape3D(line); final Appearance appear = new Appearance(); @@ -127,7 +128,7 @@ public class ElementLine extends Element3D { for (int i = 0; i < size - 1; i++) { - createLine(vertex.get(i), vertex.get(i + 1), new Color3f(color.get(i + 1))); + createLine(vertex.get(i), vertex.get(i + 1), new Color3f(color.get(i + 1).getRGBColorComponents(null))); } } diff --git a/logo/src/xlogo/kernel/perspective/ElementPoint.java b/logo/src/xlogo/kernel/perspective/ElementPoint.java index 670dee3..474edee 100644 --- a/logo/src/xlogo/kernel/perspective/ElementPoint.java +++ b/logo/src/xlogo/kernel/perspective/ElementPoint.java @@ -28,21 +28,22 @@ package xlogo.kernel.perspective; -import javax.media.j3d.Appearance; -import javax.media.j3d.Material; -import javax.media.j3d.PointArray; -import javax.media.j3d.PolygonAttributes; -import javax.media.j3d.Transform3D; -import javax.media.j3d.TransformGroup; -import javax.vecmath.Point3d; -import javax.vecmath.Color3f; -import javax.vecmath.Vector3d; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointArray; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3d; import xlogo.kernel.LogoError; -import javax.media.j3d.Shape3D; +import org.jogamp.java3d.Shape3D; -import com.sun.j3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.geometry.Sphere; /** * @author Marko - I decoupled this from Application @@ -69,7 +70,7 @@ public class ElementPoint extends Element3D for (int i = 0; i < vertex.size(); i++) { point.setCoordinate(i, vertex.get(i)); - point.setColor(i, new Color3f(color.get(i))); + point.setColor(i, new Color3f(color.get(i).getRGBColorComponents(null))); } v3d.add3DObject(new Shape3D(point)); } @@ -77,7 +78,7 @@ public class ElementPoint extends Element3D { for (int i = 0; i < vertex.size(); i++) { - createBigPoint(vertex.get(i), new Color3f(color.get(i))); + createBigPoint(vertex.get(i), new Color3f(color.get(i).getRGBColorComponents(null))); } } diff --git a/logo/src/xlogo/kernel/perspective/ElementPolygon.java b/logo/src/xlogo/kernel/perspective/ElementPolygon.java index 71ba5c3..b62fa09 100644 --- a/logo/src/xlogo/kernel/perspective/ElementPolygon.java +++ b/logo/src/xlogo/kernel/perspective/ElementPolygon.java @@ -35,14 +35,15 @@ */ package xlogo.kernel.perspective; -import javax.media.j3d.Appearance; -import javax.media.j3d.Material; -import javax.media.j3d.PolygonAttributes; -import javax.media.j3d.TriangleFanArray; -import javax.vecmath.Point3d; -import javax.media.j3d.Shape3D; -import javax.vecmath.Vector3f; -import javax.vecmath.Color3f; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.TriangleFanArray; +import org.jogamp.vecmath.Point3d; +import org.jogamp.java3d.Shape3D; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Color3f; import xlogo.Logo; import xlogo.kernel.LogoError; @@ -131,8 +132,8 @@ public class ElementPolygon extends Element3D tfa.setCoordinate(i, vertex.get(i)); // tfa2.setCoordinate(i, vertex.get(vertex.size()-1-i)); - - tfa.setColor(i, new Color3f(color.get(i))); + + tfa.setColor(i, new Color3f(color.get(i).getRGBColorComponents(null))); // tfa2.setColor(i, new Color3f(color.get(color.size()-i-1))); tfa.setNormal(i, vec2); diff --git a/logo/src/xlogo/kernel/perspective/LightDialog.java b/logo/src/xlogo/kernel/perspective/LightDialog.java index bd54658..8d7a016 100644 --- a/logo/src/xlogo/kernel/perspective/LightDialog.java +++ b/logo/src/xlogo/kernel/perspective/LightDialog.java @@ -36,10 +36,9 @@ import java.awt.Color; import xlogo.Logo; -import javax.vecmath.Color3f; -import javax.vecmath.Tuple3f; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Tuple3f; +import org.jogamp.vecmath.Point3f; import org.jogamp.vecmath.Vector3f; import javax.swing.BorderFactory; import javax.swing.JDialog; @@ -97,12 +96,15 @@ public class LightDialog extends JDialog implements ActionListener labelType = new JLabel(Logo.messages.getString("3d.light.type")); comboType = new JComboBox(type); comboType.setSelectedIndex(light.getType()); - - Color3f col = light.getColor(); - if (null != col) - panelColor = new PanelColor(col.get()); - else + + final Color3f col = light.getColor(); + if (null != col) { + final float[] t = new float[3]; + col.get(t); + panelColor = new PanelColor(new Color(t[0], t[1], t[2])); + } else { panelColor = new PanelColor(Color.white); + } panelColor.setBackground(comboType.getBackground()); panelPosition = new PanelPosition(Logo.messages.getString("3d.light.position"), light.getPosition()); @@ -183,11 +185,11 @@ public class LightDialog extends JDialog implements ActionListener private void updateLight() { - int t = comboType.getSelectedIndex(); - Color3f c = new Color3f(panelColor.getValue()); - Point3f p = panelPosition.getPosition(); - Vector3f d = panelDirection.getDirection(); - float a = panelAngle.getAngleValue(); + final int t = comboType.getSelectedIndex(); + final Color3f c = new Color3f(panelColor.getValue().getRGBColorComponents(null)); + final Point3f p = panelPosition.getPosition(); + final Vector3f d = panelDirection.getDirection(); + final float a = panelAngle.getAngleValue(); light.setType(t); light.setColor(c); light.setPosition(p); diff --git a/logo/src/xlogo/kernel/perspective/MyFog.java b/logo/src/xlogo/kernel/perspective/MyFog.java index 9125216..95f1236 100644 --- a/logo/src/xlogo/kernel/perspective/MyFog.java +++ b/logo/src/xlogo/kernel/perspective/MyFog.java @@ -28,13 +28,13 @@ package xlogo.kernel.perspective; -import javax.media.j3d.BranchGroup; -import javax.media.j3d.LinearFog; -import javax.media.j3d.ExponentialFog; -import javax.media.j3d.Fog; -import javax.media.j3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.LinearFog; +import org.jogamp.java3d.ExponentialFog; +import org.jogamp.java3d.Fog; +import org.jogamp.java3d.BoundingSphere; -import javax.vecmath.Color3f; +import org.jogamp.vecmath.Color3f; public class MyFog extends BranchGroup { diff --git a/logo/src/xlogo/kernel/perspective/MyLight.java b/logo/src/xlogo/kernel/perspective/MyLight.java index 6285fea..a7a90c9 100644 --- a/logo/src/xlogo/kernel/perspective/MyLight.java +++ b/logo/src/xlogo/kernel/perspective/MyLight.java @@ -28,17 +28,17 @@ package xlogo.kernel.perspective; -import javax.media.j3d.AmbientLight; -import javax.media.j3d.BoundingSphere; -import javax.media.j3d.DirectionalLight; -import javax.media.j3d.Light; -import javax.media.j3d.PointLight; -import javax.media.j3d.SpotLight; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3f; -import javax.media.j3d.BranchGroup; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.SpotLight; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.java3d.BranchGroup; public class MyLight extends BranchGroup { diff --git a/logo/src/xlogo/kernel/perspective/Viewer3D.java b/logo/src/xlogo/kernel/perspective/Viewer3D.java index 2ade695..4dad400 100644 --- a/logo/src/xlogo/kernel/perspective/Viewer3D.java +++ b/logo/src/xlogo/kernel/perspective/Viewer3D.java @@ -33,22 +33,23 @@ import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.Toolkit; -import javax.media.j3d.BoundingSphere; -import javax.media.j3d.BranchGroup; -import javax.media.j3d.Canvas3D; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; import java.awt.image.BufferedImage; -import javax.media.j3d.ImageComponent2D; -import javax.media.j3d.ImageComponent; -import javax.media.j3d.GraphicsContext3D; -import javax.media.j3d.Shape3D; -import javax.media.j3d.Raster; -import javax.vecmath.Point3f; -import javax.media.j3d.Transform3D; -import javax.media.j3d.TransformGroup; -import javax.media.j3d.Node; -import javax.media.j3d.Background; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.GraphicsContext3D; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Raster; +import org.jogamp.vecmath.Point3f; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.Node; +import org.jogamp.java3d.Background; import java.awt.GridBagLayout; import java.awt.Color; @@ -59,21 +60,22 @@ import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.WindowConstants; import javax.swing.border.TitledBorder; import java.awt.GridLayout; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; import xlogo.storage.WSManager; import xlogo.utils.Utils; import xlogo.utils.WriteImage; import xlogo.Logo; -import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; -import com.sun.j3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; @@ -121,7 +123,7 @@ public class Viewer3D extends JFrame implements ActionListener public Viewer3D(final World3D w3d, final Color c) { this.w3d = w3d; - this.backgroundColor = new Color3f(c); + this.backgroundColor = new Color3f(c.getRGBColorComponents(null)); initGui(); } -- cgit v1.2.3