Package uk.ac.starlink.ttools.plot
Class DefaultStyle
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.DefaultStyle
-
- All Implemented Interfaces:
Style
public abstract class DefaultStyle extends java.lang.Object implements Style
Convenience partial implementation of Style which has a defined colour and stroke style, with other attributes given by a single object. TheotherAttsattribute characterises everything apart from colour, stroke and class which distinguish one instance of this class from another, and is used by theequals(java.lang.Object)implementation to determine object equality.otherAttsprobably ought to be immutable.- Since:
- 16 Nov 2005
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultStyle(java.awt.Color color, java.lang.Object otherAtts)Constructs a style given a colour, style andotherAttsobject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Returns true ifosatisfies 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 TheotherAttsobject specified at its creation matches (according toequals()this one'sjava.awt.ColorgetColor()Returns the colour of this style.float[]getDash()Returns the dash pattern associated with this style.intgetLineWidth()Returns the line width associated with this style.java.lang.ObjectgetOtherAtts()Returns the object which distinguishes this object from other ones of the same colour and class.java.awt.StrokegetStroke(int cap, int join)Returns a stroke suitable for drawing lines in this style.static java.awt.StrokegetStroke(java.awt.Stroke stroke, int cap, int join)Returns a stroke which resembles a given template but has specified end cap and line join policies.inthashCode()voidsetColor(java.awt.Color color)Sets the colour of this style.voidsetDash(float[] dash)Sets the dash pattern associated with this style.voidsetLineWidth(int width)Sets the line width associated with this style.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface uk.ac.starlink.ttools.plot.Style
getLegendIcon
-
-
-
-
Method Detail
-
setColor
public void setColor(java.awt.Color color)
Sets the colour of this style.- Parameters:
color- new colour
-
getColor
public java.awt.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 inBasicStroke, 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 java.awt.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 ofBasicStroke's CAP_* constantsjoin- one ofBasicStroke's JOIN_* constants- Returns:
- stroke
-
getOtherAtts
public java.lang.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(java.lang.Object o)
Returns true ifosatisfies 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
otherAttsobject specified at its creation matches (according toequals()this one's
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getStroke
public static java.awt.Stroke getStroke(java.awt.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 strokecap- one ofBasicStroke's CAP_* constantsjoin- one ofBasicStroke's JOIN_* constants- Returns:
- fixed stroke, may be the same as the input one
-
-