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


Java PText类代码示例

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


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

示例1: initialize

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
public void initialize() {
    final PComposite composite = new PComposite();

    final PNode circle = PPath.createEllipse(0, 0, 100, 100);
    final PNode rectangle = PPath.createRectangle(50, 50, 100, 100);
    final PNode text = new PText("Hello world!");

    composite.addChild(circle);
    composite.addChild(rectangle);
    composite.addChild(text);

    rectangle.rotate(Math.toRadians(45));
    rectangle.setPaint(Color.RED);

    text.scale(2.0);
    text.setPaint(Color.GREEN);

    getCanvas().getLayer().addChild(composite);
    getCanvas().removeInputEventListener(getCanvas().getPanEventHandler());
    getCanvas().addInputEventListener(new PDragEventHandler());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:22,代码来源:CompositeExample.java

示例2: createNode

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/**
 * Creates a {@link PPath} object as a rectangle that has rounded corners.
 *
 * @param text
 *            the {@link PText} object
 * @return a {@link PPath} object
 */
public static PPath createNode(PText text) {
	return PPath.createRoundRectangle(-5
			- 0.5F
					* (float) text.getWidth(), // x
			-5
					- 0.5F
							* (float) text.getHeight(), // y
			(float) text.getWidth()
					+ mOffsetWidth, // width + offset
			(float) text.getHeight()
					+ mOffsetHeight, // height + offset
			mArcWidth, // arcWidth
			mArcHeight // arcHeight
	);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:23,代码来源:RectanglesWithRoundedCornersPiccolo2dNodeRenderer.java

示例3: createNode

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
@Override
public PPath createNode(Identifier identifier, PText text) {
	IdentifierWrapper wrapper = IdentifierHelper.identifier(identifier);
	String typeName = wrapper.getTypeName();
	switch (typeName) {
		case IfmapStrings.IDENTITY_EL_NAME:
			if (ExtendedIdentifierHelper.isExtendedIdentifier(identifier)) {
				String extendedIdentifierTypeName =
						ExtendedIdentifierHelper.getExtendedIdentifierInnerTypeName(identifier);
				if (extendedIdentifierTypeName.equals("service")) {
					return EllipsePiccolo2dNodeRenderer.createNode(text);
				}
			}
		case IfmapStrings.ACCESS_REQUEST_EL_NAME:
		case IfmapStrings.DEVICE_EL_NAME:
		case IfmapStrings.IP_ADDRESS_EL_NAME:
		case IfmapStrings.MAC_ADDRESS_EL_NAME:
		default:
			return RectanglesWithRoundedCornersPiccolo2dNodeRenderer.createNode(text);
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:22,代码来源:ExamplePiccolo2dNodeRenderer.java

示例4: createNode

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/**
 * Creates a new {@link PPath} object as a ellipse.
 *
 * @param text
 *            the {@link PText} object
 * @return a {@link PPath} object
 */
public static PPath createNode(PText text) {
	PBounds bounds = text.getFullBoundsReference();
	float width = (float) (bounds.getWidth()
			+ mGlowWidth);
	float height = (float) (bounds.getHeight()
			+ mGlowHeight);

	PPath result = PPath.createEllipse(-0.5F
			* width, // x
			-0.5F
					* height, // y
			width, // width
			height // height
	);

	return result;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:25,代码来源:EllipsePiccolo2dNodeRenderer.java

示例5: mouseEntered

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
@Override
public void mouseEntered(PInputEvent e) {
	LOGGER.trace("Method mouseEntered("
			+ e + ") called.");
	super.mouseEntered(e);

	if (!mConnection.isPropablePicked()) {
		PNode pickedNode = e.getPickedNode();
		if (pickedNode instanceof PComposite) {
			PPath vNode = (PPath) pickedNode.getChild(0);
			PText vText = (PText) pickedNode.getChild(1);
			GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
			mConnection.showProperty(wrapper.getData());
			mPanel.mouseEntered(wrapper);
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:18,代码来源:NodeEventHandler.java

示例6: mouseClicked

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
@Override
public void mouseClicked(PInputEvent e) {
	LOGGER.trace("Method mouseClicked ("
			+ e + ") called.");
	super.mouseClicked(e);

	PNode pickedNode = e.getPickedNode();
	if (e.isLeftMouseButton()) {
		if (pickedNode instanceof PComposite) {
			PPath vNode = (PPath) pickedNode.getChild(0);
			PText vText = (PText) pickedNode.getChild(1);
			GraphicWrapper wrapper = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
			mConnection.pickAndShowProperties(wrapper);
		} else {
			mConnection.clearProperties();
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:19,代码来源:NodeEventHandler.java

示例7: adjustPanelSize

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/**
 * Adjust the size of the panel depending on the number and size of labels.
 */
@Override
public synchronized void adjustPanelSize() {
	LOGGER.trace("Method adjustPanelSize() called.");
	int vNumberOfNodes = mMapNode.size();
	int vNumberOfChars = 0;
	if (vNumberOfNodes > 0) {
		for (PComposite vNode : mMapNode.values()) {
			vNumberOfChars += ((PText) vNode.getChild(1)).getText()
					.length();
		}
		double vAverage = vNumberOfChars
				/ vNumberOfNodes;
		double vSize = (Math.sqrt(vNumberOfNodes)
				+ vAverage)
				* 50;
		mAreaHeight = vSize;
		mAreaWidth = vSize;
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:23,代码来源:Piccolo2DPanel.java

示例8: repaintNodes

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
@Override
public synchronized void repaintNodes(NodeType pType) {
	LOGGER.trace("Method repaintNodes("
			+ pType + ") called.");
	for (Object key : mMapNode.keySet()) {
		PComposite vCom = mMapNode.get(key);
		PPath vNode = (PPath) vCom.getChild(0);
		PText vText = (PText) vCom.getChild(1);

		if (pType == NodeType.IDENTIFIER) {
			if (vCom.getAttribute("type").equals(pType)) {
				NodeIdentifier i = (NodeIdentifier) key;
				Identifier identifier = i.getIdentifier();
				paintIdentifierNode(identifier, vNode, vText);
			}
		} else if (pType == NodeType.METADATA) {
			if (vCom.getAttribute("type").equals(pType)) {
				NodeMetadata m = (NodeMetadata) key;
				Metadata metadata = m.getMetadata();
				paintMetadataNode(metadata, vNode, vText);
			}
		}
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:25,代码来源:Piccolo2DPanel.java

示例9: create

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/**
 * Creates a new {@link Piccolo2DGraphicWrapper}.
 *
 * @param selectedNode the {@link PPath} of the selected node
 * @param selectedNodeText the {@link PText} of the selected node
 * @return a new {@link Piccolo2DGraphicWrapper}
 */
public static Piccolo2DGraphicWrapper create(PPath selectedNode, PText selectedNodeText) {
	String typeName = getTypeName(selectedNode);

	if (typeName == null) {
		return new Piccolo2DGraphicWrapper(selectedNode, selectedNodeText);
	}

	switch (typeName) {
		case "policy-action":
			return new Piccolo2DPolicyActionGraphicWrapper(selectedNode, selectedNodeText);
		case "identity":
			return new Piccolo2DIdentityGraphicWrapper(selectedNode, selectedNodeText);
		default:
			return new Piccolo2DGraphicWrapper(selectedNode, selectedNodeText);
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:24,代码来源:Piccolo2DGraphicWrapperFactory.java

示例10: getNodes

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<GraphicWrapper> getNodes() {
	ArrayList<PComposite> nodes = (ArrayList<PComposite>) mNode.getAttribute("nodes");
	List<GraphicWrapper> edgesNodes = new ArrayList<GraphicWrapper>();
	if (nodes != null) {
		for (PComposite vCom : nodes) {
			PPath vNode = (PPath) vCom.getChild(0);
			PText vText = (PText) vCom.getChild(1);

			GraphicWrapper g = Piccolo2DGraphicWrapperFactory.create(vNode, vText);
			edgesNodes.add(g);
		}
	}
	return edgesNodes;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:17,代码来源:Piccolo2DGraphicWrapper.java

示例11: createNodeUsingExistingClasses

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
public void createNodeUsingExistingClasses() {
    final PLayer layer = getCanvas().getLayer();
    layer.addChild(PPath.createEllipse(0, 0, 100, 100));
    layer.addChild(PPath.createRectangle(0, 100, 100, 100));
    layer.addChild(new PText("Hello World"));

    // Here we create an image node that displays a thumbnail
    // image of the root node. Note that you can easily get a thumbnail
    // of any node by using PNode.toImage().
    final PImage image = new PImage(layer.toImage(300, 300, null));
    layer.addChild(image);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:13,代码来源:NodeExample.java

示例12: initialize

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
    PText label = new PText("Note white at border S and E\nIt goes away when frame is resized");
    label.setOffset(200, 340);
    getCanvas().getLayer().addChild(label);
    getCanvas().setBackground(Color.PINK);
    getCanvas().setOpaque(true);
    setSize(410, 410);
    //getCanvas().setSize(410, 410);  does not help
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:11,代码来源:FrameCanvasSizeBugExample.java

示例13: createNodeUsingExistingClasses

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
public void createNodeUsingExistingClasses() {
    final PLayer layer = getCanvas().getLayer();
    layer.addChild(PPath.createEllipse(0, 0, 100, 100));
    layer.addChild(PPath.createRectangle(0, 100, 100, 100));
    layer.addChild(new PText("Hello World"));

    // Here we create an image node that displays a thumbnail
    // image of the root node. Note that you can easily get a thumbnail
    // of any node by using PNode.toImage().
    layer.addChild(new PImage(layer.toImage(300, 300, Color.YELLOW)));
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:12,代码来源:BirdsEyeViewExample.java

示例14: createTextNode

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
private void createTextNode(final int i) {
    PText text = new PText("Label " + i);
    text.setTextPaint(TEXT_PAINT);
    text.setOffset(random.nextDouble() * 1000.0d - random.nextDouble() * 1000.0,
                   random.nextDouble() * 1000.0d - random.nextDouble() * 1000.0);
    getCanvas().getLayer().addChild(text);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:8,代码来源:MouseWheelZoomExample.java

示例15: OffscreenCanvasExample

import org.piccolo2d.nodes.PText; //导入依赖的package包/类
/**
 * Create a new offscreen canvas example with the specified graphics device.
 * 
 * @param device graphics device
 */
public OffscreenCanvasExample(final GraphicsDevice device) {
    final GraphicsConfiguration configuration = device.getDefaultConfiguration();
    frame = new Frame(configuration);
    frame.setUndecorated(true);
    frame.setIgnoreRepaint(true);
    frame.setBounds(100, 100, 400, 400);
    frame.setVisible(true);
    frame.createBufferStrategy(2);

    canvas = new POffscreenCanvas(400, 400);

    final PText text = new PText("Offscreen Canvas Example");
    text.setFont(text.getFont().deriveFont(32.0f));
    text.setTextPaint(new Color(200, 200, 200));
    text.offset(200.0f - text.getWidth() / 2.0f, 200.0f - text.getHeight() / 2.0f);

    final PPath rect = PPath.createRectangle(0.0f, 0.0f, 360.0f, 360.0f);
    rect.setPaint(new Color(20, 20, 20, 80));
    rect.setStroke(new BasicStroke(2.0f));
    rect.setStrokePaint(new Color(20, 20, 20));
    rect.offset(20.0f, 20.0f);

    canvas.getCamera().getLayer(0).addChild(text);
    canvas.getCamera().getLayer(0).addChild(rect);

    final Rectangle2D right = new Rectangle2D.Double(200.0f, 200.0f, 800.0f, 800.0f);
    final Rectangle2D left = new Rectangle2D.Double(-200.0f, 200.0f, 225.0f, 225.0f);
    final Rectangle2D start = new Rectangle2D.Double(0.0f, 0.0f, 400.0f, 400.0f);
    final PActivity toRight = canvas.getCamera().animateViewToCenterBounds(right, true, 5000);
    final PActivity toLeft = canvas.getCamera().animateViewToCenterBounds(left, true, 5000);
    final PActivity toStart = canvas.getCamera().animateViewToCenterBounds(start, true, 5000);
    toLeft.startAfter(toRight);
    toStart.startAfter(toLeft);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:40,代码来源:OffscreenCanvasExample.java


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