public T setFillShapeForSelection(boolean selection) { getAttributes().setFillShapeForSelection(selection); return cast(); }
@Override public T copy() { Node<?> node = copyUnchecked(); if (null == node) { return null; } if (NodeType.SHAPE != node.getNodeType()) { return null; } Shape<?> shape = ((Shape<?>) node); if (getShapeType() != shape.getShapeType()) { return null; } return shape.cast(); }
/** * Used internally. Draws the node in the current Context2D * without applying the transformation-related attributes * (e.g. X, Y, ROTATION, SCALE, SHEAR, OFFSET and TRANSFORM.) * <p> * Shapes should apply the non-Transform related attributes (such a colors, strokeWidth etc.) * and draw the Shape's details (such as the the actual lines and fills.) */ protected void drawWithoutTransforms(Context2D context) { double alpha = getGlobalAlpha(); if (alpha <= 0) { return; } m_apsh = false; m_fill = false; Attributes attr = getAttributes(); if (prepare(context, attr, alpha)) { fill(context, attr, alpha); stroke(context, attr, alpha); } }
public Shape(ShapeType type, JSONObject node) { super(NodeType.SHAPE, node); m_type = type; final Attributes attr = getAttributes(); if (NativeInternalType.NUMBER != attr.typeOf(Attribute.X)) { setX(0); } if (NativeInternalType.NUMBER != attr.typeOf(Attribute.Y)) { setY(0); } if (NativeInternalType.NUMBER != attr.typeOf(Attribute.ALPHA)) { setAlpha(1); } else { attr.setAlpha(attr.getAlpha()); // normalizes alpha if out of range } if (NativeInternalType.BOOLEAN != attr.typeOf(Attribute.DRAGGABLE)) { setDraggable(false); } }
/** * Gets the {@link DashArray}. If this is a solid line, the dash array is empty. * * @return {@link DashArray} if this line is not dashed, there will be no elements in the {@link DashArray} */ public DashArray getDashArray() { return getAttributes().getDashArray(); }
/** * Moves this shape one layer down. * * @return T */ @SuppressWarnings("unchecked") @Override public T moveDown() { Node<?> parent = getParent(); if (null != parent) { IContainer<IPrimitive<?>> container = (IContainer<IPrimitive<?>>) parent.asContainer(); if (null != container) { container.moveDown(this); } } return cast(); }
context.setFillColor(getColorKey()); setWasFilledFlag(true); doApplyShadow(context, attr); setWasFilledFlag(true); setWasFilledFlag(true); setWasFilledFlag(true); setWasFilledFlag(true);
if (getWasFilledFlag()) color = getColorKey(); if ((isdashed) || (doStrokeExtraProperties()))
/** * Serializes this shape as a {@link JSONObject} * * @return JSONObject */ @Override public JSONObject toJSONObject() { JSONObject object = new JSONObject(); object.put("type", new JSONString(getShapeType().getValue())); object.put("attributes", new JSONObject(getAttributes())); return object; }
/** * Sets the Shape stroke. * * @param context * @param attr */ protected void stroke(Context2D context, Attributes attr, double alpha) { context.save(); if (setStrokeParams(context, attr, alpha)) { if (context.isSelection()) { context.stroke(); } else { doApplyShadow(context, attr); context.stroke(); } } context.restore(); }
if ((shape != null) && (ckey.equals(shape.getColorKey())) && (shape.isVisible()))
/** * Detaches this Shape from the Layers Color Map */ @Override public void detachFromLayerColorMap() { Layer layer = getLayer(); if (null != layer) { layer.detachShapeFromColorMap(this); } }
/** * Internal method. Attach a Shape to the Layers Color Map */ final void attachShapeToColorMap(Shape<?> shape) { if (null != shape) { Shape<?> look = m_shape_color_map.get(shape.getColorKey()); if (null == look) { m_shape_color_map.put(shape.getColorKey(), shape); } } }
@Override public void fill(Context2D context, Attributes attr, double alpha) { if (m_closed) { super.fill(context, attr, alpha); } }
IPrimitive<?> prim = shape.asPrimitive();
/** * Gets the x coordinate for this shape. * * @return double */ @Override public double getX() { return getAttributes().getX(); }
/** * Moves this shape to the top of the layers stack. * * @return T */ @SuppressWarnings("unchecked") @Override public T moveToTop() { Node<?> parent = getParent(); if (null != parent) { IContainer<IPrimitive<?>> container = (IContainer<IPrimitive<?>>) parent.asContainer(); if (null != container) { container.moveToTop(this); } } return cast(); }
/** * Attaches this Shape to the Layers Color Map */ @Override public void attachToLayerColorMap() { Layer layer = getLayer(); if (null != layer) { layer.attachShapeToColorMap(this); } }
/** * Internal method. Detach a {@link Shape} from the Layers Color Map * * @param shape */ final void detachShapeFromColorMap(Shape<?> shape) { if (null != shape) { Shape<?> look = m_shape_color_map.get(shape.getColorKey()); if (shape == look) { m_shape_color_map.remove(shape.getColorKey()); } } }