Class RMDoubleStroke
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMListenerList
-
- com.inductiveautomation.rm.base.RMObject
-
- com.inductiveautomation.rm.graphics.RMFill
-
- com.inductiveautomation.rm.graphics.RMStroke
-
- com.inductiveautomation.rm.graphics.RMDoubleStroke
-
- All Implemented Interfaces:
Archivable,RMPropertyChanger,java.lang.Cloneable
public class RMDoubleStroke extends RMStroke
Strokes a path with 2 lines of different widths, with an arbitrary separation (d) between them. This works by taking the input path and creating 'offset curves'. The offset curve is defined as being parallel to the original curve at every point. For a given parametric curve C(t)={x(t),y(t)}, the slope of the curve at t is given by mC(t)=(dy/dt) / (dx/dt) = y'(t)/x'(t) and the the normal is therefore NC(t)=Normalize({-x'(t), y'(t)}) An offset curve for a cubic bezier can not be represented by a single bezier. Therefore, we need to find a set of n curves OffC0,OffC1,...OffCn that fits, as closely as possible, the following points: OffsetPoint(t)=C(t)+d*NC(t) One possibility is to calculate a million OffsetPoints for the range t->{0,1} and run the curve fit code. In order to preserve continuity of the different bezier segments, it should also be required that mOffC0(0) = mC(0) and mOffCn(1) = mC(1) That is, the slopes at the beginning and end of the curve should the same in the offset curve as it is in the original curve. Also, since the offset points are obtained by walking along the normal vector for the original curve, the slope of the offset curve at offsetpoint(t) should be the same as mC(t). The curve fit code does not currently take into account the slope of the curve at a given input point, but it's something to look into. Knowing this may provide enough additional information to speed up the curve fit and/or reduce the number of input points needed for an accurate fit.
-
-
Field Summary
Fields Modifier and Type Field Description static intINNER_RULE_ON_PATHstatic intOUTER_RULE_ON_PATHstatic intRULE_GAP_ON_PATHstatic intRULES_CENTERED_ABOUT_PATH
-
Constructor Summary
Constructors Constructor Description RMDoubleStroke()Creates a new plain double stroke.RMDoubleStroke(RMColor col, float w)Creates a new double stroke.RMDoubleStroke(RMColor col, float outerW, float innerW, float separation, int positions)Creates a new double stroke.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RMDoubleStrokeclone()Standard clone implementation.booleanequals(java.lang.Object anObj)Standard equals implementation.java.lang.ObjectfromXML(RXArchiver anArchiver, RXElement e)XML unarchival.RMRectgetBounds(RMShape aShape)Returns the bounds required to render this fill for this shape.floatgetInnerRuleWidth()Returns the inner rule width.RMStrokegetInnerStroke()Return the stroke used on the inside of a clockwise pathfloatgetOuterRuleWidth()Returns the outer rule width.RMStrokegetOuterStroke()Return the stroke used on the outside of a clockwise pathintgetRulePositions()Returns the double stroke rule positions.floatgetRuleSeparation()voidpaint(RMShapePainter aPntr, RMShape aShape)Override to paint inner and outer strokes.protected voidreadAttributes(RXElement e)voidsetInnerRuleWidth(float _innerRuleWidth)voidsetOuterRuleWidth(float _outerRuleWidth)voidsetRulePositions(int _rulePositions)voidsetRuleSeparation(float _ruleSeparation)RXElementtoXML(RXArchiver anArchiver)XML archival.-
Methods inherited from class com.inductiveautomation.rm.graphics.RMStroke
getDashArray, getDashArray, getDashArrayString, getDashArrayString, getDashPhase, getName, getStroke, getStrokePath, getWidth, setColor, setDashArray, setDashArrayString, setDashPhase, setWidth
-
Methods inherited from class com.inductiveautomation.rm.graphics.RMFill
deriveFill, getColor, hasAlpha, toString
-
Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange
-
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
-
-
-
-
Field Detail
-
OUTER_RULE_ON_PATH
public static final int OUTER_RULE_ON_PATH
- See Also:
- Constant Field Values
-
INNER_RULE_ON_PATH
public static final int INNER_RULE_ON_PATH
- See Also:
- Constant Field Values
-
RULES_CENTERED_ABOUT_PATH
public static final int RULES_CENTERED_ABOUT_PATH
- See Also:
- Constant Field Values
-
RULE_GAP_ON_PATH
public static final int RULE_GAP_ON_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RMDoubleStroke
public RMDoubleStroke()
Creates a new plain double stroke.
-
RMDoubleStroke
public RMDoubleStroke(RMColor col, float w)
Creates a new double stroke.
-
RMDoubleStroke
public RMDoubleStroke(RMColor col, float outerW, float innerW, float separation, int positions)
Creates a new double stroke.
-
-
Method Detail
-
getRulePositions
public int getRulePositions()
Returns the double stroke rule positions.
-
setRulePositions
public void setRulePositions(int _rulePositions)
-
getInnerRuleWidth
public float getInnerRuleWidth()
Returns the inner rule width.
-
setInnerRuleWidth
public void setInnerRuleWidth(float _innerRuleWidth)
-
getOuterRuleWidth
public float getOuterRuleWidth()
Returns the outer rule width.
-
setOuterRuleWidth
public void setOuterRuleWidth(float _outerRuleWidth)
-
getOuterStroke
public RMStroke getOuterStroke()
Return the stroke used on the outside of a clockwise path
-
getInnerStroke
public RMStroke getInnerStroke()
Return the stroke used on the inside of a clockwise path
-
getRuleSeparation
public float getRuleSeparation()
-
setRuleSeparation
public void setRuleSeparation(float _ruleSeparation)
-
getBounds
public RMRect getBounds(RMShape aShape)
Returns the bounds required to render this fill for this shape.
-
paint
public void paint(RMShapePainter aPntr, RMShape aShape)
Override to paint inner and outer strokes.
-
equals
public boolean equals(java.lang.Object anObj)
Standard equals implementation.
-
clone
public RMDoubleStroke clone()
Standard clone implementation.
-
toXML
public RXElement toXML(RXArchiver anArchiver)
XML archival.- Specified by:
toXMLin interfaceArchivable- Overrides:
toXMLin classRMStroke
-
fromXML
public java.lang.Object fromXML(RXArchiver anArchiver, RXElement e)
XML unarchival.- Specified by:
fromXMLin interfaceArchivable- Overrides:
fromXMLin classRMStroke
-
readAttributes
protected void readAttributes(RXElement e)
- Overrides:
readAttributesin classRMStroke
-
-