use of android.support.constraint.solver.widgets.ConstraintWidget in project android by JetBrains.
the class Selection method setSelectedResizeHandle.
/**
* Setter for the selected resize handle
*
* @param handle the selected resize handle
*/
public void setSelectedResizeHandle(ResizeHandle handle) {
mSelectedResizeHandle = handle;
if (mSelectedResizeHandle != null) {
ConstraintWidget widget = mSelectedResizeHandle.getOwner();
mOriginalWidgetBounds.setBounds(widget.getDrawX(), widget.getDrawY(), widget.getWidth(), widget.getHeight());
} else {
mOriginalWidgetBounds.setBounds(0, 0, 0, 0);
}
}
use of android.support.constraint.solver.widgets.ConstraintWidget in project android by JetBrains.
the class AnimatedHoverAnchor method onPaint.
/**
* Paint method for the animation. We simply draw an opaque circle at (x, y),
* applying a transparency as the animation progresses.
*
* @param transform view transform
* @param g Graphics context
*/
@Override
public void onPaint(ViewTransform transform, Graphics2D g) {
int x = transform.getSwingX(mAnchor.getDrawX());
int y = transform.getSwingY(mAnchor.getDrawY());
double progress = getProgress();
int alpha = 255 - getPulsatingAlpha(progress);
int anchorSize = (int) SceneDraw.getAnchorSize(transform.getScale());
int radius = anchorSize + 4;
boolean isNewConnection = mAnchor.getAnchor().getTarget() != null && mOriginalTarget != mAnchor.getAnchor().getTarget();
Composite savedComposite = g.getComposite();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha / 255f));
ConstraintWidget widget = mAnchor.getOwner();
int l = transform.getSwingX(widget.getDrawX());
int t = transform.getSwingY(widget.getDrawY());
int w = transform.getSwingDimension(widget.getDrawWidth());
if (mIsBaseline) {
int extra = radius - 3;
g.setColor(mColor);
g.setStroke(sThinStroke);
int handleWidth = mAnchor.getBaselineHandleWidth(transform);
int padding = (w - handleWidth) / 2;
g.drawRoundRect(l + padding, t + transform.getSwingDimension(widget.getBaselineDistance()) - extra / 2, handleWidth + 1, extra, radius, radius);
} else {
if (isNewConnection) {
// use smaller circle
radius = anchorSize + 3;
}
mCircle.setFrame(x - radius, y - radius, radius * 2, radius * 2);
g.setColor(mFrame);
g.setStroke(isNewConnection ? sThinStroke : sStroke);
g.draw(mCircle);
if (isNewConnection) {
g.setColor(mColorSet.getBackground());
g.fill(mCircle);
g.setColor(mColorSet.getAnchorConnectionCircle());
radius -= 4;
mInnerCircle.setFrame(x - radius, y - radius, radius * 2, radius * 2);
g.fill(mInnerCircle);
g.draw(mInnerCircle);
} else {
mCircle.setFrame(x - radius, y - radius, radius * 2, radius * 2);
g.setColor(mColor);
}
g.draw(mCircle);
}
g.setComposite(savedComposite);
if (!mColorSet.useTooltips()) {
return;
}
boolean showTooltip = mShowTooltip;
boolean newConnection = mAnchor.getAnchor().getTarget() != mTargetAnchor;
showTooltip |= newConnection;
if (showTooltip && (System.currentTimeMillis() - mStartTime > WidgetDraw.TOOLTIP_DELAY)) {
WidgetDraw.drawTooltip(g, mColorSet, getText(), x, y, true);
}
}
Aggregations