## devisor2.foundation.boundary
Class Segment

    java.lang.Object
      devisor2.foundation.GridItem
          devisor2.foundation.boundary.Segment

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  SegmentCircle, SegmentFile, SegmentLine

public abstract class Segment
extends GridItem
implements java.io.Serializable

This class Segment builds the super class for the boundary segments. A segment is an atomic unit of the boundary curve.

See Also:
  Serialized Form

Field Summary
`protected Boundary` `boundary` link to boundary to which this segment belongs
`protected int[]` `orientation_marker_1` first point (world coords) of the orientation marker triangle
`protected int[]` `orientation_marker_2` second point (world coords) of the orientation marker triangle
`protected int[]` `orientation_marker_3` third point (world coords) of the orientation marker triangle
`protected double` `tmax` length of the segment

Fields inherited from class devisor2.foundation.GridItem
`cc, marked, transformed, xmax, xmin, ymax, ymin`

Constructor Summary
`Segment()` default constructor
`Segment(double stmax)` creates a segment with length stmax

Method Summary
`abstract void` `adjustPerimeter(Node n, int index)` change coordinates therefor, that at indes 0 that the beginning of this segment is at node 'n', else that the ending of this segment is at node 'n'.
`abstract java.lang.Object` `clone()` creates a shallow clone of this segment
`abstract void` `draw(java.awt.Graphics g)` draws the segment
`void` `drawOrientationMarker(java.awt.Graphics g)` draws the orientation marker triangle using the coordinates in the three orientation_marker local attributes.
`Boundary` `getBoundary()`
`int` `getBoundaryNumber()` return internally saved boundary number
`abstract Node` `getCartesianCoords(double t)` gets the cartesian coordinates of the node according to parameter t
`abstract double[]` `getParameters()` gets the parameters of the segment
`abstract double` `getParameterValue(Node n)` calculate parameter value of node 'n' from its x/y coordinates (note: only the relative parameter value is calculated, the boundary-wide value is not considered)
`abstract int[]` `getParams()` gets the parameters of the segment
`abstract java.awt.Rectangle` `getPerimeter()` gets the perimeter of the segment
`int` `getSegmentNumber()`
`double` `getTMax()`
`abstract boolean` `isHit(int x, int y)` Determines if the item has been hit by a click on the grid ALL IN WORLD COORDINATES to avoid the snap mechanism
`abstract boolean` `isInside(int[] topleft, int[] bottomright)` Is the item inside a given rectangular area? All in WORLD COORDINATES!!!
`abstract boolean` `isOnBoundary(int x, int y)` returns whether or not a point lies on a boundary segment
`abstract void` `performMirror(double nx, double ny, double px, double py)` This method mirrors the grid item at the given line
`abstract void` `performTransformation(GridTransformation trafo)` applies the Transformation to the Segment and calls updateInnerData
`void` `setBoundary(Boundary b)` sets the boundary of this segment
`abstract void` `setParameters(double[] ux)` sets the parameters of the segment
`abstract void` `setParams(int[] ux)` sets the parameters of the segment
`void` `setTMax(double value)` sets the maximal parameter value to the given value
`abstract void` `swapPerimeter()` inverts orientation of this segment without changing parameter values of related boundarynodes.
`abstract void` `updateInnerData()` updates the inner data used for hit detection etc.

Methods inherited from class devisor2.foundation.GridItem
`clearTransformedFlag, isMarked, setMarker, setMarker, unsetMarker`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### tmax

    protected double tmax

  length of the segment

### orientation_marker_1

    protected int[] orientation_marker_1

  first point (world coords) of the orientation marker triangle

### orientation_marker_2

    protected int[] orientation_marker_2

  second point (world coords) of the orientation marker triangle

### orientation_marker_3

    protected int[] orientation_marker_3

  third point (world coords) of the orientation marker triangle

### boundary

    protected Boundary boundary

  link to boundary to which this segment belongs

Constructor Detail

### Segment

    public Segment(double stmax)

  creates a segment with length stmax

### Segment

    public Segment()

  default constructor

Method Detail

### setTMax

    public void setTMax(double value)

  sets the maximal parameter value to the given value

### getTMax

    public double getTMax()

  Returns:
    the current max parameter value

### getBoundaryNumber

    public int getBoundaryNumber()

  return internally saved boundary number

### getBoundary

    public Boundary getBoundary()

  Returns:
    the boundary to which this segment belongs

### setBoundary

    public void setBoundary(Boundary b)

  sets the boundary of this segment

### getSegmentNumber

    public int getSegmentNumber()

  Returns:
    number of the segment in the boundary

### getCartesianCoords

    public abstract Node getCartesianCoords(double t)

  gets the cartesian coordinates of the node according to parameter t

  Parameters:
    `t` - parameter value
  Returns:
    Node representation of the coordinates

### draw

    public abstract void draw(java.awt.Graphics g)

  draws the segment

  Specified by:
    `draw` in class `GridItem`
  Parameters:
    `g` - - the graphics context to paint to

### getPerimeter

    public abstract java.awt.Rectangle getPerimeter()

  gets the perimeter of the segment

  Specified by:
    `getPerimeter` in class `GridItem`
  Returns:
    a Rectangle object defining the perimeter

### isOnBoundary

    public abstract boolean isOnBoundary(int x,
                                         int y)

  returns whether or not a point lies on a boundary segment

  Returns:
    true if the Point is on the segment, false otherwise

### getParameterValue

    public abstract double getParameterValue(Node n)

  calculate parameter value of node 'n' from its x/y coordinates (note: only the relative parameter value is calculated, the boundary-wide value is not considered)

### swapPerimeter

    public abstract void swapPerimeter()

  inverts orientation of this segment without changing parameter values of related boundarynodes.

### adjustPerimeter

    public abstract void adjustPerimeter(Node n,
                                         int index)

  change coordinates therefor, that at indes 0 that the beginning of this segment is at node 'n', else that the ending of this segment is at node 'n'.

### isInside

    public abstract boolean isInside(int[] topleft,
                                     int[] bottomright)

  Is the item inside a given rectangular area? All in WORLD COORDINATES!!!

  Specified by:
    `isInside` in class `GridItem`
  Parameters:
    `topleft` - - the topleft corner of the rectangle
    `bottomright` - - the bottom right corner of the rectangle
  Returns:
    true if the item is completely inside the rectangle

### isHit

    public abstract boolean isHit(int x,
                                  int y)

  Determines if the item has been hit by a click on the grid ALL IN WORLD COORDINATES to avoid the snap mechanism

  Specified by:
    `isHit` in class `GridItem`
  Returns:
    true if the item has been hit

### updateInnerData

    public abstract void updateInnerData()

  updates the inner data used for hit detection etc. Needs to be called after every change to the Segment

### performTransformation

    public abstract void performTransformation(GridTransformation trafo)

  applies the Transformation to the Segment and calls updateInnerData

  Specified by:
    `performTransformation` in class `GridItem`
  Parameters:
    `trafo` - - a GridTransform instance representing the transformation

### performMirror

    public abstract void performMirror(double nx,
                                       double ny,
                                       double px,
                                       double py)

  This method mirrors the grid item at the given line

  Specified by:
    `performMirror` in class `GridItem`

### clone

    public abstract java.lang.Object clone()

  creates a shallow clone of this segment

### setParameters

    public abstract void setParameters(double[] ux)

  sets the parameters of the segment

  Specified by:
    `setParameters` in class `GridItem`

### getParameters

    public abstract double[] getParameters()

  gets the parameters of the segment

  Specified by:
    `getParameters` in class `GridItem`

### setParams

    public abstract void setParams(int[] ux)

  sets the parameters of the segment

### getParams

    public abstract int[] getParams()

  gets the parameters of the segment

### drawOrientationMarker

    public void drawOrientationMarker(java.awt.Graphics g)

  draws the orientation marker triangle using the coordinates in the three orientation_marker local attributes. these attributes have to be set by the updateInnerData method.