本文整理汇总了Java中org.piccolo2d.nodes.PPath.Float方法的典型用法代码示例。如果您正苦于以下问题:Java PPath.Float方法的具体用法?Java PPath.Float怎么用?Java PPath.Float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.piccolo2d.nodes.PPath
的用法示例。
在下文中一共展示了PPath.Float方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void initialize() {
PPath line1 = PPath.createLine(5f, 10f, 5f, 100f);
line1.setStroke(new BasicStroke(0));
getCanvas().getLayer().addChild(line1);
PPath line2 = new PPath.Float();
line2.setStroke(new BasicStroke(0));
line2.moveTo(15f, 10f);
line2.lineTo(15f, 100f);
getCanvas().getLayer().addChild(line2);
PPath line3 = PPath.createLine(25f, 10f, 26f, 100f);
line3.setStroke(new BasicStroke(0));
getCanvas().getLayer().addChild(line3);
}
示例2: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PLayer layer = getCanvas().getLayer();
final PRoot root = getCanvas().getRoot();
final Random r = new Random();
for (int i = 0; i < 1000; i++) {
final PNode n = PPath.createRectangle(0, 0, 100, 80);
n.translate(10000 * r.nextFloat(), 10000 * r.nextFloat());
n.setPaint(new Color(r.nextFloat(), r.nextFloat(), r.nextFloat()));
layer.addChild(n);
}
getCanvas().getCamera().animateViewToCenterBounds(layer.getGlobalFullBounds(), true, 0);
final PActivity a = new PActivity(-1, 20) {
public void activityStep(final long currentTime) {
super.activityStep(currentTime);
rotateNodes();
}
};
root.addActivity(a);
final PPath p = new PPath.Float();
p.moveTo(0, 0);
p.lineTo(0, 1000);
final PFixedWidthStroke stroke = new PFixedWidthStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10,
new float[] { 5, 2 }, 0);
p.setStroke(stroke);
layer.addChild(p);
}
示例3: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final PLayer layer = getCanvas().getLayer();
final PNode animatedNode = PPath.createRectangle(0, 0, 100, 80);
layer.addChild(animatedNode);
// create animation path
final GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
path.lineTo(300, 300);
path.lineTo(300, 0);
path.append(new Arc2D.Float(0, 0, 300, 300, 90, -90, Arc2D.OPEN), true);
path.closePath();
// create node to display animation path
final PPath ppath = new PPath.Float(path);
layer.addChild(ppath);
// create activity to run animation.
final PPositionPathActivity positionPathActivity = new PPositionPathActivity(5000, 0,
new PPositionPathActivity.Target() {
public void setPosition(final double x, final double y) {
animatedNode.setOffset(x, y);
}
});
// positionPathActivity.setSlowInSlowOut(false);
positionPathActivity.setPositions(path);
positionPathActivity.setLoopCount(Integer.MAX_VALUE);
// add the activity.
animatedNode.addActivity(positionPathActivity);
}
示例4: startDrag
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void startDrag(final PInputEvent e) {
super.startDrag(e);
final Point2D p = e.getPosition();
// Create a new squiggle and add it to the canvas.
squiggle = new PPath.Float();
squiggle.moveTo((float) p.getX(), (float) p.getY());
squiggle.setStroke(new BasicStroke((float) (1 / e.getCamera().getViewScale())));
canvas.getLayer().addChild(squiggle);
// Reset the keydboard focus.
e.getInputManager().setKeyboardFocus(null);
}
示例5: PLens
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
/**
* Constructs the default PLens.
*/
public PLens() {
// Drag bar gets resized to fit the available space, so any rectangle
// will do here
dragBarRect = new Rectangle2D.Float(0.0f, 0.0f, 1.0f, 1.0f);
dragBar = new PPath.Float(dragBarRect);
dragBar.setPaint(DEFAULT_DRAGBAR_PAINT);
// This forces drag events to percolate up to PLens object
dragBar.setPickable(false);
addChild(dragBar);
camera = new PCamera();
camera.setPaint(DEFAULT_LENS_PAINT);
addChild(camera);
// create an event handler to drag the lens around. Note that this event
// handler consumes events in case another conflicting event handler has
// been installed higher up in the heirarchy.
lensDragger = new PDragEventHandler();
lensDragger.getEventFilter().setMarksAcceptedEventsAsHandled(true);
addInputEventListener(lensDragger);
// When this PLens is dragged around adjust the cameras view transform.
addPropertyChangeListener(PNode.PROPERTY_TRANSFORM, new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
camera.setViewTransform(getInverseTransform());
}
});
}
示例6: addEdge
import org.piccolo2d.nodes.PPath; //导入方法依赖的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);
}
示例7: initialize
import org.piccolo2d.nodes.PPath; //导入方法依赖的package包/类
public void initialize() {
final int numNodes = 50;
final int numEdges = 50;
// Initialize, and create a layer for the edges (always underneath the
// nodes)
final PLayer nodeLayer = getCanvas().getLayer();
final PLayer edgeLayer = new PLayer();
getCanvas().getCamera().addLayer(0, edgeLayer);
final Random rnd = new Random();
ArrayList tmp;
for (int i = 0; i < numNodes; i++) {
final float x = (float) (300. * rnd.nextDouble());
final float y = (float) (400. * rnd.nextDouble());
final PPath path = PPath.createEllipse(x, y, 20, 20);
tmp = new ArrayList();
path.addAttribute("edges", tmp);
nodeLayer.addChild(path);
}
// Create some random edges
// Each edge's Tag has an ArrayList used to store associated nodes
for (int i = 0; i < numEdges; i++) {
final int n1 = rnd.nextInt(numNodes);
final int n2 = rnd.nextInt(numNodes);
final PNode node1 = nodeLayer.getChild(n1);
final PNode node2 = nodeLayer.getChild(n2);
final Point2D.Double bound1 = (Point2D.Double) node1.getBounds().getCenter2D();
final Point2D.Double bound2 = (Point2D.Double) node2.getBounds().getCenter2D();
final PPath edge = new PPath.Float();
edge.moveTo((float) bound1.getX(), (float) bound1.getY());
edge.lineTo((float) bound2.getX(), (float) bound2.getY());
tmp = (ArrayList) node1.getAttribute("edges");
tmp.add(edge);
tmp = (ArrayList) node2.getAttribute("edges");
tmp.add(edge);
tmp = new ArrayList();
tmp.add(node1);
tmp.add(node2);
edge.addAttribute("nodes", tmp);
edgeLayer.addChild(edge);
}
// Create event handler to move nodes and update edges
nodeLayer.addInputEventListener(new NodeDragHandler());
}