Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Compiling error

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Compiling error

    I am not sure of what is wrong with my code, I hope any of you guys can point on it.

    Here's my code:

    package assignment10;

    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.image.BufferedImage;
    import java.awt.image.ColorModel;
    import java.io.File;
    import java.io.IOException;
    import java.math.BigInteger;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.HashMap;

    import javax.imageio.ImageIO;


    public class ChainCode {

    BufferedImage image;
    int width;
    int height;

    private int direction = 7;


    public ChainCode(BufferedImage image){
    this.image = image;
    this.width = image.getWidth();
    this.height = image.getHeight();
    }


    public ArrayList<Complex> getChainCodePixels(){
    ArrayList<Complex> list = new ArrayList<Complex>();

    int x,y;
    x = y = 0;

    outer:
    for(y =0;y < height; y++){
    for(x=0 ;x < width; x++){
    Color c = new Color(image.getRGB(x, y));
    if(c.getBlue() > 0){
    list.addAll(f(x,y));
    break outer;
    }
    }
    }
    return list;
    }



    private ArrayList<Complex> f(int x, int y) {
    ArrayList<Complex> code = new ArrayList<Complex>();

    Dimension firstCell = new Dimension(x,y);
    Dimension d1 = firstCell;
    code.add(new Complex(x,y)); //Add cell1

    Dimension secondCell = getNextCell8(x, y);
    Dimension d2 = secondCell;

    do{
    x = (int) d2.getWidth();
    y = (int) d2.getHeight();

    d1 = d2;
    d2 = getNextCell8(x, y);
    code.add(new Complex(x,y));

    }while(!d1.equals(firstCell) && !d2.equals(secondCell) && d2!=null);

    code.remove(0); //Since cell1 got added twice.
    return code;
    }

    /**
    * 321
    * 4_0
    * 567
    */
    private Dimension getNextCell8(int x, int y){
    int startDirection = ((direction & 1) == 0)?((direction+7) % 8)direction+6) % 8);
    int i = 0;
    Dimension d = null;
    while(i<7){
    d = getCellInDirection(x, y, startDirection);
    if(d != null){
    direction = startDirection;
    break;
    }
    startDirection = mod ((startDirection +1), 8);
    i++;
    }
    return d;
    }



    private Dimension getCellInDirection(int x, int y, int dir){
    switch(dir){
    case 0:
    return (inBounds(x+1,y) && isObjectPixel(x+1,y))?new Dimension(x+1, y):null;
    case 1:
    return(inBounds(x+1,y-1) && isObjectPixel(x+1,y-1))?new Dimension(x+1, y-1):null;
    case 2:
    return(inBounds(x,y-1) && isObjectPixel(x,y-1))?new Dimension(x, y-1):null;
    case 3:
    return(inBounds(x-1,y-1) && isObjectPixel(x-1,y-1))?new Dimension(x-1, y-1):null;
    case 4:
    return(inBounds(x-1,y) && isObjectPixel(x-1,y))?new Dimension(x-1, y):null;
    case 5:
    return(inBounds(x-1,y+1) && isObjectPixel(x-1,y+1))?new Dimension(x-1, y+1):null;
    case 6:
    return(inBounds(x,y+1) && isObjectPixel(x,y+1))?new Dimension(x, y+1):null;
    case 7:
    return(inBounds(x+1,y+1) && isObjectPixel(x+1,y+1))?new Dimension(x+1, y+1):null;
    default:
    return null;
    }
    }



    private boolean inBounds(int x, int y){
    return ((x>=0 && x<width) && (y>=0 && y<height));
    }

    private boolean isObjectPixel(int x, int y){
    return (new Color(image.getRGB(x, y)).getBlue()>0);
    }

    private int mod(int a, int b){
    assert(b>0);
    int k = (int) Math.ceil((float)Math.abs(a)/b);
    a += (a<0)?k*b:0;
    return a % b;
    }

    }

    It's giving me this error upon compilation:

    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:33: error: cannot find symbol
    public ArrayList<Complex> getChainCodePixels(){
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:54: error: cannot find symbol
    private ArrayList<Complex> f(int x, int y) {
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:34: error: cannot find symbol
    ArrayList<Complex> list = new ArrayList<Complex>();
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:34: error: cannot find symbol
    ArrayList<Complex> list = new ArrayList<Complex>();
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:55: error: cannot find symbol
    ArrayList<Complex> code = new ArrayList<Complex>();
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:55: error: cannot find symbol
    ArrayList<Complex> code = new ArrayList<Complex>();
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:59: error: cannot find symbol
    code.add(new Complex(x,y)); //Add cell1
    ^
    symbol: class Complex
    location: class ChainCode
    C:\Users\dv3\Desktop\Chain Code Algo\ChainCode.java:70: error: cannot find symbol
    code.add(new Complex(x,y));
    ^
    symbol: class Complex
    location: class ChainCode
    8 errors

    Process completed.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Compiling error

    The "cannot find symbol" error is because the compiler can not find a definition for a class or variable.
    The name of the missing class or variable is given in the error message. Look at the error message, get the name of the missing item and then look at the code and find where the definition is.
    You may have to add a definition for the missing item.

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. .class compiling error
    By nijininjin in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 26th, 2012, 03:01 PM
  2. Compiling error
    By Bri4n in forum Java Theory & Questions
    Replies: 5
    Last Post: November 7th, 2011, 10:26 PM
  3. Compiling error
    By tangara in forum Java IDEs
    Replies: 3
    Last Post: September 4th, 2011, 03:00 AM
  4. Compiling Error?
    By Arkeshen in forum Java Theory & Questions
    Replies: 2
    Last Post: June 22nd, 2011, 04:31 AM
  5. Strange Compiling Error
    By crism85 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 13th, 2009, 12:59 AM