當前位置: 首頁>>代碼示例>>Java>>正文


Java PComposite類代碼示例

本文整理匯總了Java中org.piccolo2d.extras.nodes.PComposite的典型用法代碼示例。如果您正苦於以下問題:Java PComposite類的具體用法?Java PComposite怎麽用?Java PComposite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PComposite類屬於org.piccolo2d.extras.nodes包,在下文中一共展示了PComposite類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的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: startDrag

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
protected void startDrag(PInputEvent e) {
	LOGGER.trace("Method startDrag("
			+ e + ") called.");
	PNode pickedNode = e.getPickedNode();
	if (pickedNode instanceof PComposite) {
		super.startDrag(e);
		e.setHandled(true);
		pickedNode.raiseToTop();
		Position position = (Position) pickedNode.getAttribute("position");
		if (position != null) {
			position.setInUse(true);
		}

		PActivity activity = (PActivity) pickedNode.getAttribute("activity");
		if (activity != null) {
			activity.terminate();
		}
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:21,代碼來源:NodeEventHandler.java

示例3: drag

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
@SuppressWarnings({"unchecked"})
protected void drag(PInputEvent e) {
	LOGGER.trace("Method drag("
			+ e + ") called.");
	PNode pickedNode = e.getPickedNode();
	if (pickedNode instanceof PComposite) {
		super.drag(e);
		PComposite vNode = (PComposite) pickedNode;

		/* Redraw edges */
		ArrayList<PPath> vEdges = (ArrayList<PPath>) vNode.getAttribute("edges");
		for (PPath vEdge : vEdges) {
			mPanel.updateEdge(vEdge, (Position) vNode.getAttribute("position"));
		}
		/* TODO Redraw the shadow */
		PPath vShadow = (PPath) vNode.getAttribute("glow");
		if (vShadow != null) {
			vShadow.setOffset(vNode.getOffset());
		}
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:23,代碼來源:NodeEventHandler.java

示例4: endDrag

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
protected void endDrag(PInputEvent e) {
	LOGGER.trace("Method endDrag("
			+ e + ") called.");
	PNode pickedNode = e.getPickedNode();
	if (pickedNode instanceof PComposite) {
		super.endDrag(e);
		/* Set new position */
		Point2D vPoint = e.getPickedNode().getOffset();
		boolean pinNode = e.isControlDown() ? true : false;
		Position vNode = (Position) e.getPickedNode().getAttribute("position");
		mConnection.updateNode(vNode, // Position-Object
				(vPoint.getX()
						/ mPanel.getAreaWidth())
						+ mPanel.getAreaOffsetX(), // x
				(vPoint.getY()
						/ mPanel.getAreaHeight())
						+ mPanel.getAreaOffsetY(), // y
				0.0, // z
				pinNode);
		vNode.setInUse(false);
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:24,代碼來源:NodeEventHandler.java

示例5: mouseEntered

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的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.extras.nodes.PComposite; //導入依賴的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: deleteNode

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
public synchronized void deleteNode(Position pPosition) {
	LOGGER.trace("Method deleteNode("
			+ pPosition + ") called.");
	PComposite vNode = mMapNode.get(pPosition);
	if (vNode != null) {
		/* Delete node from layer */
		mLayerNode.removeChild(vNode);
		/* Remove Shadow */
		PPath vShadow = (PPath) vNode.getAttribute("glow");
		if (vShadow != null) {
			mLayerGlow.removeChild(vShadow);
		}
		/* Metadata */
		if (pPosition instanceof NodeMetadata) {
			/* Delete edges from layer */
			for (PPath vEdge : mMapEdge.get(pPosition)) {
				deleteEdge(pPosition, vEdge);
			}
			/* Delete edge from HashMap */
			mMapEdge.remove(pPosition);
		}
		/* Delete node from HashMap */
		mMapNode.remove(pPosition);
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:27,代碼來源:Piccolo2DPanel.java

示例8: markAsNew

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
public synchronized void markAsNew(final Position pPosition) {
	LOGGER.trace("Method markAsNew("
			+ pPosition + ") called.");
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			PComposite vNode = mMapNode.get(pPosition);
			if (vNode != null) {
				addGlow(vNode, mColorNewNode);
			} else {
				LOGGER.debug("Coundn't find "
						+ pPosition
						+ " to mark as new.");
			}
		}
	});
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:19,代碼來源:Piccolo2DPanel.java

示例9: markAsDelete

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
public synchronized void markAsDelete(final Position pPosition) {
	LOGGER.trace("Method markAsDelete("
			+ pPosition + ") called.");
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			PComposite vNode = mMapNode.get(pPosition);
			if (vNode != null) {
				addGlow(vNode, mColorDeleteNode);
			} else {
				LOGGER.debug("Coundn't find "
						+ pPosition
						+ " to mark as delete.");
			}
		}
	});
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:19,代碼來源:Piccolo2DPanel.java

示例10: adjustPanelSize

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的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

示例11: repaintNodes

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的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

示例12: getNodes

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的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

示例13: mouseExited

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
public void mouseExited(PInputEvent e) {
	LOGGER.trace("Method mouseExited("
			+ e + ") called.");
	super.mouseExited(e);
	
	if (!mConnection.isPropablePicked()) {
		PNode pickedNode = e.getPickedNode();
		if (pickedNode instanceof PComposite) {
			mPanel.mouseExited();
		}
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:14,代碼來源:NodeEventHandler.java

示例14: addEdge

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
/**
 * Add an edge to the graph.
 *
 * @param pKey
 *            a key to group the edge.
 * @param pNodeFirst
 *            the node where the edge starts.
 * @param pNodeSecond
 *            the node where the edge ends.
 */
@Override
@SuppressWarnings("unchecked")
public synchronized void addEdge(NodeMetadata pKey, Position pNodeFirst,
		Position pNodeSecond) {
	LOGGER.trace("Method addEdge("
			+ pKey + ", " + pNodeFirst + ", "
			+ pNodeSecond + ") called.");
	PPath vEdge = new PPath.Float();
	PComposite vNodeFirst = mMapNode.get(pNodeFirst);
	PComposite vNodeSecond = mMapNode.get(pNodeSecond);
	/* Add Edge to Node. */
	((ArrayList<PPath>) vNodeFirst.getAttribute("edges")).add(vEdge);
	((ArrayList<PPath>) vNodeSecond.getAttribute("edges")).add(vEdge);
	/* Add Node to Edge. */
	vEdge.addAttribute("nodes", new ArrayList<PComposite>());
	((ArrayList<PComposite>) vEdge.getAttribute("nodes")).add(vNodeFirst);
	((ArrayList<PComposite>) vEdge.getAttribute("nodes")).add(vNodeSecond);
	/* Add edge to layer. */
	mLayerEdge.addChild(vEdge);
	/* Add edge to HashMap. */
	ArrayList<PPath> vEdges = mMapEdge.get(pKey);
	if (vEdges == null) { // Is first entry?
		vEdges = new ArrayList<>();
		mMapEdge.put(pKey, vEdges);
	}
	vEdges.add(vEdge);
	updateEdge(vEdge, pKey);
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:39,代碼來源:Piccolo2DPanel.java

示例15: deleteEdge

import org.piccolo2d.extras.nodes.PComposite; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void deleteEdge(Object pKey, PPath pEdge) {
	LOGGER.trace("Method deleteEdge("
			+ pKey + ", " + pEdge + ") called.");
	/* Remove edge from layer */
	mLayerEdge.removeChild(pEdge);
	/* Remove edge from node */
	for (PComposite vNode : ((ArrayList<PComposite>) pEdge
			.getAttribute("nodes"))) {
		((ArrayList<PPath>) vNode.getAttribute("edges")).remove(pEdge);
	}
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:14,代碼來源:Piccolo2DPanel.java


注:本文中的org.piccolo2d.extras.nodes.PComposite類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。