|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectshady.common.Environment
shady.common.multi.MultiEnvironment
public class MultiEnvironment
An Environment for MultiShady.
A MultiEnvironment is a set of MultiSegments.
Copyright (C) 2006 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
| Field Summary | |
|---|---|
static double |
CONSISTENCY_CHECK_ORIENTATION_SLOP
Orientation tolerance for place consistency check in degrees. |
static double |
CONSISTENCY_CHECK_TRANSLATION_SLOP
Translation tolerance for place consistency check in meters. |
private static java.lang.String |
cvsid
CVS id. |
static double |
DEFAULT_BASE_WIDTH
The width of the grounded base segment in the default environment. |
protected boolean |
deferPlace
Whether place() is currently deferred. |
protected boolean |
needsPlace
Whether place() needs to be called after deferPlace is
turned off. |
| Fields inherited from class shady.common.Environment |
|---|
boundsDirty, centerX, centerY, DEFAULT_BAR_WIDTH, DEFAULT_COLUMN_WIDTH, DEFAULT_MAX_LOWER_ROW_HEIGHT, DEFAULT_MIN_LOWER_ROW_HEIGHT, DEFAULT_NUM_PANE_COLUMNS, DEFAULT_UPPER_ROW_HEIGHT, height, listeners, lockBounds, maxX, maxY, minX, minY, segments, width |
| Constructor Summary | |
|---|---|
MultiEnvironment()
Makes a default environment (see makeDefaultEnvironment()). |
|
MultiEnvironment(MultiSegment[] segment)
Make a new MulitEnvironment. |
|
| Method Summary | |
|---|---|
int |
addSegment(double startX,
double startY,
double endX,
double endY)
Covers addSegment(double, double, double, double, boolean),
always adds a grounded segment. |
int |
addSegment(double startX,
double startY,
double endX,
double endY,
boolean grounded)
Add a new segment at the end of the list. |
protected boolean |
checkPrune(MultiSegment child,
MemberShadyCommonAPI member,
ShadyPose pose)
Check if child needs to be placed. |
boolean |
isDeferPlace()
Check whether place is currently deferred. |
protected void |
makeDefaultEnvironment()
Makes a default environment with a single horizontal grounded base segment of width DEFAULT_BASE_WIDTH centered at the origin. |
void |
moveSegment(int index,
double startX,
double startY,
double endX,
double endY)
Move the Segment at index. |
int |
place()
Try to place all non-grounded segments. |
protected boolean |
placeChild(MultiSegment child,
Point.OnSegment parentPoint,
Point.OnSegment childPoint,
double parentToChildOrientation,
double childOrientation,
double l)
Place the segment child. |
protected int |
placeFrom(MultiSegment root,
ShadyPose pose)
Recursively place unplaced segments in a DFS starting from root. |
protected int |
placeImpl()
Implementation of place(). |
void |
setDeferPlace(boolean deferPlace)
Whether to defer all calls to place(). |
| Methods inherited from class shady.common.Environment |
|---|
addListener, clearSegments, enumerateSegments, fireEnvironmentChanged, getCenterX, getCenterY, getHeight, getMaxX, getMaxY, getMinX, getMinY, getSegment, getWidth, isEmpty, makeDefaultEnvironment, numSegments, pick, pick, pick, recomputeBounds, removeLastSegment, removeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String cvsid
CVS id.
public static final double CONSISTENCY_CHECK_ORIENTATION_SLOP
Orientation tolerance for place consistency check in degrees.
public static final double CONSISTENCY_CHECK_TRANSLATION_SLOP
Translation tolerance for place consistency check in meters.
public static final double DEFAULT_BASE_WIDTH
The width of the grounded base segment in the default environment.
protected boolean needsPlace
Whether place() needs to be called after deferPlace is
turned off.
protected boolean deferPlace
Whether place() is currently deferred.
| Constructor Detail |
|---|
public MultiEnvironment()
Makes a default environment (see makeDefaultEnvironment()).
public MultiEnvironment(MultiSegment[] segment)
Make a new MulitEnvironment.
segment - the set of MultiSegments, not null, a copy is made, the
connected Shady sets (MultiSegment.members) are not copied| Method Detail |
|---|
public int addSegment(double startX,
double startY,
double endX,
double endY)
Covers addSegment(double, double, double, double, boolean),
always adds a grounded segment.
addSegment in class EnvironmentstartX - the start X coord of the segment in metersstartY - the start Y coord of the segment in metersendX - the end X coord of the segment in metersendY - the end Y coord of the segment in meters
public int addSegment(double startX,
double startY,
double endX,
double endY,
boolean grounded)
Add a new segment at the end of the list.
Same as Environment.addSegment(double, double, double, double) but includes
groundedspecification.
grounded - whether the new segment is grounded
public void moveSegment(int index,
double startX,
double startY,
double endX,
double endY)
Move the Segment at index.
A EnvironmentListener.environmentChanged(shady.common.Environment) event will be fired to
all registered listeners.
Extends super impl to place().
moveSegment in class Environmentindex - the zero-based index of the segment to movestartX - the new start X coord of the segment in metersstartY - the new start Y coord of the segment in metersendX - the new end X coord of the segment in metersendY - the new end Y coord of the segment in meterspublic void setDeferPlace(boolean deferPlace)
Whether to defer all calls to place().
Has no effect if request is same as current defer state.
If defer is turned off then place() will be called
immediately iff it was called at all while defer was on.
deferPlace - whether to defer all calls to place().public boolean isDeferPlace()
Check whether place is currently deferred.
public int place()
Try to place all non-grounded segments.
The implementation is currently a depth-first traversal of the
connectivity graph starting from all grounded segments. First all
non-grounded segments are marked not MultiSegment.placed. Then
segments adjacent to placed or grounded segments in the connectivity graph
are recursively placed. This continues until no unplaced segments adj
placed or grounded segments remain. Note that unplaced segments will
still remain iff the connectivity graph contains any connected components
with zero grounded segments.
Overconstrained non-grounded segments are placed only by the first path found in the connectivity graph.
Calls to this method should be synchronized wrt modifications to the topology of the connectivity graph and the state of all members. By convention, the MultiShady object is used for this synchronization.
It is not normally necessary to call this method manually. It is called
by implementations of MemberShadyCommonAPI after rotations or
gripper opens or closes, and by moveSegment(int, double, double, double, double).
It is possible to defer the place algorithm, see setDeferPlace(boolean).
protected int placeImpl()
Implementation of place().
Synchronized.
protected int placeFrom(MultiSegment root,
ShadyPose pose)
Recursively place unplaced segments in a DFS starting from
root.
See place().
root - the starting segment, assumed MultiSegment.grounded or
MultiSegment.placedpose - a ShadyPose to use as scratch
protected boolean checkPrune(MultiSegment child,
MemberShadyCommonAPI member,
ShadyPose pose)
Check if child needs to be placed.
child - the segment to checkmember - the connecting member shady, to be used for consistency
check if necessarypose - the pose of member
child does not need to be placed
protected boolean placeChild(MultiSegment child,
Point.OnSegment parentPoint,
Point.OnSegment childPoint,
double parentToChildOrientation,
double childOrientation,
double l)
Place the segment child.
Does not set child.placed.
child - the segment to placeparentPoint - the member attachment point on the parent segmentchildPoint - the member attachment point on childparentToChildOrientation - the absolute orientation of the member in
degrees from parentPoint to childPointchildOrientation - the absolute orientation in degrees of
childl - the center-to-center length of the connecting member in meters
child was successfully placedprotected void makeDefaultEnvironment()
Makes a default environment with a single horizontal grounded base
segment of widthDEFAULT_BASE_WIDTH centered at the origin.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||