本文整理匯總了Java中processing.core.PConstants.CENTER屬性的典型用法代碼示例。如果您正苦於以下問題:Java PConstants.CENTER屬性的具體用法?Java PConstants.CENTER怎麽用?Java PConstants.CENTER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類processing.core.PConstants
的用法示例。
在下文中一共展示了PConstants.CENTER屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ellipse
public final void ellipse(Ellipse e) {
Vec2D r = e.getRadii();
switch (gfx.ellipseMode) {
case PConstants.CENTER:
gfx.ellipse(e.x, e.y, r.x * 2, r.y * 2);
break;
case PConstants.RADIUS:
gfx.ellipse(e.x, e.y, r.x, r.y);
break;
case PConstants.CORNER:
case PConstants.CORNERS:
gfx.ellipse(e.x - r.x, e.y - r.y, r.x * 2, r.y * 2);
break;
default:
logger.warning("invalid ellipse mode: " + gfx.ellipseMode);
}
}
示例2: rect
public final void rect(Rect r) {
switch (gfx.rectMode) {
case PConstants.CORNER:
gfx.rect(r.x, r.y, r.width, r.height);
break;
case PConstants.CORNERS:
gfx.rect(r.x, r.y, r.x + r.width, r.y + r.height);
break;
case PConstants.CENTER:
gfx.rect(r.x + r.width * 0.5f, r.y + r.height * 0.5f, r.width,
r.height);
break;
case PConstants.RADIUS:
float rw = r.width * 0.5f;
float rh = r.height * 0.5f;
gfx.rect(r.x + rw, r.y + rh, rw, rh);
break;
default:
logger.warning("invalid rect mode: " + gfx.rectMode);
}
}
示例3: mouseEvent
public void mouseEvent(final MouseEvent e) {
if (resetOnDoubleClick && e.getID() == MouseEvent.MOUSE_CLICKED
&& e.getClickCount() == 2) {
reset();
} else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
dragConstraint = null;
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.X
: Constraint.Y;
}
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
}
}
示例4: mouseEvent
public void mouseEvent(final MouseEvent e) {
if (resetOnDoubleClick && e.getID() == MouseEvent.MOUSE_CLICKED
&& e.getClickCount() == 2) {
reset();
} else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
dragConstraint = null;
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.YAW
: Constraint.PITCH;
}
} else if (permaConstraint != null) {
dragConstraint = permaConstraint;
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
}
}
示例5: nativeMouseEvent
protected void nativeMouseEvent(com.jogamp.newt.event.MouseEvent nativeEvent,
int peAction) {
int modifiers = nativeEvent.getModifiers();
int peModifiers = modifiers &
(InputEvent.SHIFT_MASK |
InputEvent.CTRL_MASK |
InputEvent.META_MASK |
InputEvent.ALT_MASK);
int peButton = 0;
if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
peButton = PConstants.LEFT;
} else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
peButton = PConstants.CENTER;
} else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
peButton = PConstants.RIGHT;
}
if (PApplet.platform == PConstants.MACOSX) {
//if (nativeEvent.isPopupTrigger()) {
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
peButton = PConstants.RIGHT;
}
}
int peCount = 0;
if (peAction == MouseEvent.WHEEL) {
peCount = nativeEvent.isShiftDown() ? (int)nativeEvent.getRotation()[0] :
(int)nativeEvent.getRotation()[1];
} else {
peCount = nativeEvent.getClickCount();
}
MouseEvent me = new MouseEvent(nativeEvent, nativeEvent.getWhen(),
peAction, peModifiers,
nativeEvent.getX(), nativeEvent.getY(),
peButton,
peCount);
pg.parent.postEvent(me);
}
示例6: mouseEvent
public void mouseEvent(final MouseEvent e) {
switch (e.getAction()) {
case MouseEvent.WHEEL:
wheelHandler.handleWheel((int)e.getCount());
break;
case MouseEvent.RELEASE:
dragConstraint = null;
break;
case MouseEvent.CLICK:
if (resetOnDoubleClick && 2 == (int)e.getCount()) {
reset();
}
break;
case MouseEvent.DRAG:
final double dx = p.mouseX - p.pmouseX;
final double dy = p.mouseY - p.pmouseY;
if (e.isShiftDown()) {
if (dragConstraint == null && Math.abs(dx - dy) > 1) {
dragConstraint = Math.abs(dx) > Math.abs(dy) ? Constraint.YAW
: Constraint.PITCH;
}
} else if (permaConstraint != null) {
dragConstraint = permaConstraint;
} else {
dragConstraint = null;
}
final int b = p.mouseButton;
if (centerDragHandler != null
&& (b == PConstants.CENTER || (b == PConstants.LEFT && e
.isMetaDown()))) {
centerDragHandler.handleDrag(dx, dy);
} else if (leftDragHandler != null && b == PConstants.LEFT) {
leftDragHandler.handleDrag(dx, dy);
} else if (rightDraghandler != null && b == PConstants.RIGHT) {
rightDraghandler.handleDrag(dx, dy);
}
break;
}
}