Class collision

When I run XSD, it is putting the import for the current class into the .JAVA code which causes a compile error e.g. in the CtBar.java file:
package foo;
import foo.CtBar
public class CtBar ...
Is there some way of stopping this?
Message was edited by:
RandyS

What's this "XSD" you are running? In the XML context I think of XSD as being an abbreviation for XML Schema Definition, and so does Google. But in your case it looks like something for generating Java code? Clarification would help.

Similar Messages

  • Collision detection issues - help please?

    Hi guys,
    I'm currently developing my own shoot em'up game where I'm having  problems setting up the collision detention for bullets hitting/damaging  the enemy, I'm not sure why it isn't working. I'm got four classes for  this game so far which communicate to each other;
    Player class - movement and  bullet control/action for player
    MainShapeShooter class - enemy behaviour and game logic
    Bullet class - Bullet properies
    Collision class - Collision between player and enemies
    Note: player and enemy have collision boxes, but when the player  fires bullets, bullets go through the enemy, enemy isn't detenting the  bullets.
    Player class
    Code:
    private function shootBullet():void
                   //Bullet's velocity
                   var bullet_Vx:Number=Math.cos(_angle) * -10;
                   var bullet_Vy:Number=Math.sin(_angle) * -10;
                   //Bullet's start position
                   var radius:int =- 50;
                   var bullet_StartX:Number = x + radius * Math.cos(_angle);
                   var bullet_StartY:Number = y + radius * Math.sin(_angle);
                   //Create bullet instance and add it to the stage
                   var bullet:Bullet = new Bullet(bullet_Vx, bullet_Vy, bullet_StartX, bullet_StartY, "square");
                   parent.addChild(bullet);
                   MovieClip(parent).checkCollisionWithEnemies(this);
    MainShapeShooter class
    Code:
    function onEnterFrame(event:Event):void
                   if (player.hitTestObject(enemy))
                        health.meter.width--;
                        player.gotoAndStop(2);
                        else
                             player.gotoAndStop(1);
                        Collision.block(player, enemy);
                        Collision.block(player_C, enemy);
              function checkCollisionWithEnemies(bullet:MovieClip)
                   //Enemy
                   if (enemy!= null)
                        if (enemy.hitTestPoint(bullet.x, bullet.y,true))
                             enemy.meter.width -= 10;
                             enemy.gotoAndStop(2);
                             if (enemy.meter.width < 1)
                                  enemy.stop();
                                  removeChild(enemy);
                                  enemy = null;
                             removeChild(bullet);
                             bullet = null;
    The last 3 lines of the player class;
    Code:
    var bullet:Bullet = new Bullet(bullet_Vx, bullet_Vy, bullet_StartX, bullet_StartY, "square");
                   parent.addChild(bullet);
                   MovieClip(parent).checkCollisionWithEnemies(this);
    shouldn't this allow/link to "function checkCollisionWithEnemies"  function within the MainShapeShooter class to allow the enemy to detent  the bullets. Maybe I'm missing something? :s
    Any help would be greatly appreciated.
    Thanks
    Jonesy

    I ended up going to the Apple store at Chermside (Brisbane) and the Genius could not have been more helpful or apologetic about my broken iPhone. Was changed in 7 minutes, I timed him:).
    Now if I can get the wifi problem solved everything will be great.
    Adrian

  • Error for class in use running wsdlc with packageName

    Running wsdlc on a wsdl... Using type=JAXWS. Works fine without a package name... The default will be used from namespace.
    However when i specify packageName getting a long stream of errors regarding class collisions for xsd generated classes!
    I know that there are multiple imports for same xsd schema in various files, but could not find a solution for this, and seems basic enough to be previously encountered by others.
    [wsdlc] [ERROR] A class/interface with the same name "MyClass" is already in use. Use a class customization to resolve this conflict.
    thanks,
    Stefan

    actually looking at the link you sent found the explanation for my initial error!
    thanks again!
    The way wsdlc/packageName is used between JAX-RPC vs JAX-WS is completely different!!
    With second option all classes will end-up with same package name, which is why did not see the collision with first one.
    For me the difference looks fairly drastic, surprised there is not an option just to generate the same way...
    Here's the actual documentation:
    <<
    Depending on the type of partial implementation you generate (JAX-WS or JAX-RPC), the Java package name of the generated complex data types differs, as described in the following guidelines:
    •     For JAX-WS, if you specify the packageName attribute, then all artifacts (Java complex data types, JWS interface, and the JWS interface implementation) are generated into this package. If you want to change the package name of the generated Java complex data types in this case, use the <binding> child element of the wsdlc Ant task to specify a custom binding declarations file. For information about creating a custom binding declarations file, see "Using JAXB Data Binding" in Getting Started With JAX-WS Web Services for Oracle WebLogic Server.
    •     For JAX-RPC, if you specify the packageName attribute of the wsdlc Ant task, only the generated JWS interface and implementation are in this package. The package name of the generated Java complex data types, however, always corresponds to the XSD Schema type namespace, whether you specify the packageName attribute or not.
    >>

  • Breakpoints not firing

    Hello Dev's,
    I am having a problem in only one project and I have even tried to recreate the project with no success but previous projects created years prier (made with previous versions of FB) are not experiencing this.
    I am trying to place breakpoints on functions in deep rooted classes (a class that is loaded by a class by a class, its a smaller component from a greater project) which I know is firing as I see the results on the screen.
    However the break point does not fire and remains a blue circle, indicating it won't fire. If I remove and re add the break point while the app is running, it will become checked but once I run the debugger the break point turns back into a blue dot.
    If I put a break point in one of the first lines of the application class, like in it's constructor, it will trigger and then my deeper break points will fire. But if I don't make this out of the way break point (in the main class) the following break points are not firing.
    Thoughts?
    Flex Builder 4.5
    SDK 4.5.1
    Debugger 11.6.5.635 (in FireFox)

    I haven’t seen that before, but in theory would be possible if several SWFs are being loaded and you get a class collision and the breakpoint in the app changes the timing of the loaded SWFs.

  • How to integrate a .abc file into swf by using mxmlc?

    Enviroment: CrossBridge1.0.1, Flex SDK 4.6
    I use g++ to compile 2 .cc files (the c2as wrapper) & a .a file (the logic)  into a .swc file; then use this .swc as a library for mxmlc to compile the main .as file.
    The Makefile is as follows:
    "$(FLASCC)/usr/bin/g++" $(BASE_CFLAGS) -O4 -L. main.cc test_as3.cc -lmytest -emit-swc=sample.mytest -o mytest.swc
    "$(FLEX)/bin/mxmlc" -static-link-runtime-shared-libraries -library-path=mytest.swc -debug=false MainView.as -o test.swf
    everything is ok.
    But when I add some function calls in .as file, it uses the CModule package:
    in MainView.as:
    import com.adobe.flascc.CModule;
    CModule.malloc
    CModule.writeBytes
    CModule.free
    the mxmlc complains that
    Access of undefined property, CModule.malloc,
    Access of undefined property, CModule.writeBytes,
    Access of undefined property, CModule.free
    Definition com.adobe.flascc:CModule could not be found.
    I found the CModule.abc in sdk/usr/lib folder, and I explored that it do have those functions. but how to import this .abc package into .swf ?
    the follow command doesn't work:
    "$(FLEX)/bin/mxmlc" -static-link-runtime-shared-libraries -library-path=mytest.swc  -import CModule.abc -debug=false MainView.as -o test.swf

    First, you should check out the new version at CrossBridge — CrossBridge
    1.0.1 is quite old.
    For your problem, you don't need to compile Cmodule.abc into your swf, it is already present into your SWC file. Here is the reason why your import is not working.
    When you compile directly to SWF with crossbridge, the compiler put all the crossbridge stuff (CModule included) into the com.adobe.flascc namespace.
    The problem is that, when you build a SWC, there is no garantee that your end application won't include multiple SWC compiled by crossbridge. To prevent namespace clashing, (having multiple Cmodule under the same namespace), all the stuff in the SWC is namespace with the namespace you gave after the -emit-swc command. In this particular case "-emit-swc=sample.mytest"  your namespace is "sample.mytest".
    So you need yo change the import from :
    import com.adobe.flascc.CModule;
    to
    import sample.mytest.CModule;
    and it should work.
    More detail in the documentation : http://crossbridge.io/docs/Reference.html#section_gcc
    Building SWCs
    A SWC is the Flash Runtime equivalent of a shared library. You can link a SWC into a pure ActionScript project either with an IDE (Flash Builder, for example), or via the command-line ActionScript compiler (named mxmlc). A SWC contains the compiled ActionScript bytecode, along with an API catalog so that Flash Builder can perform code hinting while a developer writes ActionScript that uses the API exposed by a SWC.
    When you generate a SWC you must specify an AS3 package name to contain the generated code, and the internal Crossbridge boilerplate code. This lets you link multiple Crossbridge-generated SWCs into one SWF without any function or class collisions. Anywhere you would have previously seen a name starting with com.adobe.flascc this namespace will be replaced with the string passed in the gcc/g++ -emit-swc=... argument.
    -emit-swc=
    Emits a SWC that can be linked into a Flash Builder project or distributed for others to link into their own projects. You must specify the namespace that you want to use to replace the default com.adobe.flascc namespace, this lets you link multiple Crossbridge-generated SWCs into a single project.

  • How to make "Levels" in simple java game

    I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
    Here is my source, the polygons are by the massive ///////// areas.
    I cut out the majority of the program, because it was too long.
    public class collision extends Applet implements MouseListener,MouseMotionListener
        private  Image rickImage,mazeImage;
       Image Buffer;
       Graphics gBuffer;
       int x, y;
       int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
       int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
       //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
      // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
       int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       boolean mouseInside, collide;
       boolean rolled = false;
       boolean msg = true;
       int sX=204,sY=490,sW=12,sH=9;
       //Declare the rectangles
       Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
       //Declare the polygons
       Polygon leftWall,playerArea,rightWall;
            ///Initiate
            public void init()
                 rickImage = getImage(getDocumentBase(), "rick.jpg");
                 mazeImage = getImage(getDocumentBase(), "maze1.jpg");
                 collide=false;
                 Buffer=createImage(getSize().width,getSize().height);
                 gBuffer=Buffer.getGraphics();
                 rightWall=new Polygon(RightWallX,RightWallY,18);
                 playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
                 leftWall= new Polygon(LeftWallX,LeftWallY,17);
            public void paint(Graphics g)
                 drawStuff();
                 g.drawImage (Buffer,0,0, this);
    */

    I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
    I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

  • Does calling class methods from bean and JSP cause collision?

    Hi,
    Please look at the class below:
    public class X
    // no member variable
    public X() {}
    // pay attention to static keyword
    public static int getY()
    Think a bean (say BeanZ) that make calls to getY() method without initializing the class X (like this: X.getY() )
    And think many users having "page scope" in JSP make call to BeanZ or directly calls it from JSP.
    I'm wondering if any collision occurs because of STATIC method? Should I use "SYNCHRONIZED" keyword with it? If so, what about Math.cos() which also is a non synchronized static method ? Shouldn't I use Math.cos() (and the other static methods) in JSP or bean?
    Thank you for your help.
    Ali Sadik

    Hi,
    Thank you for your quick answer. Think my class like this:
    public class X
    // no member variable
    public X() {}
    // pay attention to static keyword
    public static int[] getY(int a, int[] b)
    // i know there is no need for the extra array.
    // just for example ;)
    int[] ret = new int[b.length];
    for(int i = 0; i < b.length; i++)
    ret[i] = a * b;
    return ret;
    Does it the type of class that you've mentioned ? It makes calculation to produce dynamic result. Shouldn't I use it as static ? If your answer is yes, what about Math.cos()? Doesn't it have dynamic calculation?
    Thanks a lot.

  • Application builder and dynamic class VIs name collision

    I'm, using LabView 8.6 and I'm trying to make executable file. 
    The application builder returns warning:  
    "LabVIEW prevented a file name collision during the build. Duplicate file names cannot be copied to the same destination. You can rename files as part of the build process to avoid name conflicts."
    ...and no executable is created.
    I'm pretty sure the warning comes from the fact that I use dynamic class member VIs, that are by definition have to have same names in both parent and children.    
    The following link (http://zone.ni.com/reference/en-XX/help/371361E-01/lvhowto/caveats_apps_dlls/) says " If you don't rename the files, Application Builder moves the files to different folders for you to avoid a filename collision.", but no folders are created.
    Any help here? 

    Hi,
    If you have a parent class and one or more child classes, during the build LV will create a folder for each class with a conflicting VI.  The offending VIs will be dumped in their respective folders, resolving the conflict.  For what it's worth, I've used dynamic dispatch VIs several times in executables in LV 8.6 without seeing the issue you're reporting.
    My only advice would be to:
    1) make sure that you haven't somehow put two VIs of the same name in the same class (not even sure that's possible).
    2) make sure you aren't renaming a VI during the build and creating a conflict
    JasonP - CLD

  • Wsdl2java: Two declarations cause a collision in the ObjectFactory class.

    I am using Apache CXF wsdl2java tool to create client classes for a wsdl generated by microsoft .net webservice.
    I get this error:
    WSDLToJava Error: Thrown by JAXB : Two declarations cause a collision in the ObjectFactory class.
    the generated wsdl have complexTypes and elements of the same name for many of its response objects.
    For example:
    <xs:complexType name="ResponseCode">
    <xs:sequence>
    <xs:element minOccurs="0" name="Code" type="xs:int"/>
    <xs:element minOccurs="0" name="Description" nillable="true" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="ResponseCode" nillable="true" type="tns:ResponseCode"/>
    Does anyone know a solution for dealing with this so that wsdl2java will correctly generate client classes to talk to this server?
    Thanks.

    I partially fixed this issue by using a jaxb bindings file. This resolved all the places where an element and complextype had the same name.
    However, there is still a place where Type: Prompt has an Element: Value
    which conflicts with the fact that there is a Type and Element names PromptValue
    Here is the binding I used to fix so far, but cannot figure out how to fix the second issue yet.
         <jxb:schemaBindings>
              <jxb:package name="org.datacontract.schemas"/>
              <jxb:nameXmlTransform>
                   <jxb:elementName suffix="Element"/>
              </jxb:nameXmlTransform>
         </jxb:schemaBindings>
    If anyone has solved this I would appreciate the help.
    Thanks.

  • Class name collision

    What is the difference from this:
    package webservice
    import mx.rpc.soap.WSDL;
    public class WebService
    private var service:mx.rpc.soap.WebService;
    public function WebService(url:String)
    and this:
    package webservice
    public class WebService
    private var service:mx.rpc.soap.WebService;
    public function WebService(url:String)
    In the latter case, there is no import directive. Which i
    shouldn't need, right?
    Anyway, the latter case gives the error #1046: Type was not
    found or was not a compile-time constant.
    myatem

    In ActionScript 3 the import statement is required even if
    you fully-qualify the class.

  • Workaround for Class name collisions

    I'm using wimas3 for an AIM API, which has a User class, but
    I also have a User class in my codebase. In Java, you reference the
    absolute classpath:
    private com.aol.api.wim.data.User myUser = new
    com.aol.api.wim.data.User();
    How do I do it in Flex?

    Nevermind. I misread the error. It's the same:
    var user:com.aol.api.wim.data.User =new
    com.aol.api.wim.data.User;

  • Collisions (Separating Axis Theorem)

    Hi,
    I'm working on a 2D game, it's top-down like GTA2, but I'm havinfgproblems with the collision detector. I know there are a lot of posts about collision already but they didn't help me much. I'm using the separating axis theorem (explained here: http://www.harveycartel.org/metanet/tutorials/tutorialA.html#section1) and most of the code is inspired by http://www.codeproject.com/cs/media/PolygonCollision.asp .
    Separating axis theorem:
    find all axis perpendicular to all the edges of both objects,
    project both objects on the axis,
    if there is an axis where the projections do not overlap, then the objects do not overlap.
    The problem is that I think my code should work. And guess what, it doesn't. I checked the code 30 times this weekend but maybe there is some tiny mistake I overlook each time..
    When I run the program with 6 objects I get this:
    1 2 3 4 5 6
    1: - 0 0 0 0 0
    2: 0 - 1 0 0 0
    3: 0 1 - 0 0 0
    4: 0 0 0 - 0 0
    5: 0 0 0 0 - 0
    6: 0 0 0 0 0 - (1=intersect, 0=doesn't intersect)
    but this is completely wrong. You can run the program yourself to see the exact locations of the objects.
    1 is the triangle at the top,
    2 and 3 are the triangles who share an edge
    4 is the one on the left intersecting with 3
    5 is the triangle on the right
    6 is the parallelogram
    But it really gets weird when I add a 7th object (the one in the comments):
    1 2 3 4 5 6 7
    1: - 0 0 0 0 0 0
    2: 0 - 0 0 0 0 0
    3: 0 0 - 0 0 0 0
    4: 0 0 0 - 0 0 0
    5: 0 0 0 0 - 0 0
    6: 0 0 0 0 0 - 0
    7: 0 0 0 0 0 0 -
    Now 2 and 3 don't intersect anymore! They didn't change I just added another object.
    I'm adding a short explanationof all the classes and the code itself. I know it's a lot of code but I added all the test classes so you can just run Test.Test
    I hope someone can help me with this.
    Thanks,
    El Bandano
    _<h5>package CollisionDetector:</h5>_
    <h6>CollisionDetector</h6>
    The class that is supposed to check for collisions. It will take 2 Props and return a CollisionResult
    <h6>CollisionResult</h6>
    A small class with 2 public fields. For now only the boolean Intersect matters.
    <h6>Interval</h6>
    Another small class that represents an interval of floats. It's pretty simple. Distance should return something negative if 2 intervals overlap.
    _<h5>package World</h5>_
    <h6>MovableProp</h6>
    An interface of an object. All objects should be convex.
    <h6>Vector2D</h6>
    A 2D-vector. It has an x and a y value (floats) and some simple methods. a 2D vector can represent a point or an edge/axis. For a point the x and y are the coordinates. For an axis you need a normalized vector (x^2+y^2=1) and the x and y are coordinates on a parrallell line through (0,0).
    _<h5>package Test</h5>_
    <h6>Test</h6>
    The main class. It makes some objects, prints a matrix showin which intersect eachother and shows a window with all objects.
    <h6>TestMovProp</h6>
    A basic implementation of MovableProp.
    <h6>TestPanel</h6>
    A panel that draws MovableProp.
    _<h5>package CollisionDetector:</h5>_
    <h6>CollisionDetector</h6>
    package CollsisionDetector;
    import World.MovableProp;
    import World.Vector2D;
    import java.util.ArrayList;
    public class CollisionDetector {
        public CollisionDetector(){
        public CollisionResult DetectCollision(MovableProp propA, MovableProp propB) {
            CollisionResult result = new CollisionResult();
            result.Intersect = true;
            result.WillIntersect = true;
            Vector2D[] edges = UniqueEdges(propA, propB);
            // loop through the edges
            // find an axis perpendicular to the edge
            // project the props on the axis
            // check wether they intersect on that axis
            for (Vector2D edge: edges){
                Vector2D axis = edge.getPerpendicular();
                Interval intA = projectPointsOnAxis(propA.getCoordinates(), axis);
                Interval intB = projectPointsOnAxis(propB.getCoordinates(), axis);
                if (intA.distance(intB) > 0)
                    result.Intersect = false;
            return result;
        public Interval projectPointsOnAxis(Vector2D[] points, Vector2D axis){
            Interval i = new Interval();
            for (Vector2D p: points)
                i.add(projectPointOnAxis(p, axis));
            return i;
        public float projectPointOnAxis(Vector2D point, Vector2D axis){
            // axis <-> y=a*x
            float a  = axis.y / axis.x;
            // line <-> y=(-a/1)*x+b
            float a2 = -axis.x / axis.y;
            // b = y-a2*x
            float b = point.y - a2*point.x;
            // y = a *x
            // y = a2*x + b
            // => a*x = a2*x + b
            float x = b/(a-a2);
            float y = a*x;
            // is there a better way to do this?
            return new Float(Math.sqrt(x*x + y*y)).floatValue();
         * Put all edges in 1 array, eliminate doubles (parallels).
        public Vector2D[] UniqueEdges(MovableProp propA,MovableProp propB){
            Vector2D[] aEdges = propA.getEdges();
            Vector2D[] bEdges = propB.getEdges();
            ArrayList<Vector2D> tmp = new ArrayList<Vector2D>();
            for (Vector2D v: aEdges){
                tmp.add(v);
            for (Vector2D v: bEdges){
               if (! tmp.contains(v))
                    tmp.add(v);
            return tmp.toArray(new Vector2D[tmp.size()]);
    }<h6>CollisionResult</h6>
    package CollsisionDetector;
    import World.Vector2D;
    public class CollisionResult {
        public boolean WillIntersect;
        public boolean Intersect;
        public Vector2D MinimumTranslationVector;
        public CollisionResult() {
    }<h6>Interval</h6>
    package CollsisionDetector;
    public class Interval {
        public float min;
        public float max;
        public Interval() {
            min = Float.MAX_VALUE;
            max = Float.MIN_VALUE;
        public void add(float f){
            // no 'else'! In an empty interval both will be true
            if (f>max)
                max = f;
            if (f<min)
                min = f;
        public float distance(Interval interval){
            if (this.min < interval.min) {
                return interval.min - this.min;
            } else {
                return this.min - interval.min;
    }_<h5>package World</h5>_
    <h6>MovableProp</h6>
    package World;
    public interface MovableProp {
        public int getNPoints();
        public Vector2D[] getEdges();
        public Vector2D[] getCoordinates();
    }<h6>Vector2D</h6>
    package World;
    public class Vector2D {
        public float x;
        public float y;
        public Vector2D(float x, float y) {
            this.x = x;
            this.y = y;
        public boolean equals(Object obj){
            if (!(obj instanceof Vector2D)){
                return false;
            }else
                return (this.x == ((Vector2D)obj).x && this.y == ((Vector2D)obj).y);
        public String toString() {
            return ("Vector2D  x=" + x + " ,  y=" + y);
        public void normalize(){
            if (x*x + y*y != 1){
                float x2 = x;
                x /= Math.sqrt(x2*x2+y*y);
                y /= Math.sqrt(x2*x2+y*y);
        public Vector2D getPerpendicular(){
            Vector2D per = new Vector2D(-y,x);
            per.normalize();
            return per;
    }_<h5>package Test</h5>_
    <h6>Test</h6>
    package Test;
    import CollsisionDetector.CollisionDetector;
    import World.MovableProp;
    import java.awt.Polygon;
    import java.util.ArrayList;
    import java.util.Vector;
    import javax.swing.JFrame;
    public class Test {
        public static void main(String args[]) {
            CollisionDetector detect = new CollisionDetector();
            float[] x = new float[3];
            float[] y = new float[3];
            ArrayList<MovableProp> list = new ArrayList<MovableProp>();
            x[0] = 200; x[1] = 300; x[2] = 500;
            y[0] = 400; y[1] = 200; y[2] = 300;
            list.add(new TestMovProp(x,y));
            x[0] = 300; x[1] = 500; x[2] = 600;
            y[0] = 400; y[1] = 400; y[2] = 500;
            list.add(new TestMovProp(x,y));
            x[0] = 200; x[1] = 300; x[2] = 600;
            y[0] = 600; y[1] = 400; y[2] = 500;
            list.add(new TestMovProp(x,y));
            x[0] = 100; x[1] = 200; x[2] = 300;
            y[0] = 800; y[1] = 500; y[2] = 700;
            list.add(new TestMovProp(x,y));
            x[0] = 600; x[1] = 600; x[2] = 700;
            y[0] = 400; y[1] = 700; y[2] = 500;
            list.add(new TestMovProp(x,y));
    //        x[0] = 100; x[1] = 001; x[2] = 900;
    //        y[0] = 001; y[1] = 900; y[2] = 500;
    //        list.add(new TestMovProp(x,y));
            x = new float[4];
            y = new float[4];
            x[0] = 450; x[1] = 550; x[2] = 500; x[3] = 400;
            y[0] = 200; y[1] = 250; y[2] = 650; y[3] = 600;
            list.add(new TestMovProp(x,y));
            int n = list.size();
            boolean[][] matrix = new boolean[n][n];
            for (int i=0; i<n; i++){
                for (int j=0; j<n; j++){
                    if (i!=j)
                    matrix[i][j] = detect.DetectCollision(list.get(i),list.get(j)).Intersect;
            System.out.print("  ");
            for (int i=0; i<n; i++){
                System.out.print("  " + (i+1));
            for (int i=0; i<n; i++){
                System.out.print("\n" + (i+1) + ":  ");
                for (int j=0; j<n; j++){
                    if (i==j)
                        System.out.print("-  ");
                    else if (matrix[i][j])
                        System.out.print("1  ");
                    else
                        System.out.print("0  ");
            System.out.println();
            JFrame window = new JFrame();
            window.setDefaultCloseOperation(window.EXIT_ON_CLOSE);
            window.pack();
            window.setVisible(true);
            window.setContentPane( new TestPanel(list));
            window.pack();
    }<h6>TestMovProp</h6>
    package Test;
    import World.MovableProp;
    import World.Vector2D;
    public class TestMovProp implements MovableProp{
        float[] X;
        float[] Y;
        Vector2D[] coor;
        public TestMovProp(float[] x, float[] y) {
            X=x; Y=y;
            coor = new Vector2D[getNPoints()];
            for(int i=0; i< getNPoints(); i++){
                coor[i] = new Vector2D(X, Y[i]);
    public Vector2D[] getCoordinates(){
    return coor;
    public int getNPoints() {
    return X.length;
    public Vector2D[] getEdges() {
    int n = getNPoints();
    Vector2D[] v = new Vector2D[n];
    for (int i=0; i<n-1; i++){
    v[i] = new Vector2D(X[i]-X[i+1], Y[i]-Y[i+1]);
    v[i].normalize();
    v[n-1] = new Vector2D(X[0]-X[n-1], Y[0]-Y[n-1]);
    v[n-1].normalize();
    return v;
    public String toString() {
    String s = "\n";
    for (Vector2D v: getCoordinates())
    s += ("\n" + v);
    return s;
    <h6>TestPanel</h6>package Test;
    import World.MovableProp;
    import World.Vector2D;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Polygon;
    import java.util.ArrayList;
    import javax.swing.JPanel;
    public class TestPanel extends JPanel {
    public ArrayList<MovableProp> list;
    public TestPanel(ArrayList<MovableProp> list) {
    super();
    this.list = list;
    setPreferredSize(new Dimension(1000,850));
    public void paint(Graphics g) {
    super.paint(g);
    for (MovableProp prop:list){
    Vector2D[] coor = prop.getCoordinates();
    int n = prop.getNPoints();
    g.drawLine((int)coor[0].x, (int)coor[0].y, (int)coor[n-1].x, (int)coor[n-1].y);
    for (int i=0; i<n-1; i++){
    g.drawLine((int)coor[i].x, (int)coor[i].y, (int)coor[i+1].x, (int)coor[i+1].y);

    .java wrote:
    I have been search for what seems like hours, Nice try, but in less than 15 seconds I found a complete discussion on the subject.
    and I still have not managed to find anybody or anything that can clearly answer these three questions:
    1. What is SAT?
    2. How does it apply to 2D collision detection? (How would it be different with 3D collision detection?)
    3. How can this be implemented in Java using Shape objects?
    Note: I am easily confused by geometric terminology.This really looks like a question you should have an answer for in your notes from class, or in your book. If not perhaps you need to go ask your teacher what it is and explain why you don't have it in your notes or book.

  • Bouncing balls collision

    I am creating a program that has two balls which produce a sound when bouncing off the walls and each other. I am having trouble when they collide with each other, as my value for when they hit each other does not seem to be working. Here is my source code :
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.*;
    import java.applet.AudioClip;
    import java.awt.event. *;
    public class BallBouncing extends Applet implements Runnable {
            int x_pos = 20;
            int y_pos = 100;
            int x_speed = 1;
            int y_speed = 1;
            int x1_pos = 70;
            int y1_pos = 130;
            int x1_speed = 1;
            int y1_speed = 1;
            int appletsize_x = 300;
            int appletsize_y = 200;
            int radius = 20;
            int pos = (x_pos - x1_pos)*(x_pos - x1_pos) + (y_pos - y1_pos)*(y_pos - y1_pos);
            double pos1 = Math.sqrt(pos);       
            public AudioClip sound1, sound2;       
            Thread t;
            Button b1 = new Button("Reverse Direction");
            public void init() {
                b1.addActionListener(new B1());           
                add(b1);
            class B1 implements ActionListener {
            public void actionPerformed(ActionEvent e) {
            x_speed = +3;
            y_speed = -3;
            public void start() {
                            t = new Thread(this);
                            t.start();
            public void stop() {
            public void paint(Graphics g) {
                    g.setColor (Color.blue);
                    g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
                    g.fillOval(x1_pos - radius, y1_pos - radius, 2 * radius, 2 * radius);
            public void run() {
                    sound1 = getAudioClip( getDocumentBase(), "Audio1.au" );
                    sound2 = getAudioClip( getDocumentBase(), "Audio2.au" );
                    while (true) {
                        try {
                            Thread.sleep(20);
                        } catch (InterruptedException e) {}
                        if (x_pos > appletsize_x - radius)
                            x_speed = -3;
                            sound2.play();
                        else if (x_pos < radius)
                            x_speed = +3;
                            sound2.play();
                        else if (y_pos > appletsize_y - radius)
                            y_speed = -3;
                            sound2.play();
                        else if (y_pos < radius)
                            y_speed = +3;
                            sound2.play();
                        else if (x1_pos > appletsize_x - radius)
                            x1_speed = -3;
                            sound2.play();
                        else if (x1_pos < radius)
                            x1_speed = +3;
                            sound2.play();
                        else if (y1_pos > appletsize_y - radius)
                            y1_speed = -3;
                            sound2.play();
                        else if (y1_pos < radius)
                            y1_speed = +3;
                            sound2.play();
                        else if (pos1 < 40)
                            x_speed = -3;
                            x1_speed = +3;
                            y_speed = -3;
                            y1_speed = +3;
                            sound1.play();
                            x_pos += x_speed;
                            y_pos += y_speed;
                            x1_pos += x1_speed;
                            y1_pos += y1_speed;
                            repaint();
    }Any help would be appreciated, thanks.

    Hi, here is a solution to your problem I hope. I have also included some extra features and brought your code up to a higher standard in terms of java conventions (however the {} on the next line is my convention, from C# :p).
    A few things:
    - For the balls deflecting at the proper angles then you will need to learn vector maths and I am afraid that my knowledge of that is rather sketchy (still 1st year uni student, more on that next year :p)
    - I used Graphics2D purely because I was lazy so I could write g2.draw(bounds); instead of using g.drawRect(x, y, height, width); - both methods give the same result
    - You will need to look up how to do drawing in applets to remove that flickering, I'm not sure if you do the same thing as normal swing/awt components (ie double buffering), as applets aren't my strong point.
    - I removed the button because it was unneccessary, it will take you 60 seconds to add it back in if you want.
    - You really REALLY should write a 'Ball' class and make some Ball objects instead of having separate variables for each ball. I will leave that up to you :)
    - I STRONGLY recommend the use of comments throughout any program you use, not because of convention but because it not only helps other developers to understand your code and what it does, but also to refresh your memory when you come back from a break and try to keep writing. (trust me, do not underestimate the power of comments!) . I have put a few in to show you what they should look like; they should be brief and concise, explain what a section of code does, and how it does it.
    - Enjoy!
    package sunforum_bounceball;
    import java.applet.*;
    import java.awt.*;
    public class BallBouncing extends Applet implements Runnable
         private static final long serialVersionUID = 1L;
         // ball 1
         private int x1_pos;
         private int y1_pos;
         private int x1_speed;
         private int y1_speed;
         private int b1_radius;
         // ball 2
         private int x2_pos;
         private int y2_pos;
         private int x2_speed;
         private int y2_speed;
         private int b2_radius;
         // other variables
         private Rectangle bounds;
         private Dimension appletSize;
         private boolean hasCollision;
         private boolean debugCollisionTesting;
         private AudioClip sound1, sound2;       
         private Thread t;
         public BallBouncing()
              // ball 1
              x1_pos = 100;
              y1_pos = 109;
              x1_speed = 2;
              y1_speed = 1;
              b1_radius = 40;
              // ball 2
              x2_pos = 100;
              y2_pos = 237;
              x2_speed = 1;
              y2_speed = 1;
              b2_radius = 20;
              hasCollision = false;
              // This is just for your help; turn this on to disable the balls changing direction when they collide.
              // This will enable you to check that when the balls are touching, we are detecting it.
              debugCollisionTesting = false;
              // Variables for the size of the applet and the bounding rectangle for the balls.
              appletSize = new Dimension(400, 400);
              bounds = new Rectangle(0, 0, 400, 400);
         public void start()
              t = new Thread(this);
              t.start();
         public void stop()
         public void paint(Graphics g)
              Graphics2D g2 = (Graphics2D)g;
              if (hasCollision)
              { g2.setColor(Color.RED); }
              else
              { g2.setColor(Color.BLUE); }
              g2.fillOval(x1_pos - b1_radius, y1_pos - b1_radius, 2 * b1_radius, 2 * b1_radius);
              g2.fillOval(x2_pos - b2_radius, y2_pos - b2_radius, 2 * b2_radius, 2 * b2_radius);
              g2.setColor(Color.BLACK);
              g2.draw(bounds);
         public void run()
              // +1 just so we can see the border of the collision area. Try taking out the +1's and see what happens.
              this.setSize(appletSize.width + 1, appletSize.height + 1);
              sound1 = getAudioClip( getDocumentBase(), "Audio1.au" );
              sound2 = getAudioClip( getDocumentBase(), "Audio2.au" );
              // Used to hold the distance between the balls.
              double p;
              while (true)
                   try
                   { Thread.sleep(20); }
                   catch (InterruptedException e)
                   // ball 1 x coordinate.
                   if (x1_pos > (bounds.x + bounds.width) - b1_radius || x1_pos < bounds.x + b1_radius)
                        x1_speed *= -1;
                        sound2.play();
                   // ball 1 y coordinate.
                   else if (y1_pos > (bounds.y + bounds.height) - b1_radius || y1_pos < bounds.y + b1_radius)
                        y1_speed *= -1;
                        sound2.play();
                   // ball 2 x coordinate.
                   if (x2_pos > (bounds.x + bounds.width) - b2_radius || x2_pos < bounds.x + b2_radius)
                        x2_speed *= -1;
                        sound2.play();
                   // ball 2 y coordinate.
                   else if (y2_pos > (bounds.y + bounds.height) - b2_radius || y2_pos < bounds.y + b2_radius)
                        y2_speed *= -1;
                        sound2.play();
                   // Checks the distance between the balls. If it is less than the sum of the radii, then they are colliding.
                   p = Math.sqrt(Math.pow((x1_pos - x2_pos), 2) + Math.pow((y1_pos - y2_pos), 2));
                   if (p < (b1_radius + b2_radius))
                        // To check there is a collision. Useful for debugging.
                        // System.out.println("Collision");
                        hasCollision = true;
                        // see declaration for details
                        if (!debugCollisionTesting)
                             x1_speed *= -1;
                             x2_speed *= -1;
                             y1_speed *= -1;
                             y2_speed *= -1;
                             sound1.play();
                   else
                   { hasCollision = false; }
                   // Move both balls.
                   x1_pos += x1_speed;
                   y1_pos += y1_speed;
                   x2_pos += x2_speed;
                   y2_pos += y2_speed;
                   // Repaint the scene
                   repaint();
    }Cheers
    Sutasman
    Edited by: Sutasman on Dec 6, 2009 1:17 AM

  • Time enry collisions and wage type issues

    Hi Experts,
    We do not have holiday's embedded in our schedules due to the flexibility in when employees are allowed to take the paid time off and also due to
    our "flex" work schedules being more than 8 hour work days but the holiday benefit is an 8 hour benefit.  This has caused us a lot of issues with
    time entry, however, we thought it had been corrected.  We are now running into the same issues.  Here is an example:
    First Issue:
    Work Schedule week of 12/31/07 - 01/05/08
                Sun   Mon   Tues  Wed   Thur  Fri   Sat
    Schedule    0     10    10    10    10    0     0
    Tuesday the 1st is a holiday and the employee must enter Absence type 240 for 10 hours to fit his schedule.  Employee also work on the holiday and
    needs to enter Attendance type 832 for unscheduled holiday work.  When we try to enter the attendance we receive a full day collision error and
    cannot continue.
    Second Issue:
    Work Schedule week of 12/31/07 - 01/05/08
                Sun   Mon   Tues  Wed   Thur  Fri   Sat
    Schedule    0     8     8     8     8     8     0
    Tuesday is the holiday and the employee enters Absence type 240 for 8 hours to fit her schedule.  She is also on Standy-By time for the holiday.  We
    had to configure standby time specifically as a wage type and activate the wage type column in the CATS entry screen.  She must enter W/T (it's the
    only option) 1802 and then record 24 hours in the date 01/01/08.  This entry also gives us a full day collision message and we cannot continue.
    We can provide more examples when a consultant is assigned.  These options used to work and we do not know why they are no longer working.
    Advice me to resolve this ticket on time, its high priority ticket.

    Hi,
    I think your 1st problem comes from the misunderstanding of SAP work schedule logic.
    As you mentioned, you want to input ab type 240 to fit work schedule. But it's not necessary.
    For that day is a WORK day with holiday class 1. That means scheduled work can be overwrited by holiday. If the employee does not come to work in that day without any 2001 informations, he/she is NOT absence,because that day is a paid time off.
    And as for the attendance type, it's also no needed. Because if employee came to work in a public holiday, the working hours will automatically counted as OT hours but UNAPPORVED! To approve this OT, you need input 2007 attendance quota. In this example, the employee got 10 hours OT in puplic holiday which is recorded by SAP TM but unapporved. Then you should create a 2007 record with 10 hours attendance quota in the same day. By doing this, the TM evaluation will count those 10 hours as paid OT.
    I think the way above is what you called "flexibility in when employees are allowed to take the paid time off "
    Hope helpful
    Br,Kee

  • File name collision during build that includes Report Generation toolkit. How to correct?

    When I switched to LV 8.6 (it's also in 8.6.1) I started getting a file name collision warning when building an installer that included the Report Generation toolkit. The executable works, but I don't like to leave warnings uninvestigated. I don't understand 1) why it's happening now and 2) what it's recommending for the fix. Here's part of the actual warning it gives.
    LabVIEW prevented a file name collision during the
    build. Duplicate file names cannot be copied to the same destination. You can
    rename files as part of the build process to avoid name conflicts.
    The following files were moved to a unique
    location:
    C:\Program Files\National Instruments\LabVIEW
    8.6\vi.lib\Utility\NIReport.llb\Append Control Image to Report.vi
    C:\Program
    Files\National Instruments\LabVIEW 8.6\vi.lib\Utility\NIReport.llb\HTML\Append
    Control Image to Report.vi
    C:\Program Files\National Instruments\LabVIEW
    8.6\vi.lib\Utility\NIReport.llb\Append File to Report.vi
    C:\Program
    Files\National Instruments\LabVIEW 8.6\vi.lib\Utility\NIReport.llb\HTML\Append
    File to Report.vi
    C:\Program Files\National Instruments\LabVIEW
    8.6\vi.lib\Utility\NIReport.llb\Append Horizontal Line to Report.vi...........

    Hi GS,
    The architecture of the Report Generation Toolkit was changed in LabVIEW 8.6 to utilize LabVIEW Classes.  As such, there are some warnings during an EXE build because the class VIs have identical names.  Classes were not used in the toolkit in LabVIEW 8.5 and previous...that's why you didn't see any warnings during the build until now.
    Your EXE should still function properly, and you shouldn't have to change anything about your build.  The purpose of the warnings is to let you know that the duplicate-named VIs needed to be handled differently during the build.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

Maybe you are looking for