Package uk.ac.starlink.ttools.plot
Class DefaultStyle
java.lang.Object
uk.ac.starlink.ttools.plot.DefaultStyle
- All Implemented Interfaces:
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(java.lang.Object) implementation to determine object equality.
otherAtts probably ought to be immutable.- Since:
- 16 Nov 2005
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefaultStyle(Color color, Object otherAtts) Constructs a style given a colour, style andotherAttsobject. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns 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'sgetColor()Returns the colour of this style.float[]getDash()Returns the dash pattern associated with this style.intReturns the line width associated with this style.Returns the object which distinguishes this object from other ones of the same colour and class.getStroke(int cap, int join) Returns a stroke suitable for drawing lines in this style.static StrokeReturns a stroke which resembles a given template but has specified end cap and line join policies.inthashCode()voidSets 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.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface uk.ac.starlink.ttools.plot.Style
getLegendIcon
-
Constructor Details
-
DefaultStyle
Constructs a style given a colour, style andotherAttsobject.- Parameters:
color- initial colourotherAtts- object distinguishing this instance
-
-
Method Details
-
setColor
Sets the colour of this style.- Parameters:
color- new colour
-
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
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
Returns the object which distinguishes this object from other ones of the same colour and class.- Returns:
- otherAtts object
-
equals
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
-
hashCode
public int hashCode() -
toString
-
getStroke
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
-