/** * Sends the given input event with the given type to the current * InputManager. * * @param event event to dispatch * @param type type of event being dispatched */ protected void sendInputEventToInputManager(final InputEvent event, final int type) { getRoot().getDefaultInputManager().processEventFromCamera(event, type, getCamera()); }
private void sendRetypedMouseEventToInputManager(final MouseEvent e, final int newType) { final MouseEvent retypedEvent = buildRetypedMouseEvent(e, newType); sendInputEventToInputManager(retypedEvent, newType); } }
/** {@inheritDoc} */ public void setChildPaintInvalid(final boolean childPaintInvalid) { super.setChildPaintInvalid(childPaintInvalid); scheduleProcessInputsIfNeeded(); }
/** * Creates the simplest possible scene graph. 1 Camera, 1 Layer, 1 Root * * @return a basic scene with 1 camera, layer and root */ public static PCamera createBasicScenegraph() { final PRoot root = new PRoot(); final PLayer layer = new PLayer(); final PCamera camera = new PCamera(); root.addChild(camera); root.addChild(layer); camera.addLayer(layer); return camera; }
/** * Add an input listener to the camera associated with this canvas. * * @param listener listener to register for event notifications */ public void addInputEventListener(final PInputEventListener listener) { getCamera().addInputEventListener(listener); }
/** * Remove an input listener to the camera associated with this canvas. * * @param listener listener to unregister from event notifications */ public void removeInputEventListener(final PInputEventListener listener) { getCamera().removeInputEventListener(listener); }
/** {@inheritDoc} */ public void setFullBoundsInvalid(final boolean fullLayoutInvalid) { super.setFullBoundsInvalid(fullLayoutInvalid); scheduleProcessInputsIfNeeded(); }
/** * Return true if this canvas has been marked as interacting, or whether * it's root is interacting. If so the canvas will normally render at a * lower quality that is faster. * * @return whether the canvas has been flagged as being interacted with */ public boolean getInteracting() { return interacting > 0 || getRoot().getInteracting(); }
/** {@inheritDoc} */ public void setPaintInvalid(final boolean paintInvalid) { super.setPaintInvalid(paintInvalid); scheduleProcessInputsIfNeeded(); }
/** {@inheritDoc} */ public void setChildBoundsInvalid(final boolean childLayoutInvalid) { super.setChildBoundsInvalid(childLayoutInvalid); scheduleProcessInputsIfNeeded(); }
/** * Set the scale applied by the view transform to the list of layers * viewed by this camera to <code>scale</code>. * * @param scale view transform scale */ public void setViewScale(final double scale) { scaleView(scale / getViewScale()); }
/** * Return root for this canvas. * * @return the root PNode at the "bottom" of the scene */ public PRoot getRoot() { return camera.getRoot(); }
/** * Return layer for this canvas. * * @return the first layer attached to this camera */ public PLayer getLayer() { return camera.getLayer(0); }
/** * Get the default input manager to be used when processing input events. * PCanvas's use this method when they forward new swing input events to the * PInputManager. * * @return a singleton instance of PInputManager */ public PInputManager getDefaultInputManager() { if (defaultInputManager == null) { defaultInputManager = new PInputManager(); addInputSource(defaultInputManager); } return defaultInputManager; }
/** * Set the component for this camera to <code>component</code>. The * component, if non-null, receives repaint notification from this camera. * * @param component component for this camera */ public void setComponent(final PComponent component) { this.component = component; invalidatePaint(); }
/** * Scale the view transform applied to the list of layers viewed by this * camera by <code>scale</code> about the point <code>[0, 0]</code>. * * @param scale view transform scale */ public void scaleView(final double scale) { scaleViewAboutPoint(scale, 0, 0); }
/** * Scale this nodes transform by the given amount. This will affect this * node and all of its descendants. * * @param scale the amount to scale by */ public void scale(final double scale) { scaleAboutPoint(scale, 0, 0); }
/** * Changes the associated camera and target for this sticky handle. * * @param newCamera new camera onto which this handle should appear * @param newTarget new target which this handle will control */ public void setCameraTarget(final PCamera newCamera, final PNode newTarget) { camera = newCamera; camera.addChild(this); target = newTarget; }
/** * Creates a selection event handler. * * @param marqueeParent The node to which the event handler dynamically adds * a marquee (temporarily) to represent the area being selected. * @param selectableParent The node whose children will be selected by this * event handler. */ public PSWTSelectionEventHandler(final PNode marqueeParent, final PNode selectableParent) { super(new PNode(), selectableParent); this.marqueeParent = marqueeParent; }