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
,Cloneable
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
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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
Modifier and TypeMethodDescriptionclone()
Standard clone implementation.boolean
Standard equals implementation.fromXML
(RXArchiver anArchiver, RXElement e) XML unarchival.Returns the bounds required to render this fill for this shape.float
Returns the inner rule width.Return the stroke used on the inside of a clockwise pathfloat
Returns the outer rule width.Return the stroke used on the outside of a clockwise pathint
Returns the double stroke rule positions.float
void
paint
(RMShapePainter aPntr, RMShape aShape) Override to paint inner and outer strokes.protected void
void
setInnerRuleWidth
(float _innerRuleWidth) void
setOuterRuleWidth
(float _outerRuleWidth) void
setRulePositions
(int _rulePositions) void
setRuleSeparation
(float _ruleSeparation) toXML
(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 Details
-
OUTER_RULE_ON_PATH
public static final int OUTER_RULE_ON_PATH- See Also:
-
INNER_RULE_ON_PATH
public static final int INNER_RULE_ON_PATH- See Also:
-
RULES_CENTERED_ABOUT_PATH
public static final int RULES_CENTERED_ABOUT_PATH- See Also:
-
RULE_GAP_ON_PATH
public static final int RULE_GAP_ON_PATH- See Also:
-
-
Constructor Details
-
RMDoubleStroke
public RMDoubleStroke()Creates a new plain double stroke. -
RMDoubleStroke
Creates a new double stroke. -
RMDoubleStroke
Creates a new double stroke.
-
-
Method Details
-
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
Return the stroke used on the outside of a clockwise path -
getInnerStroke
Return the stroke used on the inside of a clockwise path -
getRuleSeparation
public float getRuleSeparation() -
setRuleSeparation
public void setRuleSeparation(float _ruleSeparation) -
getBounds
Returns the bounds required to render this fill for this shape. -
paint
Override to paint inner and outer strokes. -
equals
Standard equals implementation. -
clone
Standard clone implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceArchivable
- Overrides:
toXML
in classRMStroke
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceArchivable
- Overrides:
fromXML
in classRMStroke
-
readAttributes
- Overrides:
readAttributes
in classRMStroke
-