# Class DefaultStyle

java.lang.Object
uk.ac.starlink.ttools.plot.DefaultStyle

All Implemented Interfaces:
  `Style`

Direct Known Subclasses:
  `BarStyle, MarkStyle`

public abstract class DefaultStyle extends Object implements Style
Convenience partial implementation of Style which has a defined colour and stroke style, with other attributes given by a single object. The `otherAtts` attribute characterises everything apart from colour, stroke and class which distinguish one instance of this class from another, and is used by the `equals(Object)` implementation to determine object equality. `otherAtts` probably ought to be immutable.

Since:
  16 Nov 2005
Author:
  Mark Taylor

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`DefaultStyle(Color color, Object otherAtts)`
Constructs a style given a colour, style and `otherAtts` object.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object o)`
Returns true if `o` satisfies the following conditions It has the same class as this one It has the same colour as this one It has the same stroke as this one The `otherAtts` object specified at its creation matches (according to `equals()` this one's
`Color`
`getColor()`
Returns the colour of this style.
`float[]`
`getDash()`
Returns the dash pattern associated with this style.
`int`
`getLineWidth()`
Returns the line width associated with this style.
`Object`
`getOtherAtts()`
Returns the object which distinguishes this object from other ones of the same colour and class.
`Stroke`
`getStroke(int cap, int join)`
Returns a stroke suitable for drawing lines in this style.
`static Stroke`
`getStroke(Stroke stroke, int cap, int join)`
Returns a stroke which resembles a given template but has specified end cap and line join policies.
`int`
`hashCode()`
`void`
`setColor(Color color)`
Sets the colour of this style.
`void`
`setDash(float[] dash)`
Sets the dash pattern associated with this style.
`void`
`setLineWidth(int width)`
Sets the line width associated with this style.
`String`
`toString()`

### Methods inherited from class Object

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

### Methods inherited from interface Style

`getLegendIcon`

## Constructor Details

### DefaultStyle

protected DefaultStyle(Color color, Object otherAtts)
Constructs a style given a colour, style and `otherAtts` object.

Parameters:
  `color` - initial colour
  `otherAtts` - object distinguishing this instance

## Method Details

### setColor

public void setColor(Color color)
Sets the colour of this style.

Parameters:
  `color` - new colour

### getColor

public Color getColor()
Returns the colour of this style.

Returns:
  colour

### setLineWidth

public void setLineWidth(int width)
Sets the line width associated with this style.

Parameters:
  `width` - line width (>=1)

### getLineWidth

public int getLineWidth()
Returns the line width associated with this style.

Returns:
  line width

### setDash

public void setDash(float[] dash)
Sets the dash pattern associated with this style. This is like the dash array in `BasicStroke`, except that it is multiplied by the line width before use. May be null for a solid line.

Parameters:
  `dash` - dash array

### getDash

public float[] getDash()
Returns the dash pattern associated with this style. May be null for a solid line.

Returns:
  dash array

### getStroke

public Stroke getStroke(int cap, int join)
Returns a stroke suitable for drawing lines in this style. The line join and cap policy must be provided.

Parameters:
  `cap` - one of `BasicStroke`'s CAP_* constants
  `join` - one of `BasicStroke`'s JOIN_* constants
Returns:
  stroke

### getOtherAtts

public Object getOtherAtts()
Returns the object which distinguishes this object from other ones of the same colour and class.

Returns:
  otherAtts object

### equals

public boolean equals(Object o)
Returns true if `o` satisfies the following conditions

1. It has the same class as this one
2. It has the same colour as this one
3. It has the same stroke as this one
4. The `otherAtts` object specified at its creation matches (according to `equals()` this one's

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### getStroke

public static Stroke getStroke(Stroke stroke, int cap, int join)
Returns a stroke which resembles a given template but has specified end cap and line join policies.

Parameters:
  `stroke` - template stroke
  `cap` - one of `BasicStroke`'s CAP_* constants
  `join` - one of `BasicStroke`'s JOIN_* constants
Returns:
  fixed stroke, may be the same as the input one