本文整理汇总了Java中prefuse.visual.VisualItem类的典型用法代码示例。如果您正苦于以下问题:Java VisualItem类的具体用法?Java VisualItem怎么用?Java VisualItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VisualItem类属于prefuse.visual包,在下文中一共展示了VisualItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: itemDragged
import prefuse.visual.VisualItem; //导入依赖的package包/类
/**
* @see Control#itemDragged(VisualItem, MouseEvent)
*/
public void itemDragged( VisualItem item, MouseEvent e )
{
if ( !UILib.isButtonPressed( e, button ) )
return;
if ( !( item instanceof NodeItem ) )
return;
Display d = (Display)e.getComponent();
tmp = d.getAbsoluteCoordinate( e.getPoint(), tmp );
double dx = tmp.getX() - down.getX();
double dy = tmp.getY() - down.getY();
updateLocations( (NodeItem)item, dx, dy );
down.setLocation( tmp );
item.getVisualization().repaint();
}
示例2: itemClicked
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
public void itemClicked( VisualItem item, MouseEvent e )
{
actionQueue.clear();
timer.stop();
if ( e.getClickCount() == 1 ) {
// Process immediate single-click actions
actions.stream()
.filter( ma -> ma.matches( e, TriggerAreaTypes.VISUAL_ITEM, true ) )
.forEach( ma -> ma.execute( item, e ) );
}
actions.stream()
.filter( ma -> ma.matches( e, TriggerAreaTypes.VISUAL_ITEM, false ) )
.forEach( ma -> actionQueue.add( () -> ma.execute( item, e ) ) );
timer.restart();
}
示例3: run
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
public void run( double frac )
{
Iterator<?> iter = m_vis.items( m_group );
while ( iter.hasNext() ) {
DecoratorItem decorator = (DecoratorItem)iter.next();
VisualItem decoratedItem = decorator.getDecoratedItem();
Rectangle2D bounds = decoratedItem.getBounds();
double x = bounds.getCenterX();
double y = bounds.getCenterY();
setX( decorator, null, x );
setY( decorator, null, y );
}
}
示例4: getRawShape
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
protected Shape getRawShape( VisualItem item )
{
shape.setFrame(
item.getX() - shape.getWidth() * 0.5,
item.getY() - shape.getHeight() * 0.5,
shape.getWidth(), shape.getHeight()
);
if ( !drawLabels || stringRenderer.getText( item ) == null ) {
return shape;
}
else {
Area a = new Area( stringRenderer.getRawShape( item ) );
a.add( new Area( shape ) );
return a;
}
}
示例5: 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 );
}
示例6: createColorizeActions
import prefuse.visual.VisualItem; //导入依赖的package包/类
private ActionList createColorizeActions( Color color )
{
ActionList list = new ActionList();
list.add(
new ColorAction(
DATA_ID,
VisualItem.FILLCOLOR, color.getRGB()
)
);
list.add(
new ColorAction(
DATA_ID,
VisualItem.STROKECOLOR, color.darker().getRGB()
)
);
return list;
}
示例7: getColor
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
public int getColor( VisualItem item )
{
if ( pCurrent.getBoolean( item ) ) {
return tmp.getCurrentGroupColor().getRGB();
}
else if ( pParent.getBoolean( item ) ) {
return tmp.getParentGroupColor().getRGB();
}
else if ( pAncestor.getBoolean( item ) ) {
return tmp.getAncestorGroupColor().getRGB();
}
else if ( pChild.getBoolean( item ) ) {
return tmp.getChildGroupColor().getRGB();
}
else if ( pOther.getBoolean( item ) ) {
return tmp.getOtherGroupColor().getRGB();
}
else {
return Color.magenta.getRGB();
}
}
示例8: render
import prefuse.visual.VisualItem; //导入依赖的package包/类
public void render(Graphics2D g, VisualItem item) {
// render the edge line
super.render(g, item);
// Add label:
Shape s = getShape(item);
if (s != null) {
Rectangle2D r = s.getBounds2D();
boolean useInt = 1.5 > Math.max(g.getTransform().getScaleX(), g.getTransform().getScaleY());
if (m_font == null)
m_font = item.getFont();
// scale the font as needed
FontMetrics fm = DEFAULT_GRAPHICS.getFontMetrics(m_font);
if (item.canGetString("name")) {
g.setFont(m_font);
g.setPaint(ColorLib.getColor(item.getTextColor()));
drawString(g, fm, item.getString("name"), useInt, r.getX(), r.getY(), r.getWidth(), r.getHeight());
}
}
}
示例9: 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);
}
示例10: storeLayout
import prefuse.visual.VisualItem; //导入依赖的package包/类
/**
* Stores current positions of the tables.
*/
@SuppressWarnings("unchecked")
public void storeLayout() {
if (root != null && layoutHasBeenSet) {
synchronized (visualization) {
LayoutStorage.removeAll(root.getName());
Iterator items = visualization.items(BooleanLiteral.TRUE);
for (int m_visibleCount=0; items.hasNext(); ++m_visibleCount ) {
VisualItem item = (VisualItem)items.next();
if (item.canGetString("label") ) {
String tableName;
tableName = item.getString("label");
if (tableName != null) {
LayoutStorage.setPosition(root.getName(), tableName, new double[] { item.getX(), item.getY(), item.isFixed()? 1.0:0.0 });
}
}
}
LayoutStorage.checkSignificance(root.getName());
}
}
}
示例11: visibleItems
import prefuse.visual.VisualItem; //导入依赖的package包/类
public Set<String> visibleItems() {
Set<String> result = new HashSet<String>();
synchronized (visualization) {
Iterator items = visualization.items(BooleanLiteral.TRUE);
while (items.hasNext()) {
VisualItem item = (VisualItem)items.next();
if (item.canGetString("label") ) {
String tableName;
tableName = item.getString("label");
if (tableName != null) {
result.add(tableName);
}
}
}
}
return result;
}
示例12: createDummy
import prefuse.visual.VisualItem; //导入依赖的package包/类
public VisualItem createDummy() {
// create the dummy node for the creatingEdge mode
nodeSourceDummy = g.addNode();
nodeSourceDummy.set(VisualItem.LABEL, "");
nodeVisualDummy = vis.getVisualItem(graphNodes, nodeSourceDummy);
nodeVisualDummy.setSize(0.0);
nodeVisualDummy.setVisible(false);
/*
*
* initially set the dummy's location. upon mouseMove events, we
*
* will do that there. otherwise, the dummy would appear on top
*
* left position until the mouse moves
*
*/
double x = d.getBounds().getCenterX();
double y = d.getBounds().getCenterY();
mousePosition.setLocation(x, y);
nodeVisualDummy.setX(mousePosition.getX());
nodeVisualDummy.setY(mousePosition.getY());
return nodeVisualDummy;
}
示例13: getColor
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
public int getColor( VisualItem item )
{
if( item instanceof NodeItem )
{
NodeItem nItem = (NodeItem) item;
if( m_vis.isInGroup( nItem, Visualization.FOCUS_ITEMS ) )
{
int c = CMAP.getColor( nItem.getDepth() );
return ColorLib.darker( c );
}
return CMAP.getColor( nItem.getDepth() );
}
else
{
return CMAP.getColor( 0 );
}
}
示例14: ordinalLayout
import prefuse.visual.VisualItem; //导入依赖的package包/类
/**
* Compute an ordinal axis layout.
*/
protected void ordinalLayout(TupleSet ts) {
if ( !m_modelSet) {
Object[] array = DataLib.ordinalArray(ts, m_field);
if ( m_model == null ) {
m_model = new ObjectRangeModel(array);
} else {
((ObjectRangeModel)m_model).setValueRange(array);
}
}
ObjectRangeModel model = (ObjectRangeModel)m_model;
int start = model.getValue();
int end = start + model.getExtent();
double total = (double)(end-start);
Iterator<VisualItem> iter = m_vis.items(m_group, m_filter);
while ( iter.hasNext() ) {
VisualItem item = iter.next();
int order = model.getIndex(item.get(m_field)) - start;
set(item, (total > 0.0) ? order/total : 0.5);
}
}
示例15: getColor
import prefuse.visual.VisualItem; //导入依赖的package包/类
@Override
public int getColor( VisualItem item )
{
if( m_vis.isInGroup( item, Visualization.SEARCH_ITEMS ) )
{
return ColorLib.rgb( 255, 190, 190 );
}
else if( m_vis.isInGroup( item, Visualization.FOCUS_ITEMS ) )
{
return ColorLib.rgb( 198, 229, 229 );
}
else if( item.getDOI() > -1 )
{
return ColorLib.rgb( 164, 193, 193 );
}
else
{
return ColorLib.rgba( 255, 255, 255, 0 );
}
}