本文整理汇总了Java中prefuse.visual.VisualItem.getY方法的典型用法代码示例。如果您正苦于以下问题:Java VisualItem.getY方法的具体用法?Java VisualItem.getY怎么用?Java VisualItem.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.VisualItem
的用法示例。
在下文中一共展示了VisualItem.getY方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAlignedPoint
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* Helper method, which calculates the top-left co-ordinate of an item
* given the item's alignment.
*/
protected static void getAlignedPoint(
Point2D p, VisualItem item,
double w, double h, int xAlign, int yAlign )
{
double x = item.getX(), y = item.getY();
if ( Double.isNaN( x ) || Double.isInfinite( x ) )
x = 0; // safety check
if ( Double.isNaN( y ) || Double.isInfinite( y ) )
y = 0; // safety check
if ( xAlign == Constants.CENTER ) {
x = x - ( w / 2 );
}
else if ( xAlign == Constants.RIGHT ) {
x = x - w;
}
if ( yAlign == Constants.CENTER ) {
y = y - ( h / 2 );
}
else if ( yAlign == Constants.BOTTOM ) {
y = y - h;
}
p.setLocation( x, y );
}
示例2: getAlignedPoint
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* Helper method, which calculates the top-left co-ordinate of an item
* given the item's alignment.
*/
protected static void getAlignedPoint(Point2D p, VisualItem item,
double w, double h, int xAlign, int yAlign)
{
double x = item.getX(), y = item.getY();
if ( Double.isNaN(x) || Double.isInfinite(x) )
x = 0; // safety check
if ( Double.isNaN(y) || Double.isInfinite(y) )
y = 0; // safety check
if ( xAlign == Constants.CENTER ) {
x = x-(w/2);
} else if ( xAlign == Constants.RIGHT ) {
x = x-w;
}
if ( yAlign == Constants.CENTER ) {
y = y-(h/2);
} else if ( yAlign == Constants.BOTTOM ) {
y = y-h;
}
p.setLocation(x,y);
}
示例3: getCentroid
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* Return the centroid (averaged location) of a group of items.
* @param iter an iterator of VisualItems
* @param p a Point2D instance in which to store the result
* @return the centroid point. This is the same object as the
* parameter <code>p</code>.
*/
public static Point2D getCentroid(Iterator iter, Point2D p) {
double cx = 0, cy = 0;
int count = 0;
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
double x = item.getX(), y = item.getY();
if ( !(Double.isInfinite(x) || Double.isNaN(x)) &&
!(Double.isInfinite(y) || Double.isNaN(y)) )
{
cx += x;
cy += y;
count++;
}
}
if ( count > 0 ) {
cx /= count;
cy /= count;
}
p.setLocation(cx, cy);
return p;
}
示例4: move
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
protected static void move(VisualItem item, double dx, double dy) {
if ( item instanceof AggregateItem ) {
Iterator items = ((AggregateItem)item).items();
while ( items.hasNext() ) {
move((VisualItem)items.next(), dx, dy);
}
} else {
double x = item.getX();
double y = item.getY();
item.setStartX(x); item.setStartY(y);
item.setX(x+dx); item.setY(y+dy);
item.setEndX(x+dx); item.setEndY(y+dy);
}
}
示例5: move
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
protected static void move(VisualItem item, double dx, double dy) {
if ( item instanceof AggregateItem ) {
Iterator<?> items = ((AggregateItem)item).items();
while ( items.hasNext() ) {
move((VisualItem)items.next(), dx, dy);
}
} else {
double x = item.getX();
double y = item.getY();
item.setStartX(x); item.setStartY(y);
item.setX(x+dx); item.setY(y+dy);
item.setEndX(x+dx); item.setEndY(y+dy);
}
}
示例6: move
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
protected static void move(VisualItem item, double dx, double dy) {
if ( item instanceof AggregateItem ) {
Iterator<?> items = ((AggregateItem)item).items();
while ( items.hasNext() ) {
move((VisualItem)items.next(), dx, dy);
}
} else {
double x = item.getX();
double y = item.getY();
item.setStartX(x); item.setStartY(y);
item.setX(x+dx); item.setY(y+dy);
item.setEndX(x+dx); item.setEndY(y+dy);
}
}
示例7: getRawShape
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
float[] poly = (float[])item.get(m_polyfield);
if ( poly == null ) { return null; }
float x = (float)item.getX();
float y = (float)item.getY();
// initialize the path
m_path.reset();
m_path.moveTo(x+poly[0],y+poly[1]);
if ( m_polyType == Constants.POLY_TYPE_LINE )
{
// create a polygon
for ( int i=2; i<poly.length; i+=2 ) {
if ( Float.isNaN(poly[i]) ) break;
m_path.lineTo(x+poly[i],y+poly[i+1]);
}
}
else if ( m_polyType == Constants.POLY_TYPE_CURVE )
{
// interpolate the polygon points with a cardinal spline
return GraphicsLib.cardinalSpline(m_path, poly,
m_slack, m_closed, x, y);
}
else if ( m_polyType == Constants.POLY_TYPE_STACK )
{
// used curved lines, except for non-sloping segments
return GraphicsLib.stackSpline(m_path, poly,
m_epsilon, m_slack, m_closed, x, y);
}
if ( m_closed ) m_path.closePath();
return m_path;
}
示例8: run
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* @see prefuse.action.Action#run(double)
*/
public void run(double frac) {
Rectangle2D bounds = getLayoutBounds();
Point2D anchor = correct(m_anchor, bounds);
final Iterator iter = getVisualization().visibleItems(m_group);
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
if ( item.isFixed() ) continue;
// reset distorted values
// TODO - make this play nice with animation?
item.setX(item.getEndX());
item.setY(item.getEndY());
item.setSize(item.getEndSize());
// compute distortion if we have a distortion focus
if ( anchor != null ) {
Rectangle2D bbox = item.getBounds();
double x = item.getX();
double y = item.getY();
// position distortion
if ( m_distortX )
item.setX(x=distortX(x, anchor, bounds));
if ( m_distortY )
item.setY(y=distortY(y, anchor, bounds));
// size distortion
if ( m_distortSize ) {
double sz = distortSize(bbox, x, y, anchor, bounds);
item.setSize(sz*item.getSize());
}
}
}
}
示例9: getRawShape
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
protected Shape getRawShape( VisualItem item )
{
double width, height;
double x = item.getX();
if ( Double.isNaN( x ) || Double.isInfinite( x ) )
x = 0;
double y = item.getY();
if ( Double.isNaN( y ) || Double.isInfinite( y ) )
y = 0;
if ( m_isVertical ) {
// @@@ what is the getSize for?
width = m_barWidth * item.getSize();
if ( m_orientation == Constants.ORIENT_BOTTOM_TOP ) {
height = m_bounds.getMaxY() - y;
}
else {
height = y;
y = m_bounds.getMinY();
}
// Center the bar around the x-location
if ( width > 1 ) {
x = x - width / 2;
}
}
else {
height = m_barWidth * item.getSize();
if ( m_orientation == Constants.ORIENT_LEFT_RIGHT ) {
width = x;
x = m_bounds.getMinX();
}
else {
width = m_bounds.getMaxX() - x;
}
// Center the bar around the y-location
if ( height > 1 ) {
y = y - height / 2;
}
}
m_rect.setFrame( x, y, width, height );
return m_rect;
}
示例10: getRawShape
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
int stype = item.getShape();
double x = item.getX();
if ( Double.isNaN(x) || Double.isInfinite(x) )
x = 0;
double y = item.getY();
if ( Double.isNaN(y) || Double.isInfinite(y) )
y = 0;
double width = m_baseSize*item.getSize();
double height = m_baseSize*item.getSizeY();
// Center the shape around the specified x and y
if ( width > 1 ) {
x = x-width/2;
if (Double.isNaN(height))
y = y-width/2;
else
y = y-height/2;
}
if (Double.isNaN(height)) {
switch ( stype ) {
case Constants.SHAPE_NONE:
return null;
case Constants.SHAPE_RECTANGLE:
return rectangle(x, y, width, width);
case Constants.SHAPE_ELLIPSE:
return ellipse(x, y, width, width);
case Constants.SHAPE_TRIANGLE_UP:
return triangle_up((float)x, (float)y, (float)width);
case Constants.SHAPE_TRIANGLE_DOWN:
return triangle_down((float)x, (float)y, (float)width);
case Constants.SHAPE_TRIANGLE_LEFT:
return triangle_left((float)x, (float)y, (float)width);
case Constants.SHAPE_TRIANGLE_RIGHT:
return triangle_right((float)x, (float)y, (float)width);
case Constants.SHAPE_CROSS:
return cross((float)x, (float)y, (float)width);
case Constants.SHAPE_STAR:
return star((float)x, (float)y, (float)width);
case Constants.SHAPE_HEXAGON:
return hexagon((float)x, (float)y, (float)width);
case Constants.SHAPE_DIAMOND:
return diamond((float)x, (float)y, (float)width);
default:
return extendedShape(stype,x,y,width,width);
}
} else {
switch ( stype ) {
case Constants.SHAPE_NONE:
return null;
case Constants.SHAPE_RECTANGLE:
return rectangle(x, y, width, height);
case Constants.SHAPE_ELLIPSE:
return ellipse(x, y, width, height);
case Constants.SHAPE_TRIANGLE_UP:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_TRIANGLE_DOWN:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_TRIANGLE_LEFT:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_TRIANGLE_RIGHT:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_CROSS:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_STAR:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_HEXAGON:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
case Constants.SHAPE_DIAMOND:
throw new IllegalStateException("Shape cannot be scaled vertically: "+stype);
default:
return extendedShape(stype,x,y,width,height);
}
}
}
示例11: setY
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* Update the y-coordinate of an item. The current y value will become the
* new starting y value, while the given value will become the new current
* x and ending y values. This method also supports an optional referrer
* item, whose y coordinate will become the new starting y coordinate
* of item if item's current x value is NaN.
* @param item the VisualItem to update
* @param referrer an optional referrer VisualItem
* @param y the y value to set
*/
public static void setY(VisualItem item, VisualItem referrer, double y) {
double sy = item.getY();
if ( Double.isNaN(sy) )
sy = (referrer != null ? referrer.getY() : y);
item.setStartY(sy);
item.setEndY(y);
item.setY(y);
}
示例12: distance
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* Get the distance between the x,y points of two VisualItems.
* @param vi1 the first VisualItem
* @param vi2 the second VisualItem
* @return the distance between the items' x,y coordinates
*/
public static double distance(VisualItem vi1, VisualItem vi2) {
double dx = vi1.getX() - vi2.getX();
double dy = vi1.getY() - vi2.getY();
return Math.sqrt(dx*dx + dy*dy);
}