edu.mit.sketch.ddg
Class Primitive

java.lang.Object
  extended by edu.mit.sketch.ddg.Primitive
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Primitive
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

An abstract geometric primitive that is part of an object description (like "line l2"). Stores the type and the name of the primitive in the drawing.

Primitive.java Created: Sat Nov 20 21:36:00 2001

Author:
Olya Veselova
See Also:
Serialized Form

Field Summary
static int ARC
           
static int ELLIPSE
           
static int GROUP
           
static int LINE
           
static int POINT
           
static int UNKNOWN
           
 
Constructor Summary
Primitive(int type, java.lang.String name)
          Constructs the primitive of the type and name
Primitive(java.lang.String type, java.lang.String name)
          Constructs the primitive of the type and name
 
Method Summary
 java.lang.Object clone()
          Clone the primitive
static Primitive convertFrom(GeometricObject o, int index)
          Constructs a primitive from a given object with index in the name.
 boolean equals(java.lang.Object p)
          The two primitives are the same if their name and type are the same.
 int hashCode()
          The hashcode of a primitive is a hash code of it's string description.
 java.lang.String name()
          Name of the primitive (like "l2" in "line l2")
 java.lang.String toString()
          String description of the primitive (like "line l2") - includes both type and name
 int type()
          Type of the primitive (like "line" in "line l2")
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

POINT

public static final int POINT
See Also:
Constant Field Values

LINE

public static final int LINE
See Also:
Constant Field Values

ELLIPSE

public static final int ELLIPSE
See Also:
Constant Field Values

ARC

public static final int ARC
See Also:
Constant Field Values

GROUP

public static final int GROUP
See Also:
Constant Field Values
Constructor Detail

Primitive

public Primitive(int type,
                 java.lang.String name)
Constructs the primitive of the type and name


Primitive

public Primitive(java.lang.String type,
                 java.lang.String name)
Constructs the primitive of the type and name

Method Detail

convertFrom

public static Primitive convertFrom(GeometricObject o,
                                    int index)
Constructs a primitive from a given object with index in the name. Example: if index is 4 and the object is a line the primitive will be "line l4".


toString

public java.lang.String toString()
String description of the primitive (like "line l2") - includes both type and name

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object p)
The two primitives are the same if their name and type are the same. For use in hashtable representing the constraint graph.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The hashcode of a primitive is a hash code of it's string description. For use in hashtable representing the constraint graph

Overrides:
hashCode in class java.lang.Object

name

public java.lang.String name()
Name of the primitive (like "l2" in "line l2")


type

public int type()
Type of the primitive (like "line" in "line l2")


clone

public java.lang.Object clone()
Clone the primitive

Overrides:
clone in class java.lang.Object