当前位置: 首页>>代码示例>>Java>>正文


Java Layer类代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.Layer的典型用法代码示例。如果您正苦于以下问题:Java Layer类的具体用法?Java Layer怎么用?Java Layer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Layer类属于edu.uci.ics.jung.visualization包,在下文中一共展示了Layer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
	ShapeTransformer masterViewTransformer = master.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.VIEW);
	ShapeTransformer masterLayoutTransformer = master
			.getRenderContext().getMultiLayerTransformer()
			.getTransformer(Layer.LAYOUT);
	ShapeTransformer vvLayoutTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);

	// changed: bounds without offset
	Shape lens = new Rectangle(new Point(), master.getSize());

	lens = masterViewTransformer.inverseTransform(lens);
	lens = masterLayoutTransformer.inverseTransform(lens);
	lens = vvLayoutTransformer.transform(lens);
	Graphics2D g2d = (Graphics2D) g;
	Color old = g.getColor();
	Color lensColor = master.getBackground();
	vv.setBackground(lensColor.darker());
	g.setColor(lensColor);
	g2d.fill(lens);
	g.setColor(Color.gray);
	g2d.draw(lens);
	g.setColor(old);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:27,代码来源:MySatelliteVisualizationViewer.java

示例2: setScrollBarValues

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
/**
 * Corrects the scrollbar sync issue with JUNG 2.0.1
 * 
 * recalculated at every scroll/translate/addvertex operation
 */
@Override
protected void setScrollBarValues(Rectangle rectangle, Point2D h0,
		Point2D h1, Point2D v0, Point2D v1) {
	// inject real graph bounds
	rectangle.setRect(vv.getGraphBoundsCache());
	// inject offset
	BidirectionalTransformer viewTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.VIEW);
	BidirectionalTransformer layoutTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
	Point2D location = layoutTransformer.inverseTransform(viewTransformer
			.inverseTransform(new Point2D.Double()));
	double xoff = h0.getX() - location.getX();
	double yoff = v0.getY() - location.getY();
	// offset
	h0.setLocation(h0.getX() - xoff, h0.getY() - yoff);
	h1.setLocation(h1.getX() - xoff, h1.getY() - yoff);
	v0.setLocation(v0.getX() - xoff, v0.getY() - yoff);
	v1.setLocation(v1.getX() - xoff, v1.getY() - yoff);
	//
	super.setScrollBarValues(rectangle, h0, h1, v0, v1);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:28,代码来源:MyGraphZoomScrollPane.java

示例3: zoomOneToOneMoveFocus

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
/**
 * Zoom one to one and move the focus, so that the elements as visible.
 * @param visViewer the VisualizationViewer
 */
private void zoomOneToOneMoveFocus(VisualizationViewer<GraphNode, GraphEdge> visViewer) {
	
	visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
	visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
	
	Graph<GraphNode, GraphEdge> graph = visViewer.getGraphLayout().getGraph();
	Rectangle2D graphDimension = GraphGlobals.getGraphSpreadDimension(graph);
	double moveXOnVisView = graphDimension.getX();
	double moveYOnVisView = graphDimension.getX();
	if (moveXOnVisView<=graphMargin) {
		moveXOnVisView = 0;
	} else {
		moveXOnVisView = (graphMargin-graphDimension.getX());
	}
	if (moveYOnVisView<=graphMargin) {
		moveYOnVisView = 0;
	} else {
		moveYOnVisView = (graphMargin-graphDimension.getY());
	}
	if ((moveXOnVisView!=0 || moveYOnVisView!=0)) {
		visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(moveXOnVisView, moveYOnVisView);	
	}

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:29,代码来源:BasicGraphGui.java

示例4: zoomComponent

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
/**
 * Zoom component.
 */
private void zoomComponent() {
	
	Set<GraphNode> nodesPicked = this.getVisualizationViewer().getPickedVertexState().getPicked();
	if (nodesPicked.size()!=0) {
		HashSet<NetworkComponent> components = this.graphController.getNetworkModelAdapter().getNetworkComponentsFullySelected(nodesPicked);
		if (components!=null && components.size()!=0) {
			// --- Get the dimension of the selected nodes ------ 
			Rectangle2D areaSelected = GraphGlobals.getGraphSpreadDimension(nodesPicked);
			Point2D areaCenter = new Point2D.Double(areaSelected.getCenterX(), areaSelected.getCenterY());
			// --- Create temporary GraphNode -------------------
			GraphNode tmpNode = new GraphNode("tmPCenter", areaCenter);
			this.getVisualizationViewer().getGraphLayout().getGraph().addVertex(tmpNode);
			// --- Get the needed positions ---------------------
			Point2D tmpNodePos = this.getVisualizationViewer().getGraphLayout().transform(tmpNode);
			Point2D visViewCenter = this.getVisualizationViewer().getRenderContext().getMultiLayerTransformer().inverseTransform(this.getVisualizationViewer().getCenter());
			// --- Calculate movement ---------------------------
			final double dx = (visViewCenter.getX() - tmpNodePos.getX());
			final double dy = (visViewCenter.getY() - tmpNodePos.getY());
			// --- Remove temporary GraphNode and move view -----
			this.getVisualizationViewer().getGraphLayout().getGraph().removeVertex(tmpNode);
			this.getVisualizationViewer().getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx, dy); 
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:28,代码来源:BasicGraphGui.java

示例5: paint

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void paint(Graphics graphics) {
	
	Graphics2D g2d = (Graphics2D) graphics;
   	AffineTransform oldXform = g2d.getTransform();
       AffineTransform lat = this.visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).getTransform();
       AffineTransform vat = this.visViewer.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).getTransform();
       AffineTransform at = new AffineTransform();
       at.concatenate(g2d.getTransform());
       at.concatenate(vat);
       at.concatenate(lat);
       g2d.setTransform(at);

       Image mapImage = this.getMapImage();
       if (mapImage!=null) {
       	g2d.drawImage(mapImage, 0, 0, mapImage.getWidth(this.visViewer), mapImage.getWidth(this.visViewer), this.visViewer);	
       }

       g2d.setTransform(oldXform);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:MapPreRenderer.java

示例6: centerVisualization

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
public void centerVisualization(V vertex, final boolean immediate) {
    if (vertex != null) {
        Layout<V,E> layout = this.getGraphLayout();
        Point2D q = layout.transform(vertex);
        Point2D lvc = this.getRenderContext().getMultiLayerTransformer().inverseTransform(this.getCenter());
        final int steps = (immediate ? 1 : 10);
        final double dx = (lvc.getX() - q.getX()) / steps;
        final double dy = (lvc.getY() - q.getY()) / steps;

        new Thread() {
            public void run() {
                MutableTransformer transformer = GraphVisualizationPanel.this.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT); 
                for (int i = 0; i < steps; i++) {
                    transformer.translate(dx, dy);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    }
                }
            }
        }.start();
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:GraphVisualizationPanel.java

示例7: graphReleased

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void graphReleased(ViwnNode v, MouseEvent me) {
    /* the 'everything wrecking jumping graphs' ultimate problem solver */

    // remember node location
    Point2D p1 = (Point2D) owner.getLayout().transform(v).clone();

    // propagate event to nodes
    v.mouseClick(me, owner);

    // find new node location
    Point2D p2 = (Point2D) owner.getLayout().transform(v).clone();

    double xdif = p1.getX() - p2.getX();
    double ydif = p1.getY() - p2.getY();

    owner.getVisualizationViewer().getRenderContext().
            getMultiLayerTransformer().getTransformer(Layer.LAYOUT)
            .translate(xdif, ydif);
    if (me.getButton() == MouseEvent.BUTTON1) {
        owner.vertexSelectionChange(v);
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:24,代码来源:ViwnGraphMouseListener.java

示例8: paintVertex

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
/**
 * Paint vertex <code>v</code> on <code>g</code> at <code>(x,y)</code>.
 *
 * @param rc
 * @param v
 * @param layout
 */
protected void paintVertex(
        RenderContext<ViwnNode, ViwnEdge> rc,
        ViwnNode v,
        Layout<ViwnNode, ViwnEdge> layout) {
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);

    if (v instanceof ViwnNodeSet) {
        delegate.paintVertex(rc, layout, v);
        renderSet(rc, p, (ViwnNodeSet) v);
    } else if (v instanceof ViwnNodeSynset) {
        renderSynset(rc, p, (ViwnNodeSynset) v, layout);
    } else if (v instanceof ViwnNodeWord) {
        delegate.paintVertex(rc, layout, v);
        renderWord(rc, p, (ViwnNodeWord) v);
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:25,代码来源:ViwnVertexRenderer.java

示例9: renderElement

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void renderElement(JPanel jp, Object elem) {
    if (elem instanceof ViwnNode) {
        ViwnNode vn = (ViwnNode) elem;

        // one node visualisation
        Graph<ViwnNode, ViwnEdge> g = new DirectedSparseGraph<>();
        g.addVertex(vn);
        VisualizationViewer<ViwnNode, ViwnEdge> vv = new VisualizationViewer<>(new StaticLayout<>(g));
        vv.getRenderer().setVertexRenderer(new ViwnVertexRenderer(vv.getRenderer().getVertexRenderer()));

        vv.getRenderContext().setVertexShapeTransformer((ViwnNode v) -> v.getShape());

        vv.getRenderContext().setVertexFillPaintTransformer(new ViwnVertexFillColor(vv.getPickedVertexState(), null));
        vv.setVertexToolTipTransformer(new ViwnVertexToolTipTransformer());
        vv.setPreferredSize(new Dimension(110, 50));
        Point2D q = vv.getGraphLayout().transform(vn);
        Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
        vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(lvc.getX() - q.getX(), lvc.getY() - q.getY());
        jp.add(vv, "vfill br");
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:23,代码来源:ViwnLockerViewUI.java

示例10: labelVertex

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void labelVertex(RenderContext<GUINode, GUILink> rc, Layout<GUINode, GUILink> layout, GUINode v, String label)
{
    if (!callback.getVisualizationState().isVisibleInCanvas(v)) return;
    if (callback.getVisualizationState().isCanvasShowNodeNames() && v.getLayer().isDefaultLayer())
    {
        Point2D vertexPositionInPixels = layout.transform(v);
        vertexPositionInPixels = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, vertexPositionInPixels);
        final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), "<html><font color='black'>" + v.getLabel() + "</font></html>", rc.getPickedVertexState().isPicked(v), v);
        final GraphicsDecorator g = rc.getGraphicsContext();
        final Dimension dimensionMessage = component.getPreferredSize();
        final Icon vertexIcon = v.getIcon();
        final Rectangle2D boundsVertex = new Rectangle2D.Double(vertexPositionInPixels.getX() - vertexIcon.getIconWidth() / 2, vertexPositionInPixels.getY() - vertexIcon.getIconHeight() / 2, vertexIcon.getIconWidth(), vertexIcon.getIconHeight());
        final Point anchorPointInPixels = getAnchorPoint(boundsVertex, dimensionMessage, Renderer.VertexLabel.Position.NE);
        g.draw(component, rc.getRendererPane(), anchorPointInPixels.x, anchorPointInPixels.y, dimensionMessage.width, dimensionMessage.height, true);
    }
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:18,代码来源:JUNGCanvas.java

示例11: vertexHit

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
protected boolean vertexHit(RenderContext<V, E> rc, Shape s) {
	JComponent vv = rc.getScreenDevice();
	Rectangle deviceRectangle = null;
	if (vv != null) {
		Dimension d = vv.getSize();
		deviceRectangle = new Rectangle(0, 0, d.width, d.height);
	}
	if (deviceRectangle != null) {
		MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
		if (vt instanceof MutableTransformerDecorator) {
			vt = ((MutableTransformerDecorator) vt).getDelegate();
		}
		return vt.transform(s).intersects(deviceRectangle);
	} else {
		return false;
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:18,代码来源:TreeModelNodeRenderer.java

示例12: paint

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
public void paint(Graphics g) {
	g.setColor(Color.gray);

	Graphics2D g2d = (Graphics2D)g;

	Ellipse2D ellipse = new Ellipse2D.Double();
	for(String v : layout.getGraph().getVertices()) {
		Double radius = layout.getRadii().get(v);
		if(radius == null) continue;
		Point2D p = layout.transform(v);
		ellipse.setFrame(-radius, -radius, 2*radius, 2*radius);
		AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
		Shape shape = at.createTransformedShape(ellipse);
		
		MutableTransformer viewTransformer =
			vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
		
		if(viewTransformer instanceof MutableTransformerDecorator) {
			shape = vv.getRenderContext().getMultiLayerTransformer().transform(shape);
		} else {
			shape = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT,shape);
		}

		g2d.draw(shape);
	}
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:27,代码来源:BalloonLayoutDemo.java

示例13: Animator

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
public void Animator(String vertex) {
    Layout<String, String> layout = vv.getGraphLayout();
    Point2D q = layout.transform(vertex);
    Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
    final double dx = (lvc.getX() - q.getX()) / 10;
    final double dy = (lvc.getY() - q.getY()) / 10;
    Runnable animator = new Runnable() {

        public void run() {
            for (int i = 0; i < 10; i++) {
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx, dy);

                try {
                    Thread.sleep(100);
                } catch (InterruptedException ex) {
                }
            }
        }
    };
    Thread thread = new Thread(animator);
    thread.start();
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:23,代码来源:GraphViewerPanel.java

示例14: paint

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
    ShapeTransformer masterViewTransformer = master.getRenderContext()
            .getMultiLayerTransformer().getTransformer(Layer.VIEW);
    ShapeTransformer masterLayoutTransformer = master
            .getRenderContext().getMultiLayerTransformer()
            .getTransformer(Layer.LAYOUT);
    ShapeTransformer vvLayoutTransformer = vv.getRenderContext()
            .getMultiLayerTransformer().getTransformer(Layer.LAYOUT);

    // changed: bounds without offset
    Shape lens = new Rectangle(new Point(), master.getSize());

    lens = masterViewTransformer.inverseTransform(lens);
    lens = masterLayoutTransformer.inverseTransform(lens);
    lens = vvLayoutTransformer.transform(lens);
    Graphics2D g2d = (Graphics2D) g;
    Color old = g.getColor();
    Color lensColor = master.getBackground();
    vv.setBackground(lensColor.darker());
    g.setColor(lensColor);
    g2d.fill(lens);
    g.setColor(Color.gray);
    g2d.draw(lens);
    g.setColor(old);
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:27,代码来源:MySatelliteVisualizationViewer.java

示例15: setScrollBarValues

import edu.uci.ics.jung.visualization.Layer; //导入依赖的package包/类
/**
 * Corrects the scrollbar sync issue with JUNG 2.0.1
 * <p/>
 * recalculated at every scroll/translate/addvertex operation
 */
@Override
protected void setScrollBarValues(Rectangle rectangle, Point2D h0,
                                  Point2D h1, Point2D v0, Point2D v1) {
    // inject real graph bounds
    rectangle.setRect(vv.getGraphBoundsCache());
    // inject offset
    BidirectionalTransformer viewTransformer = vv.getRenderContext()
            .getMultiLayerTransformer().getTransformer(Layer.VIEW);
    BidirectionalTransformer layoutTransformer = vv.getRenderContext()
            .getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
    Point2D location = layoutTransformer.inverseTransform(viewTransformer
            .inverseTransform(new Point2D.Double()));
    double xoff = h0.getX() - location.getX();
    double yoff = v0.getY() - location.getY();
    // offset
    h0.setLocation(h0.getX() - xoff, h0.getY() - yoff);
    h1.setLocation(h1.getX() - xoff, h1.getY() - yoff);
    v0.setLocation(v0.getX() - xoff, v0.getY() - yoff);
    v1.setLocation(v1.getX() - xoff, v1.getY() - yoff);
    //
    super.setScrollBarValues(rectangle, h0, h1, v0, v1);
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:28,代码来源:MyGraphZoomScrollPane.java


注:本文中的edu.uci.ics.jung.visualization.Layer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。