# Class Surround.Block

java.lang.Object
uk.ac.starlink.ttools.plot2.Surround.Block

Enclosing class:
  `Surround`

public static class Surround.Block extends Object
Represents the space taken along one side of a rectangle. The extent is considered to be the distance perpendicular to the side away from the rectangle, while the under/over values are non-negative overhang distances in the negative/positive directions parallel to the side. The top block is represented by the following magnificent ASCII-art:

          ----------------------------------------------------------
          |           .              ^                  .          |
          |           .              |                  .          |
          |(--under--).            extent               .(--over--)|
          |           .              |                  .          |
          |-----------.              V                  .----------|
                      +++++++++++++++++++++++++++++++++++
                      ++++++ Attached rectangle +++++++++
                      +++++++++++++++++++++++++++++++++++

Since:
  7 Dec 2022
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`int`
`extent`
`int`
`over`
`int`
`under`

## Constructor Summary

Constructors
Constructor
Description
`Block()`
Constructs an empty block.
`Block(int extent)`
Constructs a block with an extent but no over or under.
`Block(int extent, int under, int over)`
Constructs a block with all members supplied.
`Block(Surround.Block other)`
Clone constructor.

## Method Summary

Modifier and Type
Method
Description
`Surround.Block`
`add(Surround.Block other)`
Creates a block which is represents the sum of this and another.
`String`
`toString()`
`Surround.Block`
`union(Surround.Block other)`
Creates a block which represents the union of this and another.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### extent

public int extent

### under

public int under

### over

public int over

## Constructor Details

### Block

public Block()
Constructs an empty block.

### Block

public Block(Surround.Block other)
Clone constructor. A deep copy of the provided template is constructed.

Parameters:
  `other` - template block

### Block

public Block(int extent)
Constructs a block with an extent but no over or under.

Parameters:
  `extent` - extent

### Block

public Block(int extent, int under, int over)
Constructs a block with all members supplied.

Parameters:
  `extent` - extent perpendicular to axis
  `under` - non-negative overhang in negative direction parallel to axis
  `over` - non-negative overhang in positive direction parallel to axis

## Method Details

### add

public Surround.Block add(Surround.Block other)
Creates a block which is represents the sum of this and another. Extents are added, and the larger over/under values are used.

Parameters:
  `other` - block to add to this one
Returns:
  new block

### union

public Surround.Block union(Surround.Block other)
Creates a block which represents the union of this and another. For each of extent, under and over, the maximum values is used.

Parameters:
  `other` - block to add to this one
Returns:
  new block

### toString

public String toString()

Overrides:
  `toString` in class `Object`